@turf/boolean-contains
Advanced tools
+45
-16
@@ -6,2 +6,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts | ||
| var _invariant = require('@turf/invariant'); | ||
| var _helpers = require('@turf/helpers'); | ||
| var _linesplit = require('@turf/line-split'); | ||
| function booleanContains(feature1, feature2) { | ||
@@ -52,2 +54,4 @@ const geom1 = _invariant.getGeom.call(void 0, feature1); | ||
| return isMultiPointInPoly(geom1, geom2); | ||
| case "MultiPolygon": | ||
| return isMultiPolyInPoly(geom1, geom2); | ||
| default: | ||
@@ -72,2 +76,7 @@ throw new Error("feature2 " + type2 + " geometry not supported"); | ||
| } | ||
| function isMultiPolyInPoly(polygon, multiPolygon) { | ||
| return multiPolygon.coordinates.every( | ||
| (coords) => isPolyInPoly(polygon, { type: "Polygon", coordinates: coords }) | ||
| ); | ||
| } | ||
| function isPointInMultiPoint(multiPoint, pt) { | ||
@@ -99,9 +108,9 @@ let i; | ||
| } | ||
| function isMultiPointOnLine(lineString, multiPoint) { | ||
| function isMultiPointOnLine(lineString2, multiPoint) { | ||
| let haveFoundInteriorPoint = false; | ||
| for (const coord of multiPoint.coordinates) { | ||
| if (_booleanpointonline.booleanPointOnLine.call(void 0, coord, lineString, { ignoreEndVertices: true })) { | ||
| if (_booleanpointonline.booleanPointOnLine.call(void 0, coord, lineString2, { ignoreEndVertices: true })) { | ||
| haveFoundInteriorPoint = true; | ||
| } | ||
| if (!_booleanpointonline.booleanPointOnLine.call(void 0, coord, lineString)) { | ||
| if (!_booleanpointonline.booleanPointOnLine.call(void 0, coord, lineString2)) { | ||
| return false; | ||
@@ -139,5 +148,17 @@ } | ||
| } | ||
| function splitLineIntoSegmentsOnPolygon(linestring, polygon) { | ||
| const coords = linestring.coordinates; | ||
| const outputSegments = []; | ||
| for (let i = 0; i < coords.length - 1; i++) { | ||
| const seg = _helpers.lineString.call(void 0, [coords[i], coords[i + 1]]); | ||
| const split = _linesplit.lineSplit.call(void 0, seg, _helpers.feature.call(void 0, polygon)); | ||
| if (split.features.length === 0) { | ||
| outputSegments.push(seg); | ||
| } else { | ||
| outputSegments.push(...split.features); | ||
| } | ||
| } | ||
| return _helpers.featureCollection.call(void 0, outputSegments); | ||
| } | ||
| function isLineInPoly(polygon, linestring) { | ||
| let output = false; | ||
| let i = 0; | ||
| const polyBbox = _bbox.bbox.call(void 0, polygon); | ||
@@ -148,15 +169,22 @@ const lineBbox = _bbox.bbox.call(void 0, linestring); | ||
| } | ||
| for (i; i < linestring.coordinates.length - 1; i++) { | ||
| const midPoint = getMidpoint( | ||
| linestring.coordinates[i], | ||
| linestring.coordinates[i + 1] | ||
| for (const coord of linestring.coordinates) { | ||
| if (!_booleanpointinpolygon.booleanPointInPolygon.call(void 0, coord, polygon)) { | ||
| return false; | ||
| } | ||
| } | ||
| let isContainedByPolygonBoundary = false; | ||
| const lineSegments = splitLineIntoSegmentsOnPolygon(linestring, polygon); | ||
| for (const lineSegment of lineSegments.features) { | ||
| const midpoint = getMidpoint( | ||
| lineSegment.geometry.coordinates[0], | ||
| lineSegment.geometry.coordinates[1] | ||
| ); | ||
| if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0, { type: "Point", coordinates: midPoint }, polygon, { | ||
| ignoreBoundary: true | ||
| })) { | ||
| output = true; | ||
| break; | ||
| if (!_booleanpointinpolygon.booleanPointInPolygon.call(void 0, midpoint, polygon)) { | ||
| return false; | ||
| } | ||
| if (!isContainedByPolygonBoundary && _booleanpointinpolygon.booleanPointInPolygon.call(void 0, midpoint, polygon, { ignoreBoundary: true })) { | ||
| isContainedByPolygonBoundary = true; | ||
| } | ||
| } | ||
| return output; | ||
| return isContainedByPolygonBoundary; | ||
| } | ||
@@ -221,3 +249,4 @@ function isPolyInPoly(feature1, feature2) { | ||
| exports.booleanContains = booleanContains; exports.compareCoords = compareCoords; exports.default = index_default; exports.doBBoxOverlap = doBBoxOverlap; exports.getMidpoint = getMidpoint; exports.isLineInPoly = isLineInPoly; exports.isLineOnLine = isLineOnLine; exports.isMultiPointInMultiPoint = isMultiPointInMultiPoint; exports.isMultiPointInPoly = isMultiPointInPoly; exports.isMultiPointOnLine = isMultiPointOnLine; exports.isPointInMultiPoint = isPointInMultiPoint; exports.isPolyInPoly = isPolyInPoly; exports.isPolygonInMultiPolygon = isPolygonInMultiPolygon; | ||
| exports.booleanContains = booleanContains; exports.compareCoords = compareCoords; exports.default = index_default; exports.doBBoxOverlap = doBBoxOverlap; exports.getMidpoint = getMidpoint; exports.isLineInPoly = isLineInPoly; exports.isLineOnLine = isLineOnLine; exports.isMultiPointInMultiPoint = isMultiPointInMultiPoint; exports.isMultiPointInPoly = isMultiPointInPoly; exports.isMultiPointOnLine = isMultiPointOnLine; exports.isMultiPolyInPoly = isMultiPolyInPoly; exports.isPointInMultiPoint = isPointInMultiPoint; exports.isPolyInPoly = isPolyInPoly; exports.isPolygonInMultiPolygon = isPolygonInMultiPolygon; | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-boolean-contains/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACUA,kCAAiC;AACjC,uEAAsC;AACtC,iEAAoD;AACpD,4CAAwB;AAmBxB,SAAS,eAAA,CACP,QAAA,EACA,QAAA,EACA;AACA,EAAA,MAAM,MAAA,EAAQ,gCAAA,QAAgB,CAAA;AAC9B,EAAA,MAAM,MAAA,EAAQ,gCAAA,QAAgB,CAAA;AAC9B,EAAA,MAAM,MAAA,EAAQ,KAAA,CAAM,IAAA;AACpB,EAAA,MAAM,MAAA,EAAQ,KAAA,CAAM,IAAA;AACpB,EAAA,MAAM,QAAA,EAAU,KAAA,CAAM,WAAA;AACtB,EAAA,MAAM,QAAA,EAAU,KAAA,CAAM,WAAA;AAEtB,EAAA,OAAA,CAAQ,KAAA,EAAO;AAAA,IACb,KAAK,OAAA;AACH,MAAA,OAAA,CAAQ,KAAA,EAAO;AAAA,QACb,KAAK,OAAA;AACH,U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AO,KAAA;AAAA,EACT;AACA,EAAA,GAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAG;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,GAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAG;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,GAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAG;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAUA,SAAS,aAAA,CAAc,KAAA,EAAiB,KAAA,EAAiB;AACvD,EAAA,OAAO,KAAA,CAAM,CAAC,EAAA,IAAM,KAAA,CAAM,CAAC,EAAA,GAAK,KAAA,CAAM,CAAC,EAAA,IAAM,KAAA,CAAM,CAAC,CAAA;AACtD;AAEA,SAAS,WAAA,CAAY,KAAA,EAAiB,KAAA,EAAiB;AACrD,EAAA,OAAO,CAAA,CAAE,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAA,EAAK,CAAA,EAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAA,EAAK,CAAC,CAAA;AAC9D;AAiBA,IAAO,cAAA,EAAQ,eAAA;AD1Ff;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wjBAAC","file":"/home/runner/work/turf/turf/packages/turf-boolean-contains/dist/cjs/index.cjs","sourcesContent":[null,"import {\n BBox,\n Feature,\n Geometry,\n LineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { bbox as calcBbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { booleanPointOnLine as isPointOnLine } from \"@turf/boolean-point-on-line\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Boolean-contains returns True if the second geometry is completely contained by the first geometry.\n * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b)\n * must not intersect the exterior of the primary (geometry a).\n * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`.\n *\n * @function\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n * var point = turf.point([1, 2]);\n *\n * turf.booleanContains(line, point);\n * //=true\n */\nfunction booleanContains(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n) {\n const geom1 = getGeom(feature1);\n const geom2 = getGeom(feature2);\n const type1 = geom1.type;\n const type2 = geom2.type;\n const coords1 = geom1.coordinates;\n const coords2 = geom2.coordinates;\n\n switch (type1) {\n case \"Point\":\n switch (type2) {\n case \"Point\":\n return compareCoords(coords1, coords2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPoint\":\n switch (type2) {\n case \"Point\":\n return isPointInMultiPoint(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInMultiPoint(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"LineString\":\n switch (type2) {\n case \"Point\":\n return isPointOnLine(geom2, geom1, { ignoreEndVertices: true });\n case \"LineString\":\n return isLineOnLine(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointOnLine(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"Polygon\":\n switch (type2) {\n case \"Point\":\n return booleanPointInPolygon(geom2, geom1, { ignoreBoundary: true });\n case \"LineString\":\n return isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return isPolyInPoly(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInPoly(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPolygon\":\n switch (type2) {\n case \"Polygon\":\n return isPolygonInMultiPolygon(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n default:\n throw new Error(\"feature1 \" + type1 + \" geometry not supported\");\n }\n}\n\nfunction isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon) {\n return multiPolygon.coordinates.some((coords) =>\n isPolyInPoly({ type: \"Polygon\", coordinates: coords }, polygon)\n );\n}\n\nfunction isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) {\n let i;\n let output = false;\n for (i = 0; i < multiPoint.coordinates.length; i++) {\n if (compareCoords(multiPoint.coordinates[i], pt.coordinates)) {\n output = true;\n break;\n }\n }\n return output;\n}\n\nfunction isMultiPointInMultiPoint(\n multiPoint1: MultiPoint,\n multiPoint2: MultiPoint\n) {\n for (const coord2 of multiPoint2.coordinates) {\n let matchFound = false;\n for (const coord1 of multiPoint1.coordinates) {\n if (compareCoords(coord2, coord1)) {\n matchFound = true;\n break;\n }\n }\n if (!matchFound) {\n return false;\n }\n }\n return true;\n}\n\nfunction isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) {\n let haveFoundInteriorPoint = false;\n for (const coord of multiPoint.coordinates) {\n if (isPointOnLine(coord, lineString, { ignoreEndVertices: true })) {\n haveFoundInteriorPoint = true;\n }\n if (!isPointOnLine(coord, lineString)) {\n return false;\n }\n }\n if (haveFoundInteriorPoint) {\n return true;\n }\n return false;\n}\n\nfunction isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) {\n for (const coord of multiPoint.coordinates) {\n if (!booleanPointInPolygon(coord, polygon, { ignoreBoundary: true })) {\n return false;\n }\n }\n return true;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n let haveFoundInteriorPoint = false;\n for (const coords of lineString2.coordinates) {\n if (\n isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: true,\n })\n ) {\n haveFoundInteriorPoint = true;\n }\n if (\n !isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: false,\n })\n ) {\n return false;\n }\n }\n return haveFoundInteriorPoint;\n}\n\nfunction isLineInPoly(polygon: Polygon, linestring: LineString) {\n let output = false;\n let i = 0;\n\n const polyBbox = calcBbox(polygon);\n const lineBbox = calcBbox(linestring);\n if (!doBBoxOverlap(polyBbox, lineBbox)) {\n return false;\n }\n for (i; i < linestring.coordinates.length - 1; i++) {\n const midPoint = getMidpoint(\n linestring.coordinates[i],\n linestring.coordinates[i + 1]\n );\n if (\n booleanPointInPolygon({ type: \"Point\", coordinates: midPoint }, polygon, {\n ignoreBoundary: true,\n })\n ) {\n output = true;\n break;\n }\n }\n return output;\n}\n\n/**\n * Is Polygon2 in Polygon1\n * Only takes into account outer rings\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(\n feature1: Feature<Polygon> | Polygon,\n feature2: Feature<Polygon> | Polygon\n) {\n // Handle Nulls\n if (feature1.type === \"Feature\" && feature1.geometry === null) {\n return false;\n }\n if (feature2.type === \"Feature\" && feature2.geometry === null) {\n return false;\n }\n\n const poly1Bbox = calcBbox(feature1);\n const poly2Bbox = calcBbox(feature2);\n if (!doBBoxOverlap(poly1Bbox, poly2Bbox)) {\n return false;\n }\n\n const coords = getGeom(feature2).coordinates;\n for (const ring of coords) {\n for (const coord of ring) {\n if (!booleanPointInPolygon(coord, feature1)) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction doBBoxOverlap(bbox1: BBox, bbox2: BBox) {\n if (bbox1[0] > bbox2[0]) {\n return false;\n }\n if (bbox1[2] < bbox2[2]) {\n return false;\n }\n if (bbox1[1] > bbox2[1]) {\n return false;\n }\n if (bbox1[3] < bbox2[3]) {\n return false;\n }\n return true;\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nfunction getMidpoint(pair1: number[], pair2: number[]) {\n return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];\n}\n\nexport {\n booleanContains,\n isPolygonInMultiPolygon,\n isPointInMultiPoint,\n isMultiPointInMultiPoint,\n isMultiPointOnLine,\n isMultiPointInPoly,\n isLineOnLine,\n isLineInPoly,\n isPolyInPoly,\n doBBoxOverlap,\n compareCoords,\n getMidpoint,\n};\n\nexport default booleanContains;\n"]} | ||
| {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-boolean-contains/dist/cjs/index.cjs","../../index.ts"],"names":["lineString"],"mappings":"AAAA;ACUA,kCAAiC;AACjC,uEAAsC;AACtC,iEAAoD;AACpD,4CAAwB;AACxB,wCAAuD;AACvD,6CAA0B;AAkB1B,SAAS,eAAA,CACP,QAAA,EACA,QAAA,EACA;AACA,EAAA,MAAM,MAAA,EAAQ,gCAAA,QAAgB,CAAA;AAC9B,EAAA,MAAM,MAAA,EAAQ,gCAAA,QAAgB,CAAA;AAC9B,EAAA,MAAM,MAAA,EAAQ,KAAA,CAAM,IAAA;AACpB,EAAA,MAAM,MAAA,EAAQ,KAAA,CAAM,IAAA;AACpB,EAAA,MAAM,QAAA,EAAU,KAAA,CAAM,WAAA;AACtB,EAAA,MAAM,QAAA,EAAU,KAAA,CAAM,WAAA;AAEtB,EAAA,OAAA,CAAQ,KAAA,EAAO;AAAA,IACb,KAAK,OAAA;AACH,MAAA,OAAA,CAAQ,KAAA,EAAO;AAAA,QACb,KAAK,OAAA;AACH,UAAA,OAAO,aAAA,CAAc,OAAA,EAAS,OAAO,CAAA;AAAA,QACvC,OAAA;AACE,UAAA,MAAM,IAAI,KAAA,CAAM,YAAA,EAAc,MAAA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AAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAG;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,GAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAG;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,GAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAG;AACvB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAUA,SAAS,aAAA,CAAc,KAAA,EAAiB,KAAA,EAAiB;AACvD,EAAA,OAAO,KAAA,CAAM,CAAC,EAAA,IAAM,KAAA,CAAM,CAAC,EAAA,GAAK,KAAA,CAAM,CAAC,EAAA,IAAM,KAAA,CAAM,CAAC,CAAA;AACtD;AAEA,SAAS,WAAA,CAAY,KAAA,EAAiB,KAAA,EAAiB;AACrD,EAAA,OAAO,CAAA,CAAE,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAA,EAAK,CAAA,EAAA,CAAI,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,CAAM,CAAC,CAAA,EAAA,EAAK,CAAC,CAAA;AAC9D;AAkBA,IAAO,cAAA,EAAQ,eAAA;AD7Gf;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,umBAAC","file":"/home/runner/work/turf/turf/packages/turf-boolean-contains/dist/cjs/index.cjs","sourcesContent":[null,"import {\n BBox,\n Feature,\n Geometry,\n LineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { bbox as calcBbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { booleanPointOnLine as isPointOnLine } from \"@turf/boolean-point-on-line\";\nimport { getGeom } from \"@turf/invariant\";\nimport { feature, featureCollection, lineString } from \"@turf/helpers\";\nimport { lineSplit } from \"@turf/line-split\";\n\n/**\n * Tests whether geometry a contains geometry b.\n * The interiors of both geometries must intersect, and the interior and boundary of geometry b must not intersect the exterior of geometry a.\n * booleanContains(a, b) is equivalent to booleanWithin(b, a)\n *\n * @function\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n * var point = turf.point([1, 2]);\n *\n * turf.booleanContains(line, point);\n * //=true\n */\nfunction booleanContains(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n) {\n const geom1 = getGeom(feature1);\n const geom2 = getGeom(feature2);\n const type1 = geom1.type;\n const type2 = geom2.type;\n const coords1 = geom1.coordinates;\n const coords2 = geom2.coordinates;\n\n switch (type1) {\n case \"Point\":\n switch (type2) {\n case \"Point\":\n return compareCoords(coords1, coords2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPoint\":\n switch (type2) {\n case \"Point\":\n return isPointInMultiPoint(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInMultiPoint(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"LineString\":\n switch (type2) {\n case \"Point\":\n return isPointOnLine(geom2, geom1, { ignoreEndVertices: true });\n case \"LineString\":\n return isLineOnLine(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointOnLine(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"Polygon\":\n switch (type2) {\n case \"Point\":\n return booleanPointInPolygon(geom2, geom1, { ignoreBoundary: true });\n case \"LineString\":\n return isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return isPolyInPoly(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInPoly(geom1, geom2);\n case \"MultiPolygon\":\n return isMultiPolyInPoly(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPolygon\":\n switch (type2) {\n case \"Polygon\":\n return isPolygonInMultiPolygon(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n default:\n throw new Error(\"feature1 \" + type1 + \" geometry not supported\");\n }\n}\n\nfunction isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon) {\n return multiPolygon.coordinates.some((coords) =>\n isPolyInPoly({ type: \"Polygon\", coordinates: coords }, polygon)\n );\n}\n\nfunction isMultiPolyInPoly(polygon: Polygon, multiPolygon: MultiPolygon) {\n return multiPolygon.coordinates.every((coords) =>\n isPolyInPoly(polygon, { type: \"Polygon\", coordinates: coords })\n );\n}\n\nfunction isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) {\n let i;\n let output = false;\n for (i = 0; i < multiPoint.coordinates.length; i++) {\n if (compareCoords(multiPoint.coordinates[i], pt.coordinates)) {\n output = true;\n break;\n }\n }\n return output;\n}\n\nfunction isMultiPointInMultiPoint(\n multiPoint1: MultiPoint,\n multiPoint2: MultiPoint\n) {\n for (const coord2 of multiPoint2.coordinates) {\n let matchFound = false;\n for (const coord1 of multiPoint1.coordinates) {\n if (compareCoords(coord2, coord1)) {\n matchFound = true;\n break;\n }\n }\n if (!matchFound) {\n return false;\n }\n }\n return true;\n}\n\nfunction isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) {\n let haveFoundInteriorPoint = false;\n for (const coord of multiPoint.coordinates) {\n if (isPointOnLine(coord, lineString, { ignoreEndVertices: true })) {\n haveFoundInteriorPoint = true;\n }\n if (!isPointOnLine(coord, lineString)) {\n return false;\n }\n }\n if (haveFoundInteriorPoint) {\n return true;\n }\n return false;\n}\n\nfunction isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) {\n for (const coord of multiPoint.coordinates) {\n if (!booleanPointInPolygon(coord, polygon, { ignoreBoundary: true })) {\n return false;\n }\n }\n return true;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n let haveFoundInteriorPoint = false;\n for (const coords of lineString2.coordinates) {\n if (\n isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: true,\n })\n ) {\n haveFoundInteriorPoint = true;\n }\n if (\n !isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: false,\n })\n ) {\n return false;\n }\n }\n return haveFoundInteriorPoint;\n}\n\nfunction splitLineIntoSegmentsOnPolygon(\n linestring: LineString,\n polygon: Polygon\n) {\n const coords = linestring.coordinates;\n\n const outputSegments: Feature<LineString>[] = [];\n\n for (let i = 0; i < coords.length - 1; i++) {\n const seg = lineString([coords[i], coords[i + 1]]);\n const split = lineSplit(seg, feature(polygon));\n\n if (split.features.length === 0) {\n outputSegments.push(seg);\n } else {\n outputSegments.push(...split.features);\n }\n }\n\n return featureCollection(outputSegments);\n}\n\nfunction isLineInPoly(polygon: Polygon, linestring: LineString) {\n const polyBbox = calcBbox(polygon);\n const lineBbox = calcBbox(linestring);\n\n if (!doBBoxOverlap(polyBbox, lineBbox)) {\n return false;\n }\n\n for (const coord of linestring.coordinates) {\n if (!booleanPointInPolygon(coord, polygon)) {\n return false;\n }\n }\n\n let isContainedByPolygonBoundary = false;\n // split intersecting segments and verify their inclusion\n const lineSegments = splitLineIntoSegmentsOnPolygon(linestring, polygon);\n\n for (const lineSegment of lineSegments.features) {\n const midpoint = getMidpoint(\n lineSegment.geometry.coordinates[0],\n lineSegment.geometry.coordinates[1]\n );\n\n // make sure all segments do not intersect with polygon exterior\n if (!booleanPointInPolygon(midpoint, polygon)) {\n return false;\n }\n\n // make sure at least 1 segment intersects with the polygon's interior\n if (\n !isContainedByPolygonBoundary &&\n booleanPointInPolygon(midpoint, polygon, { ignoreBoundary: true })\n ) {\n isContainedByPolygonBoundary = true;\n }\n }\n\n return isContainedByPolygonBoundary;\n}\n\n/**\n * Is Polygon2 in Polygon1\n * Only takes into account outer rings\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(\n feature1: Feature<Polygon> | Polygon,\n feature2: Feature<Polygon> | Polygon\n) {\n // Handle Nulls\n if (feature1.type === \"Feature\" && feature1.geometry === null) {\n return false;\n }\n if (feature2.type === \"Feature\" && feature2.geometry === null) {\n return false;\n }\n\n const poly1Bbox = calcBbox(feature1);\n const poly2Bbox = calcBbox(feature2);\n if (!doBBoxOverlap(poly1Bbox, poly2Bbox)) {\n return false;\n }\n\n const coords = getGeom(feature2).coordinates;\n for (const ring of coords) {\n for (const coord of ring) {\n if (!booleanPointInPolygon(coord, feature1)) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction doBBoxOverlap(bbox1: BBox, bbox2: BBox) {\n if (bbox1[0] > bbox2[0]) {\n return false;\n }\n if (bbox1[2] < bbox2[2]) {\n return false;\n }\n if (bbox1[1] > bbox2[1]) {\n return false;\n }\n if (bbox1[3] < bbox2[3]) {\n return false;\n }\n return true;\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nfunction getMidpoint(pair1: number[], pair2: number[]) {\n return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];\n}\n\nexport {\n booleanContains,\n isPolygonInMultiPolygon,\n isPointInMultiPoint,\n isMultiPointInMultiPoint,\n isMultiPointOnLine,\n isMultiPointInPoly,\n isLineOnLine,\n isLineInPoly,\n isPolyInPoly,\n isMultiPolyInPoly,\n doBBoxOverlap,\n compareCoords,\n getMidpoint,\n};\n\nexport default booleanContains;\n"]} |
| import { Feature, Geometry, MultiPolygon, Polygon, MultiPoint, Point, LineString, BBox } from 'geojson'; | ||
| /** | ||
| * Boolean-contains returns True if the second geometry is completely contained by the first geometry. | ||
| * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) | ||
| * must not intersect the exterior of the primary (geometry a). | ||
| * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`. | ||
| * Tests whether geometry a contains geometry b. | ||
| * The interiors of both geometries must intersect, and the interior and boundary of geometry b must not intersect the exterior of geometry a. | ||
| * booleanContains(a, b) is equivalent to booleanWithin(b, a) | ||
| * | ||
@@ -22,2 +21,3 @@ * @function | ||
| declare function isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon): boolean; | ||
| declare function isMultiPolyInPoly(polygon: Polygon, multiPolygon: MultiPolygon): boolean; | ||
| declare function isPointInMultiPoint(multiPoint: MultiPoint, pt: Point): boolean; | ||
@@ -51,2 +51,2 @@ declare function isMultiPointInMultiPoint(multiPoint1: MultiPoint, multiPoint2: MultiPoint): boolean; | ||
| export { booleanContains, compareCoords, booleanContains as default, doBBoxOverlap, getMidpoint, isLineInPoly, isLineOnLine, isMultiPointInMultiPoint, isMultiPointInPoly, isMultiPointOnLine, isPointInMultiPoint, isPolyInPoly, isPolygonInMultiPolygon }; | ||
| export { booleanContains, compareCoords, booleanContains as default, doBBoxOverlap, getMidpoint, isLineInPoly, isLineOnLine, isMultiPointInMultiPoint, isMultiPointInPoly, isMultiPointOnLine, isMultiPolyInPoly, isPointInMultiPoint, isPolyInPoly, isPolygonInMultiPolygon }; |
| import { Feature, Geometry, MultiPolygon, Polygon, MultiPoint, Point, LineString, BBox } from 'geojson'; | ||
| /** | ||
| * Boolean-contains returns True if the second geometry is completely contained by the first geometry. | ||
| * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) | ||
| * must not intersect the exterior of the primary (geometry a). | ||
| * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`. | ||
| * Tests whether geometry a contains geometry b. | ||
| * The interiors of both geometries must intersect, and the interior and boundary of geometry b must not intersect the exterior of geometry a. | ||
| * booleanContains(a, b) is equivalent to booleanWithin(b, a) | ||
| * | ||
@@ -22,2 +21,3 @@ * @function | ||
| declare function isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon): boolean; | ||
| declare function isMultiPolyInPoly(polygon: Polygon, multiPolygon: MultiPolygon): boolean; | ||
| declare function isPointInMultiPoint(multiPoint: MultiPoint, pt: Point): boolean; | ||
@@ -51,2 +51,2 @@ declare function isMultiPointInMultiPoint(multiPoint1: MultiPoint, multiPoint2: MultiPoint): boolean; | ||
| export { booleanContains, compareCoords, booleanContains as default, doBBoxOverlap, getMidpoint, isLineInPoly, isLineOnLine, isMultiPointInMultiPoint, isMultiPointInPoly, isMultiPointOnLine, isPointInMultiPoint, isPolyInPoly, isPolygonInMultiPolygon }; | ||
| export { booleanContains, compareCoords, booleanContains as default, doBBoxOverlap, getMidpoint, isLineInPoly, isLineOnLine, isMultiPointInMultiPoint, isMultiPointInPoly, isMultiPointOnLine, isMultiPolyInPoly, isPointInMultiPoint, isPolyInPoly, isPolygonInMultiPolygon }; |
+44
-15
@@ -6,2 +6,4 @@ // index.ts | ||
| import { getGeom } from "@turf/invariant"; | ||
| import { feature, featureCollection, lineString } from "@turf/helpers"; | ||
| import { lineSplit } from "@turf/line-split"; | ||
| function booleanContains(feature1, feature2) { | ||
@@ -52,2 +54,4 @@ const geom1 = getGeom(feature1); | ||
| return isMultiPointInPoly(geom1, geom2); | ||
| case "MultiPolygon": | ||
| return isMultiPolyInPoly(geom1, geom2); | ||
| default: | ||
@@ -72,2 +76,7 @@ throw new Error("feature2 " + type2 + " geometry not supported"); | ||
| } | ||
| function isMultiPolyInPoly(polygon, multiPolygon) { | ||
| return multiPolygon.coordinates.every( | ||
| (coords) => isPolyInPoly(polygon, { type: "Polygon", coordinates: coords }) | ||
| ); | ||
| } | ||
| function isPointInMultiPoint(multiPoint, pt) { | ||
@@ -99,9 +108,9 @@ let i; | ||
| } | ||
| function isMultiPointOnLine(lineString, multiPoint) { | ||
| function isMultiPointOnLine(lineString2, multiPoint) { | ||
| let haveFoundInteriorPoint = false; | ||
| for (const coord of multiPoint.coordinates) { | ||
| if (isPointOnLine(coord, lineString, { ignoreEndVertices: true })) { | ||
| if (isPointOnLine(coord, lineString2, { ignoreEndVertices: true })) { | ||
| haveFoundInteriorPoint = true; | ||
| } | ||
| if (!isPointOnLine(coord, lineString)) { | ||
| if (!isPointOnLine(coord, lineString2)) { | ||
| return false; | ||
@@ -139,5 +148,17 @@ } | ||
| } | ||
| function splitLineIntoSegmentsOnPolygon(linestring, polygon) { | ||
| const coords = linestring.coordinates; | ||
| const outputSegments = []; | ||
| for (let i = 0; i < coords.length - 1; i++) { | ||
| const seg = lineString([coords[i], coords[i + 1]]); | ||
| const split = lineSplit(seg, feature(polygon)); | ||
| if (split.features.length === 0) { | ||
| outputSegments.push(seg); | ||
| } else { | ||
| outputSegments.push(...split.features); | ||
| } | ||
| } | ||
| return featureCollection(outputSegments); | ||
| } | ||
| function isLineInPoly(polygon, linestring) { | ||
| let output = false; | ||
| let i = 0; | ||
| const polyBbox = calcBbox(polygon); | ||
@@ -148,15 +169,22 @@ const lineBbox = calcBbox(linestring); | ||
| } | ||
| for (i; i < linestring.coordinates.length - 1; i++) { | ||
| const midPoint = getMidpoint( | ||
| linestring.coordinates[i], | ||
| linestring.coordinates[i + 1] | ||
| for (const coord of linestring.coordinates) { | ||
| if (!booleanPointInPolygon(coord, polygon)) { | ||
| return false; | ||
| } | ||
| } | ||
| let isContainedByPolygonBoundary = false; | ||
| const lineSegments = splitLineIntoSegmentsOnPolygon(linestring, polygon); | ||
| for (const lineSegment of lineSegments.features) { | ||
| const midpoint = getMidpoint( | ||
| lineSegment.geometry.coordinates[0], | ||
| lineSegment.geometry.coordinates[1] | ||
| ); | ||
| if (booleanPointInPolygon({ type: "Point", coordinates: midPoint }, polygon, { | ||
| ignoreBoundary: true | ||
| })) { | ||
| output = true; | ||
| break; | ||
| if (!booleanPointInPolygon(midpoint, polygon)) { | ||
| return false; | ||
| } | ||
| if (!isContainedByPolygonBoundary && booleanPointInPolygon(midpoint, polygon, { ignoreBoundary: true })) { | ||
| isContainedByPolygonBoundary = true; | ||
| } | ||
| } | ||
| return output; | ||
| return isContainedByPolygonBoundary; | ||
| } | ||
@@ -218,2 +246,3 @@ function isPolyInPoly(feature1, feature2) { | ||
| isMultiPointOnLine, | ||
| isMultiPolyInPoly, | ||
| isPointInMultiPoint, | ||
@@ -220,0 +249,0 @@ isPolyInPoly, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n BBox,\n Feature,\n Geometry,\n LineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { bbox as calcBbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { booleanPointOnLine as isPointOnLine } from \"@turf/boolean-point-on-line\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Boolean-contains returns True if the second geometry is completely contained by the first geometry.\n * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b)\n * must not intersect the exterior of the primary (geometry a).\n * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`.\n *\n * @function\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n * var point = turf.point([1, 2]);\n *\n * turf.booleanContains(line, point);\n * //=true\n */\nfunction booleanContains(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n) {\n const geom1 = getGeom(feature1);\n const geom2 = getGeom(feature2);\n const type1 = geom1.type;\n const type2 = geom2.type;\n const coords1 = geom1.coordinates;\n const coords2 = geom2.coordinates;\n\n switch (type1) {\n case \"Point\":\n switch (type2) {\n case \"Point\":\n return compareCoords(coords1, coords2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPoint\":\n switch (type2) {\n case \"Point\":\n return isPointInMultiPoint(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInMultiPoint(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"LineString\":\n switch (type2) {\n case \"Point\":\n return isPointOnLine(geom2, geom1, { ignoreEndVertices: true });\n case \"LineString\":\n return isLineOnLine(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointOnLine(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"Polygon\":\n switch (type2) {\n case \"Point\":\n return booleanPointInPolygon(geom2, geom1, { ignoreBoundary: true });\n case \"LineString\":\n return isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return isPolyInPoly(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInPoly(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPolygon\":\n switch (type2) {\n case \"Polygon\":\n return isPolygonInMultiPolygon(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n default:\n throw new Error(\"feature1 \" + type1 + \" geometry not supported\");\n }\n}\n\nfunction isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon) {\n return multiPolygon.coordinates.some((coords) =>\n isPolyInPoly({ type: \"Polygon\", coordinates: coords }, polygon)\n );\n}\n\nfunction isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) {\n let i;\n let output = false;\n for (i = 0; i < multiPoint.coordinates.length; i++) {\n if (compareCoords(multiPoint.coordinates[i], pt.coordinates)) {\n output = true;\n break;\n }\n }\n return output;\n}\n\nfunction isMultiPointInMultiPoint(\n multiPoint1: MultiPoint,\n multiPoint2: MultiPoint\n) {\n for (const coord2 of multiPoint2.coordinates) {\n let matchFound = false;\n for (const coord1 of multiPoint1.coordinates) {\n if (compareCoords(coord2, coord1)) {\n matchFound = true;\n break;\n }\n }\n if (!matchFound) {\n return false;\n }\n }\n return true;\n}\n\nfunction isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) {\n let haveFoundInteriorPoint = false;\n for (const coord of multiPoint.coordinates) {\n if (isPointOnLine(coord, lineString, { ignoreEndVertices: true })) {\n haveFoundInteriorPoint = true;\n }\n if (!isPointOnLine(coord, lineString)) {\n return false;\n }\n }\n if (haveFoundInteriorPoint) {\n return true;\n }\n return false;\n}\n\nfunction isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) {\n for (const coord of multiPoint.coordinates) {\n if (!booleanPointInPolygon(coord, polygon, { ignoreBoundary: true })) {\n return false;\n }\n }\n return true;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n let haveFoundInteriorPoint = false;\n for (const coords of lineString2.coordinates) {\n if (\n isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: true,\n })\n ) {\n haveFoundInteriorPoint = true;\n }\n if (\n !isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: false,\n })\n ) {\n return false;\n }\n }\n return haveFoundInteriorPoint;\n}\n\nfunction isLineInPoly(polygon: Polygon, linestring: LineString) {\n let output = false;\n let i = 0;\n\n const polyBbox = calcBbox(polygon);\n const lineBbox = calcBbox(linestring);\n if (!doBBoxOverlap(polyBbox, lineBbox)) {\n return false;\n }\n for (i; i < linestring.coordinates.length - 1; i++) {\n const midPoint = getMidpoint(\n linestring.coordinates[i],\n linestring.coordinates[i + 1]\n );\n if (\n booleanPointInPolygon({ type: \"Point\", coordinates: midPoint }, polygon, {\n ignoreBoundary: true,\n })\n ) {\n output = true;\n break;\n }\n }\n return output;\n}\n\n/**\n * Is Polygon2 in Polygon1\n * Only takes into account outer rings\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(\n feature1: Feature<Polygon> | Polygon,\n feature2: Feature<Polygon> | Polygon\n) {\n // Handle Nulls\n if (feature1.type === \"Feature\" && feature1.geometry === null) {\n return false;\n }\n if (feature2.type === \"Feature\" && feature2.geometry === null) {\n return false;\n }\n\n const poly1Bbox = calcBbox(feature1);\n const poly2Bbox = calcBbox(feature2);\n if (!doBBoxOverlap(poly1Bbox, poly2Bbox)) {\n return false;\n }\n\n const coords = getGeom(feature2).coordinates;\n for (const ring of coords) {\n for (const coord of ring) {\n if (!booleanPointInPolygon(coord, feature1)) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction doBBoxOverlap(bbox1: BBox, bbox2: BBox) {\n if (bbox1[0] > bbox2[0]) {\n return false;\n }\n if (bbox1[2] < bbox2[2]) {\n return false;\n }\n if (bbox1[1] > bbox2[1]) {\n return false;\n }\n if (bbox1[3] < bbox2[3]) {\n return false;\n }\n return true;\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nfunction getMidpoint(pair1: number[], pair2: number[]) {\n return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];\n}\n\nexport {\n booleanContains,\n isPolygonInMultiPolygon,\n isPointInMultiPoint,\n isMultiPointInMultiPoint,\n isMultiPointOnLine,\n isMultiPointInPoly,\n isLineOnLine,\n isLineInPoly,\n isPolyInPoly,\n doBBoxOverlap,\n compareCoords,\n getMidpoint,\n};\n\nexport default booleanContains;\n"],"mappings":";AAUA,SAAS,QAAQ,gBAAgB;AACjC,SAAS,6BAA6B;AACtC,SAAS,sBAAsB,qBAAqB;AACpD,SAAS,eAAe;AAmBxB,SAAS,gBACP,UACA,UACA;AACA,QAAM,QAAQ,QAAQ,QAAQ;AAC9B,QAAM,QAAQ,QAAQ,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,SAAS,MAAM;AACxB,UAAI,CAAC,sBAAsB,OAAO,QAAQ,GAAG;AAC3C,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,cAAc,OAAa,OAAa;AAC/C,MAAI,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG;AACvB,WAAO;AAAA,EACT;AACA,MAAI,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG;AACvB,WAAO;AAAA,EACT;AACA,MAAI,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG;AACvB,WAAO;AAAA,EACT;AACA,MAAI,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAUA,SAAS,cAAc,OAAiB,OAAiB;AACvD,SAAO,MAAM,CAAC,MAAM,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,MAAM,CAAC;AACtD;AAEA,SAAS,YAAY,OAAiB,OAAiB;AACrD,SAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;AAC9D;AAiBA,IAAO,gBAAQ;","names":[]} | ||
| {"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n BBox,\n Feature,\n Geometry,\n LineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport { bbox as calcBbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { booleanPointOnLine as isPointOnLine } from \"@turf/boolean-point-on-line\";\nimport { getGeom } from \"@turf/invariant\";\nimport { feature, featureCollection, lineString } from \"@turf/helpers\";\nimport { lineSplit } from \"@turf/line-split\";\n\n/**\n * Tests whether geometry a contains geometry b.\n * The interiors of both geometries must intersect, and the interior and boundary of geometry b must not intersect the exterior of geometry a.\n * booleanContains(a, b) is equivalent to booleanWithin(b, a)\n *\n * @function\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n * var point = turf.point([1, 2]);\n *\n * turf.booleanContains(line, point);\n * //=true\n */\nfunction booleanContains(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n) {\n const geom1 = getGeom(feature1);\n const geom2 = getGeom(feature2);\n const type1 = geom1.type;\n const type2 = geom2.type;\n const coords1 = geom1.coordinates;\n const coords2 = geom2.coordinates;\n\n switch (type1) {\n case \"Point\":\n switch (type2) {\n case \"Point\":\n return compareCoords(coords1, coords2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPoint\":\n switch (type2) {\n case \"Point\":\n return isPointInMultiPoint(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInMultiPoint(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"LineString\":\n switch (type2) {\n case \"Point\":\n return isPointOnLine(geom2, geom1, { ignoreEndVertices: true });\n case \"LineString\":\n return isLineOnLine(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointOnLine(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"Polygon\":\n switch (type2) {\n case \"Point\":\n return booleanPointInPolygon(geom2, geom1, { ignoreBoundary: true });\n case \"LineString\":\n return isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return isPolyInPoly(geom1, geom2);\n case \"MultiPoint\":\n return isMultiPointInPoly(geom1, geom2);\n case \"MultiPolygon\":\n return isMultiPolyInPoly(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n case \"MultiPolygon\":\n switch (type2) {\n case \"Polygon\":\n return isPolygonInMultiPolygon(geom1, geom2);\n default:\n throw new Error(\"feature2 \" + type2 + \" geometry not supported\");\n }\n default:\n throw new Error(\"feature1 \" + type1 + \" geometry not supported\");\n }\n}\n\nfunction isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon) {\n return multiPolygon.coordinates.some((coords) =>\n isPolyInPoly({ type: \"Polygon\", coordinates: coords }, polygon)\n );\n}\n\nfunction isMultiPolyInPoly(polygon: Polygon, multiPolygon: MultiPolygon) {\n return multiPolygon.coordinates.every((coords) =>\n isPolyInPoly(polygon, { type: \"Polygon\", coordinates: coords })\n );\n}\n\nfunction isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) {\n let i;\n let output = false;\n for (i = 0; i < multiPoint.coordinates.length; i++) {\n if (compareCoords(multiPoint.coordinates[i], pt.coordinates)) {\n output = true;\n break;\n }\n }\n return output;\n}\n\nfunction isMultiPointInMultiPoint(\n multiPoint1: MultiPoint,\n multiPoint2: MultiPoint\n) {\n for (const coord2 of multiPoint2.coordinates) {\n let matchFound = false;\n for (const coord1 of multiPoint1.coordinates) {\n if (compareCoords(coord2, coord1)) {\n matchFound = true;\n break;\n }\n }\n if (!matchFound) {\n return false;\n }\n }\n return true;\n}\n\nfunction isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) {\n let haveFoundInteriorPoint = false;\n for (const coord of multiPoint.coordinates) {\n if (isPointOnLine(coord, lineString, { ignoreEndVertices: true })) {\n haveFoundInteriorPoint = true;\n }\n if (!isPointOnLine(coord, lineString)) {\n return false;\n }\n }\n if (haveFoundInteriorPoint) {\n return true;\n }\n return false;\n}\n\nfunction isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) {\n for (const coord of multiPoint.coordinates) {\n if (!booleanPointInPolygon(coord, polygon, { ignoreBoundary: true })) {\n return false;\n }\n }\n return true;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n let haveFoundInteriorPoint = false;\n for (const coords of lineString2.coordinates) {\n if (\n isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: true,\n })\n ) {\n haveFoundInteriorPoint = true;\n }\n if (\n !isPointOnLine({ type: \"Point\", coordinates: coords }, lineString1, {\n ignoreEndVertices: false,\n })\n ) {\n return false;\n }\n }\n return haveFoundInteriorPoint;\n}\n\nfunction splitLineIntoSegmentsOnPolygon(\n linestring: LineString,\n polygon: Polygon\n) {\n const coords = linestring.coordinates;\n\n const outputSegments: Feature<LineString>[] = [];\n\n for (let i = 0; i < coords.length - 1; i++) {\n const seg = lineString([coords[i], coords[i + 1]]);\n const split = lineSplit(seg, feature(polygon));\n\n if (split.features.length === 0) {\n outputSegments.push(seg);\n } else {\n outputSegments.push(...split.features);\n }\n }\n\n return featureCollection(outputSegments);\n}\n\nfunction isLineInPoly(polygon: Polygon, linestring: LineString) {\n const polyBbox = calcBbox(polygon);\n const lineBbox = calcBbox(linestring);\n\n if (!doBBoxOverlap(polyBbox, lineBbox)) {\n return false;\n }\n\n for (const coord of linestring.coordinates) {\n if (!booleanPointInPolygon(coord, polygon)) {\n return false;\n }\n }\n\n let isContainedByPolygonBoundary = false;\n // split intersecting segments and verify their inclusion\n const lineSegments = splitLineIntoSegmentsOnPolygon(linestring, polygon);\n\n for (const lineSegment of lineSegments.features) {\n const midpoint = getMidpoint(\n lineSegment.geometry.coordinates[0],\n lineSegment.geometry.coordinates[1]\n );\n\n // make sure all segments do not intersect with polygon exterior\n if (!booleanPointInPolygon(midpoint, polygon)) {\n return false;\n }\n\n // make sure at least 1 segment intersects with the polygon's interior\n if (\n !isContainedByPolygonBoundary &&\n booleanPointInPolygon(midpoint, polygon, { ignoreBoundary: true })\n ) {\n isContainedByPolygonBoundary = true;\n }\n }\n\n return isContainedByPolygonBoundary;\n}\n\n/**\n * Is Polygon2 in Polygon1\n * Only takes into account outer rings\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(\n feature1: Feature<Polygon> | Polygon,\n feature2: Feature<Polygon> | Polygon\n) {\n // Handle Nulls\n if (feature1.type === \"Feature\" && feature1.geometry === null) {\n return false;\n }\n if (feature2.type === \"Feature\" && feature2.geometry === null) {\n return false;\n }\n\n const poly1Bbox = calcBbox(feature1);\n const poly2Bbox = calcBbox(feature2);\n if (!doBBoxOverlap(poly1Bbox, poly2Bbox)) {\n return false;\n }\n\n const coords = getGeom(feature2).coordinates;\n for (const ring of coords) {\n for (const coord of ring) {\n if (!booleanPointInPolygon(coord, feature1)) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction doBBoxOverlap(bbox1: BBox, bbox2: BBox) {\n if (bbox1[0] > bbox2[0]) {\n return false;\n }\n if (bbox1[2] < bbox2[2]) {\n return false;\n }\n if (bbox1[1] > bbox2[1]) {\n return false;\n }\n if (bbox1[3] < bbox2[3]) {\n return false;\n }\n return true;\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nfunction getMidpoint(pair1: number[], pair2: number[]) {\n return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];\n}\n\nexport {\n booleanContains,\n isPolygonInMultiPolygon,\n isPointInMultiPoint,\n isMultiPointInMultiPoint,\n isMultiPointOnLine,\n isMultiPointInPoly,\n isLineOnLine,\n isLineInPoly,\n isPolyInPoly,\n isMultiPolyInPoly,\n doBBoxOverlap,\n compareCoords,\n getMidpoint,\n};\n\nexport default booleanContains;\n"],"mappings":";AAUA,SAAS,QAAQ,gBAAgB;AACjC,SAAS,6BAA6B;AACtC,SAAS,sBAAsB,qBAAqB;AACpD,SAAS,eAAe;AACxB,SAAS,SAAS,mBAAmB,kBAAkB;AACvD,SAAS,iBAAiB;AAkB1B,SAAS,gBACP,UACA,UACA;AACA,QAAM,QAAQ,QAAQ,QAAQ;AAC9B,QAAM,QAAQ,QAAQ,QAAQ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ACA,SAAO;AACT;AAUA,SAAS,cAAc,OAAiB,OAAiB;AACvD,SAAO,MAAM,CAAC,MAAM,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,MAAM,CAAC;AACtD;AAEA,SAAS,YAAY,OAAiB,OAAiB;AACrD,SAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;AAC9D;AAkBA,IAAO,gBAAQ;","names":["lineString"]} |
+10
-8
| { | ||
| "name": "@turf/boolean-contains", | ||
| "version": "7.3.1", | ||
| "version": "7.3.2", | ||
| "description": "Determines whether the second geometry is completely within the first geometry.", | ||
@@ -8,3 +8,4 @@ "author": "Turf Authors", | ||
| "Rowan Winsemius <@rowanwins>", | ||
| "Denis Carriere <@DenisCarriere>" | ||
| "Denis Carriere <@DenisCarriere>", | ||
| "Samuel Arbibe <@samuelarbibe>" | ||
| ], | ||
@@ -72,11 +73,12 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@turf/bbox": "7.3.1", | ||
| "@turf/boolean-point-in-polygon": "7.3.1", | ||
| "@turf/boolean-point-on-line": "7.3.1", | ||
| "@turf/helpers": "7.3.1", | ||
| "@turf/invariant": "7.3.1", | ||
| "@turf/bbox": "7.3.2", | ||
| "@turf/boolean-point-in-polygon": "7.3.2", | ||
| "@turf/boolean-point-on-line": "7.3.2", | ||
| "@turf/helpers": "7.3.2", | ||
| "@turf/invariant": "7.3.2", | ||
| "@turf/line-split": "7.3.2", | ||
| "@types/geojson": "^7946.0.10", | ||
| "tslib": "^2.8.1" | ||
| }, | ||
| "gitHead": "b7f1b4eafb760431e03955499d8eac9489438219" | ||
| "gitHead": "099d9915467bacf45d554be4533fa9998c4efc88" | ||
| } |
+4
-5
@@ -7,6 +7,5 @@ # @turf/boolean-contains | ||
| Boolean-contains returns True if the second geometry is completely contained by the first geometry. | ||
| The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) | ||
| must not intersect the exterior of the primary (geometry a). | ||
| Boolean-contains returns the exact opposite result of the `@turf/boolean-within`. | ||
| Tests whether geometry a contains geometry b. | ||
| The interiors of both geometries must intersect, and the interior and boundary of geometry b must not intersect the exterior of geometry a. | ||
| booleanContains(a, b) is equivalent to booleanWithin(b, a) | ||
@@ -59,2 +58,2 @@ ### Parameters | ||
|  | ||
|  |
57410
14.48%523
12.23%8
14.29%57
-1.72%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated