@turf/boolean-point-in-polygon
Advanced tools
Comparing version 5.1.0 to 5.1.5
18
main.js
@@ -35,8 +35,8 @@ 'use strict'; | ||
options = options || {}; | ||
if (typeof options !== 'object') { throw new Error('options is invalid'); } | ||
if (typeof options !== 'object') throw new Error('options is invalid'); | ||
var ignoreBoundary = options.ignoreBoundary; | ||
// validation | ||
if (!point) { throw new Error('point is required'); } | ||
if (!polygon) { throw new Error('polygon is required'); } | ||
if (!point) throw new Error('point is required'); | ||
if (!polygon) throw new Error('polygon is required'); | ||
@@ -49,6 +49,6 @@ var pt = invariant.getCoord(point); | ||
// Quick elimination if point is not inside bbox | ||
if (bbox && inBBox(pt, bbox) === false) { return false; } | ||
if (bbox && inBBox(pt, bbox) === false) return false; | ||
// normalize to multipolygon | ||
if (type === 'Polygon') { polys = [polys]; } | ||
if (type === 'Polygon') polys = [polys]; | ||
@@ -67,3 +67,3 @@ for (var i = 0, insidePoly = false; i < polys.length && !insidePoly; i++) { | ||
} | ||
if (!inHole) { insidePoly = true; } | ||
if (!inHole) insidePoly = true; | ||
} | ||
@@ -85,3 +85,3 @@ } | ||
var isInside = false; | ||
if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1]) { ring = ring.slice(0, ring.length - 1); } | ||
if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1]) ring = ring.slice(0, ring.length - 1); | ||
@@ -93,6 +93,6 @@ for (var i = 0, j = ring.length - 1; i < ring.length; j = i++) { | ||
((xi - pt[0]) * (xj - pt[0]) <= 0) && ((yi - pt[1]) * (yj - pt[1]) <= 0); | ||
if (onBoundary) { return !ignoreBoundary; } | ||
if (onBoundary) return !ignoreBoundary; | ||
var intersect = ((yi > pt[1]) !== (yj > pt[1])) && | ||
(pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi); | ||
if (intersect) { isInside = !isInside; } | ||
if (intersect) isInside = !isInside; | ||
} | ||
@@ -99,0 +99,0 @@ return isInside; |
{ | ||
"name": "@turf/boolean-point-in-polygon", | ||
"version": "5.1.0", | ||
"version": "5.1.5", | ||
"description": "turf boolean-point-in-polygon module", | ||
"main": "main.js", | ||
"module": "main.mjs", | ||
"module": "main.es.js", | ||
"types": "index.d.ts", | ||
@@ -12,3 +12,3 @@ "files": [ | ||
"main.js", | ||
"main.mjs" | ||
"main.es.js" | ||
], | ||
@@ -18,2 +18,3 @@ "scripts": { | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
@@ -44,8 +45,7 @@ "docs": "node ../../scripts/generate-readmes" | ||
"rollup": "*", | ||
"rollup-plugin-buble": "*", | ||
"tape": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/helpers": "^5.1.0", | ||
"@turf/invariant": "^5.1.0" | ||
"@turf/helpers": "^5.1.5", | ||
"@turf/invariant": "^5.1.5" | ||
}, | ||
@@ -52,0 +52,0 @@ "@std/esm": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16619
4
Updated@turf/helpers@^5.1.5
Updated@turf/invariant@^5.1.5