@turf/boolean-disjoint
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-disjoint | ||
* http://turfjs.org/docs/#booleandisjoint | ||
*/ | ||
declare function booleanDisjoint(feature1: Feature, feature2: Feature): boolean; | ||
declare namespace booleanDisjoint { } | ||
export = booleanDisjoint; | ||
export default function ( | ||
feature1: Feature<any> | GeometryObject, | ||
feature2: Feature<any> | GeometryObject | ||
): boolean; |
38
index.js
@@ -1,5 +0,5 @@ | ||
var inside = require('@turf/inside'); | ||
var flattenEach = require('@turf/meta').flattenEach; | ||
var lineIntersect = require('@turf/line-intersect'); | ||
var polyToLinestring = require('@turf/polygon-to-linestring'); | ||
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'; | ||
@@ -12,6 +12,6 @@ /** | ||
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry | ||
* @returns {Boolean} true/false | ||
* @returns {boolean} true/false | ||
* @example | ||
* const point = turf.point([2, 2]); | ||
* const line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
* var point = turf.point([2, 2]); | ||
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
* | ||
@@ -21,3 +21,3 @@ * turf.booleanDisjoint(line, point); | ||
*/ | ||
module.exports = function (feature1, feature2) { | ||
function booleanDisjoint(feature1, feature2) { | ||
var boolean; | ||
@@ -31,3 +31,3 @@ flattenEach(feature1, function (flatten1) { | ||
return boolean; | ||
}; | ||
} | ||
@@ -40,3 +40,3 @@ /** | ||
* @param {Geometry<any>} geom2 GeoJSON Geometry | ||
* @returns {Boolean} true/false | ||
* @returns {boolean} true/false | ||
*/ | ||
@@ -52,3 +52,3 @@ function disjoint(geom1, geom2) { | ||
case 'Polygon': | ||
return !inside(geom1, geom2); | ||
return !booleanPointInPolygon(geom1, geom2); | ||
} | ||
@@ -71,3 +71,3 @@ /* istanbul ignore next */ | ||
case 'Point': | ||
return !inside(geom2, geom1); | ||
return !booleanPointInPolygon(geom2, geom1); | ||
case 'LineString': | ||
@@ -100,3 +100,3 @@ return !isLineInPoly(geom1, geom2); | ||
function isLineInPoly(polygon, lineString) { | ||
var doLinesIntersect = lineIntersect(lineString, polyToLinestring(polygon)); | ||
var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon)); | ||
if (doLinesIntersect.features.length > 0) { | ||
@@ -116,7 +116,7 @@ return true; | ||
* @param {Geometry|Feature<Polygon>} feature2 Polygon2 | ||
* @returns {Boolean} true/false | ||
* @returns {boolean} true/false | ||
*/ | ||
function isPolyInPoly(feature1, feature2) { | ||
for (var i = 0; i < feature1.coordinates[0].length; i++) { | ||
if (inside(feature1.coordinates[0][i], feature2)) { | ||
if (booleanPointInPolygon(feature1.coordinates[0][i], feature2)) { | ||
return true; | ||
@@ -126,3 +126,3 @@ } | ||
for (var i2 = 0; i2 < feature2.coordinates[0].length; i2++) { | ||
if (inside(feature2.coordinates[0][i2], feature1)) { | ||
if (booleanPointInPolygon(feature2.coordinates[0][i2], feature1)) { | ||
return true; | ||
@@ -160,4 +160,4 @@ } | ||
* @private | ||
* @param {[number, number]} pair1 point [x,y] | ||
* @param {[number, number]} pair2 point [x,y] | ||
* @param {Array<number>} pair1 point [x,y] | ||
* @param {Array<number>} pair2 point [x,y] | ||
* @returns {boolean} true/false if coord pairs match | ||
@@ -168,1 +168,3 @@ */ | ||
} | ||
export default booleanDisjoint; |
{ | ||
"name": "@turf/boolean-disjoint", | ||
"version": "4.7.3", | ||
"version": "5.0.4", | ||
"description": "turf boolean-disjoint 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,14 +40,20 @@ "repository": { | ||
"devDependencies": { | ||
"@turf/helpers": "^4.7.3", | ||
"benchmark": "2.1.4", | ||
"boolean-shapely": "0.1.2", | ||
"load-json-file": "2.0.0", | ||
"tape": "4.7.0" | ||
"@std/esm": "*", | ||
"@turf/helpers": "^5.0.4", | ||
"benchmark": "*", | ||
"boolean-shapely": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"tape": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/inside": "^4.7.3", | ||
"@turf/line-intersect": "^4.7.3", | ||
"@turf/meta": "^4.7.3", | ||
"@turf/polygon-to-linestring": "^4.7.3" | ||
"@turf/boolean-point-in-polygon": "^5.0.4", | ||
"@turf/line-intersect": "^5.0.4", | ||
"@turf/meta": "^5.0.4", | ||
"@turf/polygon-to-line": "^5.0.4" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
# @turf/boolean-disjoint | ||
# booleanDisjoint | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
## booleanDisjoint | ||
Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set. | ||
@@ -15,4 +17,4 @@ | ||
```javascript | ||
const point = turf.point([2, 2]); | ||
const line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
var point = turf.point([2, 2]); | ||
var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]); | ||
@@ -23,3 +25,3 @@ turf.booleanDisjoint(line, point); | ||
Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false | ||
Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false | ||
@@ -26,0 +28,0 @@ <!-- This file is automatically generated. Please don't edit it directly: |
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
14219
6
311
50
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/line-intersect@^5.0.4
Updated@turf/meta@^5.0.4