@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 CHANGED
@@ -30,26 +30,21 @@ Returns **[boolean][3]** true/false
30
30
 
31
31
  [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
32
32
 
33
- <!-- This file is automatically generated. Please don't edit it directly:
34
- if you find an error, edit the source file (likely index.js), and re-run
35
- ./scripts/generate-readmes in the turf project. -->
33
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
36
34
 
37
35
  ---
38
36
 
39
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
40
- module collection dedicated to geographic algorithms. It is maintained in the
41
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
42
- PRs and issues.
37
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
43
38
 
44
39
  ### Installation
45
40
 
46
- Install this module individually:
41
+ Install this single module individually:
47
42
 
48
43
  ```sh
49
44
  $ npm install @turf/boolean-touches
50
45
  ```
51
46
 
52
- Or install the Turf module that includes it as a function:
47
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
53
48
 
54
49
  ```sh
55
50
  $ npm install @turf/turf
@@ -0,0 +1,655 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ var _booleanpointonline = require('@turf/boolean-point-on-line');
6
+ var _booleanpointinpolygon = require('@turf/boolean-point-in-polygon');
7
+ var _invariant = require('@turf/invariant');
8
+ function booleanTouches(feature1, feature2) {
9
+ var geom1 = _invariant.getGeom.call(void 0, feature1);
10
+ var geom2 = _invariant.getGeom.call(void 0, feature2);
11
+ var type1 = geom1.type;
12
+ var type2 = geom2.type;
13
+ switch (type1) {
14
+ case "Point":
15
+ switch (type2) {
16
+ case "LineString":
17
+ return isPointOnLineEnd(geom1, geom2);
18
+ case "MultiLineString":
19
+ var foundTouchingPoint = false;
20
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
21
+ if (isPointOnLineEnd(geom1, {
22
+ type: "LineString",
23
+ coordinates: geom2.coordinates[ii]
24
+ }))
25
+ foundTouchingPoint = true;
26
+ }
27
+ return foundTouchingPoint;
28
+ case "Polygon":
29
+ for (var i = 0; i < geom2.coordinates.length; i++) {
30
+ if (_booleanpointonline.booleanPointOnLine.call(void 0, geom1, {
31
+ type: "LineString",
32
+ coordinates: geom2.coordinates[i]
33
+ }))
34
+ return true;
35
+ }
36
+ return false;
37
+ case "MultiPolygon":
38
+ for (var i = 0; i < geom2.coordinates.length; i++) {
39
+ for (var ii = 0; ii < geom2.coordinates[i].length; ii++) {
40
+ if (_booleanpointonline.booleanPointOnLine.call(void 0, geom1, {
41
+ type: "LineString",
42
+ coordinates: geom2.coordinates[i][ii]
43
+ }))
44
+ return true;
45
+ }
46
+ }
47
+ return false;
48
+ default:
49
+ throw new Error("feature2 " + type2 + " geometry not supported");
50
+ }
51
+ case "MultiPoint":
52
+ switch (type2) {
53
+ case "LineString":
54
+ var foundTouchingPoint = false;
55
+ for (var i = 0; i < geom1.coordinates.length; i++) {
56
+ if (!foundTouchingPoint) {
57
+ if (isPointOnLineEnd(
58
+ { type: "Point", coordinates: geom1.coordinates[i] },
59
+ geom2
60
+ ))
61
+ foundTouchingPoint = true;
62
+ }
63
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
64
+ { type: "Point", coordinates: geom1.coordinates[i] },
65
+ geom2,
66
+ { ignoreEndVertices: true }
67
+ ))
68
+ return false;
69
+ }
70
+ return foundTouchingPoint;
71
+ case "MultiLineString":
72
+ var foundTouchingPoint = false;
73
+ for (var i = 0; i < geom1.coordinates.length; i++) {
74
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
75
+ if (!foundTouchingPoint) {
76
+ if (isPointOnLineEnd(
77
+ { type: "Point", coordinates: geom1.coordinates[i] },
78
+ { type: "LineString", coordinates: geom2.coordinates[ii] }
79
+ ))
80
+ foundTouchingPoint = true;
81
+ }
82
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
83
+ { type: "Point", coordinates: geom1.coordinates[i] },
84
+ { type: "LineString", coordinates: geom2.coordinates[ii] },
85
+ { ignoreEndVertices: true }
86
+ ))
87
+ return false;
88
+ }
89
+ }
90
+ return foundTouchingPoint;
91
+ case "Polygon":
92
+ var foundTouchingPoint = false;
93
+ for (var i = 0; i < geom1.coordinates.length; i++) {
94
+ if (!foundTouchingPoint) {
95
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
96
+ { type: "Point", coordinates: geom1.coordinates[i] },
97
+ { type: "LineString", coordinates: geom2.coordinates[0] }
98
+ ))
99
+ foundTouchingPoint = true;
100
+ }
101
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
102
+ { type: "Point", coordinates: geom1.coordinates[i] },
103
+ geom2,
104
+ { ignoreBoundary: true }
105
+ ))
106
+ return false;
107
+ }
108
+ return foundTouchingPoint;
109
+ case "MultiPolygon":
110
+ var foundTouchingPoint = false;
111
+ for (var i = 0; i < geom1.coordinates.length; i++) {
112
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
113
+ if (!foundTouchingPoint) {
114
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
115
+ { type: "Point", coordinates: geom1.coordinates[i] },
116
+ {
117
+ type: "LineString",
118
+ coordinates: geom2.coordinates[ii][0]
119
+ }
120
+ ))
121
+ foundTouchingPoint = true;
122
+ }
123
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
124
+ { type: "Point", coordinates: geom1.coordinates[i] },
125
+ { type: "Polygon", coordinates: geom2.coordinates[ii] },
126
+ { ignoreBoundary: true }
127
+ ))
128
+ return false;
129
+ }
130
+ }
131
+ return foundTouchingPoint;
132
+ default:
133
+ throw new Error("feature2 " + type2 + " geometry not supported");
134
+ }
135
+ case "LineString":
136
+ switch (type2) {
137
+ case "Point":
138
+ return isPointOnLineEnd(geom2, geom1);
139
+ case "MultiPoint":
140
+ var foundTouchingPoint = false;
141
+ for (var i = 0; i < geom2.coordinates.length; i++) {
142
+ if (!foundTouchingPoint) {
143
+ if (isPointOnLineEnd(
144
+ { type: "Point", coordinates: geom2.coordinates[i] },
145
+ geom1
146
+ ))
147
+ foundTouchingPoint = true;
148
+ }
149
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
150
+ { type: "Point", coordinates: geom2.coordinates[i] },
151
+ geom1,
152
+ { ignoreEndVertices: true }
153
+ ))
154
+ return false;
155
+ }
156
+ return foundTouchingPoint;
157
+ case "LineString":
158
+ var endMatch = false;
159
+ if (isPointOnLineEnd(
160
+ { type: "Point", coordinates: geom1.coordinates[0] },
161
+ geom2
162
+ ))
163
+ endMatch = true;
164
+ if (isPointOnLineEnd(
165
+ {
166
+ type: "Point",
167
+ coordinates: geom1.coordinates[geom1.coordinates.length - 1]
168
+ },
169
+ geom2
170
+ ))
171
+ endMatch = true;
172
+ if (endMatch === false)
173
+ return false;
174
+ for (var i = 0; i < geom1.coordinates.length; i++) {
175
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
176
+ { type: "Point", coordinates: geom1.coordinates[i] },
177
+ geom2,
178
+ { ignoreEndVertices: true }
179
+ ))
180
+ return false;
181
+ }
182
+ return endMatch;
183
+ case "MultiLineString":
184
+ var endMatch = false;
185
+ for (var i = 0; i < geom2.coordinates.length; i++) {
186
+ if (isPointOnLineEnd(
187
+ { type: "Point", coordinates: geom1.coordinates[0] },
188
+ { type: "LineString", coordinates: geom2.coordinates[i] }
189
+ ))
190
+ endMatch = true;
191
+ if (isPointOnLineEnd(
192
+ {
193
+ type: "Point",
194
+ coordinates: geom1.coordinates[geom1.coordinates.length - 1]
195
+ },
196
+ { type: "LineString", coordinates: geom2.coordinates[i] }
197
+ ))
198
+ endMatch = true;
199
+ for (var ii = 0; ii < geom1.coordinates[i].length; ii++) {
200
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
201
+ { type: "Point", coordinates: geom1.coordinates[ii] },
202
+ { type: "LineString", coordinates: geom2.coordinates[i] },
203
+ { ignoreEndVertices: true }
204
+ ))
205
+ return false;
206
+ }
207
+ }
208
+ return endMatch;
209
+ case "Polygon":
210
+ var foundTouchingPoint = false;
211
+ for (var i = 0; i < geom1.coordinates.length; i++) {
212
+ if (!foundTouchingPoint) {
213
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
214
+ { type: "Point", coordinates: geom1.coordinates[i] },
215
+ { type: "LineString", coordinates: geom2.coordinates[0] }
216
+ ))
217
+ foundTouchingPoint = true;
218
+ }
219
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
220
+ { type: "Point", coordinates: geom1.coordinates[i] },
221
+ geom2,
222
+ { ignoreBoundary: true }
223
+ ))
224
+ return false;
225
+ }
226
+ return foundTouchingPoint;
227
+ case "MultiPolygon":
228
+ var foundTouchingPoint = false;
229
+ for (var i = 0; i < geom1.coordinates.length; i++) {
230
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
231
+ if (!foundTouchingPoint) {
232
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
233
+ { type: "Point", coordinates: geom1.coordinates[i] },
234
+ {
235
+ type: "LineString",
236
+ coordinates: geom2.coordinates[ii][0]
237
+ }
238
+ ))
239
+ foundTouchingPoint = true;
240
+ }
241
+ }
242
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
243
+ { type: "Point", coordinates: geom1.coordinates[i] },
244
+ geom2,
245
+ { ignoreBoundary: true }
246
+ ))
247
+ return false;
248
+ }
249
+ return foundTouchingPoint;
250
+ default:
251
+ throw new Error("feature2 " + type2 + " geometry not supported");
252
+ }
253
+ case "MultiLineString":
254
+ switch (type2) {
255
+ case "Point":
256
+ for (var i = 0; i < geom1.coordinates.length; i++) {
257
+ if (isPointOnLineEnd(geom2, {
258
+ type: "LineString",
259
+ coordinates: geom1.coordinates[i]
260
+ }))
261
+ return true;
262
+ }
263
+ return false;
264
+ case "MultiPoint":
265
+ var foundTouchingPoint = false;
266
+ for (var i = 0; i < geom1.coordinates.length; i++) {
267
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
268
+ if (!foundTouchingPoint) {
269
+ if (isPointOnLineEnd(
270
+ { type: "Point", coordinates: geom2.coordinates[ii] },
271
+ { type: "LineString", coordinates: geom1.coordinates[ii] }
272
+ ))
273
+ foundTouchingPoint = true;
274
+ }
275
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
276
+ { type: "Point", coordinates: geom2.coordinates[ii] },
277
+ { type: "LineString", coordinates: geom1.coordinates[ii] },
278
+ { ignoreEndVertices: true }
279
+ ))
280
+ return false;
281
+ }
282
+ }
283
+ return foundTouchingPoint;
284
+ case "LineString":
285
+ var endMatch = false;
286
+ for (var i = 0; i < geom1.coordinates.length; i++) {
287
+ if (isPointOnLineEnd(
288
+ { type: "Point", coordinates: geom1.coordinates[i][0] },
289
+ geom2
290
+ ))
291
+ endMatch = true;
292
+ if (isPointOnLineEnd(
293
+ {
294
+ type: "Point",
295
+ coordinates: geom1.coordinates[i][geom1.coordinates[i].length - 1]
296
+ },
297
+ geom2
298
+ ))
299
+ endMatch = true;
300
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
301
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
302
+ { type: "Point", coordinates: geom2.coordinates[ii] },
303
+ { type: "LineString", coordinates: geom1.coordinates[i] },
304
+ { ignoreEndVertices: true }
305
+ ))
306
+ return false;
307
+ }
308
+ }
309
+ return endMatch;
310
+ case "MultiLineString":
311
+ var endMatch = false;
312
+ for (var i = 0; i < geom1.coordinates.length; i++) {
313
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
314
+ if (isPointOnLineEnd(
315
+ { type: "Point", coordinates: geom1.coordinates[i][0] },
316
+ { type: "LineString", coordinates: geom2.coordinates[ii] }
317
+ ))
318
+ endMatch = true;
319
+ if (isPointOnLineEnd(
320
+ {
321
+ type: "Point",
322
+ coordinates: geom1.coordinates[i][geom1.coordinates[i].length - 1]
323
+ },
324
+ { type: "LineString", coordinates: geom2.coordinates[ii] }
325
+ ))
326
+ endMatch = true;
327
+ for (var iii = 0; iii < geom1.coordinates[i].length; iii++) {
328
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
329
+ { type: "Point", coordinates: geom1.coordinates[i][iii] },
330
+ { type: "LineString", coordinates: geom2.coordinates[ii] },
331
+ { ignoreEndVertices: true }
332
+ ))
333
+ return false;
334
+ }
335
+ }
336
+ }
337
+ return endMatch;
338
+ case "Polygon":
339
+ var foundTouchingPoint = false;
340
+ for (var i = 0; i < geom1.coordinates.length; i++) {
341
+ for (var ii = 0; ii < geom1.coordinates.length; ii++) {
342
+ if (!foundTouchingPoint) {
343
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
344
+ { type: "Point", coordinates: geom1.coordinates[i][ii] },
345
+ { type: "LineString", coordinates: geom2.coordinates[0] }
346
+ ))
347
+ foundTouchingPoint = true;
348
+ }
349
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
350
+ { type: "Point", coordinates: geom1.coordinates[i][ii] },
351
+ geom2,
352
+ { ignoreBoundary: true }
353
+ ))
354
+ return false;
355
+ }
356
+ }
357
+ return foundTouchingPoint;
358
+ case "MultiPolygon":
359
+ var foundTouchingPoint = false;
360
+ for (var i = 0; i < geom2.coordinates[0].length; i++) {
361
+ for (var ii = 0; ii < geom1.coordinates.length; ii++) {
362
+ for (var iii = 0; iii < geom1.coordinates[ii].length; iii++) {
363
+ if (!foundTouchingPoint) {
364
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
365
+ {
366
+ type: "Point",
367
+ coordinates: geom1.coordinates[ii][iii]
368
+ },
369
+ {
370
+ type: "LineString",
371
+ coordinates: geom2.coordinates[0][i]
372
+ }
373
+ ))
374
+ foundTouchingPoint = true;
375
+ }
376
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
377
+ { type: "Point", coordinates: geom1.coordinates[ii][iii] },
378
+ { type: "Polygon", coordinates: [geom2.coordinates[0][i]] },
379
+ { ignoreBoundary: true }
380
+ ))
381
+ return false;
382
+ }
383
+ }
384
+ }
385
+ return foundTouchingPoint;
386
+ default:
387
+ throw new Error("feature2 " + type2 + " geometry not supported");
388
+ }
389
+ case "Polygon":
390
+ switch (type2) {
391
+ case "Point":
392
+ for (var i = 0; i < geom1.coordinates.length; i++) {
393
+ if (_booleanpointonline.booleanPointOnLine.call(void 0, geom2, {
394
+ type: "LineString",
395
+ coordinates: geom1.coordinates[i]
396
+ }))
397
+ return true;
398
+ }
399
+ return false;
400
+ case "MultiPoint":
401
+ var foundTouchingPoint = false;
402
+ for (var i = 0; i < geom2.coordinates.length; i++) {
403
+ if (!foundTouchingPoint) {
404
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
405
+ { type: "Point", coordinates: geom2.coordinates[i] },
406
+ { type: "LineString", coordinates: geom1.coordinates[0] }
407
+ ))
408
+ foundTouchingPoint = true;
409
+ }
410
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
411
+ { type: "Point", coordinates: geom2.coordinates[i] },
412
+ geom1,
413
+ { ignoreBoundary: true }
414
+ ))
415
+ return false;
416
+ }
417
+ return foundTouchingPoint;
418
+ case "LineString":
419
+ var foundTouchingPoint = false;
420
+ for (var i = 0; i < geom2.coordinates.length; i++) {
421
+ if (!foundTouchingPoint) {
422
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
423
+ { type: "Point", coordinates: geom2.coordinates[i] },
424
+ { type: "LineString", coordinates: geom1.coordinates[0] }
425
+ ))
426
+ foundTouchingPoint = true;
427
+ }
428
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
429
+ { type: "Point", coordinates: geom2.coordinates[i] },
430
+ geom1,
431
+ { ignoreBoundary: true }
432
+ ))
433
+ return false;
434
+ }
435
+ return foundTouchingPoint;
436
+ case "MultiLineString":
437
+ var foundTouchingPoint = false;
438
+ for (var i = 0; i < geom2.coordinates.length; i++) {
439
+ for (var ii = 0; ii < geom2.coordinates[i].length; ii++) {
440
+ if (!foundTouchingPoint) {
441
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
442
+ { type: "Point", coordinates: geom2.coordinates[i][ii] },
443
+ { type: "LineString", coordinates: geom1.coordinates[0] }
444
+ ))
445
+ foundTouchingPoint = true;
446
+ }
447
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
448
+ { type: "Point", coordinates: geom2.coordinates[i][ii] },
449
+ geom1,
450
+ { ignoreBoundary: true }
451
+ ))
452
+ return false;
453
+ }
454
+ }
455
+ return foundTouchingPoint;
456
+ case "Polygon":
457
+ var foundTouchingPoint = false;
458
+ for (var i = 0; i < geom1.coordinates[0].length; i++) {
459
+ if (!foundTouchingPoint) {
460
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
461
+ { type: "Point", coordinates: geom1.coordinates[0][i] },
462
+ { type: "LineString", coordinates: geom2.coordinates[0] }
463
+ ))
464
+ foundTouchingPoint = true;
465
+ }
466
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
467
+ { type: "Point", coordinates: geom1.coordinates[0][i] },
468
+ geom2,
469
+ { ignoreBoundary: true }
470
+ ))
471
+ return false;
472
+ }
473
+ return foundTouchingPoint;
474
+ case "MultiPolygon":
475
+ var foundTouchingPoint = false;
476
+ for (var i = 0; i < geom2.coordinates[0].length; i++) {
477
+ for (var ii = 0; ii < geom1.coordinates[0].length; ii++) {
478
+ if (!foundTouchingPoint) {
479
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
480
+ { type: "Point", coordinates: geom1.coordinates[0][ii] },
481
+ { type: "LineString", coordinates: geom2.coordinates[0][i] }
482
+ ))
483
+ foundTouchingPoint = true;
484
+ }
485
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
486
+ { type: "Point", coordinates: geom1.coordinates[0][ii] },
487
+ { type: "Polygon", coordinates: geom2.coordinates[0][i] },
488
+ { ignoreBoundary: true }
489
+ ))
490
+ return false;
491
+ }
492
+ }
493
+ return foundTouchingPoint;
494
+ default:
495
+ throw new Error("feature2 " + type2 + " geometry not supported");
496
+ }
497
+ case "MultiPolygon":
498
+ switch (type2) {
499
+ case "Point":
500
+ for (var i = 0; i < geom1.coordinates[0].length; i++) {
501
+ if (_booleanpointonline.booleanPointOnLine.call(void 0, geom2, {
502
+ type: "LineString",
503
+ coordinates: geom1.coordinates[0][i]
504
+ }))
505
+ return true;
506
+ }
507
+ return false;
508
+ case "MultiPoint":
509
+ var foundTouchingPoint = false;
510
+ for (var i = 0; i < geom1.coordinates[0].length; i++) {
511
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
512
+ if (!foundTouchingPoint) {
513
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
514
+ { type: "Point", coordinates: geom2.coordinates[ii] },
515
+ { type: "LineString", coordinates: geom1.coordinates[0][i] }
516
+ ))
517
+ foundTouchingPoint = true;
518
+ }
519
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
520
+ { type: "Point", coordinates: geom2.coordinates[ii] },
521
+ { type: "Polygon", coordinates: geom1.coordinates[0][i] },
522
+ { ignoreBoundary: true }
523
+ ))
524
+ return false;
525
+ }
526
+ }
527
+ return foundTouchingPoint;
528
+ case "LineString":
529
+ var foundTouchingPoint = false;
530
+ for (var i = 0; i < geom1.coordinates[0].length; i++) {
531
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
532
+ if (!foundTouchingPoint) {
533
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
534
+ { type: "Point", coordinates: geom2.coordinates[ii] },
535
+ { type: "LineString", coordinates: geom1.coordinates[0][i] }
536
+ ))
537
+ foundTouchingPoint = true;
538
+ }
539
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
540
+ { type: "Point", coordinates: geom2.coordinates[ii] },
541
+ { type: "Polygon", coordinates: geom1.coordinates[0][i] },
542
+ { ignoreBoundary: true }
543
+ ))
544
+ return false;
545
+ }
546
+ }
547
+ return foundTouchingPoint;
548
+ case "MultiLineString":
549
+ var foundTouchingPoint = false;
550
+ for (var i = 0; i < geom1.coordinates.length; i++) {
551
+ for (var ii = 0; ii < geom2.coordinates.length; ii++) {
552
+ for (var iii = 0; iii < geom2.coordinates[ii].length; iii++) {
553
+ if (!foundTouchingPoint) {
554
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
555
+ {
556
+ type: "Point",
557
+ coordinates: geom2.coordinates[ii][iii]
558
+ },
559
+ {
560
+ type: "LineString",
561
+ coordinates: geom1.coordinates[i][0]
562
+ }
563
+ ))
564
+ foundTouchingPoint = true;
565
+ }
566
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
567
+ { type: "Point", coordinates: geom2.coordinates[ii][iii] },
568
+ { type: "Polygon", coordinates: [geom1.coordinates[i][0]] },
569
+ { ignoreBoundary: true }
570
+ ))
571
+ return false;
572
+ }
573
+ }
574
+ }
575
+ return foundTouchingPoint;
576
+ case "Polygon":
577
+ var foundTouchingPoint = false;
578
+ for (var i = 0; i < geom1.coordinates[0].length; i++) {
579
+ for (var ii = 0; ii < geom1.coordinates[0][i].length; ii++) {
580
+ if (!foundTouchingPoint) {
581
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
582
+ { type: "Point", coordinates: geom1.coordinates[0][i][ii] },
583
+ { type: "LineString", coordinates: geom2.coordinates[0] }
584
+ ))
585
+ foundTouchingPoint = true;
586
+ }
587
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
588
+ { type: "Point", coordinates: geom1.coordinates[0][i][ii] },
589
+ geom2,
590
+ { ignoreBoundary: true }
591
+ ))
592
+ return false;
593
+ }
594
+ }
595
+ return foundTouchingPoint;
596
+ case "MultiPolygon":
597
+ var foundTouchingPoint = false;
598
+ for (var i = 0; i < geom1.coordinates[0].length; i++) {
599
+ for (var ii = 0; ii < geom2.coordinates[0].length; ii++) {
600
+ for (var iii = 0; iii < geom1.coordinates[0].length; iii++) {
601
+ if (!foundTouchingPoint) {
602
+ if (_booleanpointonline.booleanPointOnLine.call(void 0,
603
+ {
604
+ type: "Point",
605
+ coordinates: geom1.coordinates[0][i][iii]
606
+ },
607
+ {
608
+ type: "LineString",
609
+ coordinates: geom2.coordinates[0][ii]
610
+ }
611
+ ))
612
+ foundTouchingPoint = true;
613
+ }
614
+ if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0,
615
+ {
616
+ type: "Point",
617
+ coordinates: geom1.coordinates[0][i][iii]
618
+ },
619
+ { type: "Polygon", coordinates: geom2.coordinates[0][ii] },
620
+ { ignoreBoundary: true }
621
+ ))
622
+ return false;
623
+ }
624
+ }
625
+ }
626
+ return foundTouchingPoint;
627
+ default:
628
+ throw new Error("feature2 " + type2 + " geometry not supported");
629
+ }
630
+ default:
631
+ throw new Error("feature1 " + type1 + " geometry not supported");
632
+ }
633
+ }
634
+ __name(booleanTouches, "booleanTouches");
635
+ function isPointOnLineEnd(point, line) {
636
+ if (compareCoords(line.coordinates[0], point.coordinates))
637
+ return true;
638
+ if (compareCoords(
639
+ line.coordinates[line.coordinates.length - 1],
640
+ point.coordinates
641
+ ))
642
+ return true;
643
+ return false;
644
+ }
645
+ __name(isPointOnLineEnd, "isPointOnLineEnd");
646
+ function compareCoords(pair1, pair2) {
647
+ return pair1[0] === pair2[0] && pair1[1] === pair2[1];
648
+ }
649
+ __name(compareCoords, "compareCoords");
650
+ var turf_boolean_touches_default = booleanTouches;
651
+
652
+
653
+
654
+ exports.booleanTouches = booleanTouches; exports.default = turf_boolean_touches_default;
655
+ //# sourceMappingURL=index.cjs.map