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 4.7.3 to 5.0.4

main.js

13

index.d.ts

@@ -1,10 +0,9 @@

/// <reference types="geojson" />
import { Feature, GeometryObject } from '@turf/helpers'
type Feature = GeoJSON.Feature<any> | GeoJSON.GeometryObject;
/**
* http://turfjs.org/docs/#boolean-crosses
* http://turfjs.org/docs/#booleancrosses
*/
declare function booleanCrosses(feature1: Feature, feature2: Feature): boolean;
declare namespace booleanCrosses { }
export = booleanCrosses;
export default function (
feature1: Feature<any> | GeometryObject,
feature2: Feature<any> | GeometryObject
): boolean;

@@ -1,8 +0,6 @@

var helpers = require('@turf/helpers');
var inside = require('@turf/inside');
var lineIntersect = require('@turf/line-intersect');
var polyToLinestring = require('@turf/polygon-to-linestring');
var invariant = require('@turf/invariant');
var getGeom = invariant.getGeom;
var getGeomType = invariant.getGeomType;
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';

@@ -27,5 +25,5 @@ /**

*/
module.exports = function (feature1, feature2) {
var type1 = getGeomType(feature1);
var type2 = getGeomType(feature2);
function booleanCrosses(feature1, feature2) {
var type1 = getType(feature1);
var type2 = getType(feature2);
var geom1 = getGeom(feature1);

@@ -67,3 +65,3 @@ var geom2 = getGeom(feature2);

}
};
}

@@ -111,3 +109,3 @@ function doMultiPointAndLineStringCross(multiPoint, lineString) {

function doLineStringAndPolygonCross(lineString, polygon) {
var doLinesIntersect = lineIntersect(lineString, polyToLinestring(polygon));
var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
if (doLinesIntersect.features.length > 0) {

@@ -119,6 +117,2 @@ return true;

function isPointInPoly(polygon, point) {
return inside(point, polygon);
}
function doesMultiPointCrossPoly(multiPoint, polygon) {

@@ -130,3 +124,3 @@ var foundIntPoint = false;

while (i < pointLength && foundIntPoint && foundExtPoint) {
if (isPointInPoly(polygon, helpers.point(multiPoint.coordinates[0][i]), true)) {
if (booleanPointInPolygon(point(multiPoint.coordinates[0][i]), polygon)) {
foundIntPoint = true;

@@ -148,11 +142,11 @@ } else {

* @private
* @param {Array} lineSegmentStart coord pair of start of line
* @param {Array} lineSegmentEnd coord pair of end of line
* @param {Array} point coord pair of point to check
* @param {number[]} lineSegmentStart coord pair of start of line
* @param {number[]} lineSegmentEnd coord pair of end of line
* @param {number[]} pt coord pair of point to check
* @param {boolean} incEnd whether the point is allowed to fall on the line ends
* @returns {boolean} true/false
*/
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, point, incEnd) {
var dxc = point[0] - lineSegmentStart[0];
var dyc = point[1] - lineSegmentStart[1];
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt, incEnd) {
var dxc = pt[0] - lineSegmentStart[0];
var dyc = pt[1] - lineSegmentStart[1];
var dxl = lineSegmentEnd[0] - lineSegmentStart[0];

@@ -166,11 +160,13 @@ var dyl = lineSegmentEnd[1] - lineSegmentStart[1];

if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? lineSegmentStart[0] <= point[0] && point[0] <= lineSegmentEnd[0] : lineSegmentEnd[0] <= point[0] && point[0] <= lineSegmentStart[0];
return dxl > 0 ? lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0] : lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];
}
return dyl > 0 ? lineSegmentStart[1] <= point[1] && point[1] <= lineSegmentEnd[1] : lineSegmentEnd[1] <= point[1] && point[1] <= lineSegmentStart[1];
return dyl > 0 ? lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1] : lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
} else {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? lineSegmentStart[0] < point[0] && point[0] < lineSegmentEnd[0] : lineSegmentEnd[0] < point[0] && point[0] < lineSegmentStart[0];
return dxl > 0 ? lineSegmentStart[0] < pt[0] && pt[0] < lineSegmentEnd[0] : lineSegmentEnd[0] < pt[0] && pt[0] < lineSegmentStart[0];
}
return dyl > 0 ? lineSegmentStart[1] < point[1] && point[1] < lineSegmentEnd[1] : lineSegmentEnd[1] < point[1] && point[1] < lineSegmentStart[1];
return dyl > 0 ? lineSegmentStart[1] < pt[1] && pt[1] < lineSegmentEnd[1] : lineSegmentEnd[1] < pt[1] && pt[1] < lineSegmentStart[1];
}
}
export default booleanCrosses;
{
"name": "@turf/boolean-crosses",
"version": "4.7.3",
"version": "5.0.4",
"description": "turf boolean-crosses module",
"main": "index.js",
"main": "main",
"module": "index",
"jsnext:main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"main.js"
],
"scripts": {
"test": "node test.js",
"bench": "node bench.js"
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"bench": "node -r @std/esm bench.js"
},

@@ -36,15 +40,21 @@ "repository": {

"devDependencies": {
"benchmark": "2.1.4",
"boolean-shapely": "0.1.2",
"glob": "7.1.2",
"load-json-file": "2.0.0",
"tape": "4.7.0"
"@std/esm": "*",
"benchmark": "*",
"boolean-shapely": "*",
"glob": "*",
"load-json-file": "*",
"rollup": "*",
"tape": "*"
},
"dependencies": {
"@turf/helpers": "^4.7.3",
"@turf/inside": "^4.7.3",
"@turf/invariant": "^4.7.3",
"@turf/line-intersect": "^4.7.3",
"@turf/polygon-to-linestring": "^4.7.3"
"@turf/boolean-point-in-polygon": "^5.0.4",
"@turf/helpers": "^5.0.4",
"@turf/invariant": "^5.0.4",
"@turf/line-intersect": "^5.0.4",
"@turf/polygon-to-line": "^5.0.4"
},
"@std/esm": {
"esm": "js",
"cjs": true
}
}
# @turf/boolean-crosses
# booleanCrosses
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## booleanCrosses
Boolean-Crosses returns True if the intersection results in a geometry whose dimension is one less than

@@ -6,0 +8,0 @@ the maximum dimension of the two source geometries and the intersection set is interior to

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