@math.gl/geospatial 5.0.0-rc.2 → 5.0.1

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.
Files changed (356) hide show
  1. package/README.md +6 -6
  2. package/dist/coordinates.cjs +2523 -0
  3. package/dist/coordinates.cjs.map +6 -0
  4. package/dist/coordinates.d.ts +4 -0
  5. package/dist/coordinates.d.ts.map +1 -1
  6. package/dist/coordinates.js +2 -0
  7. package/dist/coordinates.js.map +1 -1
  8. package/dist/entries/ellipsoid.cjs +1209 -0
  9. package/dist/entries/ellipsoid.cjs.map +6 -0
  10. package/dist/entries/ellipsoid.d.ts +3 -19
  11. package/dist/entries/ellipsoid.d.ts.map +1 -1
  12. package/dist/entries/ellipsoid.js +1 -9
  13. package/dist/entries/ellipsoid.js.map +1 -1
  14. package/dist/expressions.cjs +726 -0
  15. package/dist/expressions.cjs.map +6 -0
  16. package/dist/geodesics.cjs +3195 -0
  17. package/dist/geodesics.cjs.map +6 -0
  18. package/dist/geodesics.d.ts +18 -0
  19. package/dist/geodesics.d.ts.map +1 -0
  20. package/dist/geodesics.js +13 -0
  21. package/dist/geodesics.js.map +1 -0
  22. package/dist/geographic-atlas/sampling.d.ts +1 -1
  23. package/dist/geographic-atlas/sampling.d.ts.map +1 -1
  24. package/dist/geographic-atlas/sampling.js +1 -1
  25. package/dist/geographic-atlas/sampling.js.map +1 -1
  26. package/dist/geographic-cuts.cjs +4160 -0
  27. package/dist/geographic-cuts.cjs.map +6 -0
  28. package/dist/geographic-cuts.d.ts +2 -0
  29. package/dist/geographic-cuts.d.ts.map +1 -1
  30. package/dist/geographic-cuts.js +1 -0
  31. package/dist/geographic-cuts.js.map +1 -1
  32. package/dist/geographic-seams/subdivide-cut.d.ts +1 -1
  33. package/dist/geographic-seams/subdivide-cut.d.ts.map +1 -1
  34. package/dist/geographic-seams/subdivide-cut.js +1 -1
  35. package/dist/geographic-seams/subdivide-cut.js.map +1 -1
  36. package/dist/geographic-seams/types.shared.cjs +32 -0
  37. package/dist/geographic-seams/types.shared.cjs.map +6 -0
  38. package/dist/globe.cjs +4223 -0
  39. package/dist/globe.cjs.map +6 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +2 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/line-simplification.d.ts +7 -0
  45. package/dist/line-simplification.d.ts.map +1 -1
  46. package/dist/line-simplification.js +4 -13
  47. package/dist/line-simplification.js.map +1 -1
  48. package/dist/linear-referencing.d.ts +13 -1
  49. package/dist/linear-referencing.d.ts.map +1 -1
  50. package/dist/linear-referencing.js +29 -9
  51. package/dist/linear-referencing.js.map +1 -1
  52. package/dist/maps/map-transition.shared.cjs +364 -0
  53. package/dist/maps/map-transition.shared.cjs.map +6 -0
  54. package/dist/maps/myriahedral/unfold.d.ts +1 -1
  55. package/dist/maps/myriahedral/unfold.d.ts.map +1 -1
  56. package/dist/maps/myriahedral/unfold.js +1 -1
  57. package/dist/maps/myriahedral/unfold.js.map +1 -1
  58. package/dist/maps/presets.cjs +2 -2
  59. package/dist/maps/presets.cjs.map +2 -2
  60. package/dist/maps/transitions.cjs +3 -342
  61. package/dist/maps/transitions.cjs.map +3 -3
  62. package/dist/maps.cjs +15 -319
  63. package/dist/maps.cjs.map +3 -3
  64. package/dist/measure-referencing.d.ts +16 -0
  65. package/dist/measure-referencing.d.ts.map +1 -0
  66. package/dist/measure-referencing.js +143 -0
  67. package/dist/measure-referencing.js.map +1 -0
  68. package/dist/polygon-simplification.d.ts +6 -0
  69. package/dist/polygon-simplification.d.ts.map +1 -0
  70. package/dist/polygon-simplification.js +141 -0
  71. package/dist/polygon-simplification.js.map +1 -0
  72. package/dist/projection/experimental/core.cjs +63 -1317
  73. package/dist/projection/experimental/core.cjs.map +3 -3
  74. package/dist/projection/experimental/core.d.ts +1 -1
  75. package/dist/projection/experimental/core.d.ts.map +1 -1
  76. package/dist/projection/experimental/crs/projjson.cjs +26 -45
  77. package/dist/projection/experimental/crs/projjson.cjs.map +3 -3
  78. package/dist/projection/experimental/crs/types.shared.cjs +44 -0
  79. package/dist/projection/experimental/crs/types.shared.cjs.map +6 -0
  80. package/dist/projection/experimental/crs/wkt.cjs +36 -52
  81. package/dist/projection/experimental/crs/wkt.cjs.map +3 -3
  82. package/dist/projection/experimental/entries/projections/ob_tran.cjs +9 -23
  83. package/dist/projection/experimental/entries/projections/ob_tran.cjs.map +3 -3
  84. package/dist/projection/experimental/lazy-projections/aea.cjs +1 -1
  85. package/dist/projection/experimental/lazy-projections/aea.js +1 -1
  86. package/dist/projection/experimental/lazy-projections/aeqd.cjs +1 -1
  87. package/dist/projection/experimental/lazy-projections/aeqd.js +1 -1
  88. package/dist/projection/experimental/lazy-projections/bonne.cjs +1 -1
  89. package/dist/projection/experimental/lazy-projections/bonne.js +1 -1
  90. package/dist/projection/experimental/lazy-projections/cass.cjs +1 -1
  91. package/dist/projection/experimental/lazy-projections/cass.js +1 -1
  92. package/dist/projection/experimental/lazy-projections/cea.cjs +1 -1
  93. package/dist/projection/experimental/lazy-projections/cea.js +1 -1
  94. package/dist/projection/experimental/lazy-projections/eck6.cjs +1 -1
  95. package/dist/projection/experimental/lazy-projections/eck6.js +1 -1
  96. package/dist/projection/experimental/lazy-projections/eqc.cjs +1 -1
  97. package/dist/projection/experimental/lazy-projections/eqc.js +1 -1
  98. package/dist/projection/experimental/lazy-projections/eqdc.cjs +1 -1
  99. package/dist/projection/experimental/lazy-projections/eqdc.js +1 -1
  100. package/dist/projection/experimental/lazy-projections/eqearth.cjs +1 -1
  101. package/dist/projection/experimental/lazy-projections/eqearth.js +1 -1
  102. package/dist/projection/experimental/lazy-projections/equi.cjs +1 -1
  103. package/dist/projection/experimental/lazy-projections/equi.js +1 -1
  104. package/dist/projection/experimental/lazy-projections/etmerc.cjs +1 -1
  105. package/dist/projection/experimental/lazy-projections/etmerc.js +1 -1
  106. package/dist/projection/experimental/lazy-projections/geocent.cjs +1 -1
  107. package/dist/projection/experimental/lazy-projections/geocent.js +1 -1
  108. package/dist/projection/experimental/lazy-projections/geos.cjs +1 -1
  109. package/dist/projection/experimental/lazy-projections/geos.js +1 -1
  110. package/dist/projection/experimental/lazy-projections/gnom.cjs +1 -1
  111. package/dist/projection/experimental/lazy-projections/gnom.js +1 -1
  112. package/dist/projection/experimental/lazy-projections/gstmerc.cjs +1 -1
  113. package/dist/projection/experimental/lazy-projections/gstmerc.js +1 -1
  114. package/dist/projection/experimental/lazy-projections/index.cjs +60 -903
  115. package/dist/projection/experimental/lazy-projections/index.cjs.map +3 -3
  116. package/dist/projection/experimental/lazy-projections/krovak.cjs +1 -1
  117. package/dist/projection/experimental/lazy-projections/krovak.js +1 -1
  118. package/dist/projection/experimental/lazy-projections/laea.cjs +1 -1
  119. package/dist/projection/experimental/lazy-projections/laea.js +1 -1
  120. package/dist/projection/experimental/lazy-projections/lcc.cjs +1 -1
  121. package/dist/projection/experimental/lazy-projections/lcc.js +1 -1
  122. package/dist/projection/experimental/lazy-projections/merc.cjs +1 -1
  123. package/dist/projection/experimental/lazy-projections/merc.js +1 -1
  124. package/dist/projection/experimental/lazy-projections/mill.cjs +1 -1
  125. package/dist/projection/experimental/lazy-projections/mill.js +1 -1
  126. package/dist/projection/experimental/lazy-projections/moll.cjs +1 -1
  127. package/dist/projection/experimental/lazy-projections/moll.js +1 -1
  128. package/dist/projection/experimental/lazy-projections/nzmg.cjs +1 -1
  129. package/dist/projection/experimental/lazy-projections/nzmg.js +1 -1
  130. package/dist/projection/experimental/lazy-projections/ob_tran.cjs +1 -1
  131. package/dist/projection/experimental/lazy-projections/ob_tran.js +1 -1
  132. package/dist/projection/experimental/lazy-projections/omerc.cjs +1 -1
  133. package/dist/projection/experimental/lazy-projections/omerc.js +1 -1
  134. package/dist/projection/experimental/lazy-projections/ortho.cjs +1 -1
  135. package/dist/projection/experimental/lazy-projections/ortho.js +1 -1
  136. package/dist/projection/experimental/lazy-projections/poly.cjs +1 -1
  137. package/dist/projection/experimental/lazy-projections/poly.js +1 -1
  138. package/dist/projection/experimental/lazy-projections/qsc.cjs +1 -1
  139. package/dist/projection/experimental/lazy-projections/qsc.js +1 -1
  140. package/dist/projection/experimental/lazy-projections/robin.cjs +1 -1
  141. package/dist/projection/experimental/lazy-projections/robin.js +1 -1
  142. package/dist/projection/experimental/lazy-projections/sinu.cjs +1 -1
  143. package/dist/projection/experimental/lazy-projections/sinu.js +1 -1
  144. package/dist/projection/experimental/lazy-projections/somerc.cjs +1 -1
  145. package/dist/projection/experimental/lazy-projections/somerc.js +1 -1
  146. package/dist/projection/experimental/lazy-projections/stere.cjs +1 -1
  147. package/dist/projection/experimental/lazy-projections/stere.js +1 -1
  148. package/dist/projection/experimental/lazy-projections/sterea.cjs +1 -1
  149. package/dist/projection/experimental/lazy-projections/sterea.js +1 -1
  150. package/dist/projection/experimental/lazy-projections/tmerc.cjs +1 -1
  151. package/dist/projection/experimental/lazy-projections/tmerc.js +1 -1
  152. package/dist/projection/experimental/lazy-projections/tpers.cjs +1 -1
  153. package/dist/projection/experimental/lazy-projections/tpers.js +1 -1
  154. package/dist/projection/experimental/lazy-projections/utm.cjs +1 -1
  155. package/dist/projection/experimental/lazy-projections/utm.js +1 -1
  156. package/dist/projection/experimental/lazy-projections/vandg.cjs +1 -1
  157. package/dist/projection/experimental/lazy-projections/vandg.js +1 -1
  158. package/dist/projection/experimental/projection-engine.shared.cjs +1184 -0
  159. package/dist/projection/experimental/projection-engine.shared.cjs.map +6 -0
  160. package/dist/projection/experimental/typescript-projection.shared.cjs +1703 -0
  161. package/dist/projection/experimental/typescript-projection.shared.cjs.map +6 -0
  162. package/dist/projection/index.cjs +622 -1535
  163. package/dist/projection/index.cjs.map +3 -3
  164. package/dist/projection/pipeline.cjs +44 -58
  165. package/dist/projection/pipeline.cjs.map +3 -3
  166. package/dist/projection/transform-analysis.cjs +20 -936
  167. package/dist/projection/transform-analysis.cjs.map +3 -3
  168. package/dist/spatial-box-clipping.d.ts +9 -0
  169. package/dist/spatial-box-clipping.d.ts.map +1 -0
  170. package/dist/spatial-box-clipping.js +123 -0
  171. package/dist/spatial-box-clipping.js.map +1 -0
  172. package/dist/spatial-dwithin.d.ts +19 -0
  173. package/dist/spatial-dwithin.d.ts.map +1 -0
  174. package/dist/spatial-dwithin.js +107 -0
  175. package/dist/spatial-dwithin.js.map +1 -0
  176. package/dist/spatial-hulls.d.ts +6 -0
  177. package/dist/spatial-hulls.d.ts.map +1 -0
  178. package/dist/spatial-hulls.js +176 -0
  179. package/dist/spatial-hulls.js.map +1 -0
  180. package/dist/spatial-line-intersection-result.d.ts +4 -0
  181. package/dist/spatial-line-intersection-result.d.ts.map +1 -0
  182. package/dist/spatial-line-intersection-result.js +79 -0
  183. package/dist/spatial-line-intersection-result.js.map +1 -0
  184. package/dist/spatial-line-polygon-intersection.d.ts +4 -0
  185. package/dist/spatial-line-polygon-intersection.d.ts.map +1 -0
  186. package/dist/spatial-line-polygon-intersection.js +130 -0
  187. package/dist/spatial-line-polygon-intersection.js.map +1 -0
  188. package/dist/spatial-planar-intersects.d.ts +11 -0
  189. package/dist/spatial-planar-intersects.d.ts.map +1 -1
  190. package/dist/spatial-planar-intersects.js +20 -12
  191. package/dist/spatial-planar-intersects.js.map +1 -1
  192. package/dist/spatial-planar.d.ts +9 -0
  193. package/dist/spatial-planar.d.ts.map +1 -1
  194. package/dist/spatial-planar.js +13 -1
  195. package/dist/spatial-planar.js.map +1 -1
  196. package/dist/spatial-polygon-overlay.d.ts +5 -0
  197. package/dist/spatial-polygon-overlay.d.ts.map +1 -0
  198. package/dist/spatial-polygon-overlay.js +23 -0
  199. package/dist/spatial-polygon-overlay.js.map +1 -0
  200. package/dist/spatial-sql.d.ts +13 -2
  201. package/dist/spatial-sql.d.ts.map +1 -1
  202. package/dist/spatial-sql.js +30 -12
  203. package/dist/spatial-sql.js.map +1 -1
  204. package/dist/spatial-subdivision.d.ts +9 -0
  205. package/dist/spatial-subdivision.d.ts.map +1 -0
  206. package/dist/spatial-subdivision.js +61 -0
  207. package/dist/spatial-subdivision.js.map +1 -0
  208. package/dist/spatial-touches.d.ts +13 -0
  209. package/dist/spatial-touches.d.ts.map +1 -0
  210. package/dist/spatial-touches.js +192 -0
  211. package/dist/spatial-touches.js.map +1 -0
  212. package/dist/st-functions.cjs +2411 -112
  213. package/dist/st-functions.cjs.map +3 -3
  214. package/dist/st-functions.d.ts +67 -2
  215. package/dist/st-functions.d.ts.map +1 -1
  216. package/dist/st-functions.js +195 -12
  217. package/dist/st-functions.js.map +1 -1
  218. package/dist/st-geodesic-functions.d.ts +33 -0
  219. package/dist/st-geodesic-functions.d.ts.map +1 -0
  220. package/dist/st-geodesic-functions.js +84 -0
  221. package/dist/st-geodesic-functions.js.map +1 -0
  222. package/dist/st-hull-functions.cjs +386 -0
  223. package/dist/st-hull-functions.cjs.map +6 -0
  224. package/dist/st-hull-functions.d.ts +17 -0
  225. package/dist/st-hull-functions.d.ts.map +1 -0
  226. package/dist/st-hull-functions.js +14 -0
  227. package/dist/st-hull-functions.js.map +1 -0
  228. package/dist/st-overlay-functions.cjs +621 -0
  229. package/dist/st-overlay-functions.cjs.map +6 -0
  230. package/dist/st-overlay-functions.d.ts +36 -0
  231. package/dist/st-overlay-functions.d.ts.map +1 -0
  232. package/dist/st-overlay-functions.js +183 -0
  233. package/dist/st-overlay-functions.js.map +1 -0
  234. package/dist/st-viewport-functions.cjs +481 -0
  235. package/dist/st-viewport-functions.cjs.map +6 -0
  236. package/dist/st-viewport-functions.d.ts +13 -0
  237. package/dist/st-viewport-functions.d.ts.map +1 -0
  238. package/dist/st-viewport-functions.js +81 -0
  239. package/dist/st-viewport-functions.js.map +1 -0
  240. package/dist/subdivide-geodesic-polyline.d.ts +1 -1
  241. package/dist/subdivide-geodesic-polyline.d.ts.map +1 -1
  242. package/dist/subdivide-geodesic-polyline.js +1 -1
  243. package/dist/subdivide-geodesic-polyline.js.map +1 -1
  244. package/dist/subdivide-globe-mesh.d.ts +1 -1
  245. package/dist/subdivide-globe-mesh.d.ts.map +1 -1
  246. package/dist/subdivide-globe-mesh.js +1 -1
  247. package/dist/subdivide-globe-mesh.js.map +1 -1
  248. package/dist/subdivide-rhumb-polyline.d.ts +1 -1
  249. package/dist/subdivide-rhumb-polyline.d.ts.map +1 -1
  250. package/dist/subdivide-rhumb-polyline.js +1 -1
  251. package/dist/subdivide-rhumb-polyline.js.map +1 -1
  252. package/dist/tasks/index.cjs +808 -2993
  253. package/dist/tasks/index.cjs.map +3 -3
  254. package/dist/terrain/geometry.d.ts +1 -1
  255. package/dist/terrain/geometry.d.ts.map +1 -1
  256. package/dist/terrain/geometry.js +1 -1
  257. package/dist/terrain/geometry.js.map +1 -1
  258. package/dist/terrain/index.cjs +95 -22
  259. package/dist/terrain/index.cjs.map +3 -3
  260. package/dist/terrain/index.d.ts +1 -0
  261. package/dist/terrain/index.d.ts.map +1 -1
  262. package/dist/terrain/index.js +1 -0
  263. package/dist/terrain/index.js.map +1 -1
  264. package/dist/terrain/regional-watersheds.d.ts +44 -0
  265. package/dist/terrain/regional-watersheds.d.ts.map +1 -0
  266. package/dist/terrain/regional-watersheds.js +108 -0
  267. package/dist/terrain/regional-watersheds.js.map +1 -0
  268. package/dist/terrain/tile-cutout-update.d.ts.map +1 -1
  269. package/dist/terrain/tile-cutout-update.js +28 -22
  270. package/dist/terrain/tile-cutout-update.js.map +1 -1
  271. package/dist/tiles.cjs +354 -0
  272. package/dist/tiles.cjs.map +6 -0
  273. package/dist/turf-functions.cjs +16 -9
  274. package/dist/turf-functions.cjs.map +1 -1
  275. package/package.json +154 -117
  276. package/src/coordinates.ts +5 -0
  277. package/src/entries/ellipsoid.ts +7 -32
  278. package/src/geodesics.ts +40 -0
  279. package/src/geographic-atlas/sampling.ts +1 -1
  280. package/src/geographic-cuts.ts +21 -0
  281. package/src/geographic-seams/subdivide-cut.ts +1 -1
  282. package/src/index.ts +2 -0
  283. package/src/line-simplification.ts +4 -16
  284. package/src/linear-referencing.ts +44 -16
  285. package/src/maps/myriahedral/unfold.ts +1 -1
  286. package/src/measure-referencing.ts +165 -0
  287. package/src/polygon-simplification.ts +185 -0
  288. package/src/projection/experimental/core.ts +1 -1
  289. package/src/projection/experimental/lazy-projections/aea.ts +1 -1
  290. package/src/projection/experimental/lazy-projections/aeqd.ts +1 -1
  291. package/src/projection/experimental/lazy-projections/bonne.ts +1 -1
  292. package/src/projection/experimental/lazy-projections/cass.ts +1 -1
  293. package/src/projection/experimental/lazy-projections/cea.ts +1 -1
  294. package/src/projection/experimental/lazy-projections/eck6.ts +1 -1
  295. package/src/projection/experimental/lazy-projections/eqc.ts +1 -1
  296. package/src/projection/experimental/lazy-projections/eqdc.ts +1 -1
  297. package/src/projection/experimental/lazy-projections/eqearth.ts +1 -1
  298. package/src/projection/experimental/lazy-projections/equi.ts +1 -1
  299. package/src/projection/experimental/lazy-projections/etmerc.ts +1 -1
  300. package/src/projection/experimental/lazy-projections/geocent.ts +1 -1
  301. package/src/projection/experimental/lazy-projections/geos.ts +1 -1
  302. package/src/projection/experimental/lazy-projections/gnom.ts +1 -1
  303. package/src/projection/experimental/lazy-projections/gstmerc.ts +1 -1
  304. package/src/projection/experimental/lazy-projections/krovak.ts +1 -1
  305. package/src/projection/experimental/lazy-projections/laea.ts +1 -1
  306. package/src/projection/experimental/lazy-projections/lcc.ts +1 -1
  307. package/src/projection/experimental/lazy-projections/merc.ts +1 -1
  308. package/src/projection/experimental/lazy-projections/mill.ts +1 -1
  309. package/src/projection/experimental/lazy-projections/moll.ts +1 -1
  310. package/src/projection/experimental/lazy-projections/nzmg.ts +1 -1
  311. package/src/projection/experimental/lazy-projections/ob_tran.ts +1 -1
  312. package/src/projection/experimental/lazy-projections/omerc.ts +1 -1
  313. package/src/projection/experimental/lazy-projections/ortho.ts +1 -1
  314. package/src/projection/experimental/lazy-projections/poly.ts +1 -1
  315. package/src/projection/experimental/lazy-projections/qsc.ts +1 -1
  316. package/src/projection/experimental/lazy-projections/robin.ts +1 -1
  317. package/src/projection/experimental/lazy-projections/sinu.ts +1 -1
  318. package/src/projection/experimental/lazy-projections/somerc.ts +1 -1
  319. package/src/projection/experimental/lazy-projections/stere.ts +1 -1
  320. package/src/projection/experimental/lazy-projections/sterea.ts +1 -1
  321. package/src/projection/experimental/lazy-projections/tmerc.ts +1 -1
  322. package/src/projection/experimental/lazy-projections/tpers.ts +1 -1
  323. package/src/projection/experimental/lazy-projections/utm.ts +1 -1
  324. package/src/projection/experimental/lazy-projections/vandg.ts +1 -1
  325. package/src/spatial-box-clipping.ts +140 -0
  326. package/src/spatial-dwithin.ts +135 -0
  327. package/src/spatial-hulls.ts +203 -0
  328. package/src/spatial-line-intersection-result.ts +93 -0
  329. package/src/spatial-line-polygon-intersection.ts +147 -0
  330. package/src/spatial-planar-intersects.ts +21 -15
  331. package/src/spatial-planar.ts +20 -1
  332. package/src/spatial-polygon-overlay.ts +30 -0
  333. package/src/spatial-sql.ts +47 -12
  334. package/src/spatial-subdivision.ts +75 -0
  335. package/src/spatial-touches.ts +218 -0
  336. package/src/st-functions.ts +283 -15
  337. package/src/st-geodesic-functions.ts +121 -0
  338. package/src/st-hull-functions.ts +25 -0
  339. package/src/st-overlay-functions.ts +244 -0
  340. package/src/st-viewport-functions.ts +98 -0
  341. package/src/subdivide-geodesic-polyline.ts +2 -2
  342. package/src/subdivide-globe-mesh.ts +2 -2
  343. package/src/subdivide-rhumb-polyline.ts +2 -2
  344. package/src/terrain/geometry.ts +1 -1
  345. package/src/terrain/index.ts +7 -0
  346. package/src/terrain/regional-watersheds.ts +153 -0
  347. package/src/terrain/tile-cutout-update.ts +32 -26
  348. package/dist/index.cjs +0 -18674
  349. package/dist/index.cjs.map +0 -6
  350. package/dist/turf-expressions.cjs +0 -1997
  351. package/dist/turf-expressions.cjs.map +0 -6
  352. package/dist/turf-expressions.d.ts +0 -3
  353. package/dist/turf-expressions.d.ts.map +0 -1
  354. package/dist/turf-expressions.js +0 -7
  355. package/dist/turf-expressions.js.map +0 -1
  356. package/src/turf-expressions.ts +0 -7
