@math.gl/geospatial 5.0.0-beta.9 → 5.0.0-rc.2

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 (559) hide show
  1. package/README.md +3 -3
  2. package/dist/crs/crs-descriptor-types.d.ts +2 -1
  3. package/dist/crs/crs-descriptor-types.d.ts.map +1 -1
  4. package/dist/crs/index.cjs +54 -0
  5. package/dist/crs/index.cjs.map +2 -2
  6. package/dist/crs/index.d.ts +1 -0
  7. package/dist/crs/index.d.ts.map +1 -1
  8. package/dist/crs/index.js +1 -0
  9. package/dist/crs/index.js.map +1 -1
  10. package/dist/crs/spatial-reference-metadata.d.ts +20 -0
  11. package/dist/crs/spatial-reference-metadata.d.ts.map +1 -0
  12. package/dist/crs/spatial-reference-metadata.js +86 -0
  13. package/dist/crs/spatial-reference-metadata.js.map +1 -0
  14. package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts +1 -1
  15. package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts.map +1 -1
  16. package/dist/ellipsoid-helpers/ellipsoid-transform.js +2 -2
  17. package/dist/ellipsoid-helpers/ellipsoid-transform.js.map +1 -1
  18. package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js +1 -1
  19. package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js.map +1 -1
  20. package/dist/ellipsoid-helpers/tangent-plane-numerics.d.ts +1 -1
  21. package/dist/ellipsoid-helpers/tangent-plane-numerics.d.ts.map +1 -1
  22. package/dist/ellipsoid-tangent-plane.d.ts +2 -2
  23. package/dist/ellipsoid-tangent-plane.d.ts.map +1 -1
  24. package/dist/ellipsoid-tangent-plane.js +1 -1
  25. package/dist/ellipsoid-tangent-plane.js.map +1 -1
  26. package/dist/ellipsoid-transforms.d.ts +2 -2
  27. package/dist/ellipsoid-transforms.d.ts.map +1 -1
  28. package/dist/ellipsoid-transforms.js +1 -1
  29. package/dist/ellipsoid-transforms.js.map +1 -1
  30. package/dist/ellipsoid.d.ts +2 -2
  31. package/dist/ellipsoid.d.ts.map +1 -1
  32. package/dist/ellipsoid.js +2 -2
  33. package/dist/ellipsoid.js.map +1 -1
  34. package/dist/expressions.d.ts +1 -1
  35. package/dist/expressions.d.ts.map +1 -1
  36. package/dist/expressions.js +1 -1
  37. package/dist/expressions.js.map +1 -1
  38. package/dist/geodesic-buffer.d.ts +1 -1
  39. package/dist/geodesic-buffer.d.ts.map +1 -1
  40. package/dist/geodesic-path.d.ts +1 -1
  41. package/dist/geodesic-path.d.ts.map +1 -1
  42. package/dist/geometry-constructors.d.ts +6 -0
  43. package/dist/geometry-constructors.d.ts.map +1 -0
  44. package/dist/geometry-constructors.js +37 -0
  45. package/dist/geometry-constructors.js.map +1 -0
  46. package/dist/geometry-inspection.d.ts +8 -0
  47. package/dist/geometry-inspection.d.ts.map +1 -0
  48. package/dist/geometry-inspection.js +61 -0
  49. package/dist/geometry-inspection.js.map +1 -0
  50. package/dist/index.cjs +2514 -558
  51. package/dist/index.cjs.map +3 -3
  52. package/dist/index.d.ts +164 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +106 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/line-simplification.d.ts +4 -0
  57. package/dist/line-simplification.d.ts.map +1 -0
  58. package/dist/line-simplification.js +83 -0
  59. package/dist/line-simplification.js.map +1 -0
  60. package/dist/linear-referencing.d.ts +6 -0
  61. package/dist/linear-referencing.d.ts.map +1 -0
  62. package/dist/linear-referencing.js +74 -0
  63. package/dist/linear-referencing.js.map +1 -0
  64. package/dist/lng-lat-rectangle.d.ts +1 -1
  65. package/dist/lng-lat-rectangle.d.ts.map +1 -1
  66. package/dist/lng-lat-rectangle.js +1 -1
  67. package/dist/lng-lat-rectangle.js.map +1 -1
  68. package/dist/local-reference-frame.d.ts +3 -3
  69. package/dist/local-reference-frame.d.ts.map +1 -1
  70. package/dist/local-reference-frame.js +2 -2
  71. package/dist/local-reference-frame.js.map +1 -1
  72. package/dist/make-obb-from-region.d.ts +1 -1
  73. package/dist/make-obb-from-region.d.ts.map +1 -1
  74. package/dist/make-obb-from-region.js +1 -1
  75. package/dist/make-obb-from-region.js.map +1 -1
  76. package/dist/maps/air-ocean-mesh.js +1 -1
  77. package/dist/maps/air-ocean-mesh.js.map +1 -1
  78. package/dist/maps/myriahedral/unfold.d.ts +1 -1
  79. package/dist/maps/myriahedral/unfold.d.ts.map +1 -1
  80. package/dist/maps/myriahedral/unfold.js +1 -1
  81. package/dist/maps/myriahedral/unfold.js.map +1 -1
  82. package/dist/maps/presets.cjs +6 -6
  83. package/dist/maps/presets.cjs.map +2 -2
  84. package/dist/maps.cjs +6 -6
  85. package/dist/maps.cjs.map +2 -2
  86. package/dist/projection/deformation.cjs +5 -5
  87. package/dist/projection/deformation.cjs.map +2 -2
  88. package/dist/projection/experimental/core.cjs +8 -4
  89. package/dist/projection/experimental/core.cjs.map +1 -1
  90. package/dist/projection/experimental/crs/spatial-reference.d.ts.map +1 -1
  91. package/dist/projection/experimental/crs/spatial-reference.js.map +1 -1
  92. package/dist/projection/experimental/crs/types.d.ts +1 -1
  93. package/dist/projection/experimental/crs/types.d.ts.map +1 -1
  94. package/dist/projection/experimental/crs-rendering-scale.d.ts.map +1 -1
  95. package/dist/projection/experimental/crs-rendering-scale.js +13 -2
  96. package/dist/projection/experimental/crs-rendering-scale.js.map +1 -1
  97. package/dist/projection/experimental/datum.js +1 -1
  98. package/dist/projection/experimental/datum.js.map +1 -1
  99. package/dist/projection/experimental/entries/projections/geocent.cjs +3 -3
  100. package/dist/projection/experimental/entries/projections/geocent.cjs.map +1 -1
  101. package/dist/projection/experimental/lazy-projections/aea.cjs +4 -1
  102. package/dist/projection/experimental/lazy-projections/aea.cjs.map +1 -1
  103. package/dist/projection/experimental/lazy-projections/aea.d.ts.map +1 -1
  104. package/dist/projection/experimental/lazy-projections/aea.js +4 -1
  105. package/dist/projection/experimental/lazy-projections/aea.js.map +1 -1
  106. package/dist/projection/experimental/lazy-projections/bonne.cjs +4 -1
  107. package/dist/projection/experimental/lazy-projections/bonne.cjs.map +1 -1
  108. package/dist/projection/experimental/lazy-projections/bonne.d.ts.map +1 -1
  109. package/dist/projection/experimental/lazy-projections/bonne.js +4 -1
  110. package/dist/projection/experimental/lazy-projections/bonne.js.map +1 -1
  111. package/dist/projection/experimental/lazy-projections/cass.cjs +4 -1
  112. package/dist/projection/experimental/lazy-projections/cass.cjs.map +1 -1
  113. package/dist/projection/experimental/lazy-projections/cass.d.ts.map +1 -1
  114. package/dist/projection/experimental/lazy-projections/cass.js +4 -1
  115. package/dist/projection/experimental/lazy-projections/cass.js.map +1 -1
  116. package/dist/projection/experimental/lazy-projections/eck6.cjs +4 -1
  117. package/dist/projection/experimental/lazy-projections/eck6.cjs.map +1 -1
  118. package/dist/projection/experimental/lazy-projections/eck6.d.ts.map +1 -1
  119. package/dist/projection/experimental/lazy-projections/eck6.js +4 -1
  120. package/dist/projection/experimental/lazy-projections/eck6.js.map +1 -1
  121. package/dist/projection/experimental/lazy-projections/eqdc.cjs +4 -1
  122. package/dist/projection/experimental/lazy-projections/eqdc.cjs.map +1 -1
  123. package/dist/projection/experimental/lazy-projections/eqdc.d.ts.map +1 -1
  124. package/dist/projection/experimental/lazy-projections/eqdc.js +4 -1
  125. package/dist/projection/experimental/lazy-projections/eqdc.js.map +1 -1
  126. package/dist/projection/experimental/lazy-projections/eqearth.cjs +4 -1
  127. package/dist/projection/experimental/lazy-projections/eqearth.cjs.map +1 -1
  128. package/dist/projection/experimental/lazy-projections/eqearth.d.ts.map +1 -1
  129. package/dist/projection/experimental/lazy-projections/eqearth.js +4 -1
  130. package/dist/projection/experimental/lazy-projections/eqearth.js.map +1 -1
  131. package/dist/projection/experimental/lazy-projections/equi.cjs +4 -1
  132. package/dist/projection/experimental/lazy-projections/equi.cjs.map +1 -1
  133. package/dist/projection/experimental/lazy-projections/equi.d.ts.map +1 -1
  134. package/dist/projection/experimental/lazy-projections/equi.js +4 -1
  135. package/dist/projection/experimental/lazy-projections/equi.js.map +1 -1
  136. package/dist/projection/experimental/lazy-projections/geocent.cjs +4 -1
  137. package/dist/projection/experimental/lazy-projections/geocent.cjs.map +1 -1
  138. package/dist/projection/experimental/lazy-projections/geocent.d.ts.map +1 -1
  139. package/dist/projection/experimental/lazy-projections/geocent.js +4 -1
  140. package/dist/projection/experimental/lazy-projections/geocent.js.map +1 -1
  141. package/dist/projection/experimental/lazy-projections/geos.cjs +4 -1
  142. package/dist/projection/experimental/lazy-projections/geos.cjs.map +1 -1
  143. package/dist/projection/experimental/lazy-projections/geos.d.ts.map +1 -1
  144. package/dist/projection/experimental/lazy-projections/geos.js +4 -1
  145. package/dist/projection/experimental/lazy-projections/geos.js.map +1 -1
  146. package/dist/projection/experimental/lazy-projections/gnom.cjs +4 -1
  147. package/dist/projection/experimental/lazy-projections/gnom.cjs.map +1 -1
  148. package/dist/projection/experimental/lazy-projections/gnom.d.ts.map +1 -1
  149. package/dist/projection/experimental/lazy-projections/gnom.js +4 -1
  150. package/dist/projection/experimental/lazy-projections/gnom.js.map +1 -1
  151. package/dist/projection/experimental/lazy-projections/index.cjs +100 -27
  152. package/dist/projection/experimental/lazy-projections/index.cjs.map +1 -1
  153. package/dist/projection/experimental/lazy-projections/krovak.cjs +4 -1
  154. package/dist/projection/experimental/lazy-projections/krovak.cjs.map +1 -1
  155. package/dist/projection/experimental/lazy-projections/krovak.d.ts.map +1 -1
  156. package/dist/projection/experimental/lazy-projections/krovak.js +4 -1
  157. package/dist/projection/experimental/lazy-projections/krovak.js.map +1 -1
  158. package/dist/projection/experimental/lazy-projections/merc.cjs +4 -1
  159. package/dist/projection/experimental/lazy-projections/merc.cjs.map +1 -1
  160. package/dist/projection/experimental/lazy-projections/merc.d.ts.map +1 -1
  161. package/dist/projection/experimental/lazy-projections/merc.js +4 -1
  162. package/dist/projection/experimental/lazy-projections/merc.js.map +1 -1
  163. package/dist/projection/experimental/lazy-projections/mill.cjs +4 -1
  164. package/dist/projection/experimental/lazy-projections/mill.cjs.map +1 -1
  165. package/dist/projection/experimental/lazy-projections/mill.d.ts.map +1 -1
  166. package/dist/projection/experimental/lazy-projections/mill.js +4 -1
  167. package/dist/projection/experimental/lazy-projections/mill.js.map +1 -1
  168. package/dist/projection/experimental/lazy-projections/moll.cjs +4 -1
  169. package/dist/projection/experimental/lazy-projections/moll.cjs.map +1 -1
  170. package/dist/projection/experimental/lazy-projections/moll.d.ts.map +1 -1
  171. package/dist/projection/experimental/lazy-projections/moll.js +4 -1
  172. package/dist/projection/experimental/lazy-projections/moll.js.map +1 -1
  173. package/dist/projection/experimental/lazy-projections/nzmg.cjs +4 -1
  174. package/dist/projection/experimental/lazy-projections/nzmg.cjs.map +1 -1
  175. package/dist/projection/experimental/lazy-projections/nzmg.d.ts.map +1 -1
  176. package/dist/projection/experimental/lazy-projections/nzmg.js +4 -1
  177. package/dist/projection/experimental/lazy-projections/nzmg.js.map +1 -1
  178. package/dist/projection/experimental/lazy-projections/omerc.cjs +4 -1
  179. package/dist/projection/experimental/lazy-projections/omerc.cjs.map +1 -1
  180. package/dist/projection/experimental/lazy-projections/omerc.d.ts.map +1 -1
  181. package/dist/projection/experimental/lazy-projections/omerc.js +4 -1
  182. package/dist/projection/experimental/lazy-projections/omerc.js.map +1 -1
  183. package/dist/projection/experimental/lazy-projections/ortho.cjs +4 -1
  184. package/dist/projection/experimental/lazy-projections/ortho.cjs.map +1 -1
  185. package/dist/projection/experimental/lazy-projections/ortho.d.ts.map +1 -1
  186. package/dist/projection/experimental/lazy-projections/ortho.js +4 -1
  187. package/dist/projection/experimental/lazy-projections/ortho.js.map +1 -1
  188. package/dist/projection/experimental/lazy-projections/poly.cjs +4 -1
  189. package/dist/projection/experimental/lazy-projections/poly.cjs.map +1 -1
  190. package/dist/projection/experimental/lazy-projections/poly.d.ts.map +1 -1
  191. package/dist/projection/experimental/lazy-projections/poly.js +4 -1
  192. package/dist/projection/experimental/lazy-projections/poly.js.map +1 -1
  193. package/dist/projection/experimental/lazy-projections/robin.cjs +4 -1
  194. package/dist/projection/experimental/lazy-projections/robin.cjs.map +1 -1
  195. package/dist/projection/experimental/lazy-projections/robin.d.ts.map +1 -1
  196. package/dist/projection/experimental/lazy-projections/robin.js +4 -1
  197. package/dist/projection/experimental/lazy-projections/robin.js.map +1 -1
  198. package/dist/projection/experimental/lazy-projections/sinu.cjs +4 -1
  199. package/dist/projection/experimental/lazy-projections/sinu.cjs.map +1 -1
  200. package/dist/projection/experimental/lazy-projections/sinu.d.ts.map +1 -1
  201. package/dist/projection/experimental/lazy-projections/sinu.js +4 -1
  202. package/dist/projection/experimental/lazy-projections/sinu.js.map +1 -1
  203. package/dist/projection/experimental/lazy-projections/stere.cjs +4 -1
  204. package/dist/projection/experimental/lazy-projections/stere.cjs.map +1 -1
  205. package/dist/projection/experimental/lazy-projections/stere.d.ts.map +1 -1
  206. package/dist/projection/experimental/lazy-projections/stere.js +4 -1
  207. package/dist/projection/experimental/lazy-projections/stere.js.map +1 -1
  208. package/dist/projection/experimental/lazy-projections/tpers.cjs +4 -1
  209. package/dist/projection/experimental/lazy-projections/tpers.cjs.map +1 -1
  210. package/dist/projection/experimental/lazy-projections/tpers.d.ts.map +1 -1
  211. package/dist/projection/experimental/lazy-projections/tpers.js +4 -1
  212. package/dist/projection/experimental/lazy-projections/tpers.js.map +1 -1
  213. package/dist/projection/experimental/lazy-projections/vandg.cjs +4 -1
  214. package/dist/projection/experimental/lazy-projections/vandg.cjs.map +1 -1
  215. package/dist/projection/experimental/lazy-projections/vandg.d.ts.map +1 -1
  216. package/dist/projection/experimental/lazy-projections/vandg.js +4 -1
  217. package/dist/projection/experimental/lazy-projections/vandg.js.map +1 -1
  218. package/dist/projection/experimental/spatial-deformation.js +1 -1
  219. package/dist/projection/experimental/spatial-deformation.js.map +1 -1
  220. package/dist/projection/index.cjs +8 -4
  221. package/dist/projection/index.cjs.map +1 -1
  222. package/dist/projection/index.d.ts.map +1 -1
  223. package/dist/projection/index.js.map +1 -1
  224. package/dist/projection/lib/projection.js.map +1 -1
  225. package/dist/projection/pipeline.cjs +3 -3
  226. package/dist/projection/pipeline.cjs.map +1 -1
  227. package/dist/projection/temporal.cjs +5 -5
  228. package/dist/projection/temporal.cjs.map +2 -2
  229. package/dist/projection/transform-analysis.cjs +3 -3
  230. package/dist/projection/transform-analysis.cjs.map +1 -1
  231. package/dist/rhumb-path.d.ts +1 -1
  232. package/dist/rhumb-path.d.ts.map +1 -1
  233. package/dist/spatial-planar-intersects.d.ts +4 -0
  234. package/dist/spatial-planar-intersects.d.ts.map +1 -0
  235. package/dist/spatial-planar-intersects.js +108 -0
  236. package/dist/spatial-planar-intersects.js.map +1 -0
  237. package/dist/spatial-planar.d.ts +16 -0
  238. package/dist/spatial-planar.d.ts.map +1 -0
  239. package/dist/spatial-planar.js +240 -0
  240. package/dist/spatial-planar.js.map +1 -0
  241. package/dist/spatial-sql.d.ts +45 -0
  242. package/dist/spatial-sql.d.ts.map +1 -0
  243. package/dist/spatial-sql.js +192 -0
  244. package/dist/spatial-sql.js.map +1 -0
  245. package/dist/st-functions.cjs +1616 -0
  246. package/dist/st-functions.cjs.map +6 -0
  247. package/dist/st-functions.d.ts +307 -0
  248. package/dist/st-functions.d.ts.map +1 -0
  249. package/dist/st-functions.js +593 -0
  250. package/dist/st-functions.js.map +1 -0
  251. package/dist/subdivide-globe-mesh.js +1 -1
  252. package/dist/subdivide-globe-mesh.js.map +1 -1
  253. package/dist/tasks/index.cjs +216 -98
  254. package/dist/tasks/index.cjs.map +2 -2
  255. package/dist/tasks/terrain-residency.d.ts +9 -0
  256. package/dist/tasks/terrain-residency.d.ts.map +1 -1
  257. package/dist/tasks/terrain-residency.js +98 -19
  258. package/dist/tasks/terrain-residency.js.map +1 -1
  259. package/dist/terrain/cutout-polygons.d.ts +21 -0
  260. package/dist/terrain/cutout-polygons.d.ts.map +1 -0
  261. package/dist/terrain/cutout-polygons.js +172 -0
  262. package/dist/terrain/cutout-polygons.js.map +1 -0
  263. package/dist/terrain/cutout-region.d.ts +34 -0
  264. package/dist/terrain/cutout-region.d.ts.map +1 -0
  265. package/dist/terrain/cutout-region.js +33 -0
  266. package/dist/terrain/cutout-region.js.map +1 -0
  267. package/dist/terrain/cutout-skirts.d.ts +34 -0
  268. package/dist/terrain/cutout-skirts.d.ts.map +1 -0
  269. package/dist/terrain/cutout-skirts.js +29 -0
  270. package/dist/terrain/cutout-skirts.js.map +1 -0
  271. package/dist/terrain/depression-fill.d.ts +25 -0
  272. package/dist/terrain/depression-fill.d.ts.map +1 -0
  273. package/dist/terrain/depression-fill.js +106 -0
  274. package/dist/terrain/depression-fill.js.map +1 -0
  275. package/dist/terrain/geographic-cutout.d.ts +38 -0
  276. package/dist/terrain/geographic-cutout.d.ts.map +1 -0
  277. package/dist/terrain/geographic-cutout.js +120 -0
  278. package/dist/terrain/geographic-cutout.js.map +1 -0
  279. package/dist/terrain/geographic-lod-seams.d.ts +10 -0
  280. package/dist/terrain/geographic-lod-seams.d.ts.map +1 -0
  281. package/dist/terrain/geographic-lod-seams.js +100 -0
  282. package/dist/terrain/geographic-lod-seams.js.map +1 -0
  283. package/dist/terrain/geographic-neighbor.d.ts +18 -0
  284. package/dist/terrain/geographic-neighbor.d.ts.map +1 -0
  285. package/dist/terrain/geographic-neighbor.js +44 -0
  286. package/dist/terrain/geographic-neighbor.js.map +1 -0
  287. package/dist/terrain/geographic-poles.d.ts +24 -0
  288. package/dist/terrain/geographic-poles.d.ts.map +1 -0
  289. package/dist/terrain/geographic-poles.js +34 -0
  290. package/dist/terrain/geographic-poles.js.map +1 -0
  291. package/dist/terrain/hydrology.d.ts +42 -0
  292. package/dist/terrain/hydrology.d.ts.map +1 -0
  293. package/dist/terrain/hydrology.js +112 -0
  294. package/dist/terrain/hydrology.js.map +1 -0
  295. package/dist/terrain/index.cjs +2135 -161
  296. package/dist/terrain/index.cjs.map +3 -3
  297. package/dist/terrain/index.d.ts +23 -1
  298. package/dist/terrain/index.d.ts.map +1 -1
  299. package/dist/terrain/index.js +21 -0
  300. package/dist/terrain/index.js.map +1 -1
  301. package/dist/terrain/lod-screen-error.d.ts +28 -0
  302. package/dist/terrain/lod-screen-error.d.ts.map +1 -0
  303. package/dist/terrain/lod-screen-error.js +95 -0
  304. package/dist/terrain/lod-screen-error.js.map +1 -0
  305. package/dist/terrain/lod-select.d.ts +26 -10
  306. package/dist/terrain/lod-select.d.ts.map +1 -1
  307. package/dist/terrain/lod-select.js +27 -14
  308. package/dist/terrain/lod-select.js.map +1 -1
  309. package/dist/terrain/lod-stitch.d.ts +2 -0
  310. package/dist/terrain/lod-stitch.d.ts.map +1 -1
  311. package/dist/terrain/lod-stitch.js +21 -6
  312. package/dist/terrain/lod-stitch.js.map +1 -1
  313. package/dist/terrain/mesh-cutout.d.ts +45 -0
  314. package/dist/terrain/mesh-cutout.d.ts.map +1 -0
  315. package/dist/terrain/mesh-cutout.js +336 -0
  316. package/dist/terrain/mesh-cutout.js.map +1 -0
  317. package/dist/terrain/mesh-skirts.d.ts +8 -2
  318. package/dist/terrain/mesh-skirts.d.ts.map +1 -1
  319. package/dist/terrain/mesh-skirts.js +5 -4
  320. package/dist/terrain/mesh-skirts.js.map +1 -1
  321. package/dist/terrain/mixed-halo-update.d.ts.map +1 -1
  322. package/dist/terrain/mixed-halo-update.js +58 -23
  323. package/dist/terrain/mixed-halo-update.js.map +1 -1
  324. package/dist/terrain/mixed-vertex-halos.d.ts +24 -1
  325. package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -1
  326. package/dist/terrain/mixed-vertex-halos.js +75 -58
  327. package/dist/terrain/mixed-vertex-halos.js.map +1 -1
  328. package/dist/terrain/regional-viewshed.d.ts +55 -0
  329. package/dist/terrain/regional-viewshed.d.ts.map +1 -0
  330. package/dist/terrain/regional-viewshed.js +119 -0
  331. package/dist/terrain/regional-viewshed.js.map +1 -0
  332. package/dist/terrain/surface.d.ts +1 -1
  333. package/dist/terrain/surface.d.ts.map +1 -1
  334. package/dist/terrain/surface.js +1 -1
  335. package/dist/terrain/surface.js.map +1 -1
  336. package/dist/terrain/sweep-capsule.d.ts +27 -0
  337. package/dist/terrain/sweep-capsule.d.ts.map +1 -0
  338. package/dist/terrain/sweep-capsule.js +104 -0
  339. package/dist/terrain/sweep-capsule.js.map +1 -0
  340. package/dist/terrain/sweep-cylinder.d.ts +16 -0
  341. package/dist/terrain/sweep-cylinder.d.ts.map +1 -0
  342. package/dist/terrain/sweep-cylinder.js +52 -0
  343. package/dist/terrain/sweep-cylinder.js.map +1 -0
  344. package/dist/terrain/sweep-plane.d.ts +9 -0
  345. package/dist/terrain/sweep-plane.d.ts.map +1 -0
  346. package/dist/terrain/sweep-plane.js +52 -0
  347. package/dist/terrain/sweep-plane.js.map +1 -0
  348. package/dist/terrain/sweep-polytope.d.ts +42 -0
  349. package/dist/terrain/sweep-polytope.d.ts.map +1 -0
  350. package/dist/terrain/sweep-polytope.js +189 -0
  351. package/dist/terrain/sweep-polytope.js.map +1 -0
  352. package/dist/terrain/sweep-rotating-capsule.d.ts +17 -0
  353. package/dist/terrain/sweep-rotating-capsule.d.ts.map +1 -0
  354. package/dist/terrain/sweep-rotating-capsule.js +118 -0
  355. package/dist/terrain/sweep-rotating-capsule.js.map +1 -0
  356. package/dist/terrain/sweep-rotation.d.ts +35 -0
  357. package/dist/terrain/sweep-rotation.d.ts.map +1 -0
  358. package/dist/terrain/sweep-rotation.js +114 -0
  359. package/dist/terrain/sweep-rotation.js.map +1 -0
  360. package/dist/terrain/sweep-sphere.d.ts +27 -0
  361. package/dist/terrain/sweep-sphere.d.ts.map +1 -0
  362. package/dist/terrain/sweep-sphere.js +69 -0
  363. package/dist/terrain/sweep-sphere.js.map +1 -0
  364. package/dist/terrain/tile-cutout-update.d.ts +73 -0
  365. package/dist/terrain/tile-cutout-update.d.ts.map +1 -0
  366. package/dist/terrain/tile-cutout-update.js +181 -0
  367. package/dist/terrain/tile-cutout-update.js.map +1 -0
  368. package/dist/terrain/tile-cutout.d.ts +33 -0
  369. package/dist/terrain/tile-cutout.d.ts.map +1 -0
  370. package/dist/terrain/tile-cutout.js +93 -0
  371. package/dist/terrain/tile-cutout.js.map +1 -0
  372. package/dist/terrain/watershed-accumulation.d.ts +20 -0
  373. package/dist/terrain/watershed-accumulation.d.ts.map +1 -0
  374. package/dist/terrain/watershed-accumulation.js +53 -0
  375. package/dist/terrain/watershed-accumulation.js.map +1 -0
  376. package/dist/triaxial.d.ts +1 -1
  377. package/dist/triaxial.d.ts.map +1 -1
  378. package/dist/turf-expressions.cjs +1997 -0
  379. package/dist/turf-expressions.cjs.map +6 -0
  380. package/dist/turf-expressions.d.ts +3 -0
  381. package/dist/turf-expressions.d.ts.map +1 -0
  382. package/dist/turf-expressions.js +7 -0
  383. package/dist/turf-expressions.js.map +1 -0
  384. package/dist/turf-functions.cjs +743 -0
  385. package/dist/turf-functions.cjs.map +6 -0
  386. package/dist/turf-functions.d.ts +90 -0
  387. package/dist/turf-functions.d.ts.map +1 -0
  388. package/dist/{turf/expressions.js → turf-functions.js} +51 -5
  389. package/dist/turf-functions.js.map +1 -0
  390. package/dist/turf.cjs +25 -25
  391. package/dist/turf.cjs.map +2 -2
  392. package/dist/turf.d.ts +1 -1
  393. package/dist/turf.d.ts.map +1 -1
  394. package/dist/turf.js +2 -2
  395. package/dist/turf.js.map +1 -1
  396. package/dist/type-utils.d.ts +1 -1
  397. package/dist/type-utils.d.ts.map +1 -1
  398. package/dist/type-utils.js +1 -1
  399. package/dist/type-utils.js.map +1 -1
  400. package/dist/web-mercator/assert.d.ts +2 -0
  401. package/dist/web-mercator/assert.d.ts.map +1 -0
  402. package/dist/web-mercator/assert.js +12 -0
  403. package/dist/web-mercator/assert.js.map +1 -0
  404. package/dist/web-mercator/fit-bounds.d.ts +52 -0
  405. package/dist/web-mercator/fit-bounds.d.ts.map +1 -0
  406. package/dist/web-mercator/fit-bounds.js +70 -0
  407. package/dist/web-mercator/fit-bounds.js.map +1 -0
  408. package/dist/web-mercator/fly-to-viewport.d.ts +19 -0
  409. package/dist/web-mercator/fly-to-viewport.d.ts.map +1 -0
  410. package/dist/web-mercator/fly-to-viewport.js +94 -0
  411. package/dist/web-mercator/fly-to-viewport.js.map +1 -0
  412. package/dist/web-mercator/get-bounds.d.ts +3 -0
  413. package/dist/web-mercator/get-bounds.d.ts.map +1 -0
  414. package/dist/web-mercator/get-bounds.js +56 -0
  415. package/dist/web-mercator/get-bounds.js.map +1 -0
  416. package/dist/web-mercator/index.cjs +705 -0
  417. package/dist/web-mercator/index.cjs.map +6 -0
  418. package/dist/web-mercator/index.d.ts +14 -0
  419. package/dist/web-mercator/index.d.ts.map +1 -0
  420. package/dist/web-mercator/index.js +14 -0
  421. package/dist/web-mercator/index.js.map +1 -0
  422. package/dist/web-mercator/math-utils.d.ts +7 -0
  423. package/dist/web-mercator/math-utils.d.ts.map +1 -0
  424. package/dist/web-mercator/math-utils.js +30 -0
  425. package/dist/web-mercator/math-utils.js.map +1 -0
  426. package/dist/web-mercator/mercator-meters.d.ts +29 -0
  427. package/dist/web-mercator/mercator-meters.d.ts.map +1 -0
  428. package/dist/web-mercator/mercator-meters.js +61 -0
  429. package/dist/web-mercator/mercator-meters.js.map +1 -0
  430. package/dist/web-mercator/normalize-viewport-props.d.ts +16 -0
  431. package/dist/web-mercator/normalize-viewport-props.d.ts.map +1 -0
  432. package/dist/web-mercator/normalize-viewport-props.js +45 -0
  433. package/dist/web-mercator/normalize-viewport-props.js.map +1 -0
  434. package/dist/web-mercator/web-mercator-utils.d.ts +192 -0
  435. package/dist/web-mercator/web-mercator-utils.d.ts.map +1 -0
  436. package/dist/web-mercator/web-mercator-utils.js +321 -0
  437. package/dist/web-mercator/web-mercator-utils.js.map +1 -0
  438. package/dist/web-mercator/web-mercator-viewport.d.ts +177 -0
  439. package/dist/web-mercator/web-mercator-viewport.d.ts.map +1 -0
  440. package/dist/web-mercator/web-mercator-viewport.js +276 -0
  441. package/dist/web-mercator/web-mercator-viewport.js.map +1 -0
  442. package/dist/web-mercator.d.ts +1 -1
  443. package/dist/web-mercator.d.ts.map +1 -1
  444. package/dist/web-mercator.js +1 -1
  445. package/dist/web-mercator.js.map +1 -1
  446. package/package.json +34 -462
  447. package/src/crs/crs-descriptor-types.ts +2 -1
  448. package/src/crs/index.ts +7 -0
  449. package/src/crs/spatial-reference-metadata.ts +118 -0
  450. package/src/ellipsoid-helpers/ellipsoid-transform.ts +3 -3
  451. package/src/ellipsoid-helpers/scale-to-geodetic-surface.ts +1 -1
  452. package/src/ellipsoid-helpers/tangent-plane-numerics.ts +1 -1
  453. package/src/ellipsoid-tangent-plane.ts +2 -2
  454. package/src/ellipsoid-transforms.ts +2 -2
  455. package/src/ellipsoid.ts +7 -3
  456. package/src/expressions.ts +2 -2
  457. package/src/geodesic-buffer.ts +1 -1
  458. package/src/geodesic-path.ts +1 -1
  459. package/src/geometry-constructors.ts +36 -0
  460. package/src/geometry-inspection.ts +66 -0
  461. package/src/index.ts +271 -4
  462. package/src/line-simplification.ts +97 -0
  463. package/src/linear-referencing.ts +94 -0
  464. package/src/lng-lat-rectangle.ts +1 -1
  465. package/src/local-reference-frame.ts +4 -4
  466. package/src/make-obb-from-region.ts +9 -1
  467. package/src/maps/air-ocean-mesh.ts +1 -1
  468. package/src/maps/myriahedral/unfold.ts +1 -1
  469. package/src/projection/experimental/crs/spatial-reference.ts +1 -6
  470. package/src/projection/experimental/crs/types.ts +2 -2
  471. package/src/projection/experimental/crs/wkt.ts +1 -1
  472. package/src/projection/experimental/crs-descriptor.ts +1 -1
  473. package/src/projection/experimental/crs-rendering-scale.ts +16 -4
  474. package/src/projection/experimental/datum.ts +1 -1
  475. package/src/projection/experimental/lazy-projections/aea.ts +4 -1
  476. package/src/projection/experimental/lazy-projections/bonne.ts +4 -1
  477. package/src/projection/experimental/lazy-projections/cass.ts +4 -1
  478. package/src/projection/experimental/lazy-projections/eck6.ts +4 -1
  479. package/src/projection/experimental/lazy-projections/eqdc.ts +4 -1
  480. package/src/projection/experimental/lazy-projections/eqearth.ts +4 -1
  481. package/src/projection/experimental/lazy-projections/equi.ts +4 -1
  482. package/src/projection/experimental/lazy-projections/geocent.ts +4 -1
  483. package/src/projection/experimental/lazy-projections/geos.ts +4 -1
  484. package/src/projection/experimental/lazy-projections/gnom.ts +4 -1
  485. package/src/projection/experimental/lazy-projections/krovak.ts +4 -1
  486. package/src/projection/experimental/lazy-projections/merc.ts +4 -1
  487. package/src/projection/experimental/lazy-projections/mill.ts +4 -1
  488. package/src/projection/experimental/lazy-projections/moll.ts +4 -1
  489. package/src/projection/experimental/lazy-projections/nzmg.ts +4 -1
  490. package/src/projection/experimental/lazy-projections/omerc.ts +4 -1
  491. package/src/projection/experimental/lazy-projections/ortho.ts +4 -1
  492. package/src/projection/experimental/lazy-projections/poly.ts +4 -1
  493. package/src/projection/experimental/lazy-projections/robin.ts +4 -1
  494. package/src/projection/experimental/lazy-projections/sinu.ts +4 -1
  495. package/src/projection/experimental/lazy-projections/stere.ts +4 -1
  496. package/src/projection/experimental/lazy-projections/tpers.ts +4 -1
  497. package/src/projection/experimental/lazy-projections/vandg.ts +4 -1
  498. package/src/projection/experimental/spatial-deformation.ts +1 -1
  499. package/src/projection/index.ts +1 -1
  500. package/src/projection/lib/projection.ts +1 -1
  501. package/src/rhumb-path.ts +1 -1
  502. package/src/spatial-planar-intersects.ts +134 -0
  503. package/src/spatial-planar.ts +266 -0
  504. package/src/spatial-sql.ts +276 -0
  505. package/src/st-functions.ts +852 -0
  506. package/src/subdivide-globe-mesh.ts +1 -1
  507. package/src/tasks/terrain-residency.ts +120 -24
  508. package/src/terrain/cutout-polygons.ts +202 -0
  509. package/src/terrain/cutout-region.ts +54 -0
  510. package/src/terrain/cutout-skirts.ts +52 -0
  511. package/src/terrain/depression-fill.ts +125 -0
  512. package/src/terrain/geographic-cutout.ts +154 -0
  513. package/src/terrain/geographic-lod-seams.ts +109 -0
  514. package/src/terrain/geographic-neighbor.ts +58 -0
  515. package/src/terrain/geographic-poles.ts +52 -0
  516. package/src/terrain/hydrology.ts +149 -0
  517. package/src/terrain/index.ts +122 -1
  518. package/src/terrain/lod-screen-error.ts +128 -0
  519. package/src/terrain/lod-select.ts +65 -31
  520. package/src/terrain/lod-stitch.ts +25 -7
  521. package/src/terrain/mesh-cutout.ts +420 -0
  522. package/src/terrain/mesh-skirts.ts +10 -7
  523. package/src/terrain/mixed-halo-update.ts +54 -20
  524. package/src/terrain/mixed-vertex-halos.ts +94 -78
  525. package/src/terrain/regional-viewshed.ts +177 -0
  526. package/src/terrain/surface.ts +1 -1
  527. package/src/terrain/sweep-capsule.ts +148 -0
  528. package/src/terrain/sweep-cylinder.ts +64 -0
  529. package/src/terrain/sweep-plane.ts +61 -0
  530. package/src/terrain/sweep-polytope.ts +253 -0
  531. package/src/terrain/sweep-rotating-capsule.ts +139 -0
  532. package/src/terrain/sweep-rotation.ts +149 -0
  533. package/src/terrain/sweep-sphere.ts +100 -0
  534. package/src/terrain/tile-cutout-update.ts +293 -0
  535. package/src/terrain/tile-cutout.ts +123 -0
  536. package/src/terrain/watershed-accumulation.ts +67 -0
  537. package/src/triaxial.ts +1 -1
  538. package/src/turf-expressions.ts +7 -0
  539. package/src/{turf/expressions.ts → turf-functions.ts} +121 -6
  540. package/src/turf.ts +3 -7
  541. package/src/type-utils.ts +2 -2
  542. package/src/web-mercator/assert.ts +11 -0
  543. package/src/web-mercator/fit-bounds.ts +132 -0
  544. package/src/web-mercator/fly-to-viewport.ts +157 -0
  545. package/src/web-mercator/get-bounds.ts +62 -0
  546. package/src/web-mercator/index.ts +49 -0
  547. package/src/web-mercator/math-utils.ts +35 -0
  548. package/src/web-mercator/mercator-meters.ts +83 -0
  549. package/src/web-mercator/normalize-viewport-props.ts +58 -0
  550. package/src/web-mercator/web-mercator-utils.ts +468 -0
  551. package/src/web-mercator/web-mercator-viewport.ts +406 -0
  552. package/src/web-mercator.ts +1 -1
  553. package/dist/projection/experimental/index.cjs +0 -11707
  554. package/dist/projection/experimental/index.cjs.map +0 -6
  555. package/dist/turf/expressions.cjs +0 -87
  556. package/dist/turf/expressions.cjs.map +0 -6
  557. package/dist/turf/expressions.d.ts +0 -24
  558. package/dist/turf/expressions.d.ts.map +0 -1
  559. package/dist/turf/expressions.js.map +0 -1
