@turf/boolean-disjoint 7.0.0 → 7.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +1 -1
- package/package.json +7 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
5
2
|
var _booleanpointinpolygon = require('@turf/boolean-point-in-polygon');
|
|
6
3
|
var _lineintersect = require('@turf/line-intersect');
|
|
7
4
|
var _meta = require('@turf/meta');
|
|
@@ -18,7 +15,6 @@ function booleanDisjoint(feature1, feature2) {
|
|
|
18
15
|
});
|
|
19
16
|
return bool;
|
|
20
17
|
}
|
|
21
|
-
__name(booleanDisjoint, "booleanDisjoint");
|
|
22
18
|
function disjoint(geom1, geom2) {
|
|
23
19
|
switch (geom1.type) {
|
|
24
20
|
case "Point":
|
|
@@ -53,7 +49,6 @@ function disjoint(geom1, geom2) {
|
|
|
53
49
|
}
|
|
54
50
|
return false;
|
|
55
51
|
}
|
|
56
|
-
__name(disjoint, "disjoint");
|
|
57
52
|
function isPointOnLine(lineString, pt) {
|
|
58
53
|
for (let i = 0; i < lineString.coordinates.length - 1; i++) {
|
|
59
54
|
if (isPointOnLineSegment(
|
|
@@ -66,7 +61,6 @@ function isPointOnLine(lineString, pt) {
|
|
|
66
61
|
}
|
|
67
62
|
return false;
|
|
68
63
|
}
|
|
69
|
-
__name(isPointOnLine, "isPointOnLine");
|
|
70
64
|
function isLineOnLine(lineString1, lineString2) {
|
|
71
65
|
const doLinesIntersect = _lineintersect.lineIntersect.call(void 0, lineString1, lineString2);
|
|
72
66
|
if (doLinesIntersect.features.length > 0) {
|
|
@@ -74,7 +68,6 @@ function isLineOnLine(lineString1, lineString2) {
|
|
|
74
68
|
}
|
|
75
69
|
return false;
|
|
76
70
|
}
|
|
77
|
-
__name(isLineOnLine, "isLineOnLine");
|
|
78
71
|
function isLineInPoly(polygon, lineString) {
|
|
79
72
|
for (const coord of lineString.coordinates) {
|
|
80
73
|
if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0, coord, polygon)) {
|
|
@@ -87,7 +80,6 @@ function isLineInPoly(polygon, lineString) {
|
|
|
87
80
|
}
|
|
88
81
|
return false;
|
|
89
82
|
}
|
|
90
|
-
__name(isLineInPoly, "isLineInPoly");
|
|
91
83
|
function isPolyInPoly(feature1, feature2) {
|
|
92
84
|
for (const coord1 of feature1.coordinates[0]) {
|
|
93
85
|
if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0, coord1, feature2)) {
|
|
@@ -108,7 +100,6 @@ function isPolyInPoly(feature1, feature2) {
|
|
|
108
100
|
}
|
|
109
101
|
return false;
|
|
110
102
|
}
|
|
111
|
-
__name(isPolyInPoly, "isPolyInPoly");
|
|
112
103
|
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt) {
|
|
113
104
|
const dxc = pt[0] - lineSegmentStart[0];
|
|
114
105
|
const dyc = pt[1] - lineSegmentStart[1];
|
|
@@ -130,11 +121,9 @@ function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt) {
|
|
|
130
121
|
return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
|
|
131
122
|
}
|
|
132
123
|
}
|
|
133
|
-
__name(isPointOnLineSegment, "isPointOnLineSegment");
|
|
134
124
|
function compareCoords(pair1, pair2) {
|
|
135
125
|
return pair1[0] === pair2[0] && pair1[1] === pair2[1];
|
|
136
126
|
}
|
|
137
|
-
__name(compareCoords, "compareCoords");
|
|
138
127
|
var turf_boolean_disjoint_default = booleanDisjoint;
|
|
139
128
|
|
|
140
129
|
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAgB9B,SAAS,gBACP,UACA,UACS;AACT,MAAI,OAAO;AACX,cAAY,UAAU,CAAC,aAAa;AAClC,gBAAY,UAAU,CAAC,aAAa;AAClC,UAAI,SAAS,OAAO;AAClB,eAAO;AAAA,MACT;AACA,aAAO,SAAS,SAAS,UAAU,SAAS,QAAQ;AAAA,IACtD,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAUA,SAAS,SAAS,OAAY,OAAY;AACxC,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK;AACH,iBAAO,CAAC,cAAc,MAAM,aAAa,MAAM,WAAW;AAAA,QAC5D,KAAK;AACH,iBAAO,CAAC,cAAc,OAAO,KAAK;AAAA,QACpC,KAAK;AACH,iBAAO,CAAC,sBAAsB,OAAO,KAAK;AAAA,MAC9C;AAEA;AAAA,IACF,KAAK;AACH,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK;AACH,iBAAO,CAAC,cAAc,OAAO,KAAK;AAAA,QACpC,KAAK;AACH,iBAAO,CAAC,aAAa,OAAO,KAAK;AAAA,QACnC,KAAK;AACH,iBAAO,CAAC,aAAa,OAAO,KAAK;AAAA,MACrC;AAEA;AAAA,IACF,KAAK;AACH,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK;AACH,iBAAO,CAAC,sBAAsB,OAAO,KAAK;AAAA,QAC5C,KAAK;AACH,iBAAO,CAAC,aAAa,OAAO,KAAK;AAAA,QACnC,KAAK;AACH,iBAAO,CAAC,aAAa,OAAO,KAAK;AAAA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AG,CAAC,IAAI,iBAAiB,CAAC;AACtC,QAAM,MAAM,eAAe,CAAC,IAAI,iBAAiB,CAAC;AAClD,QAAM,MAAM,eAAe,CAAC,IAAI,iBAAiB,CAAC;AAClD,QAAM,QAAQ,MAAM,MAAM,MAAM;AAChC,MAAI,UAAU,GAAG;AACf,WAAO;AAAA,EACT;AACA,MAAI,KAAK,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,GAAG;AAClC,QAAI,MAAM,GAAG;AACX,aAAO,iBAAiB,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,eAAe,CAAC;AAAA,IAClE,OAAO;AACL,aAAO,eAAe,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,iBAAiB,CAAC;AAAA,IAClE;AAAA,EACF,WAAW,MAAM,GAAG;AAClB,WAAO,iBAAiB,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,eAAe,CAAC;AAAA,EAClE,OAAO;AACL,WAAO,eAAe,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,iBAAiB,CAAC;AAAA,EAClE;AACF;AAUA,SAAS,cAAc,OAAiB,OAAiB;AACvD,SAAO,MAAM,CAAC,MAAM,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,MAAM,CAAC;AACtD;AAGA,IAAO,gCAAQ","sourcesContent":["import { Feature, Geometry, LineString, Point, Polygon } from \"geojson\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { lineIntersect } from \"@turf/line-intersect\";\nimport { flattenEach } from \"@turf/meta\";\nimport { polygonToLine } from \"@turf/polygon-to-line\";\n\n/**\n * Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.\n *\n * @name booleanDisjoint\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var point = turf.point([2, 2]);\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n *\n * turf.booleanDisjoint(line, point);\n * //=true\n */\nfunction booleanDisjoint(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n): boolean {\n let bool = true;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === false) {\n return false;\n }\n bool = disjoint(flatten1.geometry, flatten2.geometry);\n });\n });\n return bool;\n}\n\n/**\n * Disjoint operation for simple Geometries (Point/LineString/Polygon)\n *\n * @private\n * @param {Geometry<any>} geom1 GeoJSON Geometry\n * @param {Geometry<any>} geom2 GeoJSON Geometry\n * @returns {boolean} true/false\n */\nfunction disjoint(geom1: any, geom2: any) {\n switch (geom1.type) {\n case \"Point\":\n switch (geom2.type) {\n case \"Point\":\n return !compareCoords(geom1.coordinates, geom2.coordinates);\n case \"LineString\":\n return !isPointOnLine(geom2, geom1);\n case \"Polygon\":\n return !booleanPointInPolygon(geom1, geom2);\n }\n /* istanbul ignore next */\n break;\n case \"LineString\":\n switch (geom2.type) {\n case \"Point\":\n return !isPointOnLine(geom1, geom2);\n case \"LineString\":\n return !isLineOnLine(geom1, geom2);\n case \"Polygon\":\n return !isLineInPoly(geom2, geom1);\n }\n /* istanbul ignore next */\n break;\n case \"Polygon\":\n switch (geom2.type) {\n case \"Point\":\n return !booleanPointInPolygon(geom2, geom1);\n case \"LineString\":\n return !isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return !isPolyInPoly(geom2, geom1);\n }\n }\n return false;\n}\n\n// http://stackoverflow.com/a/11908158/1979085\nfunction isPointOnLine(lineString: LineString, pt: Point) {\n for (let i = 0; i < lineString.coordinates.length - 1; i++) {\n if (\n isPointOnLineSegment(\n lineString.coordinates[i],\n lineString.coordinates[i + 1],\n pt.coordinates\n )\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n const doLinesIntersect = lineIntersect(lineString1, lineString2);\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\nfunction isLineInPoly(polygon: Polygon, lineString: LineString) {\n for (const coord of lineString.coordinates) {\n if (booleanPointInPolygon(coord, polygon)) {\n return true;\n }\n }\n const doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\n/**\n * Is Polygon (geom1) in Polygon (geom2)\n * Only takes into account outer rings\n * See http://stackoverflow.com/a/4833823/1979085\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(feature1: Polygon, feature2: Polygon) {\n for (const coord1 of feature1.coordinates[0]) {\n if (booleanPointInPolygon(coord1, feature2)) {\n return true;\n }\n }\n for (const coord2 of feature2.coordinates[0]) {\n if (booleanPointInPolygon(coord2, feature1)) {\n return true;\n }\n }\n const doLinesIntersect = lineIntersect(\n polygonToLine(feature1),\n polygonToLine(feature2)\n );\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\nfunction isPointOnLineSegment(\n lineSegmentStart: number[],\n lineSegmentEnd: number[],\n pt: number[]\n) {\n const dxc = pt[0] - lineSegmentStart[0];\n const dyc = pt[1] - lineSegmentStart[1];\n const dxl = lineSegmentEnd[0] - lineSegmentStart[0];\n const dyl = lineSegmentEnd[1] - lineSegmentStart[1];\n const cross = dxc * dyl - dyc * dxl;\n if (cross !== 0) {\n return false;\n }\n if (Math.abs(dxl) >= Math.abs(dyl)) {\n if (dxl > 0) {\n return lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0];\n } else {\n return lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];\n }\n } else if (dyl > 0) {\n return lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1];\n } else {\n return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];\n }\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nexport { booleanDisjoint };\nexport default booleanDisjoint;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// index.ts
|
|
5
2
|
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
|
6
3
|
import { lineIntersect } from "@turf/line-intersect";
|
|
@@ -18,7 +15,6 @@ function booleanDisjoint(feature1, feature2) {
|
|
|
18
15
|
});
|
|
19
16
|
return bool;
|
|
20
17
|
}
|
|
21
|
-
__name(booleanDisjoint, "booleanDisjoint");
|
|
22
18
|
function disjoint(geom1, geom2) {
|
|
23
19
|
switch (geom1.type) {
|
|
24
20
|
case "Point":
|
|
@@ -53,7 +49,6 @@ function disjoint(geom1, geom2) {
|
|
|
53
49
|
}
|
|
54
50
|
return false;
|
|
55
51
|
}
|
|
56
|
-
__name(disjoint, "disjoint");
|
|
57
52
|
function isPointOnLine(lineString, pt) {
|
|
58
53
|
for (let i = 0; i < lineString.coordinates.length - 1; i++) {
|
|
59
54
|
if (isPointOnLineSegment(
|
|
@@ -66,7 +61,6 @@ function isPointOnLine(lineString, pt) {
|
|
|
66
61
|
}
|
|
67
62
|
return false;
|
|
68
63
|
}
|
|
69
|
-
__name(isPointOnLine, "isPointOnLine");
|
|
70
64
|
function isLineOnLine(lineString1, lineString2) {
|
|
71
65
|
const doLinesIntersect = lineIntersect(lineString1, lineString2);
|
|
72
66
|
if (doLinesIntersect.features.length > 0) {
|
|
@@ -74,7 +68,6 @@ function isLineOnLine(lineString1, lineString2) {
|
|
|
74
68
|
}
|
|
75
69
|
return false;
|
|
76
70
|
}
|
|
77
|
-
__name(isLineOnLine, "isLineOnLine");
|
|
78
71
|
function isLineInPoly(polygon, lineString) {
|
|
79
72
|
for (const coord of lineString.coordinates) {
|
|
80
73
|
if (booleanPointInPolygon(coord, polygon)) {
|
|
@@ -87,7 +80,6 @@ function isLineInPoly(polygon, lineString) {
|
|
|
87
80
|
}
|
|
88
81
|
return false;
|
|
89
82
|
}
|
|
90
|
-
__name(isLineInPoly, "isLineInPoly");
|
|
91
83
|
function isPolyInPoly(feature1, feature2) {
|
|
92
84
|
for (const coord1 of feature1.coordinates[0]) {
|
|
93
85
|
if (booleanPointInPolygon(coord1, feature2)) {
|
|
@@ -108,7 +100,6 @@ function isPolyInPoly(feature1, feature2) {
|
|
|
108
100
|
}
|
|
109
101
|
return false;
|
|
110
102
|
}
|
|
111
|
-
__name(isPolyInPoly, "isPolyInPoly");
|
|
112
103
|
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt) {
|
|
113
104
|
const dxc = pt[0] - lineSegmentStart[0];
|
|
114
105
|
const dyc = pt[1] - lineSegmentStart[1];
|
|
@@ -130,11 +121,9 @@ function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt) {
|
|
|
130
121
|
return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
|
|
131
122
|
}
|
|
132
123
|
}
|
|
133
|
-
__name(isPointOnLineSegment, "isPointOnLineSegment");
|
|
134
124
|
function compareCoords(pair1, pair2) {
|
|
135
125
|
return pair1[0] === pair2[0] && pair1[1] === pair2[1];
|
|
136
126
|
}
|
|
137
|
-
__name(compareCoords, "compareCoords");
|
|
138
127
|
var turf_boolean_disjoint_default = booleanDisjoint;
|
|
139
128
|
export {
|
|
140
129
|
booleanDisjoint,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Geometry, LineString, Point, Polygon } from \"geojson\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { lineIntersect } from \"@turf/line-intersect\";\nimport { flattenEach } from \"@turf/meta\";\nimport { polygonToLine } from \"@turf/polygon-to-line\";\n\n/**\n * Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.\n *\n * @name booleanDisjoint\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var point = turf.point([2, 2]);\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n *\n * turf.booleanDisjoint(line, point);\n * //=true\n */\nfunction booleanDisjoint(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n): boolean {\n let bool = true;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === false) {\n return false;\n }\n bool = disjoint(flatten1.geometry, flatten2.geometry);\n });\n });\n return bool;\n}\n\n/**\n * Disjoint operation for simple Geometries (Point/LineString/Polygon)\n *\n * @private\n * @param {Geometry<any>} geom1 GeoJSON Geometry\n * @param {Geometry<any>} geom2 GeoJSON Geometry\n * @returns {boolean} true/false\n */\nfunction disjoint(geom1: any, geom2: any) {\n switch (geom1.type) {\n case \"Point\":\n switch (geom2.type) {\n case \"Point\":\n return !compareCoords(geom1.coordinates, geom2.coordinates);\n case \"LineString\":\n return !isPointOnLine(geom2, geom1);\n case \"Polygon\":\n return !booleanPointInPolygon(geom1, geom2);\n }\n /* istanbul ignore next */\n break;\n case \"LineString\":\n switch (geom2.type) {\n case \"Point\":\n return !isPointOnLine(geom1, geom2);\n case \"LineString\":\n return !isLineOnLine(geom1, geom2);\n case \"Polygon\":\n return !isLineInPoly(geom2, geom1);\n }\n /* istanbul ignore next */\n break;\n case \"Polygon\":\n switch (geom2.type) {\n case \"Point\":\n return !booleanPointInPolygon(geom2, geom1);\n case \"LineString\":\n return !isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return !isPolyInPoly(geom2, geom1);\n }\n }\n return false;\n}\n\n// http://stackoverflow.com/a/11908158/1979085\nfunction isPointOnLine(lineString: LineString, pt: Point) {\n for (let i = 0; i < lineString.coordinates.length - 1; i++) {\n if (\n isPointOnLineSegment(\n lineString.coordinates[i],\n lineString.coordinates[i + 1],\n pt.coordinates\n )\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n const doLinesIntersect = lineIntersect(lineString1, lineString2);\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\nfunction isLineInPoly(polygon: Polygon, lineString: LineString) {\n for (const coord of lineString.coordinates) {\n if (booleanPointInPolygon(coord, polygon)) {\n return true;\n }\n }\n const doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\n/**\n * Is Polygon (geom1) in Polygon (geom2)\n * Only takes into account outer rings\n * See http://stackoverflow.com/a/4833823/1979085\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(feature1: Polygon, feature2: Polygon) {\n for (const coord1 of feature1.coordinates[0]) {\n if (booleanPointInPolygon(coord1, feature2)) {\n return true;\n }\n }\n for (const coord2 of feature2.coordinates[0]) {\n if (booleanPointInPolygon(coord2, feature1)) {\n return true;\n }\n }\n const doLinesIntersect = lineIntersect(\n polygonToLine(feature1),\n polygonToLine(feature2)\n );\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\nfunction isPointOnLineSegment(\n lineSegmentStart: number[],\n lineSegmentEnd: number[],\n pt: number[]\n) {\n const dxc = pt[0] - lineSegmentStart[0];\n const dyc = pt[1] - lineSegmentStart[1];\n const dxl = lineSegmentEnd[0] - lineSegmentStart[0];\n const dyl = lineSegmentEnd[1] - lineSegmentStart[1];\n const cross = dxc * dyl - dyc * dxl;\n if (cross !== 0) {\n return false;\n }\n if (Math.abs(dxl) >= Math.abs(dyl)) {\n if (dxl > 0) {\n return lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0];\n } else {\n return lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];\n }\n } else if (dyl > 0) {\n return lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1];\n } else {\n return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];\n }\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nexport { booleanDisjoint };\nexport default booleanDisjoint;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Geometry, LineString, Point, Polygon } from \"geojson\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { lineIntersect } from \"@turf/line-intersect\";\nimport { flattenEach } from \"@turf/meta\";\nimport { polygonToLine } from \"@turf/polygon-to-line\";\n\n/**\n * Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.\n *\n * @name booleanDisjoint\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var point = turf.point([2, 2]);\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n *\n * turf.booleanDisjoint(line, point);\n * //=true\n */\nfunction booleanDisjoint(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n): boolean {\n let bool = true;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === false) {\n return false;\n }\n bool = disjoint(flatten1.geometry, flatten2.geometry);\n });\n });\n return bool;\n}\n\n/**\n * Disjoint operation for simple Geometries (Point/LineString/Polygon)\n *\n * @private\n * @param {Geometry<any>} geom1 GeoJSON Geometry\n * @param {Geometry<any>} geom2 GeoJSON Geometry\n * @returns {boolean} true/false\n */\nfunction disjoint(geom1: any, geom2: any) {\n switch (geom1.type) {\n case \"Point\":\n switch (geom2.type) {\n case \"Point\":\n return !compareCoords(geom1.coordinates, geom2.coordinates);\n case \"LineString\":\n return !isPointOnLine(geom2, geom1);\n case \"Polygon\":\n return !booleanPointInPolygon(geom1, geom2);\n }\n /* istanbul ignore next */\n break;\n case \"LineString\":\n switch (geom2.type) {\n case \"Point\":\n return !isPointOnLine(geom1, geom2);\n case \"LineString\":\n return !isLineOnLine(geom1, geom2);\n case \"Polygon\":\n return !isLineInPoly(geom2, geom1);\n }\n /* istanbul ignore next */\n break;\n case \"Polygon\":\n switch (geom2.type) {\n case \"Point\":\n return !booleanPointInPolygon(geom2, geom1);\n case \"LineString\":\n return !isLineInPoly(geom1, geom2);\n case \"Polygon\":\n return !isPolyInPoly(geom2, geom1);\n }\n }\n return false;\n}\n\n// http://stackoverflow.com/a/11908158/1979085\nfunction isPointOnLine(lineString: LineString, pt: Point) {\n for (let i = 0; i < lineString.coordinates.length - 1; i++) {\n if (\n isPointOnLineSegment(\n lineString.coordinates[i],\n lineString.coordinates[i + 1],\n pt.coordinates\n )\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction isLineOnLine(lineString1: LineString, lineString2: LineString) {\n const doLinesIntersect = lineIntersect(lineString1, lineString2);\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\nfunction isLineInPoly(polygon: Polygon, lineString: LineString) {\n for (const coord of lineString.coordinates) {\n if (booleanPointInPolygon(coord, polygon)) {\n return true;\n }\n }\n const doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\n/**\n * Is Polygon (geom1) in Polygon (geom2)\n * Only takes into account outer rings\n * See http://stackoverflow.com/a/4833823/1979085\n *\n * @private\n * @param {Geometry|Feature<Polygon>} feature1 Polygon1\n * @param {Geometry|Feature<Polygon>} feature2 Polygon2\n * @returns {boolean} true/false\n */\nfunction isPolyInPoly(feature1: Polygon, feature2: Polygon) {\n for (const coord1 of feature1.coordinates[0]) {\n if (booleanPointInPolygon(coord1, feature2)) {\n return true;\n }\n }\n for (const coord2 of feature2.coordinates[0]) {\n if (booleanPointInPolygon(coord2, feature1)) {\n return true;\n }\n }\n const doLinesIntersect = lineIntersect(\n polygonToLine(feature1),\n polygonToLine(feature2)\n );\n if (doLinesIntersect.features.length > 0) {\n return true;\n }\n return false;\n}\n\nfunction isPointOnLineSegment(\n lineSegmentStart: number[],\n lineSegmentEnd: number[],\n pt: number[]\n) {\n const dxc = pt[0] - lineSegmentStart[0];\n const dyc = pt[1] - lineSegmentStart[1];\n const dxl = lineSegmentEnd[0] - lineSegmentStart[0];\n const dyl = lineSegmentEnd[1] - lineSegmentStart[1];\n const cross = dxc * dyl - dyc * dxl;\n if (cross !== 0) {\n return false;\n }\n if (Math.abs(dxl) >= Math.abs(dyl)) {\n if (dxl > 0) {\n return lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0];\n } else {\n return lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];\n }\n } else if (dyl > 0) {\n return lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1];\n } else {\n return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];\n }\n}\n\n/**\n * compareCoords\n *\n * @private\n * @param {Position} pair1 point [x,y]\n * @param {Position} pair2 point [x,y]\n * @returns {boolean} true/false if coord pairs match\n */\nfunction compareCoords(pair1: number[], pair2: number[]) {\n return pair1[0] === pair2[0] && pair1[1] === pair2[1];\n}\n\nexport { booleanDisjoint };\nexport default booleanDisjoint;\n"],"mappings":";AACA,SAAS,6BAA6B;AACtC,SAAS,qB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,EACT;AACA,MAAI,KAAK,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,GAAG;AAClC,QAAI,MAAM,GAAG;AACX,aAAO,iBAAiB,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,eAAe,CAAC;AAAA,IAClE,OAAO;AACL,aAAO,eAAe,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,iBAAiB,CAAC;AAAA,IAClE;AAAA,EACF,WAAW,MAAM,GAAG;AAClB,WAAO,iBAAiB,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,eAAe,CAAC;AAAA,EAClE,OAAO;AACL,WAAO,eAAe,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,KAAK,iBAAiB,CAAC;AAAA,EAClE;AACF;AAUA,SAAS,cAAc,OAAiB,OAAiB;AACvD,SAAO,MAAM,CAAC,MAAM,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,MAAM,CAAC;AACtD;AAGA,IAAO,gCAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/boolean-disjoint",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.7+0ce6ecca0",
|
|
4
4
|
"description": "turf boolean-disjoint module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"typescript": "^5.2.2"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@turf/boolean-point-in-polygon": "^7.0.
|
|
71
|
-
"@turf/helpers": "^7.0.
|
|
72
|
-
"@turf/line-intersect": "^7.0.
|
|
73
|
-
"@turf/meta": "^7.0.
|
|
74
|
-
"@turf/polygon-to-line": "^7.0.
|
|
70
|
+
"@turf/boolean-point-in-polygon": "^7.1.0-alpha.7+0ce6ecca0",
|
|
71
|
+
"@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
|
|
72
|
+
"@turf/line-intersect": "^7.1.0-alpha.7+0ce6ecca0",
|
|
73
|
+
"@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
|
|
74
|
+
"@turf/polygon-to-line": "^7.1.0-alpha.7+0ce6ecca0",
|
|
75
75
|
"tslib": "^2.6.2"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
|
|
78
78
|
}
|