@turf/boolean-point-in-polygon 7.1.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +4 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -11
package/dist/cjs/index.cjs
CHANGED
|
@@ -22,19 +22,17 @@ function booleanPointInPolygon(point, polygon, options = {}) {
|
|
|
22
22
|
let result = false;
|
|
23
23
|
for (var i = 0; i < polys.length; ++i) {
|
|
24
24
|
const polyResult = _pointinpolygonhao2.default.call(void 0, pt, polys[i]);
|
|
25
|
-
if (polyResult === 0)
|
|
26
|
-
|
|
27
|
-
else if (polyResult)
|
|
28
|
-
result = true;
|
|
25
|
+
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
26
|
+
else if (polyResult) result = true;
|
|
29
27
|
}
|
|
30
28
|
return result;
|
|
31
29
|
}
|
|
32
30
|
function inBBox(pt, bbox) {
|
|
33
31
|
return bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1];
|
|
34
32
|
}
|
|
35
|
-
var
|
|
33
|
+
var index_default = booleanPointInPolygon;
|
|
36
34
|
|
|
37
35
|
|
|
38
36
|
|
|
39
|
-
exports.booleanPointInPolygon = booleanPointInPolygon; exports.default =
|
|
37
|
+
exports.booleanPointInPolygon = booleanPointInPolygon; exports.default = index_default;
|
|
40
38
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-boolean-point-in-polygon/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACAA,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EAAA,EAAc,IAAA,EAAY;AACxC,EAAA,OACE,IAAA,CAAK,CAAC,EAAA,GAAK,EAAA,CAAG,CAAC,EAAA,GAAK,IAAA,CAAK,CAAC,EAAA,GAAK,EAAA,CAAG,CAAC,EAAA,GAAK,IAAA,CAAK,CAAC,EAAA,GAAK,EAAA,CAAG,CAAC,EAAA,GAAK,IAAA,CAAK,CAAC,EAAA,GAAK,EAAA,CAAG,CAAC,CAAA;AAE/E;AAGA,IAAO,cAAA,EAAQ,qBAAA;AD9Df;AACE;AACA;AACF,uFAAC","file":"/home/runner/work/turf/turf/packages/turf-boolean-point-in-polygon/dist/cjs/index.cjs","sourcesContent":[null,"import pip from \"point-in-polygon-hao\";\nimport {\n BBox,\n Feature,\n MultiPolygon,\n Polygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Coord } from \"@turf/helpers\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\n\n// http://en.wikipedia.org/wiki/Even%E2%80%93odd_rule\n// modified from: https://github.com/substack/point-in-polygon/blob/master/index.js\n// which was modified from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html\n/**\n * Takes a {@link Point} and a {@link Polygon} or {@link MultiPolygon} and determines if the point\n * resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.\n *\n * @function\n * @param {Coord} point input point\n * @param {Feature<Polygon|MultiPolygon>} polygon input polygon or multipolygon\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.ignoreBoundary=false] True if polygon boundary should be ignored when determining if\n * the point is inside the polygon otherwise false.\n * @returns {boolean} `true` if the Point is inside the Polygon; `false` if the Point is not inside the Polygon\n * @example\n * var pt = turf.point([-77, 44]);\n * var poly = turf.polygon([[\n * [-81, 41],\n * [-81, 47],\n * [-72, 47],\n * [-72, 41],\n * [-81, 41]\n * ]]);\n *\n * turf.booleanPointInPolygon(pt, poly);\n * //= true\n */\nfunction booleanPointInPolygon<\n G extends Polygon | MultiPolygon,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n point: Coord,\n polygon: Feature<G, P> | G,\n options: {\n ignoreBoundary?: boolean;\n } = {}\n) {\n // validation\n if (!point) {\n throw new Error(\"point is required\");\n }\n if (!polygon) {\n throw new Error(\"polygon is required\");\n }\n\n const pt = getCoord(point);\n const geom = getGeom(polygon);\n const type = geom.type;\n const bbox = polygon.bbox;\n let polys: any[] = geom.coordinates;\n\n // Quick elimination if point is not inside bbox\n if (bbox && inBBox(pt, bbox) === false) {\n return false;\n }\n\n if (type === \"Polygon\") {\n polys = [polys];\n }\n let result = false;\n for (var i = 0; i < polys.length; ++i) {\n const polyResult = pip(pt, polys[i]);\n if (polyResult === 0) return options.ignoreBoundary ? false : true;\n else if (polyResult) result = true;\n }\n\n return result;\n}\n\n/**\n * inBBox\n *\n * @private\n * @param {Position} pt point [x,y]\n * @param {BBox} bbox BBox [west, south, east, north]\n * @returns {boolean} true/false if point is inside BBox\n */\nfunction inBBox(pt: number[], bbox: BBox) {\n return (\n bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1]\n );\n}\n\nexport { booleanPointInPolygon };\nexport default booleanPointInPolygon;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { Coord } from '@turf/helpers';
|
|
|
5
5
|
* Takes a {@link Point} and a {@link Polygon} or {@link MultiPolygon} and determines if the point
|
|
6
6
|
* resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
9
|
* @param {Coord} point input point
|
|
10
10
|
* @param {Feature<Polygon|MultiPolygon>} polygon input polygon or multipolygon
|
|
11
11
|
* @param {Object} [options={}] Optional parameters
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Coord } from '@turf/helpers';
|
|
|
5
5
|
* Takes a {@link Point} and a {@link Polygon} or {@link MultiPolygon} and determines if the point
|
|
6
6
|
* resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
9
|
* @param {Coord} point input point
|
|
10
10
|
* @param {Feature<Polygon|MultiPolygon>} polygon input polygon or multipolygon
|
|
11
11
|
* @param {Object} [options={}] Optional parameters
|
package/dist/esm/index.js
CHANGED
|
@@ -22,19 +22,17 @@ function booleanPointInPolygon(point, polygon, options = {}) {
|
|
|
22
22
|
let result = false;
|
|
23
23
|
for (var i = 0; i < polys.length; ++i) {
|
|
24
24
|
const polyResult = pip(pt, polys[i]);
|
|
25
|
-
if (polyResult === 0)
|
|
26
|
-
|
|
27
|
-
else if (polyResult)
|
|
28
|
-
result = true;
|
|
25
|
+
if (polyResult === 0) return options.ignoreBoundary ? false : true;
|
|
26
|
+
else if (polyResult) result = true;
|
|
29
27
|
}
|
|
30
28
|
return result;
|
|
31
29
|
}
|
|
32
30
|
function inBBox(pt, bbox) {
|
|
33
31
|
return bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1];
|
|
34
32
|
}
|
|
35
|
-
var
|
|
33
|
+
var index_default = booleanPointInPolygon;
|
|
36
34
|
export {
|
|
37
35
|
booleanPointInPolygon,
|
|
38
|
-
|
|
36
|
+
index_default as default
|
|
39
37
|
};
|
|
40
38
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import pip from \"point-in-polygon-hao\";\nimport {\n BBox,\n Feature,\n MultiPolygon,\n Polygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Coord } from \"@turf/helpers\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\n\n// http://en.wikipedia.org/wiki/Even%E2%80%93odd_rule\n// modified from: https://github.com/substack/point-in-polygon/blob/master/index.js\n// which was modified from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html\n/**\n * Takes a {@link Point} and a {@link Polygon} or {@link MultiPolygon} and determines if the point\n * resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.\n *\n * @
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import pip from \"point-in-polygon-hao\";\nimport {\n BBox,\n Feature,\n MultiPolygon,\n Polygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Coord } from \"@turf/helpers\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\n\n// http://en.wikipedia.org/wiki/Even%E2%80%93odd_rule\n// modified from: https://github.com/substack/point-in-polygon/blob/master/index.js\n// which was modified from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html\n/**\n * Takes a {@link Point} and a {@link Polygon} or {@link MultiPolygon} and determines if the point\n * resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.\n *\n * @function\n * @param {Coord} point input point\n * @param {Feature<Polygon|MultiPolygon>} polygon input polygon or multipolygon\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.ignoreBoundary=false] True if polygon boundary should be ignored when determining if\n * the point is inside the polygon otherwise false.\n * @returns {boolean} `true` if the Point is inside the Polygon; `false` if the Point is not inside the Polygon\n * @example\n * var pt = turf.point([-77, 44]);\n * var poly = turf.polygon([[\n * [-81, 41],\n * [-81, 47],\n * [-72, 47],\n * [-72, 41],\n * [-81, 41]\n * ]]);\n *\n * turf.booleanPointInPolygon(pt, poly);\n * //= true\n */\nfunction booleanPointInPolygon<\n G extends Polygon | MultiPolygon,\n P extends GeoJsonProperties = GeoJsonProperties,\n>(\n point: Coord,\n polygon: Feature<G, P> | G,\n options: {\n ignoreBoundary?: boolean;\n } = {}\n) {\n // validation\n if (!point) {\n throw new Error(\"point is required\");\n }\n if (!polygon) {\n throw new Error(\"polygon is required\");\n }\n\n const pt = getCoord(point);\n const geom = getGeom(polygon);\n const type = geom.type;\n const bbox = polygon.bbox;\n let polys: any[] = geom.coordinates;\n\n // Quick elimination if point is not inside bbox\n if (bbox && inBBox(pt, bbox) === false) {\n return false;\n }\n\n if (type === \"Polygon\") {\n polys = [polys];\n }\n let result = false;\n for (var i = 0; i < polys.length; ++i) {\n const polyResult = pip(pt, polys[i]);\n if (polyResult === 0) return options.ignoreBoundary ? false : true;\n else if (polyResult) result = true;\n }\n\n return result;\n}\n\n/**\n * inBBox\n *\n * @private\n * @param {Position} pt point [x,y]\n * @param {BBox} bbox BBox [west, south, east, north]\n * @returns {boolean} true/false if point is inside BBox\n */\nfunction inBBox(pt: number[], bbox: BBox) {\n return (\n bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1]\n );\n}\n\nexport { booleanPointInPolygon };\nexport default booleanPointInPolygon;\n"],"mappings":";AAAA,OAAO,SAAS;AAShB,SAAS,UAAU,eAAe;AA6BlC,SAAS,sBAIP,OACA,SACA,UAEI,CAAC,GACL;AAEA,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,QAAM,KAAK,SAAS,KAAK;AACzB,QAAM,OAAO,QAAQ,OAAO;AAC5B,QAAM,OAAO,KAAK;AAClB,QAAM,OAAO,QAAQ;AACrB,MAAI,QAAe,KAAK;AAGxB,MAAI,QAAQ,OAAO,IAAI,IAAI,MAAM,OAAO;AACtC,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,WAAW;AACtB,YAAQ,CAAC,KAAK;AAAA,EAChB;AACA,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,EAAE,GAAG;AACrC,UAAM,aAAa,IAAI,IAAI,MAAM,CAAC,CAAC;AACnC,QAAI,eAAe,EAAG,QAAO,QAAQ,iBAAiB,QAAQ;AAAA,aACrD,WAAY,UAAS;AAAA,EAChC;AAEA,SAAO;AACT;AAUA,SAAS,OAAO,IAAc,MAAY;AACxC,SACE,KAAK,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC;AAE/E;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/boolean-point-in-polygon",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.0",
|
|
4
|
+
"description": "Checks if a point is inside an area, like a city boundary.",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": {
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/benchmark": "^2.1.5",
|
|
57
|
-
"@types/tape": "^
|
|
57
|
+
"@types/tape": "^5.8.1",
|
|
58
58
|
"benchmark": "^2.1.4",
|
|
59
59
|
"npm-run-all": "^4.1.5",
|
|
60
|
-
"tape": "^5.
|
|
61
|
-
"tsup": "^8.0
|
|
62
|
-
"tsx": "^4.
|
|
63
|
-
"typescript": "^5.
|
|
60
|
+
"tape": "^5.9.0",
|
|
61
|
+
"tsup": "^8.4.0",
|
|
62
|
+
"tsx": "^4.19.4",
|
|
63
|
+
"typescript": "^5.8.3"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@turf/helpers": "
|
|
67
|
-
"@turf/invariant": "
|
|
66
|
+
"@turf/helpers": "7.3.0",
|
|
67
|
+
"@turf/invariant": "7.3.0",
|
|
68
68
|
"@types/geojson": "^7946.0.10",
|
|
69
69
|
"point-in-polygon-hao": "^1.1.0",
|
|
70
|
-
"tslib": "^2.
|
|
70
|
+
"tslib": "^2.8.1"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
|
|
73
73
|
}
|