@@ -16,7 +16,9 @@ import {
16
16
  } from 'apache-arrow';
17
17
  import type {ScalarFunction} from '@math.gl/sql/arrow';
18
18
  import {
19
+ GeoArrowBuilder,
19
20
  getGeoArrowFieldInfo,
21
+ makeArrowVectorFromGeoArrowColumn,
20
22
  isGeoArrowValueValid,
21
23
  makeGeoArrowColumnFromArrowVector,
22
24
  makeGeoArrowColumnFromGeometryRows,
@@ -53,6 +55,27 @@ export const polygonKinds = ['Polygon', 'MultiPolygon'] as const;
53
55
 
54
56
  /** Supported Arrow result storage for a spatial function. */
55
57
  type SpatialResult = Int32 | Float64 | Bool | Binary | FixedSizeList<Float64> | Utf8;
58
+ /** Native geometry result storage and its row-aligned Arrow vector builder. */
59
+ export type NativeSpatialResult = {
60
+ /** Extension encoding declared on the bound result field. */
61
+ encoding: 'geoarrow.polygon' | 'geoarrow.multipolygon' | 'geoarrow.geometry';
62
+ /** Fixed physical Arrow schema for all batches. */
63
+ type: DataType;
64
+ /** Packs decoded geometry rows into native coordinate buffers. */
65
+ build: (rows: readonly (WellKnownGeometry | null)[]) => Vector;
66
+ };
67
+
68
+ /** Declares a fixed native polygon layout, including for empty or all-null batches. */
69
+ export function nativePolygonResult(
70
+ encoding: Exclude<NativeSpatialResult['encoding'], 'geoarrow.geometry'>
71
+ ): NativeSpatialResult {
72
+ const options = {encoding, dimension: 'xy', coordinateLayout: 'interleaved'} as const;
73
+ /** Packs the output rings into GeoArrow list offsets and interleaved XY coordinates. */
74
+ const build: NativeSpatialResult['build'] = rows =>
75
+ makeArrowVectorFromGeoArrowColumn(GeoArrowBuilder.build(rows, options));
76
+ return {encoding, type: build([]).type, build};
77
+ }
78
+
56
79
  /** A nullable result value passed to the Arrow vector builder. */
57
80
  type SpatialValue = string | number | boolean | number[] | Uint8Array | null;
58
81
 
@@ -135,15 +158,17 @@ export function planarGeometry(
135
158
  }
136
159
 
137
160
  /** Declares a row-preserving spatial overload using the input columns' GeoArrow types. */
138
- export function spatialFunction(
161
+ export function spatialFunction<Value extends SpatialValue | WellKnownGeometry>(
139
162
  name: string,
140
163
  signatures: readonly (readonly GeometryKind[])[],
141
- type: SpatialResult,
142
- evaluate: (geometries: readonly GeometryRow[], ...numbers: number[]) => SpatialValue,
164
+ output: SpatialResult | NativeSpatialResult,
165
+ evaluate: (geometries: readonly GeometryRow[], ...numbers: number[]) => Value,
143
166
  numericArguments = 0,
144
167
  allDimensions = false,
145
- skipNullGeometries = false
168
+ skipNullGeometries = false,
169
+ validateCRS?: (crs: unknown, name: string) => void
146
170
  ): ScalarFunction {
171
+ const type = 'encoding' in output ? output.type : output;
147
172
  return {
148
173
  kind: 'scalar',
149
174
  name,
@@ -167,13 +192,17 @@ export function spatialFunction(
167
192
  (DataType.isBinary(field.type) || DataType.isLargeBinary(field.type))
168
193
  ) {
169
194
  // WKB reveals its geometry kind and dimensionality per row.
195
+ } else if (encoding === 'geoarrow.geometry' && extension.dimension === 'xy') {
196
+ // Native XY union rows are checked against the input signature during evaluation.
170
197
  } else if (kinds.some(kind => encoding === 'geoarrow.' + kind.toLowerCase())) {
171
198
  if (!allDimensions && extension?.dimension !== 'xy')
172
199
  throw new Error(`${name} requires 2D geometry`);
173
200
  } else {
174
201
  throw new Error(`${name} argument ${index + 1} requires GeoArrow ${kinds.join(' or ')}`);
175
202
  }
203
+ validateCRS?.(extension?.metadata['crs'], name);
176
204
  if (
205
+ !validateCRS &&
177
206
  name.startsWith('ST_') &&
178
207
  name !== 'ST_SRID' &&
179
208
  name !== 'ST_SetSRID' &&
@@ -186,18 +215,22 @@ export function spatialFunction(
186
215
  .map(extension => extension?.metadata['crs'])
187
216
  .filter(crs => crs !== undefined && crs !== null);
188
217
  if (
218
+ !validateCRS &&
189
219
  name.startsWith('ST_') &&
190
220
  crsValues.some(crs => JSON.stringify(crs) !== JSON.stringify(crsValues[0]))
191
221
  ) {
192
222
  throw new Error(`${name} requires arguments in the same CRS`);
193
223
  }
194
224
  const metadata = new Map<string, string>();
195
- if (DataType.isBinary(type)) {
196
- metadata.set(EXTENSION_NAME, 'geoarrow.wkb');
197
- const inputMetadata = geometryFields
198
- .find(field => field?.metadata.has(EXTENSION_METADATA))
199
- ?.metadata.get(EXTENSION_METADATA);
200
- if (inputMetadata) metadata.set(EXTENSION_METADATA, inputMetadata);
225
+ if ('encoding' in output || DataType.isBinary(type)) {
226
+ metadata.set(EXTENSION_NAME, 'encoding' in output ? output.encoding : 'geoarrow.wkb');
227
+ const inputMetadata = extensions[0]?.metadata;
228
+ const crs = inputMetadata?.['crs'];
229
+ const crsType = crs === undefined ? undefined : inputMetadata?.['crs_type'];
230
+ const edges = inputMetadata?.['edges'];
231
+ if (crs !== undefined || edges !== undefined) {
232
+ metadata.set(EXTENSION_METADATA, JSON.stringify({crs, crs_type: crsType, edges}));
233
+ }
201
234
  }
202
235
  const arguments_ = [
203
236
  ...geometryFields.map(field => field ?? new Field('geometry', new Binary(), true)),
@@ -223,7 +256,7 @@ export function spatialFunction(
223
256
  name === 'ST_GeometryN'
224
257
  )
225
258
  );
226
- const values = new Array<SpatialValue>(rowCount).fill(null);
259
+ const values = new Array<Value | null>(rowCount).fill(null);
227
260
  for (let row = 0; row < rowCount; row++) {
228
261
  if (!activeRows[row]) continue;
229
262
  const geometries: WellKnownGeometry[] = [];
@@ -238,7 +271,9 @@ export function spatialFunction(
238
271
  }
239
272
  values[row] = evaluate(geometries, ...numbers.map(vector => Number(vector.get(row))));
240
273
  }
241
- return vectorFromArray(values, type);
274
+ return 'encoding' in output
275
+ ? output.build(values as (WellKnownGeometry | null)[])
276
+ : vectorFromArray(values as SpatialValue[], output);
242
277
  }
243
278
  };
244
279
  }
@@ -0,0 +1,75 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {WellKnownGeometry} from '@math.gl/core/arrow';
6
+ import {vertexCount} from './geometry-inspection';
7
+ import {clipPolygons, type Box} from './spatial-box-clipping';
8
+ import {planarBounds} from './spatial-planar';
9
+
10
+ /** Default vertex ceiling for ST_Subdivide, including polygon closures. */
11
+ const MAX_VERTICES = 256;
12
+
13
+ /** Maximum bisection depth before reporting an unrepresentable split. */
14
+ const MAX_DEPTH = 64;
15
+
16
+ /** Individual polygon produced by rectilinear subdivision. */
17
+ type Polygon = Extract<WellKnownGeometry, {type: 'Polygon'}>;
18
+
19
+ /** Splits a rectangle at the midpoint of its wider axis. */
20
+ function splitBox(box: Box): [Box, Box] {
21
+ const [minX, minY, maxX, maxY] = box;
22
+ if (maxX - minX >= maxY - minY) {
23
+ const mid = minX / 2 + maxX / 2;
24
+ if (mid > minX && mid < maxX)
25
+ return [
26
+ [minX, minY, mid, maxY],
27
+ [mid, minY, maxX, maxY]
28
+ ];
29
+ }
30
+ const mid = minY / 2 + maxY / 2;
31
+ if (mid > minY && mid < maxY)
32
+ return [
33
+ [minX, minY, maxX, mid],
34
+ [minX, mid, maxX, maxY]
35
+ ];
36
+ throw new Error('ST_Subdivide cannot bisect the polygon at the available coordinate precision');
37
+ }
38
+
39
+ /** Emits bounded polygon parts with rectilinear cuts, retaining holes through each split. */
40
+ export function* subdividePolygons(
41
+ geometry: WellKnownGeometry,
42
+ signal?: AbortSignal
43
+ ): Generator<Polygon> {
44
+ if (geometry.type !== 'Polygon' && geometry.type !== 'MultiPolygon') {
45
+ throw new Error('ST_Subdivide requires a Polygon or MultiPolygon');
46
+ }
47
+ const polygons = geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates;
48
+ for (const coordinates of polygons) {
49
+ yield* subdividePolygon({type: 'Polygon', coordinates}, 0, signal);
50
+ }
51
+ }
52
+
53
+ /** Recursively subdivides a single polygon until each piece fits the vertex budget. */
54
+ function* subdividePolygon(
55
+ polygon: Polygon,
56
+ depth: number,
57
+ signal?: AbortSignal
58
+ ): Generator<Polygon> {
59
+ signal?.throwIfAborted();
60
+ const count = vertexCount(polygon);
61
+ if (!count) return;
62
+ if (count <= MAX_VERTICES) {
63
+ yield polygon;
64
+ return;
65
+ }
66
+ if (depth >= MAX_DEPTH) throw new Error('ST_Subdivide could not reach the vertex limit');
67
+ const bounds = planarBounds(polygon);
68
+ if (!bounds?.every(Number.isFinite))
69
+ throw new Error('ST_Subdivide requires finite polygon bounds');
70
+ for (const box of splitBox(bounds as Box)) {
71
+ for (const coordinates of clipPolygons([polygon.coordinates], box)) {
72
+ yield* subdividePolygon({type: 'Polygon', coordinates}, depth + 1, signal);
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,218 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {WellKnownGeometry} from '@math.gl/core/arrow';
6
+ import polygonClipping from 'polygon-clipping';
7
+ import {
8
+ locatePointInPolygon,
9
+ planarIntersects,
10
+ pointOnSegment,
11
+ segmentsMeet
12
+ } from './spatial-planar-intersects';
13
+ import {polygonSet} from './spatial-polygon-overlay';
14
+
15
+ /** XY position and ordered path. */
16
+ type Position = readonly number[];
17
+ /** Ordered vertices of a line component or ring. */
18
+ type Path = readonly Position[];
19
+ /** Endpoints of one planar segment. */
20
+ type Edge = readonly [Position, Position];
21
+ /** Point and multipoint geometry. */
22
+ type Points = Extract<WellKnownGeometry, {type: 'Point' | 'MultiPoint'}>;
23
+ /** Line and multiline geometry. */
24
+ type Lines = Extract<WellKnownGeometry, {type: 'LineString' | 'MultiLineString'}>;
25
+ /** Polygon and multipolygon geometry. */
26
+ type Area = Extract<WellKnownGeometry, {type: 'Polygon' | 'MultiPolygon'}>;
27
+
28
+ /** Narrows the geometry types containing only points. */
29
+ function isPointLike(geometry: WellKnownGeometry): geometry is Points {
30
+ return geometry.type === 'Point' || geometry.type === 'MultiPoint';
31
+ }
32
+
33
+ /** Narrows line and multiline geometries. */
34
+ function isLinear(geometry: WellKnownGeometry): geometry is Lines {
35
+ return geometry.type === 'LineString' || geometry.type === 'MultiLineString';
36
+ }
37
+
38
+ /** Narrows polygon and multipolygon geometries. */
39
+ function isAreal(geometry: WellKnownGeometry): geometry is Area {
40
+ return geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';
41
+ }
42
+
43
+ /** Returns independent line components. */
44
+ function paths(geometry: Lines): readonly Path[] {
45
+ return geometry.type === 'LineString' ? [geometry.coordinates] : geometry.coordinates;
46
+ }
47
+
48
+ /** Returns independent areal components with their interior rings. */
49
+ function polygons(geometry: Area): readonly (readonly Path[])[] {
50
+ return geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates;
51
+ }
52
+
53
+ /** Compares planar coordinates without imposing a distance tolerance. */
54
+ function samePoint(a: Position, b: Position): boolean {
55
+ return a[0] === b[0] && a[1] === b[1];
56
+ }
57
+
58
+ /** Keys an XY location, including equivalent positive and negative zero. */
59
+ function pointKey(point: Position): string {
60
+ return `${point[0]}/${point[1]}`;
61
+ }
62
+
63
+ /** Iterates nonzero segments and implicitly closes rings. */
64
+ function* edges(components: readonly Path[], closed = false): Generator<Edge> {
65
+ for (const path of components) {
66
+ for (let i = closed ? 0 : 1; i < path.length; i++) {
67
+ const a = path[i ? i - 1 : path.length - 1]!;
68
+ const b = path[i]!;
69
+ if (!samePoint(a, b)) yield [a, b];
70
+ }
71
+ }
72
+ }
73
+
74
+ /** Computes the line boundary using odd endpoint incidence across all components. */
75
+ function lineBoundary(components: readonly Path[]): ReadonlyMap<string, Position> {
76
+ const boundary = new Map<string, Position>();
77
+ for (const component of components) {
78
+ if (!component.length) continue;
79
+ for (const point of [component[0]!, component[component.length - 1]!]) {
80
+ const key = pointKey(point);
81
+ if (!boundary.delete(key)) boundary.set(key, point);
82
+ }
83
+ }
84
+ return boundary;
85
+ }
86
+
87
+ /** Finds shared endpoints, including an endpoint lying in the other segment's interior. */
88
+ export function endpointContacts(a: Edge, b: Edge): Position[] {
89
+ const contacts: Position[] = [];
90
+ for (const [endpoints, other] of [
91
+ [a, b],
92
+ [b, a]
93
+ ] as const) {
94
+ for (const point of endpoints) {
95
+ if (pointOnSegment(point, ...other) && !contacts.some(value => samePoint(value, point)))
96
+ contacts.push(point);
97
+ }
98
+ }
99
+ return contacts;
100
+ }
101
+
102
+ /** Tests whether any odd endpoint is also on both segments of a proper crossing. */
103
+ function hasBoundaryCrossing(boundary: ReadonlyMap<string, Position>, a: Edge, b: Edge): boolean {
104
+ for (const point of boundary.values()) {
105
+ if (pointOnSegment(point, ...a) && pointOnSegment(point, ...b)) return true;
106
+ }
107
+ return false;
108
+ }
109
+
110
+ /** Detects line interior overlap, accounting for the whole multiline boundary. */
111
+ function lineInteriorsMeet(a: Lines, b: Lines): boolean {
112
+ const aPaths = paths(a);
113
+ const bPaths = paths(b);
114
+ const aBoundary = lineBoundary(aPaths);
115
+ const bBoundary = lineBoundary(bPaths);
116
+ const bEdges = [...edges(bPaths)];
117
+ for (const left of edges(aPaths)) {
118
+ for (const right of bEdges) {
119
+ if (!segmentsMeet(...left, ...right)) continue;
120
+ const contacts = endpointContacts(left, right);
121
+ if (contacts.length > 1) return true;
122
+ if (contacts.length) {
123
+ const key = pointKey(contacts[0]!);
124
+ if (!aBoundary.has(key) && !bBoundary.has(key)) return true;
125
+ } else if (
126
+ !hasBoundaryCrossing(aBoundary, left, right) &&
127
+ !hasBoundaryCrossing(bBoundary, left, right)
128
+ ) {
129
+ return true;
130
+ }
131
+ }
132
+ }
133
+ return false;
134
+ }
135
+
136
+ /** Tests a point against the interior of any areal component. */
137
+ function insideArea(point: Position, areas: readonly (readonly Path[])[]): boolean {
138
+ return areas.some(rings => locatePointInPolygon(point, rings) === 1);
139
+ }
140
+
141
+ /** Finds a segment parameter on its axis with the least relative rounding error. */
142
+ export function parameter(point: Position, [a, b]: Edge): number {
143
+ const dx = b[0]! - a[0]!;
144
+ const dy = b[1]! - a[1]!;
145
+ return Math.abs(dx) >= Math.abs(dy) ? (point[0]! - a[0]!) / dx : (point[1]! - a[1]!) / dy;
146
+ }
147
+
148
+ /** Tests intervals between area boundary contacts, excluding coincident boundary segments. */
149
+ function segmentEntersArea(
150
+ edge: Edge,
151
+ boundaries: readonly Edge[],
152
+ areas: readonly (readonly Path[])[]
153
+ ): boolean {
154
+ const [a, b] = edge;
155
+ if (insideArea(a, areas) || insideArea(b, areas)) return true;
156
+ const cuts = new Set([0, 1]);
157
+ const coincident: [number, number][] = [];
158
+ for (const boundary of boundaries) {
159
+ if (!segmentsMeet(...edge, ...boundary)) continue;
160
+ const contacts = endpointContacts(edge, boundary).map(point => parameter(point, edge));
161
+ if (!contacts.length) return true;
162
+ for (const contact of contacts) cuts.add(contact);
163
+ if (contacts.length === 2) coincident.push([Math.min(...contacts), Math.max(...contacts)]);
164
+ }
165
+ const sorted = [...cuts].sort((left, right) => left - right);
166
+ for (let i = 1; i < sorted.length; i++) {
167
+ const from = sorted[i - 1]!;
168
+ const to = sorted[i]!;
169
+ if (coincident.some(([start, end]) => start <= from && to <= end)) continue;
170
+ const t = (from + to) / 2;
171
+ if (insideArea([(1 - t) * a[0]! + t * b[0]!, (1 - t) * a[1]! + t * b[1]!], areas)) return true;
172
+ }
173
+ return false;
174
+ }
175
+
176
+ /** Finds any line segment that enters an areal interior. */
177
+ function lineEntersArea(line: Lines, area: Area): boolean {
178
+ const areas = polygons(area);
179
+ const boundaries = [...edges(areas.flat(), true)];
180
+ for (const edge of edges(paths(line))) {
181
+ if (segmentEntersArea(edge, boundaries, areas)) return true;
182
+ }
183
+ return false;
184
+ }
185
+
186
+ /** Checks point locations against the other geometry's interior. */
187
+ function pointsMeetInterior(points: Points, other: Lines | Area): boolean {
188
+ const positions = points.type === 'Point' ? [points.coordinates] : points.coordinates;
189
+ if (isAreal(other)) {
190
+ const areas = polygons(other);
191
+ return positions.some(
192
+ point => Number.isFinite(point[0]) && Number.isFinite(point[1]) && insideArea(point, areas)
193
+ );
194
+ }
195
+ const linePaths = paths(other);
196
+ const boundary = lineBoundary(linePaths);
197
+ const segments = [...edges(linePaths)];
198
+ return positions.some(
199
+ point => !boundary.has(pointKey(point)) && segments.some(edge => pointOnSegment(point, ...edge))
200
+ );
201
+ }
202
+
203
+ /** Reports any geometric contact without intersection between the two interiors. */
204
+ export function planarTouches(a: WellKnownGeometry, b: WellKnownGeometry): boolean {
205
+ if (
206
+ (!isPointLike(a) && !isLinear(a) && !isAreal(a)) ||
207
+ (!isPointLike(b) && !isLinear(b) && !isAreal(b))
208
+ )
209
+ throw new Error('ST_Touches requires point, line or polygon geometry');
210
+ if (isPointLike(a) && isPointLike(b)) return false;
211
+ if (!planarIntersects(a, b)) return false;
212
+ if (isPointLike(a) && !isPointLike(b)) return !pointsMeetInterior(a, b);
213
+ if (isPointLike(b) && !isPointLike(a)) return !pointsMeetInterior(b, a);
214
+ if (isLinear(a) && isLinear(b)) return !lineInteriorsMeet(a, b);
215
+ if (isLinear(a) && isAreal(b)) return !lineEntersArea(a, b);
216
+ if (isAreal(a) && isLinear(b)) return !lineEntersArea(b, a);
217
+ return !polygonClipping.intersection(polygonSet(a), polygonSet(b)).length;
218
+ }