@turf/boolean-disjoint 6.5.0 → 7.0.0-alpha.0
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/README.md +4 -4
- package/dist/es/index.js +15 -18
- package/dist/js/index.d.ts +1 -1
- package/dist/js/index.js +20 -25
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* `feature1` **([Geometry][1] | [Feature][2]\<any>)** GeoJSON Feature or Geometry
|
|
12
|
+
* `feature2` **([Geometry][1] | [Feature][2]\<any>)** GeoJSON Feature or Geometry
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### Examples
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
17
|
var point = turf.point([2, 2]);
|
package/dist/es/index.js
CHANGED
|
@@ -17,9 +17,9 @@ import polygonToLine from "@turf/polygon-to-line";
|
|
|
17
17
|
* //=true
|
|
18
18
|
*/
|
|
19
19
|
function booleanDisjoint(feature1, feature2) {
|
|
20
|
-
|
|
21
|
-
flattenEach(feature1,
|
|
22
|
-
flattenEach(feature2,
|
|
20
|
+
let bool = true;
|
|
21
|
+
flattenEach(feature1, (flatten1) => {
|
|
22
|
+
flattenEach(feature2, (flatten2) => {
|
|
23
23
|
if (bool === false) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
@@ -74,7 +74,7 @@ function disjoint(geom1, geom2) {
|
|
|
74
74
|
}
|
|
75
75
|
// http://stackoverflow.com/a/11908158/1979085
|
|
76
76
|
function isPointOnLine(lineString, pt) {
|
|
77
|
-
for (
|
|
77
|
+
for (let i = 0; i < lineString.coordinates.length - 1; i++) {
|
|
78
78
|
if (isPointOnLineSegment(lineString.coordinates[i], lineString.coordinates[i + 1], pt.coordinates)) {
|
|
79
79
|
return true;
|
|
80
80
|
}
|
|
@@ -82,20 +82,19 @@ function isPointOnLine(lineString, pt) {
|
|
|
82
82
|
return false;
|
|
83
83
|
}
|
|
84
84
|
function isLineOnLine(lineString1, lineString2) {
|
|
85
|
-
|
|
85
|
+
const doLinesIntersect = lineIntersect(lineString1, lineString2);
|
|
86
86
|
if (doLinesIntersect.features.length > 0) {
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
91
|
function isLineInPoly(polygon, lineString) {
|
|
92
|
-
for (
|
|
93
|
-
var coord = _a[_i];
|
|
92
|
+
for (const coord of lineString.coordinates) {
|
|
94
93
|
if (booleanPointInPolygon(coord, polygon)) {
|
|
95
94
|
return true;
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
|
-
|
|
97
|
+
const doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
|
|
99
98
|
if (doLinesIntersect.features.length > 0) {
|
|
100
99
|
return true;
|
|
101
100
|
}
|
|
@@ -112,30 +111,28 @@ function isLineInPoly(polygon, lineString) {
|
|
|
112
111
|
* @returns {boolean} true/false
|
|
113
112
|
*/
|
|
114
113
|
function isPolyInPoly(feature1, feature2) {
|
|
115
|
-
for (
|
|
116
|
-
var coord1 = _a[_i];
|
|
114
|
+
for (const coord1 of feature1.coordinates[0]) {
|
|
117
115
|
if (booleanPointInPolygon(coord1, feature2)) {
|
|
118
116
|
return true;
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
|
-
for (
|
|
122
|
-
var coord2 = _c[_b];
|
|
119
|
+
for (const coord2 of feature2.coordinates[0]) {
|
|
123
120
|
if (booleanPointInPolygon(coord2, feature1)) {
|
|
124
121
|
return true;
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
|
-
|
|
124
|
+
const doLinesIntersect = lineIntersect(polygonToLine(feature1), polygonToLine(feature2));
|
|
128
125
|
if (doLinesIntersect.features.length > 0) {
|
|
129
126
|
return true;
|
|
130
127
|
}
|
|
131
128
|
return false;
|
|
132
129
|
}
|
|
133
130
|
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
const dxc = pt[0] - lineSegmentStart[0];
|
|
132
|
+
const dyc = pt[1] - lineSegmentStart[1];
|
|
133
|
+
const dxl = lineSegmentEnd[0] - lineSegmentStart[0];
|
|
134
|
+
const dyl = lineSegmentEnd[1] - lineSegmentStart[1];
|
|
135
|
+
const cross = dxc * dyl - dyc * dxl;
|
|
139
136
|
if (cross !== 0) {
|
|
140
137
|
return false;
|
|
141
138
|
}
|
package/dist/js/index.d.ts
CHANGED
package/dist/js/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const boolean_point_in_polygon_1 = tslib_1.__importDefault(require("@turf/boolean-point-in-polygon"));
|
|
5
|
+
const line_intersect_1 = tslib_1.__importDefault(require("@turf/line-intersect"));
|
|
6
|
+
const meta_1 = require("@turf/meta");
|
|
7
|
+
const polygon_to_line_1 = tslib_1.__importDefault(require("@turf/polygon-to-line"));
|
|
10
8
|
/**
|
|
11
9
|
* Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.
|
|
12
10
|
*
|
|
@@ -22,9 +20,9 @@ var polygon_to_line_1 = __importDefault(require("@turf/polygon-to-line"));
|
|
|
22
20
|
* //=true
|
|
23
21
|
*/
|
|
24
22
|
function booleanDisjoint(feature1, feature2) {
|
|
25
|
-
|
|
26
|
-
meta_1.flattenEach(feature1,
|
|
27
|
-
meta_1.flattenEach(feature2,
|
|
23
|
+
let bool = true;
|
|
24
|
+
meta_1.flattenEach(feature1, (flatten1) => {
|
|
25
|
+
meta_1.flattenEach(feature2, (flatten2) => {
|
|
28
26
|
if (bool === false) {
|
|
29
27
|
return false;
|
|
30
28
|
}
|
|
@@ -79,7 +77,7 @@ function disjoint(geom1, geom2) {
|
|
|
79
77
|
}
|
|
80
78
|
// http://stackoverflow.com/a/11908158/1979085
|
|
81
79
|
function isPointOnLine(lineString, pt) {
|
|
82
|
-
for (
|
|
80
|
+
for (let i = 0; i < lineString.coordinates.length - 1; i++) {
|
|
83
81
|
if (isPointOnLineSegment(lineString.coordinates[i], lineString.coordinates[i + 1], pt.coordinates)) {
|
|
84
82
|
return true;
|
|
85
83
|
}
|
|
@@ -87,20 +85,19 @@ function isPointOnLine(lineString, pt) {
|
|
|
87
85
|
return false;
|
|
88
86
|
}
|
|
89
87
|
function isLineOnLine(lineString1, lineString2) {
|
|
90
|
-
|
|
88
|
+
const doLinesIntersect = line_intersect_1.default(lineString1, lineString2);
|
|
91
89
|
if (doLinesIntersect.features.length > 0) {
|
|
92
90
|
return true;
|
|
93
91
|
}
|
|
94
92
|
return false;
|
|
95
93
|
}
|
|
96
94
|
function isLineInPoly(polygon, lineString) {
|
|
97
|
-
for (
|
|
98
|
-
var coord = _a[_i];
|
|
95
|
+
for (const coord of lineString.coordinates) {
|
|
99
96
|
if (boolean_point_in_polygon_1.default(coord, polygon)) {
|
|
100
97
|
return true;
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
|
-
|
|
100
|
+
const doLinesIntersect = line_intersect_1.default(lineString, polygon_to_line_1.default(polygon));
|
|
104
101
|
if (doLinesIntersect.features.length > 0) {
|
|
105
102
|
return true;
|
|
106
103
|
}
|
|
@@ -117,30 +114,28 @@ function isLineInPoly(polygon, lineString) {
|
|
|
117
114
|
* @returns {boolean} true/false
|
|
118
115
|
*/
|
|
119
116
|
function isPolyInPoly(feature1, feature2) {
|
|
120
|
-
for (
|
|
121
|
-
var coord1 = _a[_i];
|
|
117
|
+
for (const coord1 of feature1.coordinates[0]) {
|
|
122
118
|
if (boolean_point_in_polygon_1.default(coord1, feature2)) {
|
|
123
119
|
return true;
|
|
124
120
|
}
|
|
125
121
|
}
|
|
126
|
-
for (
|
|
127
|
-
var coord2 = _c[_b];
|
|
122
|
+
for (const coord2 of feature2.coordinates[0]) {
|
|
128
123
|
if (boolean_point_in_polygon_1.default(coord2, feature1)) {
|
|
129
124
|
return true;
|
|
130
125
|
}
|
|
131
126
|
}
|
|
132
|
-
|
|
127
|
+
const doLinesIntersect = line_intersect_1.default(polygon_to_line_1.default(feature1), polygon_to_line_1.default(feature2));
|
|
133
128
|
if (doLinesIntersect.features.length > 0) {
|
|
134
129
|
return true;
|
|
135
130
|
}
|
|
136
131
|
return false;
|
|
137
132
|
}
|
|
138
133
|
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
const dxc = pt[0] - lineSegmentStart[0];
|
|
135
|
+
const dyc = pt[1] - lineSegmentStart[1];
|
|
136
|
+
const dxl = lineSegmentEnd[0] - lineSegmentStart[0];
|
|
137
|
+
const dyl = lineSegmentEnd[1] - lineSegmentStart[1];
|
|
138
|
+
const cross = dxc * dyl - dyc * dxl;
|
|
144
139
|
if (cross !== 0) {
|
|
145
140
|
return false;
|
|
146
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/boolean-disjoint",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf boolean-disjoint module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -61,11 +61,12 @@
|
|
|
61
61
|
"typescript": "*"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@turf/boolean-point-in-polygon": "^
|
|
65
|
-
"@turf/helpers": "^
|
|
66
|
-
"@turf/line-intersect": "^
|
|
67
|
-
"@turf/meta": "^
|
|
68
|
-
"@turf/polygon-to-line": "^
|
|
64
|
+
"@turf/boolean-point-in-polygon": "^7.0.0-alpha.0",
|
|
65
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/line-intersect": "^7.0.0-alpha.0",
|
|
67
|
+
"@turf/meta": "^7.0.0-alpha.0",
|
|
68
|
+
"@turf/polygon-to-line": "^7.0.0-alpha.0",
|
|
69
|
+
"tslib": "^2.3.0"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
71
72
|
}
|