@turf/boolean-point-in-polygon
Advanced tools
Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -82,3 +82,4 @@ import { getCoord, getGeom } from "@turf/invariant"; | ||
var isInside = false; | ||
if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][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); | ||
@@ -91,9 +92,10 @@ } | ||
var yj = ring[j][1]; | ||
var onBoundary = (pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0) && | ||
((xi - pt[0]) * (xj - pt[0]) <= 0) && ((yi - pt[1]) * (yj - pt[1]) <= 0); | ||
var onBoundary = pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0 && | ||
(xi - pt[0]) * (xj - pt[0]) <= 0 && | ||
(yi - pt[1]) * (yj - pt[1]) <= 0; | ||
if (onBoundary) { | ||
return !ignoreBoundary; | ||
} | ||
var intersect = ((yi > pt[1]) !== (yj > pt[1])) && | ||
(pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi); | ||
var intersect = yi > pt[1] !== yj > pt[1] && | ||
pt[0] < ((xj - xi) * (pt[1] - yi)) / (yj - yi) + xi; | ||
if (intersect) { | ||
@@ -114,6 +116,3 @@ isInside = !isInside; | ||
function inBBox(pt, bbox) { | ||
return bbox[0] <= pt[0] && | ||
bbox[1] <= pt[1] && | ||
bbox[2] >= pt[0] && | ||
bbox[3] >= pt[1]; | ||
return (bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1]); | ||
} |
@@ -26,4 +26,4 @@ import { Coord, Feature, MultiPolygon, Polygon, Properties } from "@turf/helpers"; | ||
*/ | ||
export default function booleanPointInPolygon<G extends Polygon | MultiPolygon, P = Properties>(point: Coord, polygon: Feature<G> | G, options?: { | ||
export default function booleanPointInPolygon<G extends Polygon | MultiPolygon, P = Properties>(point: Coord, polygon: Feature<G, P> | G, options?: { | ||
ignoreBoundary?: boolean; | ||
}): boolean; |
@@ -85,3 +85,4 @@ "use strict"; | ||
var isInside = false; | ||
if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][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); | ||
@@ -94,9 +95,10 @@ } | ||
var yj = ring[j][1]; | ||
var onBoundary = (pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0) && | ||
((xi - pt[0]) * (xj - pt[0]) <= 0) && ((yi - pt[1]) * (yj - pt[1]) <= 0); | ||
var onBoundary = pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0 && | ||
(xi - pt[0]) * (xj - pt[0]) <= 0 && | ||
(yi - pt[1]) * (yj - pt[1]) <= 0; | ||
if (onBoundary) { | ||
return !ignoreBoundary; | ||
} | ||
var intersect = ((yi > pt[1]) !== (yj > pt[1])) && | ||
(pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi); | ||
var intersect = yi > pt[1] !== yj > pt[1] && | ||
pt[0] < ((xj - xi) * (pt[1] - yi)) / (yj - yi) + xi; | ||
if (intersect) { | ||
@@ -117,6 +119,3 @@ isInside = !isInside; | ||
function inBBox(pt, bbox) { | ||
return bbox[0] <= pt[0] && | ||
bbox[1] <= pt[1] && | ||
bbox[2] >= pt[0] && | ||
bbox[3] >= pt[1]; | ||
return (bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1]); | ||
} |
{ | ||
"name": "@turf/boolean-point-in-polygon", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf boolean-point-in-polygon module", | ||
@@ -28,2 +28,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "dist/js/index.d.ts", | ||
@@ -35,10 +39,9 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "ts-node bench.js", | ||
"build": "npm-run-all build:*", | ||
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"build:js": "tsc", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"prepare": "npm-run-all prepare:*", | ||
"prepare:es": "tsc --outDir dist/es --module esnext --declaration false", | ||
"prepare:js": "tsc", | ||
"test": "npm-run-all prepare test:*", | ||
"test:tape": "node -r esm test.js" | ||
"test": "npm-run-all test:*", | ||
"test:tape": "ts-node -r esm test.js" | ||
}, | ||
@@ -50,2 +53,3 @@ "devDependencies": { | ||
"tape": "*", | ||
"ts-node": "*", | ||
"tslint": "*", | ||
@@ -55,6 +59,6 @@ "typescript": "*" | ||
"dependencies": { | ||
"@turf/helpers": "^6.2.0-alpha.2", | ||
"@turf/invariant": "^6.2.0-alpha.2" | ||
"@turf/helpers": "^6.2.0-alpha.3", | ||
"@turf/invariant": "^6.2.0-alpha.3" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
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
13959
7
7
261