@turf/boolean-crosses
Advanced tools
Comparing version 4.7.3 to 5.0.4
@@ -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; |
50
index.js
@@ -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 |
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
17535
6
323
54
7
1
+ Added@turf/polygon-to-line@^5.0.4
+ Added@turf/boolean-point-in-polygon@5.1.5(transitive)
+ Added@turf/helpers@5.1.5(transitive)
+ Added@turf/invariant@5.2.0(transitive)
+ Added@turf/line-intersect@5.1.5(transitive)
+ Added@turf/line-segment@5.1.5(transitive)
+ Added@turf/meta@5.2.0(transitive)
+ Added@turf/polygon-to-line@5.1.5(transitive)
+ Addedgeojson-rbush@2.1.0(transitive)
+ Addedquickselect@3.0.0(transitive)
+ Addedrbush@4.0.1(transitive)
- Removed@turf/inside@^4.7.3
- Removed@turf/polygon-to-linestring@^4.7.3
- Removed@turf/helpers@4.7.3(transitive)
- Removed@turf/inside@4.7.3(transitive)
- Removed@turf/invariant@4.7.3(transitive)
- Removed@turf/line-intersect@4.7.3(transitive)
- Removed@turf/line-segment@4.7.3(transitive)
- Removed@turf/meta@4.7.4(transitive)
- Removed@turf/polygon-to-linestring@4.7.3(transitive)
- Removedgeojson-rbush@1.2.0(transitive)
- Removedquickselect@1.1.1(transitive)
- Removedrbush@2.0.2(transitive)
Updated@turf/helpers@^5.0.4
Updated@turf/invariant@^5.0.4
Updated@turf/line-intersect@^5.0.4