@turf/boolean-disjoint
Advanced tools
Comparing version 5.1.6 to 6.0.0
105
index.js
@@ -1,6 +0,7 @@ | ||
import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; | ||
import { flattenEach } from '@turf/meta'; | ||
import lineIntersect from '@turf/line-intersect'; | ||
import polygonToLine from '@turf/polygon-to-line'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var boolean_point_in_polygon_1 = require("@turf/boolean-point-in-polygon"); | ||
var meta_1 = require("@turf/meta"); | ||
var line_intersect_1 = require("@turf/line-intersect"); | ||
var polygon_to_line_1 = require("@turf/polygon-to-line"); | ||
/** | ||
@@ -22,5 +23,6 @@ * Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set. | ||
var boolean; | ||
flattenEach(feature1, function (flatten1) { | ||
flattenEach(feature2, function (flatten2) { | ||
if (boolean === false) return false; | ||
meta_1.flattenEach(feature1, function (flatten1) { | ||
meta_1.flattenEach(feature2, function (flatten2) { | ||
if (boolean === false) | ||
return false; | ||
boolean = disjoint(flatten1.geometry, flatten2.geometry); | ||
@@ -31,3 +33,2 @@ }); | ||
} | ||
/** | ||
@@ -43,36 +44,35 @@ * Disjoint operation for simple Geometries (Point/LineString/Polygon) | ||
switch (geom1.type) { | ||
case 'Point': | ||
switch (geom2.type) { | ||
case 'Point': | ||
return !compareCoords(geom1.coordinates, geom2.coordinates); | ||
switch (geom2.type) { | ||
case 'Point': | ||
return !compareCoords(geom1.coordinates, geom2.coordinates); | ||
case 'LineString': | ||
return !isPointOnLine(geom2, geom1); | ||
case 'Polygon': | ||
return !boolean_point_in_polygon_1.default(geom1, geom2); | ||
} | ||
/* istanbul ignore next */ | ||
break; | ||
case 'LineString': | ||
return !isPointOnLine(geom2, geom1); | ||
switch (geom2.type) { | ||
case 'Point': | ||
return !isPointOnLine(geom1, geom2); | ||
case 'LineString': | ||
return !isLineOnLine(geom1, geom2); | ||
case 'Polygon': | ||
return !isLineInPoly(geom2, geom1); | ||
} | ||
/* istanbul ignore next */ | ||
break; | ||
case 'Polygon': | ||
return !booleanPointInPolygon(geom1, geom2); | ||
} | ||
/* istanbul ignore next */ | ||
break; | ||
case 'LineString': | ||
switch (geom2.type) { | ||
case 'Point': | ||
return !isPointOnLine(geom1, geom2); | ||
case 'LineString': | ||
return !isLineOnLine(geom1, geom2); | ||
case 'Polygon': | ||
return !isLineInPoly(geom2, geom1); | ||
} | ||
/* istanbul ignore next */ | ||
break; | ||
case 'Polygon': | ||
switch (geom2.type) { | ||
case 'Point': | ||
return !booleanPointInPolygon(geom2, geom1); | ||
case 'LineString': | ||
return !isLineInPoly(geom1, geom2); | ||
case 'Polygon': | ||
return !isPolyInPoly(geom2, geom1); | ||
} | ||
switch (geom2.type) { | ||
case 'Point': | ||
return !boolean_point_in_polygon_1.default(geom2, geom1); | ||
case 'LineString': | ||
return !isLineInPoly(geom1, geom2); | ||
case 'Polygon': | ||
return !isPolyInPoly(geom2, geom1); | ||
} | ||
} | ||
} | ||
// http://stackoverflow.com/a/11908158/1979085 | ||
@@ -87,5 +87,4 @@ function isPointOnLine(lineString, point) { | ||
} | ||
function isLineOnLine(lineString1, lineString2) { | ||
var doLinesIntersect = lineIntersect(lineString1, lineString2); | ||
var doLinesIntersect = line_intersect_1.default(lineString1, lineString2); | ||
if (doLinesIntersect.features.length > 0) { | ||
@@ -96,10 +95,9 @@ return true; | ||
} | ||
function isLineInPoly(polygon, lineString) { | ||
for (var i = 0; i < lineString.coordinates.length; i++) { | ||
if (booleanPointInPolygon(lineString.coordinates[i], polygon)) { | ||
if (boolean_point_in_polygon_1.default(lineString.coordinates[i], polygon)) { | ||
return true; | ||
} | ||
} | ||
var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon)); | ||
var doLinesIntersect = line_intersect_1.default(lineString, polygon_to_line_1.default(polygon)); | ||
if (doLinesIntersect.features.length > 0) { | ||
@@ -110,3 +108,2 @@ return true; | ||
} | ||
/** | ||
@@ -124,3 +121,3 @@ * Is Polygon (geom1) in Polygon (geom2) | ||
for (var i = 0; i < feature1.coordinates[0].length; i++) { | ||
if (booleanPointInPolygon(feature1.coordinates[0][i], feature2)) { | ||
if (boolean_point_in_polygon_1.default(feature1.coordinates[0][i], feature2)) { | ||
return true; | ||
@@ -130,7 +127,7 @@ } | ||
for (var i2 = 0; i2 < feature2.coordinates[0].length; i2++) { | ||
if (booleanPointInPolygon(feature2.coordinates[0][i2], feature1)) { | ||
if (boolean_point_in_polygon_1.default(feature2.coordinates[0][i2], feature1)) { | ||
return true; | ||
} | ||
} | ||
var doLinesIntersect = lineIntersect(polygonToLine(feature1), polygonToLine(feature2)); | ||
var doLinesIntersect = line_intersect_1.default(polygon_to_line_1.default(feature1), polygon_to_line_1.default(feature2)); | ||
if (doLinesIntersect.features.length > 0) { | ||
@@ -141,3 +138,2 @@ return true; | ||
} | ||
function isPointOnLineSegment(LineSegmentStart, LineSegmentEnd, Point) { | ||
@@ -155,12 +151,14 @@ var dxc = Point[0] - LineSegmentStart[0]; | ||
return LineSegmentStart[0] <= Point[0] && Point[0] <= LineSegmentEnd[0]; | ||
} else { | ||
} | ||
else { | ||
return LineSegmentEnd[0] <= Point[0] && Point[0] <= LineSegmentStart[0]; | ||
} | ||
} else if (dyl > 0) { | ||
} | ||
else if (dyl > 0) { | ||
return LineSegmentStart[1] <= Point[1] && Point[1] <= LineSegmentEnd[1]; | ||
} else { | ||
} | ||
else { | ||
return LineSegmentEnd[1] <= Point[1] && Point[1] <= LineSegmentStart[1]; | ||
} | ||
} | ||
/** | ||
@@ -177,3 +175,2 @@ * compareCoords | ||
} | ||
export default booleanDisjoint; | ||
exports.default = booleanDisjoint; |
{ | ||
"name": "@turf/boolean-disjoint", | ||
"version": "5.1.6", | ||
"version": "6.0.0", | ||
"description": "turf boolean-disjoint module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"types": "index.d.ts", | ||
"main": "index", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"main.js", | ||
"main.es.js" | ||
"index.ts" | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"pretest": "tsc", | ||
"test": "node test.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -42,20 +37,15 @@ }, | ||
"devDependencies": { | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"boolean-shapely": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"typescript": "*", | ||
"tape": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/boolean-point-in-polygon": "^5.1.5", | ||
"@turf/helpers": "^5.1.5", | ||
"@turf/line-intersect": "^5.1.5", | ||
"@turf/meta": "^5.1.5", | ||
"@turf/polygon-to-line": "^5.1.5" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
"@turf/boolean-point-in-polygon": "6.0.0", | ||
"@turf/helpers": "6.x", | ||
"@turf/line-intersect": "6.x", | ||
"@turf/meta": "6.x", | ||
"@turf/polygon-to-line": "6.x" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
5
14865
5
325
1
+ Added@turf/bbox@7.1.0(transitive)
+ Added@turf/boolean-point-in-polygon@6.0.0(transitive)
+ Added@turf/helpers@6.5.07.1.0(transitive)
+ Added@turf/invariant@6.5.0(transitive)
+ Added@turf/line-intersect@6.5.0(transitive)
+ Added@turf/line-segment@6.5.0(transitive)
+ Added@turf/meta@6.5.07.1.0(transitive)
+ Added@turf/polygon-to-line@6.5.0(transitive)
+ Added@types/geojson@7946.0.157946.0.8(transitive)
+ Addedgeojson-rbush@3.2.0(transitive)
+ Addedquickselect@2.0.0(transitive)
+ Addedrbush@3.0.1(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@turf/boolean-point-in-polygon@5.1.5(transitive)
- Removed@turf/helpers@5.1.5(transitive)
- Removed@turf/invariant@5.2.0(transitive)
- Removed@turf/line-intersect@5.1.5(transitive)
- Removed@turf/line-segment@5.1.5(transitive)
- Removed@turf/meta@5.2.0(transitive)
- Removed@turf/polygon-to-line@5.1.5(transitive)
- Removedgeojson-rbush@2.1.0(transitive)
- Removedquickselect@3.0.0(transitive)
- Removedrbush@4.0.1(transitive)
Updated@turf/helpers@6.x
Updated@turf/line-intersect@6.x
Updated@turf/meta@6.x
Updated@turf/polygon-to-line@6.x