index.cjs 25 KB

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