Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/boolean-disjoint

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/boolean-disjoint - npm Package Compare versions

Comparing version 5.1.6 to 6.0.0

index.ts

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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc