@turf/boolean-touches 7.0.0-alpha.2 → 7.0.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 -9
- package/dist/cjs/index.cjs +655 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +19 -0
- package/dist/{js → esm}/index.d.ts +4 -2
- package/dist/esm/index.js +655 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +35 -30
- package/dist/es/index.js +0 -482
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -485
package/dist/js/index.js
DELETED
|
@@ -1,485 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const boolean_point_on_line_1 = tslib_1.__importDefault(require("@turf/boolean-point-on-line"));
|
|
5
|
-
const boolean_point_in_polygon_1 = tslib_1.__importDefault(require("@turf/boolean-point-in-polygon"));
|
|
6
|
-
const invariant_1 = require("@turf/invariant");
|
|
7
|
-
/**
|
|
8
|
-
* Boolean-touches true if none of the points common to both geometries
|
|
9
|
-
* intersect the interiors of both geometries.
|
|
10
|
-
* @name booleanTouches
|
|
11
|
-
* @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
|
|
12
|
-
* @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
|
|
13
|
-
* @returns {boolean} true/false
|
|
14
|
-
* @example
|
|
15
|
-
* var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
|
|
16
|
-
* var point = turf.point([1, 1]);
|
|
17
|
-
*
|
|
18
|
-
* turf.booleanTouches(point, line);
|
|
19
|
-
* //=true
|
|
20
|
-
*/
|
|
21
|
-
function booleanTouches(feature1, feature2) {
|
|
22
|
-
var geom1 = invariant_1.getGeom(feature1);
|
|
23
|
-
var geom2 = invariant_1.getGeom(feature2);
|
|
24
|
-
var type1 = geom1.type;
|
|
25
|
-
var type2 = geom2.type;
|
|
26
|
-
switch (type1) {
|
|
27
|
-
case "Point":
|
|
28
|
-
switch (type2) {
|
|
29
|
-
case "LineString":
|
|
30
|
-
return isPointOnLineEnd(geom1, geom2);
|
|
31
|
-
case "MultiLineString":
|
|
32
|
-
var foundTouchingPoint = false;
|
|
33
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
34
|
-
if (isPointOnLineEnd(geom1, {
|
|
35
|
-
type: "LineString",
|
|
36
|
-
coordinates: geom2.coordinates[ii],
|
|
37
|
-
}))
|
|
38
|
-
foundTouchingPoint = true;
|
|
39
|
-
}
|
|
40
|
-
return foundTouchingPoint;
|
|
41
|
-
case "Polygon":
|
|
42
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
43
|
-
if (boolean_point_on_line_1.default(geom1, {
|
|
44
|
-
type: "LineString",
|
|
45
|
-
coordinates: geom2.coordinates[i],
|
|
46
|
-
}))
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
case "MultiPolygon":
|
|
51
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
52
|
-
for (var ii = 0; ii < geom2.coordinates[i].length; ii++) {
|
|
53
|
-
if (boolean_point_on_line_1.default(geom1, {
|
|
54
|
-
type: "LineString",
|
|
55
|
-
coordinates: geom2.coordinates[i][ii],
|
|
56
|
-
}))
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
default:
|
|
62
|
-
throw new Error("feature2 " + type2 + " geometry not supported");
|
|
63
|
-
}
|
|
64
|
-
case "MultiPoint":
|
|
65
|
-
switch (type2) {
|
|
66
|
-
case "LineString":
|
|
67
|
-
var foundTouchingPoint = false;
|
|
68
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
69
|
-
if (!foundTouchingPoint) {
|
|
70
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom1.coordinates[i] }, geom2))
|
|
71
|
-
foundTouchingPoint = true;
|
|
72
|
-
}
|
|
73
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, geom2, { ignoreEndVertices: true }))
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return foundTouchingPoint;
|
|
77
|
-
case "MultiLineString":
|
|
78
|
-
var foundTouchingPoint = false;
|
|
79
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
80
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
81
|
-
if (!foundTouchingPoint) {
|
|
82
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom1.coordinates[i] }, { type: "LineString", coordinates: geom2.coordinates[ii] }))
|
|
83
|
-
foundTouchingPoint = true;
|
|
84
|
-
}
|
|
85
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, { type: "LineString", coordinates: geom2.coordinates[ii] }, { ignoreEndVertices: true }))
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return foundTouchingPoint;
|
|
90
|
-
case "Polygon":
|
|
91
|
-
var foundTouchingPoint = false;
|
|
92
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
93
|
-
if (!foundTouchingPoint) {
|
|
94
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, { type: "LineString", coordinates: geom2.coordinates[0] }))
|
|
95
|
-
foundTouchingPoint = true;
|
|
96
|
-
}
|
|
97
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, geom2, { ignoreBoundary: true }))
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
return foundTouchingPoint;
|
|
101
|
-
case "MultiPolygon":
|
|
102
|
-
var foundTouchingPoint = false;
|
|
103
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
104
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
105
|
-
if (!foundTouchingPoint) {
|
|
106
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, {
|
|
107
|
-
type: "LineString",
|
|
108
|
-
coordinates: geom2.coordinates[ii][0],
|
|
109
|
-
}))
|
|
110
|
-
foundTouchingPoint = true;
|
|
111
|
-
}
|
|
112
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, { type: "Polygon", coordinates: geom2.coordinates[ii] }, { ignoreBoundary: true }))
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return foundTouchingPoint;
|
|
117
|
-
default:
|
|
118
|
-
throw new Error("feature2 " + type2 + " geometry not supported");
|
|
119
|
-
}
|
|
120
|
-
case "LineString":
|
|
121
|
-
switch (type2) {
|
|
122
|
-
case "Point":
|
|
123
|
-
return isPointOnLineEnd(geom2, geom1);
|
|
124
|
-
case "MultiPoint":
|
|
125
|
-
var foundTouchingPoint = false;
|
|
126
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
127
|
-
if (!foundTouchingPoint) {
|
|
128
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom2.coordinates[i] }, geom1))
|
|
129
|
-
foundTouchingPoint = true;
|
|
130
|
-
}
|
|
131
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[i] }, geom1, { ignoreEndVertices: true }))
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
return foundTouchingPoint;
|
|
135
|
-
case "LineString":
|
|
136
|
-
var endMatch = false;
|
|
137
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom1.coordinates[0] }, geom2))
|
|
138
|
-
endMatch = true;
|
|
139
|
-
if (isPointOnLineEnd({
|
|
140
|
-
type: "Point",
|
|
141
|
-
coordinates: geom1.coordinates[geom1.coordinates.length - 1],
|
|
142
|
-
}, geom2))
|
|
143
|
-
endMatch = true;
|
|
144
|
-
if (endMatch === false)
|
|
145
|
-
return false;
|
|
146
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
147
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, geom2, { ignoreEndVertices: true }))
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
return endMatch;
|
|
151
|
-
case "MultiLineString":
|
|
152
|
-
var endMatch = false;
|
|
153
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
154
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom1.coordinates[0] }, { type: "LineString", coordinates: geom2.coordinates[i] }))
|
|
155
|
-
endMatch = true;
|
|
156
|
-
if (isPointOnLineEnd({
|
|
157
|
-
type: "Point",
|
|
158
|
-
coordinates: geom1.coordinates[geom1.coordinates.length - 1],
|
|
159
|
-
}, { type: "LineString", coordinates: geom2.coordinates[i] }))
|
|
160
|
-
endMatch = true;
|
|
161
|
-
for (var ii = 0; ii < geom1.coordinates[i].length; ii++) {
|
|
162
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[ii] }, { type: "LineString", coordinates: geom2.coordinates[i] }, { ignoreEndVertices: true }))
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return endMatch;
|
|
167
|
-
case "Polygon":
|
|
168
|
-
var foundTouchingPoint = false;
|
|
169
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
170
|
-
if (!foundTouchingPoint) {
|
|
171
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, { type: "LineString", coordinates: geom2.coordinates[0] }))
|
|
172
|
-
foundTouchingPoint = true;
|
|
173
|
-
}
|
|
174
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, geom2, { ignoreBoundary: true }))
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
return foundTouchingPoint;
|
|
178
|
-
case "MultiPolygon":
|
|
179
|
-
var foundTouchingPoint = false;
|
|
180
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
181
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
182
|
-
if (!foundTouchingPoint) {
|
|
183
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, {
|
|
184
|
-
type: "LineString",
|
|
185
|
-
coordinates: geom2.coordinates[ii][0],
|
|
186
|
-
}))
|
|
187
|
-
foundTouchingPoint = true;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[i] }, geom2, { ignoreBoundary: true }))
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
return foundTouchingPoint;
|
|
194
|
-
default:
|
|
195
|
-
throw new Error("feature2 " + type2 + " geometry not supported");
|
|
196
|
-
}
|
|
197
|
-
case "MultiLineString":
|
|
198
|
-
switch (type2) {
|
|
199
|
-
case "Point":
|
|
200
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
201
|
-
if (isPointOnLineEnd(geom2, {
|
|
202
|
-
type: "LineString",
|
|
203
|
-
coordinates: geom1.coordinates[i],
|
|
204
|
-
}))
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
return false;
|
|
208
|
-
case "MultiPoint":
|
|
209
|
-
var foundTouchingPoint = false;
|
|
210
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
211
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
212
|
-
if (!foundTouchingPoint) {
|
|
213
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "LineString", coordinates: geom1.coordinates[ii] }))
|
|
214
|
-
foundTouchingPoint = true;
|
|
215
|
-
}
|
|
216
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "LineString", coordinates: geom1.coordinates[ii] }, { ignoreEndVertices: true }))
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return foundTouchingPoint;
|
|
221
|
-
case "LineString":
|
|
222
|
-
var endMatch = false;
|
|
223
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
224
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom1.coordinates[i][0] }, geom2))
|
|
225
|
-
endMatch = true;
|
|
226
|
-
if (isPointOnLineEnd({
|
|
227
|
-
type: "Point",
|
|
228
|
-
coordinates: geom1.coordinates[i][geom1.coordinates[i].length - 1],
|
|
229
|
-
}, geom2))
|
|
230
|
-
endMatch = true;
|
|
231
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
232
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "LineString", coordinates: geom1.coordinates[i] }, { ignoreEndVertices: true }))
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return endMatch;
|
|
237
|
-
case "MultiLineString":
|
|
238
|
-
var endMatch = false;
|
|
239
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
240
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
241
|
-
if (isPointOnLineEnd({ type: "Point", coordinates: geom1.coordinates[i][0] }, { type: "LineString", coordinates: geom2.coordinates[ii] }))
|
|
242
|
-
endMatch = true;
|
|
243
|
-
if (isPointOnLineEnd({
|
|
244
|
-
type: "Point",
|
|
245
|
-
coordinates: geom1.coordinates[i][geom1.coordinates[i].length - 1],
|
|
246
|
-
}, { type: "LineString", coordinates: geom2.coordinates[ii] }))
|
|
247
|
-
endMatch = true;
|
|
248
|
-
for (var iii = 0; iii < geom1.coordinates[i].length; iii++) {
|
|
249
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i][iii] }, { type: "LineString", coordinates: geom2.coordinates[ii] }, { ignoreEndVertices: true }))
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return endMatch;
|
|
255
|
-
case "Polygon":
|
|
256
|
-
var foundTouchingPoint = false;
|
|
257
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
258
|
-
for (var ii = 0; ii < geom1.coordinates.length; ii++) {
|
|
259
|
-
if (!foundTouchingPoint) {
|
|
260
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[i][ii] }, { type: "LineString", coordinates: geom2.coordinates[0] }))
|
|
261
|
-
foundTouchingPoint = true;
|
|
262
|
-
}
|
|
263
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[i][ii] }, geom2, { ignoreBoundary: true }))
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return foundTouchingPoint;
|
|
268
|
-
case "MultiPolygon":
|
|
269
|
-
var foundTouchingPoint = false;
|
|
270
|
-
for (var i = 0; i < geom2.coordinates[0].length; i++) {
|
|
271
|
-
for (var ii = 0; ii < geom1.coordinates.length; ii++) {
|
|
272
|
-
for (var iii = 0; iii < geom1.coordinates[ii].length; iii++) {
|
|
273
|
-
if (!foundTouchingPoint) {
|
|
274
|
-
if (boolean_point_on_line_1.default({
|
|
275
|
-
type: "Point",
|
|
276
|
-
coordinates: geom1.coordinates[ii][iii],
|
|
277
|
-
}, {
|
|
278
|
-
type: "LineString",
|
|
279
|
-
coordinates: geom2.coordinates[0][i],
|
|
280
|
-
}))
|
|
281
|
-
foundTouchingPoint = true;
|
|
282
|
-
}
|
|
283
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[ii][iii] }, { type: "Polygon", coordinates: [geom2.coordinates[0][i]] }, { ignoreBoundary: true }))
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return foundTouchingPoint;
|
|
289
|
-
default:
|
|
290
|
-
throw new Error("feature2 " + type2 + " geometry not supported");
|
|
291
|
-
}
|
|
292
|
-
case "Polygon":
|
|
293
|
-
switch (type2) {
|
|
294
|
-
case "Point":
|
|
295
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
296
|
-
if (boolean_point_on_line_1.default(geom2, {
|
|
297
|
-
type: "LineString",
|
|
298
|
-
coordinates: geom1.coordinates[i],
|
|
299
|
-
}))
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
return false;
|
|
303
|
-
case "MultiPoint":
|
|
304
|
-
var foundTouchingPoint = false;
|
|
305
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
306
|
-
if (!foundTouchingPoint) {
|
|
307
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[i] }, { type: "LineString", coordinates: geom1.coordinates[0] }))
|
|
308
|
-
foundTouchingPoint = true;
|
|
309
|
-
}
|
|
310
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom2.coordinates[i] }, geom1, { ignoreBoundary: true }))
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
return foundTouchingPoint;
|
|
314
|
-
case "LineString":
|
|
315
|
-
var foundTouchingPoint = false;
|
|
316
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
317
|
-
if (!foundTouchingPoint) {
|
|
318
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[i] }, { type: "LineString", coordinates: geom1.coordinates[0] }))
|
|
319
|
-
foundTouchingPoint = true;
|
|
320
|
-
}
|
|
321
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom2.coordinates[i] }, geom1, { ignoreBoundary: true }))
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
return foundTouchingPoint;
|
|
325
|
-
case "MultiLineString":
|
|
326
|
-
var foundTouchingPoint = false;
|
|
327
|
-
for (var i = 0; i < geom2.coordinates.length; i++) {
|
|
328
|
-
for (var ii = 0; ii < geom2.coordinates[i].length; ii++) {
|
|
329
|
-
if (!foundTouchingPoint) {
|
|
330
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[i][ii] }, { type: "LineString", coordinates: geom1.coordinates[0] }))
|
|
331
|
-
foundTouchingPoint = true;
|
|
332
|
-
}
|
|
333
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom2.coordinates[i][ii] }, geom1, { ignoreBoundary: true }))
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return foundTouchingPoint;
|
|
338
|
-
case "Polygon":
|
|
339
|
-
var foundTouchingPoint = false;
|
|
340
|
-
for (var i = 0; i < geom1.coordinates[0].length; i++) {
|
|
341
|
-
if (!foundTouchingPoint) {
|
|
342
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[0][i] }, { type: "LineString", coordinates: geom2.coordinates[0] }))
|
|
343
|
-
foundTouchingPoint = true;
|
|
344
|
-
}
|
|
345
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[0][i] }, geom2, { ignoreBoundary: true }))
|
|
346
|
-
return false;
|
|
347
|
-
}
|
|
348
|
-
return foundTouchingPoint;
|
|
349
|
-
case "MultiPolygon":
|
|
350
|
-
var foundTouchingPoint = false;
|
|
351
|
-
for (var i = 0; i < geom2.coordinates[0].length; i++) {
|
|
352
|
-
for (var ii = 0; ii < geom1.coordinates[0].length; ii++) {
|
|
353
|
-
if (!foundTouchingPoint) {
|
|
354
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[0][ii] }, { type: "LineString", coordinates: geom2.coordinates[0][i] }))
|
|
355
|
-
foundTouchingPoint = true;
|
|
356
|
-
}
|
|
357
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[0][ii] }, { type: "Polygon", coordinates: geom2.coordinates[0][i] }, { ignoreBoundary: true }))
|
|
358
|
-
return false;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return foundTouchingPoint;
|
|
362
|
-
default:
|
|
363
|
-
throw new Error("feature2 " + type2 + " geometry not supported");
|
|
364
|
-
}
|
|
365
|
-
case "MultiPolygon":
|
|
366
|
-
switch (type2) {
|
|
367
|
-
case "Point":
|
|
368
|
-
for (var i = 0; i < geom1.coordinates[0].length; i++) {
|
|
369
|
-
if (boolean_point_on_line_1.default(geom2, {
|
|
370
|
-
type: "LineString",
|
|
371
|
-
coordinates: geom1.coordinates[0][i],
|
|
372
|
-
}))
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
return false;
|
|
376
|
-
case "MultiPoint":
|
|
377
|
-
var foundTouchingPoint = false;
|
|
378
|
-
for (var i = 0; i < geom1.coordinates[0].length; i++) {
|
|
379
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
380
|
-
if (!foundTouchingPoint) {
|
|
381
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "LineString", coordinates: geom1.coordinates[0][i] }))
|
|
382
|
-
foundTouchingPoint = true;
|
|
383
|
-
}
|
|
384
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "Polygon", coordinates: geom1.coordinates[0][i] }, { ignoreBoundary: true }))
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return foundTouchingPoint;
|
|
389
|
-
case "LineString":
|
|
390
|
-
var foundTouchingPoint = false;
|
|
391
|
-
for (var i = 0; i < geom1.coordinates[0].length; i++) {
|
|
392
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
393
|
-
if (!foundTouchingPoint) {
|
|
394
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "LineString", coordinates: geom1.coordinates[0][i] }))
|
|
395
|
-
foundTouchingPoint = true;
|
|
396
|
-
}
|
|
397
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom2.coordinates[ii] }, { type: "Polygon", coordinates: geom1.coordinates[0][i] }, { ignoreBoundary: true }))
|
|
398
|
-
return false;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return foundTouchingPoint;
|
|
402
|
-
case "MultiLineString":
|
|
403
|
-
var foundTouchingPoint = false;
|
|
404
|
-
for (var i = 0; i < geom1.coordinates.length; i++) {
|
|
405
|
-
for (var ii = 0; ii < geom2.coordinates.length; ii++) {
|
|
406
|
-
for (var iii = 0; iii < geom2.coordinates[ii].length; iii++) {
|
|
407
|
-
if (!foundTouchingPoint) {
|
|
408
|
-
if (boolean_point_on_line_1.default({
|
|
409
|
-
type: "Point",
|
|
410
|
-
coordinates: geom2.coordinates[ii][iii],
|
|
411
|
-
}, {
|
|
412
|
-
type: "LineString",
|
|
413
|
-
coordinates: geom1.coordinates[i][0],
|
|
414
|
-
}))
|
|
415
|
-
foundTouchingPoint = true;
|
|
416
|
-
}
|
|
417
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom2.coordinates[ii][iii] }, { type: "Polygon", coordinates: [geom1.coordinates[i][0]] }, { ignoreBoundary: true }))
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
return foundTouchingPoint;
|
|
423
|
-
case "Polygon":
|
|
424
|
-
var foundTouchingPoint = false;
|
|
425
|
-
for (var i = 0; i < geom1.coordinates[0].length; i++) {
|
|
426
|
-
for (var ii = 0; ii < geom1.coordinates[0][i].length; ii++) {
|
|
427
|
-
if (!foundTouchingPoint) {
|
|
428
|
-
if (boolean_point_on_line_1.default({ type: "Point", coordinates: geom1.coordinates[0][i][ii] }, { type: "LineString", coordinates: geom2.coordinates[0] }))
|
|
429
|
-
foundTouchingPoint = true;
|
|
430
|
-
}
|
|
431
|
-
if (boolean_point_in_polygon_1.default({ type: "Point", coordinates: geom1.coordinates[0][i][ii] }, geom2, { ignoreBoundary: true }))
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
return foundTouchingPoint;
|
|
436
|
-
case "MultiPolygon":
|
|
437
|
-
var foundTouchingPoint = false;
|
|
438
|
-
for (var i = 0; i < geom1.coordinates[0].length; i++) {
|
|
439
|
-
for (var ii = 0; ii < geom2.coordinates[0].length; ii++) {
|
|
440
|
-
for (var iii = 0; iii < geom1.coordinates[0].length; iii++) {
|
|
441
|
-
if (!foundTouchingPoint) {
|
|
442
|
-
if (boolean_point_on_line_1.default({
|
|
443
|
-
type: "Point",
|
|
444
|
-
coordinates: geom1.coordinates[0][i][iii],
|
|
445
|
-
}, {
|
|
446
|
-
type: "LineString",
|
|
447
|
-
coordinates: geom2.coordinates[0][ii],
|
|
448
|
-
}))
|
|
449
|
-
foundTouchingPoint = true;
|
|
450
|
-
}
|
|
451
|
-
if (boolean_point_in_polygon_1.default({
|
|
452
|
-
type: "Point",
|
|
453
|
-
coordinates: geom1.coordinates[0][i][iii],
|
|
454
|
-
}, { type: "Polygon", coordinates: geom2.coordinates[0][ii] }, { ignoreBoundary: true }))
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
return foundTouchingPoint;
|
|
460
|
-
default:
|
|
461
|
-
throw new Error("feature2 " + type2 + " geometry not supported");
|
|
462
|
-
}
|
|
463
|
-
default:
|
|
464
|
-
throw new Error("feature1 " + type1 + " geometry not supported");
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
function isPointOnLineEnd(point, line) {
|
|
468
|
-
if (compareCoords(line.coordinates[0], point.coordinates))
|
|
469
|
-
return true;
|
|
470
|
-
if (compareCoords(line.coordinates[line.coordinates.length - 1], point.coordinates))
|
|
471
|
-
return true;
|
|
472
|
-
return false;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* compareCoords
|
|
476
|
-
*
|
|
477
|
-
* @private
|
|
478
|
-
* @param {Position} pair1 point [x,y]
|
|
479
|
-
* @param {Position} pair2 point [x,y]
|
|
480
|
-
* @returns {boolean} true/false if coord pairs match
|
|
481
|
-
*/
|
|
482
|
-
function compareCoords(pair1, pair2) {
|
|
483
|
-
return pair1[0] === pair2[0] && pair1[1] === pair2[1];
|
|
484
|
-
}
|
|
485
|
-
exports.default = booleanTouches;
|