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

@turf/boolean-crosses

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/boolean-crosses - npm Package Compare versions

Comparing version 5.1.5 to 6.0.0

index.ts

103

index.js

@@ -1,7 +0,8 @@

import { point } from '@turf/helpers';
import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
import lineIntersect from '@turf/line-intersect';
import polygonToLine from '@turf/polygon-to-line';
import { getGeom, getType } from '@turf/invariant';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var line_intersect_1 = require("@turf/line-intersect");
var polygon_to_line_1 = require("@turf/polygon-to-line");
var boolean_point_in_polygon_1 = require("@turf/boolean-point-in-polygon");
var invariant_1 = require("@turf/invariant");
var helpers_1 = require("@turf/helpers");
/**

@@ -26,42 +27,40 @@ * Boolean-Crosses returns True if the intersection results in a geometry whose dimension is one less than

function booleanCrosses(feature1, feature2) {
var type1 = getType(feature1);
var type2 = getType(feature2);
var geom1 = getGeom(feature1);
var geom2 = getGeom(feature2);
var type1 = invariant_1.getType(feature1);
var type2 = invariant_1.getType(feature2);
var geom1 = invariant_1.getGeom(feature1);
var geom2 = invariant_1.getGeom(feature2);
switch (type1) {
case 'MultiPoint':
switch (type2) {
case 'MultiPoint':
switch (type2) {
case 'LineString':
return doMultiPointAndLineStringCross(geom1, geom2);
case 'Polygon':
return doesMultiPointCrossPoly(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'LineString':
return doMultiPointAndLineStringCross(geom1, geom2);
switch (type2) {
case 'MultiPoint':// An inverse operation
return doMultiPointAndLineStringCross(geom2, geom1);
case 'LineString':
return doLineStringsCross(geom1, geom2);
case 'Polygon':
return doLineStringAndPolygonCross(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'Polygon':
return doesMultiPointCrossPoly(geom1, geom2);
switch (type2) {
case 'MultiPoint':// An inverse operation
return doesMultiPointCrossPoly(geom2, geom1);
case 'LineString':// An inverse operation
return doLineStringAndPolygonCross(geom2, geom1);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'LineString':
switch (type2) {
case 'MultiPoint': // An inverse operation
return doMultiPointAndLineStringCross(geom2, geom1);
case 'LineString':
return doLineStringsCross(geom1, geom2);
case 'Polygon':
return doLineStringAndPolygonCross(geom1, geom2);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
case 'Polygon':
switch (type2) {
case 'MultiPoint': // An inverse operation
return doesMultiPointCrossPoly(geom2, geom1);
case 'LineString': // An inverse operation
return doLineStringAndPolygonCross(geom2, geom1);
default:
throw new Error('feature2 ' + type2 + ' geometry not supported');
}
default:
throw new Error('feature1 ' + type1 + ' geometry not supported');
throw new Error('feature1 ' + type1 + ' geometry not supported');
}
}
function doMultiPointAndLineStringCross(multiPoint, lineString) {

@@ -80,3 +79,4 @@ var foundIntPoint = false;

foundIntPoint = true;
} else {
}
else {
foundExtPoint = true;

@@ -89,5 +89,4 @@ }

}
function doLineStringsCross(lineString1, lineString2) {
var doLinesIntersect = lineIntersect(lineString1, lineString2);
var doLinesIntersect = line_intersect_1.default(lineString1, lineString2);
if (doLinesIntersect.features.length > 0) {

@@ -108,5 +107,5 @@ for (var i = 0; i < lineString1.coordinates.length - 1; i++) {

}
function doLineStringAndPolygonCross(lineString, polygon) {
var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
var line = polygon_to_line_1.polygonToLine(polygon);
var doLinesIntersect = line_intersect_1.default(lineString, line);
if (doLinesIntersect.features.length > 0) {

@@ -117,3 +116,2 @@ return true;

}
function doesMultiPointCrossPoly(multiPoint, polygon) {

@@ -125,5 +123,6 @@ var foundIntPoint = false;

while (i < pointLength && foundIntPoint && foundExtPoint) {
if (booleanPointInPolygon(point(multiPoint.coordinates[0][i]), polygon)) {
if (boolean_point_in_polygon_1.default(helpers_1.point(multiPoint.coordinates[0][i]), polygon)) {
foundIntPoint = true;
} else {
}
else {
foundExtPoint = true;

@@ -133,6 +132,4 @@ }

}
return foundExtPoint && foundExtPoint;
}
/**

@@ -164,3 +161,4 @@ * Is a point on a line segment

return dyl > 0 ? lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1] : lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
} else {
}
else {
if (Math.abs(dxl) >= Math.abs(dyl)) {

@@ -172,3 +170,2 @@ return dxl > 0 ? lineSegmentStart[0] < pt[0] && pt[0] < lineSegmentEnd[0] : lineSegmentEnd[0] < pt[0] && pt[0] < lineSegmentStart[0];

}
export default booleanCrosses;
exports.default = booleanCrosses;
{
"name": "@turf/boolean-crosses",
"version": "5.1.5",
"version": "6.0.0",
"description": "turf boolean-crosses 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,3 +37,2 @@ },

"devDependencies": {
"@std/esm": "*",
"benchmark": "*",

@@ -48,16 +42,12 @@ "boolean-shapely": "*",

"load-json-file": "*",
"rollup": "*",
"typescript": "*",
"tape": "*"
},
"dependencies": {
"@turf/boolean-point-in-polygon": "^5.1.5",
"@turf/helpers": "^5.1.5",
"@turf/invariant": "^5.1.5",
"@turf/line-intersect": "^5.1.5",
"@turf/polygon-to-line": "^5.1.5"
},
"@std/esm": {
"esm": "js",
"cjs": true
"@turf/boolean-point-in-polygon": "6.x",
"@turf/helpers": "6.x",
"@turf/invariant": "6.x",
"@turf/line-intersect": "6.x",
"@turf/polygon-to-line": "6.x"
}
}

@@ -54,1 +54,6 @@ # @turf/boolean-crosses

```
### Diagrams
![esri-crosses](diagrams/esri-crosses.gif)
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