@@ -0,0 +1,852 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {
6
+ Binary,
7
+ Bool,
8
+ DataType,
9
+ Field,
10
+ FixedSizeList,
11
+ Float64,
12
+ Int32,
13
+ Utf8,
14
+ vectorFromArray
15
+ } from 'apache-arrow';
16
+ import type {AggregateFunction, ArrowTableFunction, ScalarFunction} from '@math.gl/sql/arrow';
17
+ import {
18
+ getGeoArrowFieldInfo,
19
+ getGeoArrowBounds,
20
+ getGeoArrowRowBounds,
21
+ getGeoArrowColumnView,
22
+ materializeGeoArrowRows,
23
+ visitGeoArrowCoordinates,
24
+ makeGeoArrowColumnFromArrowVector,
25
+ writeWKB,
26
+ type WellKnownGeometry
27
+ } from '@math.gl/core/arrow';
28
+ import {planarIntersects} from './spatial-planar-intersects';
29
+ import {lineLocatePoint, lineSubstring} from './linear-referencing';
30
+ import {normalizeCRSIdentifier} from './crs/crs-identifier';
31
+ import {EPSG3857ToLngLat, EPSG4326ToEPSG3857} from './web-mercator/mercator-meters';
32
+ import {vertexCount, memberCount, geometryMember} from './geometry-inspection';
33
+ import {reduceLineVertices} from './line-simplification';
34
+ import {collectPair, makeLine} from './geometry-constructors';
35
+ import {EPSG3857_HALF_CIRCUMFERENCE} from './web-mercator/mercator-meters';
36
+ import {
37
+ planarArea,
38
+ planarBounds,
39
+ planarCentroid,
40
+ planarEnvelope,
41
+ envelopeFromBounds,
42
+ planarLength,
43
+ planarPolygonPointOnSurface
44
+ } from './spatial-planar';
45
+
46
+ import {
47
+ EXTENSION_METADATA,
48
+ EXTENSION_NAME,
49
+ geometryTypes,
50
+ lineKinds,
51
+ planarGeometry,
52
+ pointCoordinates,
53
+ pointInPolygon,
54
+ pointKinds,
55
+ polygonKinds,
56
+ readActiveGeoArrowColumn,
57
+ readGeometryValue,
58
+ spatialFunction
59
+ } from './spatial-sql';
60
+
61
+ /** Constructs XY, XYZ, or XYZM points from numeric ordinates. */
62
+ export const ST_MAKEPOINT: ScalarFunction = {
63
+ kind: 'scalar',
64
+ name: 'ST_MakePoint',
65
+ prototypes: [],
66
+ /** Binds two to four numeric ordinate fields and declares a WKB result. */
67
+ resolvePrototype(fields) {
68
+ if (fields.length < 2 || fields.length > 4) return undefined;
69
+ const arguments_ = fields.map(field => {
70
+ if (field && !DataType.isInt(field.type) && !DataType.isFloat(field.type))
71
+ throw new Error('ST_MakePoint requires numeric coordinates');
72
+ return field ?? new Field('coordinate', new Float64(), true);
73
+ });
74
+ const type = new Binary();
75
+ return {
76
+ arguments: arguments_,
77
+ result: new Field('ST_MakePoint', type, true, new Map([[EXTENSION_NAME, 'geoarrow.wkb']])),
78
+ /** Writes one point per active row, retaining nulls in all other rows. */
79
+ evaluate(vectors, {activeRows, length}) {
80
+ const values = new Array<Uint8Array | null>(length).fill(null);
81
+ for (let row = 0; row < length; row++) {
82
+ if (activeRows[row]) {
83
+ const coordinates = vectors.map(vector => Number(vector.get(row)));
84
+ values[row] = writeWKB({type: 'Point', coordinates});
85
+ }
86
+ }
87
+ return vectorFromArray(values, type);
88
+ }
89
+ };
90
+ }
91
+ };
92
+
93
+ /** Computes a closed XYZ tile polygon, clipping a fractional margin to the root extent. */
94
+ function tileEnvelope(
95
+ zoom: number,
96
+ x: number,
97
+ y: number,
98
+ bounds: readonly number[],
99
+ margin: number
100
+ ): Uint8Array {
101
+ if (!Number.isInteger(zoom) || zoom < 0 || zoom > 31)
102
+ throw new Error('ST_TileEnvelope zoom must be an integer in [0,31]');
103
+ const count = 2 ** zoom;
104
+ if (![x, y].every(index => Number.isInteger(index) && index >= 0 && index < count))
105
+ throw new Error('ST_TileEnvelope tile index outside zoom level');
106
+ if (!Number.isFinite(margin) || margin < -0.5) throw new Error('Invalid ST_TileEnvelope margin');
107
+ const [west, south, east, north] = bounds as [number, number, number, number];
108
+ const width = (east - west) / count,
109
+ height = (north - south) / count;
110
+ if (!(width > 0 && height > 0 && Number.isFinite(width) && Number.isFinite(height)))
111
+ throw new Error('ST_TileEnvelope requires nondegenerate bounds');
112
+ const fullWidth = 1 + 2 * margin > count;
113
+ const left = fullWidth ? west : Math.max(west, west + (x - margin) * width);
114
+ const right = fullWidth ? east : Math.min(east, west + (x + 1 + margin) * width);
115
+ const bottom = Math.max(south, north - (y + 1 + margin) * height);
116
+ const top = Math.min(north, north - (y - margin) * height);
117
+ return writeWKB(
118
+ {
119
+ type: 'Polygon',
120
+ coordinates: [
121
+ [
122
+ [left, bottom],
123
+ [left, top],
124
+ [right, top],
125
+ [right, bottom],
126
+ [left, bottom]
127
+ ]
128
+ ]
129
+ },
130
+ 'xy'
131
+ );
132
+ }
133
+
134
+ /** Constructs an XYZ tile polygon in Web Mercator or a supplied root geometry's CRS. */
135
+ export const ST_TILEENVELOPE: ScalarFunction = {
136
+ kind: 'scalar',
137
+ name: 'ST_TileEnvelope',
138
+ prototypes: [],
139
+ /** Binds numeric tile indices and the optional GeoArrow root extent. */
140
+ resolvePrototype(fields) {
141
+ if (fields.length < 3 || fields.length > 5) return undefined;
142
+ const custom = fields.length >= 4;
143
+ const root = fields[3];
144
+ if (custom) ST_ENVELOPE.resolvePrototype!([root]);
145
+ const args = fields.map((field, i) => {
146
+ if (i === 3) return field ?? new Field('bounds', new Binary(), true);
147
+ if (field && !DataType.isInt(field.type) && !DataType.isFloat(field.type))
148
+ throw new Error('ST_TileEnvelope requires numeric indices and margin');
149
+ return field ?? new Field('number', new Float64(), true);
150
+ });
151
+ const metadata = new Map([[EXTENSION_NAME, 'geoarrow.wkb']]);
152
+ const crs = custom
153
+ ? root?.metadata.get(EXTENSION_METADATA)
154
+ : '{"crs_type":"authority_code","crs":"EPSG:3857"}';
155
+ if (crs) metadata.set(EXTENSION_METADATA, crs);
156
+ const type = new Binary();
157
+ const r = EPSG3857_HALF_CIRCUMFERENCE;
158
+ const world = [-r, -r, r, r];
159
+ return {
160
+ arguments: args,
161
+ result: new Field('ST_TileEnvelope', type, true, metadata),
162
+ /** Computes bounds for active rows using the top-left XYZ origin. */
163
+ evaluate(vectors, {activeRows, length}) {
164
+ const values = new Array<Uint8Array | null>(length).fill(null);
165
+ const read = root
166
+ ? readGeometryValue(vectors[3]!, root, activeRows, planarGeometry)
167
+ : undefined;
168
+ for (let row = 0; row < length; row++) {
169
+ if (!activeRows[row]) continue;
170
+ const bounds = read ? planarBounds(read(row)) : world;
171
+ if (!bounds) throw new Error('ST_TileEnvelope requires nonempty bounds');
172
+ values[row] = tileEnvelope(
173
+ Number(vectors[0]!.get(row)),
174
+ Number(vectors[1]!.get(row)),
175
+ Number(vectors[2]!.get(row)),
176
+ bounds,
177
+ vectors[4] ? Number(vectors[4].get(row)) : 0
178
+ );
179
+ }
180
+ return vectorFromArray(values, type);
181
+ }
182
+ };
183
+ }
184
+ };
185
+
186
+ /** Binds a point accessor while preserving the semantic distinction between Z and M. */
187
+ function pointOrdinate(ordinate: 'x' | 'y' | 'z' | 'm'): ScalarFunction {
188
+ const name = 'ST_' + ordinate.toUpperCase();
189
+ return {
190
+ kind: 'scalar',
191
+ name,
192
+ prototypes: [],
193
+ /** Accepts native Points or WKB whose geometry kind is checked per active row. */
194
+ resolvePrototype(fields) {
195
+ if (fields.length !== 1) return undefined;
196
+ const field =
197
+ fields[0] ??
198
+ new Field('point', new Binary(), true, new Map([[EXTENSION_NAME, 'geoarrow.wkb']]));
199
+ const extension = getGeoArrowFieldInfo(field);
200
+ if (extension?.metadata['edges'] === 'spherical')
201
+ throw new Error(`${name} requires planar geometry`);
202
+ const encoding = extension?.encoding;
203
+ if (
204
+ encoding !== 'geoarrow.point' &&
205
+ !(
206
+ encoding === 'geoarrow.wkb' &&
207
+ (DataType.isBinary(field.type) || DataType.isLargeBinary(field.type))
208
+ )
209
+ )
210
+ throw new Error(`${name} requires a GeoArrow Point`);
211
+ const type = new Float64();
212
+ return {
213
+ arguments: [field],
214
+ result: new Field(name, type, true),
215
+ /** Extracts ordinates using the WKB row or native field dimension. */
216
+ evaluate([vector], {length, activeRows}) {
217
+ if (encoding === 'geoarrow.point') {
218
+ const column = readActiveGeoArrowColumn(vector!, field, activeRows);
219
+ const result = new Array<number | null>(length).fill(null);
220
+ const index = column.dimension.indexOf(ordinate);
221
+ if (index >= 0) {
222
+ visitGeoArrowCoordinates(column, (coordinate, row) => {
223
+ if (Number.isFinite(coordinate[0]) && Number.isFinite(coordinate[1])) {
224
+ result[row] = coordinate[index] ?? null;
225
+ }
226
+ return coordinate;
227
+ });
228
+ }
229
+ return vectorFromArray(result, type);
230
+ }
231
+ const read = readGeometryValue(vector!, field, activeRows, (geometry, dimension) => {
232
+ if (geometry.type !== 'Point') throw new Error(`${name} requires a Point`);
233
+ return pointCoordinates(geometry)?.[dimension.indexOf(ordinate)] ?? null;
234
+ });
235
+ return vectorFromArray(
236
+ Array.from({length}, (_, i) => (activeRows[i] ? read(i) : null)),
237
+ type
238
+ );
239
+ }
240
+ };
241
+ }
242
+ };
243
+ }
244
+
245
+ /** X coordinate of a point. */
246
+ export const ST_X = /* @__PURE__ */ pointOrdinate('x');
247
+ /** Y coordinate of a point. */
248
+ export const ST_Y = /* @__PURE__ */ pointOrdinate('y');
249
+ /** Elevation of a point with a Z ordinate. */
250
+ export const ST_Z = /* @__PURE__ */ pointOrdinate('z');
251
+ /** Measure of a point with an M ordinate. */
252
+ export const ST_M = /* @__PURE__ */ pointOrdinate('m');
253
+
254
+ /** First vertex for the supported 2D geometry signature. */
255
+ export const ST_STARTPOINT = /* @__PURE__ */ spatialFunction(
256
+ 'ST_StartPoint',
257
+ [['LineString']],
258
+ /* @__PURE__ */ new Binary(),
259
+ ([line]) => {
260
+ if (line?.type !== 'LineString' || !line.coordinates.length) return null;
261
+ return writeWKB({type: 'Point', coordinates: line.coordinates[0]!}, 'xy');
262
+ }
263
+ );
264
+
265
+ /** Last vertex for the supported 2D geometry signature. */
266
+ export const ST_ENDPOINT = /* @__PURE__ */ spatialFunction(
267
+ 'ST_EndPoint',
268
+ [['LineString']],
269
+ /* @__PURE__ */ new Binary(),
270
+ ([line]) => {
271
+ if (line?.type !== 'LineString' || !line.coordinates.length) return null;
272
+ return writeWKB(
273
+ {type: 'Point', coordinates: line.coordinates[line.coordinates.length - 1]!},
274
+ 'xy'
275
+ );
276
+ }
277
+ );
278
+
279
+ /** Tests whether a point is in a polygon's interior. */
280
+ export const ST_CONTAINS = /* @__PURE__ */ spatialFunction(
281
+ 'ST_Contains',
282
+ [polygonKinds, pointKinds],
283
+ /* @__PURE__ */ new Bool(),
284
+ ([polygon, point]) => pointInPolygon(point!, polygon!, true) ?? false
285
+ );
286
+
287
+ /** Tests whether a point is in a polygon's interior or boundary. */
288
+ export const ST_COVERS = /* @__PURE__ */ spatialFunction(
289
+ 'ST_Covers',
290
+ [polygonKinds, pointKinds],
291
+ /* @__PURE__ */ new Bool(),
292
+ ([polygon, point]) => pointInPolygon(point!, polygon!) ?? false
293
+ );
294
+
295
+ /** Interior only for the supported 2D geometry signature. */
296
+ export const ST_WITHIN = /* @__PURE__ */ spatialFunction(
297
+ 'ST_Within',
298
+ [pointKinds, polygonKinds],
299
+ /* @__PURE__ */ new Bool(),
300
+ ([p, polygon]) => pointInPolygon(p!, polygon!, true) ?? false
301
+ );
302
+
303
+ /** Interior or boundary for the supported 2D geometry signature. */
304
+ export const ST_COVEREDBY = /* @__PURE__ */ spatialFunction(
305
+ 'ST_CoveredBy',
306
+ [pointKinds, polygonKinds],
307
+ /* @__PURE__ */ new Bool(),
308
+ ([p, polygon]) => pointInPolygon(p!, polygon!) ?? false
309
+ );
310
+
311
+ /** Returns a LineString vertex by signed one-based position. */
312
+ export const ST_POINTN = /* @__PURE__ */ spatialFunction(
313
+ 'ST_PointN',
314
+ [['LineString']],
315
+ /* @__PURE__ */ new Binary(),
316
+ ([line], position) => {
317
+ if (!Number.isInteger(position)) throw new Error('ST_PointN requires an integer position');
318
+ if (line?.type !== 'LineString' || !position) return null;
319
+ const index = position > 0 ? position - 1 : line.coordinates.length + position;
320
+ const coordinates = line.coordinates[index];
321
+ return coordinates ? writeWKB({type: 'Point', coordinates}, 'xy') : null;
322
+ },
323
+ 1
324
+ );
325
+
326
+ /** Constructs a closed rectangular polygon in an unspecified coordinate system. */
327
+ export const ST_MAKEENVELOPE = /* @__PURE__ */ spatialFunction(
328
+ 'ST_MakeEnvelope',
329
+ [],
330
+ /* @__PURE__ */ new Binary(),
331
+ (_, xmin, ymin, xmax, ymax) =>
332
+ writeWKB(
333
+ {
334
+ type: 'Polygon',
335
+ coordinates: [
336
+ [
337
+ [xmin, ymin],
338
+ [xmin, ymax],
339
+ [xmax, ymax],
340
+ [xmax, ymin],
341
+ [xmin, ymin]
342
+ ]
343
+ ]
344
+ },
345
+ 'xy'
346
+ ),
347
+ 4
348
+ );
349
+
350
+ /** Returns 2D Cartesian point-to-point distance in coordinate units. */
351
+ export const ST_DISTANCE = /* @__PURE__ */ spatialFunction(
352
+ 'ST_Distance',
353
+ [pointKinds, pointKinds],
354
+ /* @__PURE__ */ new Float64(),
355
+ ([a, b]) => {
356
+ const p = pointCoordinates(a!);
357
+ const q = pointCoordinates(b!);
358
+ return p && q ? Math.hypot(q[0]! - p[0]!, q[1]! - p[1]!) : null;
359
+ }
360
+ );
361
+
362
+ /** Tests an inclusive planar radius in the coordinate units of two points. */
363
+ export const ST_DWITHIN = /* @__PURE__ */ spatialFunction(
364
+ 'ST_DWithin',
365
+ [pointKinds, pointKinds],
366
+ /* @__PURE__ */ new Bool(),
367
+ ([a, b], radius) => {
368
+ if (radius! < 0) throw new Error('ST_DWithin distance must be nonnegative');
369
+ const p = pointCoordinates(a!);
370
+ const q = pointCoordinates(b!);
371
+ return Boolean(p && q && Math.hypot(q[0]! - p[0]!, q[1]! - p[1]!) <= radius!);
372
+ },
373
+ 1
374
+ );
375
+
376
+ /** Tests whether two planar geometries share any point, including their boundaries. */
377
+ export const ST_INTERSECTS = /* @__PURE__ */ spatialFunction(
378
+ 'ST_Intersects',
379
+ [
380
+ [...geometryTypes, 'GeometryCollection'],
381
+ [...geometryTypes, 'GeometryCollection']
382
+ ],
383
+ /* @__PURE__ */ new Bool(),
384
+ ([a, b]) => planarIntersects(a!, b!)
385
+ );
386
+
387
+ /** Interpolates a point at a fraction of the planar length. */
388
+ export const ST_LINEINTERPOLATEPOINT = /* @__PURE__ */ spatialFunction(
389
+ 'ST_LineInterpolatePoint',
390
+ [['LineString']],
391
+ /* @__PURE__ */ new Binary(),
392
+ ([line], fraction) =>
393
+ writeWKB(lineSubstring(line!, fraction!, fraction!) ?? {type: 'Point', coordinates: []}, 'xy'),
394
+ 1
395
+ );
396
+
397
+ /** Locates the closest point along a route, measured as a fraction of total length. */
398
+ export const ST_LINELOCATEPOINT = /* @__PURE__ */ spatialFunction(
399
+ 'ST_LineLocatePoint',
400
+ [['LineString'], pointKinds],
401
+ /* @__PURE__ */ new Float64(),
402
+ ([line, point]) => lineLocatePoint(line!, point!)
403
+ );
404
+
405
+ /** Extracts a route section between two inclusive fractions of the planar length. */
406
+ export const ST_LINESUBSTRING = /* @__PURE__ */ spatialFunction(
407
+ 'ST_LineSubstring',
408
+ [['LineString']],
409
+ /* @__PURE__ */ new Binary(),
410
+ ([line], start, end) => {
411
+ const result = lineSubstring(line!, start!, end!);
412
+ return result ? writeWKB(result, 'xy') : null;
413
+ },
414
+ 2
415
+ );
416
+
417
+ /** Extracts an EPSG code from a GeoArrow authority identifier or a PROJJSON root ID. */
418
+ function geometrySRID(crs: unknown): number {
419
+ let identifier = typeof crs === 'string' ? normalizeCRSIdentifier(crs) : '';
420
+ if (crs && typeof crs === 'object' && 'id' in crs) {
421
+ const id = crs.id;
422
+ if (
423
+ id &&
424
+ typeof id === 'object' &&
425
+ 'authority' in id &&
426
+ 'code' in id &&
427
+ id.authority === 'EPSG'
428
+ )
429
+ identifier = 'EPSG:' + String(id.code);
430
+ }
431
+ return /^EPSG:\d+$/.test(identifier) ? Number(identifier.slice(5)) : 0;
432
+ }
433
+
434
+ /** Applies a planar coordinate conversion throughout a multipart or collection geometry. */
435
+ function projectGeometry(
436
+ geometry: WellKnownGeometry,
437
+ project: (p: readonly number[]) => number[]
438
+ ): WellKnownGeometry {
439
+ const path = (points: readonly (readonly number[])[]) => points.map(project);
440
+ switch (geometry.type) {
441
+ case 'Point':
442
+ return {
443
+ type: 'Point',
444
+ coordinates:
445
+ geometry.coordinates.length && !geometry.coordinates.every(Number.isNaN)
446
+ ? project(geometry.coordinates)
447
+ : []
448
+ };
449
+ case 'MultiPoint':
450
+ return {
451
+ type: 'MultiPoint',
452
+ coordinates: geometry.coordinates.map(p =>
453
+ !p.length || p.every(Number.isNaN) ? p : project(p)
454
+ )
455
+ };
456
+ case 'LineString':
457
+ return {type: 'LineString', coordinates: path(geometry.coordinates)};
458
+ case 'MultiLineString':
459
+ case 'Polygon':
460
+ return {type: geometry.type, coordinates: geometry.coordinates.map(path)};
461
+ case 'MultiPolygon':
462
+ return {type: 'MultiPolygon', coordinates: geometry.coordinates.map(poly => poly.map(path))};
463
+ case 'GeometryCollection':
464
+ return {
465
+ type: 'GeometryCollection',
466
+ geometries: geometry.geometries.map(child => projectGeometry(child, project))
467
+ };
468
+ }
469
+ }
470
+
471
+ /** Binds a single output CRS for the entire Arrow field, including empty batches. */
472
+ function crsFunction(name: 'ST_SRID' | 'ST_SetSRID' | 'ST_Transform'): ScalarFunction {
473
+ const read = name === 'ST_SRID';
474
+ return {
475
+ kind: 'scalar',
476
+ name,
477
+ prototypes: [],
478
+ /** Resolves the source from field metadata and the target from the SQL literal. */
479
+ resolvePrototype(fields, literals) {
480
+ if (fields.length !== (read ? 1 : 2)) return undefined;
481
+ const metadata = fields[0] && getGeoArrowFieldInfo(fields[0])?.metadata;
482
+ const source = geometrySRID(metadata?.['crs']);
483
+ const target = literals?.[1] ?? 0;
484
+ if (
485
+ !read &&
486
+ (literals?.[1] === undefined ||
487
+ !Number.isSafeInteger(target) ||
488
+ target < 0 ||
489
+ target > 998999)
490
+ )
491
+ throw new Error(name + ' requires a constant integer SRID between 0 and 998999');
492
+ if (
493
+ name === 'ST_Transform' &&
494
+ (![4326, 3857].includes(source) || ![4326, 3857].includes(target))
495
+ )
496
+ throw new Error('ST_Transform supports EPSG:4326 and EPSG:3857 source and target CRS');
497
+ const implementation = spatialFunction(
498
+ name,
499
+ [[...geometryTypes, 'GeometryCollection']],
500
+ read ? new Int32() : new Binary(),
501
+ ([geometry]) => {
502
+ if (read) return source;
503
+ const output =
504
+ name === 'ST_Transform' && source !== target
505
+ ? projectGeometry(geometry!, p =>
506
+ target === 3857
507
+ ? EPSG4326ToEPSG3857([...p], {clampLatitude: false})
508
+ : EPSG3857ToLngLat([...p])
509
+ )
510
+ : geometry!;
511
+ return writeWKB(output, 'xy');
512
+ },
513
+ read ? 0 : 1
514
+ ).resolvePrototype!(fields)!;
515
+ if (!read) {
516
+ const crsMetadata = {...metadata};
517
+ delete crsMetadata['crs_type'];
518
+ delete crsMetadata['crs'];
519
+ if (target) Object.assign(crsMetadata, {crs_type: 'authority_code', crs: 'EPSG:' + target});
520
+ implementation.result.metadata.set(EXTENSION_METADATA, JSON.stringify(crsMetadata));
521
+ }
522
+ return implementation;
523
+ }
524
+ };
525
+ }
526
+
527
+ /** Returns the field EPSG code, or zero for an unidentified CRS. */
528
+ export const ST_SRID = /* @__PURE__ */ crsFunction('ST_SRID');
529
+ /** Assigns a CRS to a geometry column, preserving its coordinate values. */
530
+ export const ST_SETSRID = /* @__PURE__ */ crsFunction('ST_SetSRID');
531
+ /** Reprojects a planar geometry column between geographic and Web Mercator coordinates. */
532
+ export const ST_TRANSFORM = /* @__PURE__ */ crsFunction('ST_Transform');
533
+
534
+ /** Declares a geometry-valued line reduction with an optional default tolerance. */
535
+ function lineReduction(name: string, mode: 'simplify' | 'removeRepeated'): ScalarFunction {
536
+ return {
537
+ kind: 'scalar',
538
+ name,
539
+ prototypes: [],
540
+ /** Binds the geometry and any supplied numeric tolerance. */
541
+ resolvePrototype(fields) {
542
+ const numericArguments = mode === 'removeRepeated' && fields.length === 1 ? 0 : 1;
543
+ return spatialFunction(
544
+ name,
545
+ [lineKinds],
546
+ new Binary(),
547
+ ([line], tolerance = 0) => {
548
+ const result = reduceLineVertices(line!, tolerance, mode);
549
+ return result ? writeWKB(result, 'xy') : null;
550
+ },
551
+ numericArguments
552
+ ).resolvePrototype!(fields);
553
+ }
554
+ };
555
+ }
556
+
557
+ /** Removes consecutive duplicate or nearby vertices. */
558
+ export const ST_REMOVEREPEATEDPOINTS = /* @__PURE__ */ lineReduction(
559
+ 'ST_RemoveRepeatedPoints',
560
+ 'removeRepeated'
561
+ );
562
+ /** Reduces route vertices with Douglas-Peucker simplification. */
563
+ export const ST_SIMPLIFY = /* @__PURE__ */ lineReduction('ST_Simplify', 'simplify');
564
+
565
+ /** Returns clockwise azimuth from positive Y in radians. */
566
+ export const ST_AZIMUTH = /* @__PURE__ */ spatialFunction(
567
+ 'ST_Azimuth',
568
+ [pointKinds, pointKinds],
569
+ /* @__PURE__ */ new Float64(),
570
+ ([a, b]) => {
571
+ const p = pointCoordinates(a!);
572
+ const q = pointCoordinates(b!);
573
+ if (!p || !q) return null;
574
+ const dx = q[0]! - p[0]!;
575
+ const dy = q[1]! - p[1]!;
576
+ if (!dx && !dy) return null;
577
+ const angle = Math.atan2(dx, dy);
578
+ return angle < 0 ? angle + 2 * Math.PI : angle;
579
+ }
580
+ );
581
+
582
+ /** Returns planar polygonal area, or zero for non-areal input. */
583
+ export const ST_AREA = /* @__PURE__ */ spatialFunction(
584
+ 'ST_Area',
585
+ [geometryTypes],
586
+ /* @__PURE__ */ new Float64(),
587
+ ([geometry]) => planarArea(geometry!)
588
+ );
589
+
590
+ /** Returns planar linear length, or zero for non-linear input. */
591
+ export const ST_LENGTH = /* @__PURE__ */ spatialFunction(
592
+ 'ST_Length',
593
+ [geometryTypes],
594
+ /* @__PURE__ */ new Float64(),
595
+ ([geometry]) => planarLength(geometry!)
596
+ );
597
+
598
+ /** Returns a geometry's 2D center of mass as GeoArrow WKB. */
599
+ export const ST_CENTROID = /* @__PURE__ */ spatialFunction(
600
+ 'ST_Centroid',
601
+ [geometryTypes],
602
+ /* @__PURE__ */ new Binary(),
603
+ ([geometry]) => writeWKB(planarCentroid(geometry!), 'xy')
604
+ );
605
+
606
+ /** Inspection functions also accept WKB geometry collections. */
607
+ const inspectionKinds = [[...geometryTypes, 'GeometryCollection']] as const;
608
+
609
+ /** Vertex count including polygon ring closures. */
610
+ export const ST_NPOINTS = /* @__PURE__ */ spatialFunction(
611
+ 'ST_NPoints',
612
+ inspectionKinds,
613
+ /* @__PURE__ */ new Int32(),
614
+ ([g]) => vertexCount(g!),
615
+ 0,
616
+ true
617
+ );
618
+
619
+ /** Number of top-level components, or zero for empty geometry. */
620
+ export const ST_NUMGEOMETRIES = /* @__PURE__ */ spatialFunction(
621
+ 'ST_NumGeometries',
622
+ inspectionKinds,
623
+ /* @__PURE__ */ new Int32(),
624
+ ([g]) => memberCount(g!),
625
+ 0,
626
+ true
627
+ );
628
+
629
+ /** Whether the geometry contains no vertices. */
630
+ export const ST_ISEMPTY = /* @__PURE__ */ spatialFunction(
631
+ 'ST_IsEmpty',
632
+ inspectionKinds,
633
+ /* @__PURE__ */ new Bool(),
634
+ ([g]) => !vertexCount(g!),
635
+ 0,
636
+ true
637
+ );
638
+
639
+ /** Geometry type name with the ST_ prefix. */
640
+ export const ST_GEOMETRYTYPE = /* @__PURE__ */ spatialFunction(
641
+ 'ST_GeometryType',
642
+ inspectionKinds,
643
+ /* @__PURE__ */ new Utf8(),
644
+ ([g]) => 'ST_' + g!.type,
645
+ 0,
646
+ true
647
+ );
648
+
649
+ /** WKB geometry containing only XY ordinates. */
650
+ export const ST_FORCE2D = /* @__PURE__ */ spatialFunction(
651
+ 'ST_Force2D',
652
+ inspectionKinds,
653
+ /* @__PURE__ */ new Binary(),
654
+ ([g]) => writeWKB(g!, 'xy'),
655
+ 0,
656
+ true
657
+ );
658
+
659
+ /** One-based component as WKB with the input dimension. */
660
+ export const ST_GEOMETRYN = /* @__PURE__ */ spatialFunction(
661
+ 'ST_GeometryN',
662
+ inspectionKinds,
663
+ /* @__PURE__ */ new Binary(),
664
+ ([g], position) => {
665
+ const part = geometryMember(g!, position!);
666
+ return part ? (g!.members?.[position! - 1] ?? writeWKB(part, g!.dimension ?? 'xy')) : null;
667
+ },
668
+ 1,
669
+ true
670
+ );
671
+
672
+ /** Connects two point, multipoint or line inputs in their given order. */
673
+ export const ST_MAKELINE = /* @__PURE__ */ spatialFunction(
674
+ 'ST_MakeLine',
675
+ [
676
+ ['Point', 'MultiPoint', 'LineString'],
677
+ ['Point', 'MultiPoint', 'LineString']
678
+ ],
679
+ /* @__PURE__ */ new Binary(),
680
+ geometries => writeWKB(makeLine(geometries), 'xy')
681
+ );
682
+
683
+ /** Collects two geometries without dissolving or flattening them. */
684
+ export const ST_COLLECT = /* @__PURE__ */ spatialFunction(
685
+ 'ST_Collect',
686
+ [
687
+ [...geometryTypes, 'GeometryCollection'],
688
+ [...geometryTypes, 'GeometryCollection']
689
+ ],
690
+ /* @__PURE__ */ new Binary(),
691
+ ([a, b]) => (a ? writeWKB(b ? collectPair(a, b) : a, 'xy') : null),
692
+ 0,
693
+ false,
694
+ true
695
+ );
696
+
697
+ /** Returns an interior label point for a planar polygonal surface. */
698
+ export const ST_POINTONSURFACE = /* @__PURE__ */ spatialFunction(
699
+ 'ST_PointOnSurface',
700
+ [polygonKinds],
701
+ /* @__PURE__ */ new Binary(),
702
+ ([polygon]) => writeWKB(planarPolygonPointOnSurface(polygon!), 'xy')
703
+ );
704
+
705
+ /** Binds the WKB fallback and native row-bounds implementation. */
706
+ function makeEnvelopeFunction(): ScalarFunction {
707
+ const envelopeFunction = spatialFunction(
708
+ 'ST_Envelope',
709
+ [[...geometryTypes, 'GeometryCollection']],
710
+ /* @__PURE__ */ new Binary(),
711
+ ([geometry]) => writeWKB(planarEnvelope(geometry!), 'xy')
712
+ );
713
+
714
+ return {
715
+ ...envelopeFunction,
716
+ /** Keeps the WKB evaluator and binds the bounds kernel for native columns. */
717
+ resolvePrototype(fields) {
718
+ const prototype = envelopeFunction.resolvePrototype!(fields);
719
+ const field = fields[0];
720
+ if (
721
+ !prototype ||
722
+ !field ||
723
+ DataType.isBinary(field.type) ||
724
+ DataType.isLargeBinary(field.type)
725
+ ) {
726
+ return prototype;
727
+ }
728
+ return {
729
+ ...prototype,
730
+ /** Evaluates active rows and preserves the type of empty geometries. */
731
+ evaluate([vector], {activeRows, length}) {
732
+ const column = readActiveGeoArrowColumn(vector!, field, activeRows);
733
+ const bounds = getGeoArrowRowBounds(column);
734
+ const values = Array.from({length}, (_, row) => {
735
+ if (!activeRows[row]) return null;
736
+ const box = bounds[row];
737
+ if (box) return writeWKB(envelopeFromBounds(box), 'xy');
738
+ const [geometry] = materializeGeoArrowRows(getGeoArrowColumnView(column, row, row + 1));
739
+ return geometry ? writeWKB(geometry, 'xy') : null;
740
+ });
741
+ return vectorFromArray(values, new Binary());
742
+ }
743
+ };
744
+ }
745
+ };
746
+ }
747
+
748
+ /** Returns the 2D envelope as GeoArrow WKB. */
749
+ export const ST_ENVELOPE = /* @__PURE__ */ makeEnvelopeFunction();
750
+
751
+ /** Reduces a geometry column to its four planar bounds, ignoring null and empty rows. */
752
+ export const ST_EXTENT: AggregateFunction = {
753
+ kind: 'aggregate',
754
+ name: 'ST_Extent',
755
+ /** Binds the input geometry signature and the fixed-size box result. */
756
+ bind({arguments: fields}) {
757
+ const field = fields[0];
758
+ if (!field || fields.length !== 1) throw new Error('ST_Extent requires one geometry column');
759
+ ST_ENVELOPE.resolvePrototype!([field]);
760
+ return {
761
+ outputField: new Field(
762
+ 'ST_Extent',
763
+ new FixedSizeList(4, new Field('value', new Float64(), false)),
764
+ true
765
+ ),
766
+ /** Creates independent bounds for this group. */
767
+ createAccumulator() {
768
+ let bounds: number[] | null = null;
769
+ /** Includes a geometry or partial accumulator in the current bounds. */
770
+ function include(box: readonly number[]) {
771
+ if (!bounds) bounds = [...box];
772
+ else {
773
+ bounds[0] = Math.min(bounds[0]!, box[0]!);
774
+ bounds[1] = Math.min(bounds[1]!, box[1]!);
775
+ bounds[2] = Math.max(bounds[2]!, box[2]!);
776
+ bounds[3] = Math.max(bounds[3]!, box[3]!);
777
+ }
778
+ }
779
+ return {
780
+ /** Accumulates nonempty geometry bounds from one record batch. */
781
+ update([vector], {length}) {
782
+ if (!DataType.isBinary(field.type) && !DataType.isLargeBinary(field.type)) {
783
+ const column = makeGeoArrowColumnFromArrowVector(vector!, {field});
784
+ const box = getGeoArrowBounds(column);
785
+ if (box) include(box);
786
+ return;
787
+ }
788
+ const active = Uint8Array.from({length}, (_, i) => Number(vector!.isValid(i)));
789
+ const read = readGeometryValue(vector!, field, active, planarGeometry);
790
+ for (let i = 0; i < length; i++) {
791
+ if (!active[i]) continue;
792
+ const box = planarBounds(read(i));
793
+ if (box) include(box);
794
+ }
795
+ },
796
+ /** Combines bounds from another group partition. */
797
+ merge(partial) {
798
+ const box = partial.finalize();
799
+ if (Array.isArray(box)) include(box);
800
+ },
801
+ /** Returns a detached snapshot, or null for a group without coordinates. */
802
+ finalize: () => bounds && [...bounds]
803
+ };
804
+ }
805
+ };
806
+ }
807
+ };
808
+
809
+ /** Opt-in PostGIS-aligned 2D geometry functions for the Arrow SQL function list. */
810
+ export const POSTGIS_SPATIAL_FUNCTIONS: readonly (ArrowTableFunction | AggregateFunction)[] =
811
+ /* @__PURE__ */ Object.freeze([
812
+ ST_X,
813
+ ST_Y,
814
+ ST_Z,
815
+ ST_M,
816
+ ST_STARTPOINT,
817
+ ST_ENDPOINT,
818
+ ST_CONTAINS,
819
+ ST_COVERS,
820
+ ST_WITHIN,
821
+ ST_COVEREDBY,
822
+ ST_POINTN,
823
+ ST_MAKEENVELOPE,
824
+ ST_DISTANCE,
825
+ ST_DWITHIN,
826
+ ST_INTERSECTS,
827
+ ST_SRID,
828
+ ST_SETSRID,
829
+ ST_TRANSFORM,
830
+ ST_REMOVEREPEATEDPOINTS,
831
+ ST_SIMPLIFY,
832
+ ST_AZIMUTH,
833
+ ST_MAKEPOINT,
834
+ ST_TILEENVELOPE,
835
+ ST_AREA,
836
+ ST_LENGTH,
837
+ ST_LINEINTERPOLATEPOINT,
838
+ ST_LINELOCATEPOINT,
839
+ ST_LINESUBSTRING,
840
+ ST_POINTONSURFACE,
841
+ ST_CENTROID,
842
+ ST_NPOINTS,
843
+ ST_NUMGEOMETRIES,
844
+ ST_ISEMPTY,
845
+ ST_GEOMETRYTYPE,
846
+ ST_FORCE2D,
847
+ ST_GEOMETRYN,
848
+ ST_MAKELINE,
849
+ ST_COLLECT,
850
+ ST_ENVELOPE,
851
+ ST_EXTENT
852
+ ]);