@math.gl/geospatial 5.0.0-beta.4 → 5.0.0-beta.5

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 (455) hide show
  1. package/README.md +192 -2
  2. package/THIRD-PARTY-NOTICES.md +192 -20
  3. package/dist/expressions.d.ts +1 -1
  4. package/dist/expressions.d.ts.map +1 -1
  5. package/dist/index.cjs +212 -4614
  6. package/dist/index.cjs.map +3 -3
  7. package/dist/index.d.ts +2 -8
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/projection/experimental/common/adjust_lat.js +1 -1
  12. package/dist/projection/experimental/common/adjust_lat.js.map +1 -1
  13. package/dist/projection/experimental/common/adjust_lon.js +1 -1
  14. package/dist/projection/experimental/common/adjust_lon.js.map +1 -1
  15. package/dist/projection/experimental/common/asinhy.js +1 -1
  16. package/dist/projection/experimental/common/asinhy.js.map +1 -1
  17. package/dist/projection/experimental/common/asinz.js +1 -1
  18. package/dist/projection/experimental/common/asinz.js.map +1 -1
  19. package/dist/projection/experimental/common/authlat.js +1 -1
  20. package/dist/projection/experimental/common/authlat.js.map +1 -1
  21. package/dist/projection/experimental/common/authset.js +1 -1
  22. package/dist/projection/experimental/common/authset.js.map +1 -1
  23. package/dist/projection/experimental/common/clens.js +1 -1
  24. package/dist/projection/experimental/common/clens.js.map +1 -1
  25. package/dist/projection/experimental/common/clens_cmplx.js +1 -1
  26. package/dist/projection/experimental/common/clens_cmplx.js.map +1 -1
  27. package/dist/projection/experimental/common/constants.js +1 -1
  28. package/dist/projection/experimental/common/constants.js.map +1 -1
  29. package/dist/projection/experimental/common/cosh.js +1 -1
  30. package/dist/projection/experimental/common/cosh.js.map +1 -1
  31. package/dist/projection/experimental/common/e0fn.js +1 -1
  32. package/dist/projection/experimental/common/e0fn.js.map +1 -1
  33. package/dist/projection/experimental/common/e1fn.js +1 -1
  34. package/dist/projection/experimental/common/e1fn.js.map +1 -1
  35. package/dist/projection/experimental/common/e2fn.js +1 -1
  36. package/dist/projection/experimental/common/e2fn.js.map +1 -1
  37. package/dist/projection/experimental/common/e3fn.js +1 -1
  38. package/dist/projection/experimental/common/e3fn.js.map +1 -1
  39. package/dist/projection/experimental/common/fL.js +1 -1
  40. package/dist/projection/experimental/common/fL.js.map +1 -1
  41. package/dist/projection/experimental/common/gN.js +1 -1
  42. package/dist/projection/experimental/common/gN.js.map +1 -1
  43. package/dist/projection/experimental/common/gatg.js +1 -1
  44. package/dist/projection/experimental/common/gatg.js.map +1 -1
  45. package/dist/projection/experimental/common/hypot.js +1 -1
  46. package/dist/projection/experimental/common/hypot.js.map +1 -1
  47. package/dist/projection/experimental/common/imlfn.js +1 -1
  48. package/dist/projection/experimental/common/imlfn.js.map +1 -1
  49. package/dist/projection/experimental/common/invlatiso.js +1 -1
  50. package/dist/projection/experimental/common/invlatiso.js.map +1 -1
  51. package/dist/projection/experimental/common/iqsfnz.js +1 -1
  52. package/dist/projection/experimental/common/iqsfnz.js.map +1 -1
  53. package/dist/projection/experimental/common/latiso.js +1 -1
  54. package/dist/projection/experimental/common/latiso.js.map +1 -1
  55. package/dist/projection/experimental/common/log1py.js +1 -1
  56. package/dist/projection/experimental/common/log1py.js.map +1 -1
  57. package/dist/projection/experimental/common/mlfn.js +1 -1
  58. package/dist/projection/experimental/common/mlfn.js.map +1 -1
  59. package/dist/projection/experimental/common/msfnz.js +1 -1
  60. package/dist/projection/experimental/common/msfnz.js.map +1 -1
  61. package/dist/projection/experimental/common/phi2z.js +1 -1
  62. package/dist/projection/experimental/common/phi2z.js.map +1 -1
  63. package/dist/projection/experimental/common/pj_enfn.js +1 -1
  64. package/dist/projection/experimental/common/pj_enfn.js.map +1 -1
  65. package/dist/projection/experimental/common/pj_inv_mlfn.js +1 -1
  66. package/dist/projection/experimental/common/pj_inv_mlfn.js.map +1 -1
  67. package/dist/projection/experimental/common/pj_mlfn.js +1 -1
  68. package/dist/projection/experimental/common/pj_mlfn.js.map +1 -1
  69. package/dist/projection/experimental/common/qsfnz.js +1 -1
  70. package/dist/projection/experimental/common/qsfnz.js.map +1 -1
  71. package/dist/projection/experimental/common/sign.js +1 -1
  72. package/dist/projection/experimental/common/sign.js.map +1 -1
  73. package/dist/projection/experimental/common/sinh.js +1 -1
  74. package/dist/projection/experimental/common/sinh.js.map +1 -1
  75. package/dist/projection/experimental/common/srat.js +1 -1
  76. package/dist/projection/experimental/common/srat.js.map +1 -1
  77. package/dist/projection/experimental/common/tsfnz.js +1 -1
  78. package/dist/projection/experimental/common/tsfnz.js.map +1 -1
  79. package/dist/projection/experimental/common/vincenty.js +1 -1
  80. package/dist/projection/experimental/common/vincenty.js.map +1 -1
  81. package/dist/projection/experimental/core.cjs +100 -2
  82. package/dist/projection/experimental/core.cjs.map +2 -2
  83. package/dist/projection/experimental/core.d.ts +1 -0
  84. package/dist/projection/experimental/core.d.ts.map +1 -1
  85. package/dist/projection/experimental/crs/datum-table.js +1 -1
  86. package/dist/projection/experimental/crs/datum-table.js.map +1 -1
  87. package/dist/projection/experimental/crs/ellipsoid-table.js +1 -1
  88. package/dist/projection/experimental/crs/ellipsoid-table.js.map +1 -1
  89. package/dist/projection/experimental/crs/primemeridian-table.js +1 -1
  90. package/dist/projection/experimental/crs/primemeridian-table.js.map +1 -1
  91. package/dist/projection/experimental/crs/structured.js +1 -1
  92. package/dist/projection/experimental/crs/structured.js.map +1 -1
  93. package/dist/projection/experimental/crs/wkt.js +1 -1
  94. package/dist/projection/experimental/crs/wkt.js.map +1 -1
  95. package/dist/projection/experimental/datum.js +1 -1
  96. package/dist/projection/experimental/datum.js.map +1 -1
  97. package/dist/projection/experimental/ellipsoidal-gnomonic.js +1 -1
  98. package/dist/projection/experimental/ellipsoidal-gnomonic.js.map +1 -1
  99. package/dist/projection/experimental/entries/projections/eqc.cjs +1 -0
  100. package/dist/projection/experimental/entries/projections/eqc.cjs.map +1 -1
  101. package/dist/projection/experimental/entries/projections/merc.cjs +1 -0
  102. package/dist/projection/experimental/entries/projections/merc.cjs.map +1 -1
  103. package/dist/projection/experimental/grids/geotiff.js +1 -1
  104. package/dist/projection/experimental/grids/geotiff.js.map +1 -1
  105. package/dist/projection/experimental/grids/ntv2.js +1 -1
  106. package/dist/projection/experimental/grids/ntv2.js.map +1 -1
  107. package/dist/projection/experimental/index.cjs +102 -2
  108. package/dist/projection/experimental/index.cjs.map +3 -3
  109. package/dist/projection/experimental/kernels/aea.js +1 -1
  110. package/dist/projection/experimental/kernels/aea.js.map +1 -1
  111. package/dist/projection/experimental/kernels/aeqd.js +1 -1
  112. package/dist/projection/experimental/kernels/aeqd.js.map +1 -1
  113. package/dist/projection/experimental/kernels/bonne.js +1 -1
  114. package/dist/projection/experimental/kernels/bonne.js.map +1 -1
  115. package/dist/projection/experimental/kernels/cass.js +1 -1
  116. package/dist/projection/experimental/kernels/cass.js.map +1 -1
  117. package/dist/projection/experimental/kernels/cea.js +1 -1
  118. package/dist/projection/experimental/kernels/cea.js.map +1 -1
  119. package/dist/projection/experimental/kernels/eck6.js +1 -1
  120. package/dist/projection/experimental/kernels/eck6.js.map +1 -1
  121. package/dist/projection/experimental/kernels/eqdc.js +1 -1
  122. package/dist/projection/experimental/kernels/eqdc.js.map +1 -1
  123. package/dist/projection/experimental/kernels/eqearth.js +1 -1
  124. package/dist/projection/experimental/kernels/eqearth.js.map +1 -1
  125. package/dist/projection/experimental/kernels/equi.js +1 -1
  126. package/dist/projection/experimental/kernels/equi.js.map +1 -1
  127. package/dist/projection/experimental/kernels/etmerc.js +1 -1
  128. package/dist/projection/experimental/kernels/etmerc.js.map +1 -1
  129. package/dist/projection/experimental/kernels/gauss.js +1 -1
  130. package/dist/projection/experimental/kernels/gauss.js.map +1 -1
  131. package/dist/projection/experimental/kernels/geos.js +1 -1
  132. package/dist/projection/experimental/kernels/geos.js.map +1 -1
  133. package/dist/projection/experimental/kernels/gnom.js +1 -1
  134. package/dist/projection/experimental/kernels/gnom.js.map +1 -1
  135. package/dist/projection/experimental/kernels/gstmerc.js +1 -1
  136. package/dist/projection/experimental/kernels/gstmerc.js.map +1 -1
  137. package/dist/projection/experimental/kernels/krovak.js +1 -1
  138. package/dist/projection/experimental/kernels/krovak.js.map +1 -1
  139. package/dist/projection/experimental/kernels/laea.js +1 -1
  140. package/dist/projection/experimental/kernels/laea.js.map +1 -1
  141. package/dist/projection/experimental/kernels/lcc.js +1 -1
  142. package/dist/projection/experimental/kernels/lcc.js.map +1 -1
  143. package/dist/projection/experimental/kernels/mill.js +1 -1
  144. package/dist/projection/experimental/kernels/mill.js.map +1 -1
  145. package/dist/projection/experimental/kernels/moll.js +1 -1
  146. package/dist/projection/experimental/kernels/moll.js.map +1 -1
  147. package/dist/projection/experimental/kernels/nzmg.js +1 -1
  148. package/dist/projection/experimental/kernels/nzmg.js.map +1 -1
  149. package/dist/projection/experimental/kernels/omerc.js +1 -1
  150. package/dist/projection/experimental/kernels/omerc.js.map +1 -1
  151. package/dist/projection/experimental/kernels/poly.js +1 -1
  152. package/dist/projection/experimental/kernels/poly.js.map +1 -1
  153. package/dist/projection/experimental/kernels/qsc.js +1 -1
  154. package/dist/projection/experimental/kernels/qsc.js.map +1 -1
  155. package/dist/projection/experimental/kernels/robin.js +1 -1
  156. package/dist/projection/experimental/kernels/robin.js.map +1 -1
  157. package/dist/projection/experimental/kernels/sinu.js +1 -1
  158. package/dist/projection/experimental/kernels/sinu.js.map +1 -1
  159. package/dist/projection/experimental/kernels/somerc.js +1 -1
  160. package/dist/projection/experimental/kernels/somerc.js.map +1 -1
  161. package/dist/projection/experimental/kernels/stere.js +1 -1
  162. package/dist/projection/experimental/kernels/stere.js.map +1 -1
  163. package/dist/projection/experimental/kernels/sterea.js +1 -1
  164. package/dist/projection/experimental/kernels/sterea.js.map +1 -1
  165. package/dist/projection/experimental/kernels/tmerc.js +1 -1
  166. package/dist/projection/experimental/kernels/tmerc.js.map +1 -1
  167. package/dist/projection/experimental/kernels/tpers.js +1 -1
  168. package/dist/projection/experimental/kernels/tpers.js.map +1 -1
  169. package/dist/projection/experimental/kernels/vandg.js +1 -1
  170. package/dist/projection/experimental/kernels/vandg.js.map +1 -1
  171. package/dist/projection/experimental/kinematic-helmert.js +1 -1
  172. package/dist/projection/experimental/kinematic-helmert.js.map +1 -1
  173. package/dist/projection/experimental/lazy-projections/index.cjs +100 -2
  174. package/dist/projection/experimental/lazy-projections/index.cjs.map +2 -2
  175. package/dist/projection/experimental/projections/equidistant-cylindrical.d.ts.map +1 -1
  176. package/dist/projection/experimental/projections/equidistant-cylindrical.js +1 -0
  177. package/dist/projection/experimental/projections/equidistant-cylindrical.js.map +1 -1
  178. package/dist/projection/experimental/projections/mercator.d.ts.map +1 -1
  179. package/dist/projection/experimental/projections/mercator.js +1 -0
  180. package/dist/projection/experimental/projections/mercator.js.map +1 -1
  181. package/dist/projection/experimental/transform-description.d.ts +8 -0
  182. package/dist/projection/experimental/transform-description.d.ts.map +1 -0
  183. package/dist/projection/experimental/transform-description.js +57 -0
  184. package/dist/projection/experimental/transform-description.js.map +1 -0
  185. package/dist/projection/experimental/types.d.ts +5 -0
  186. package/dist/projection/experimental/types.d.ts.map +1 -1
  187. package/dist/projection/experimental/typescript-projection.d.ts +4 -0
  188. package/dist/projection/experimental/typescript-projection.d.ts.map +1 -1
  189. package/dist/projection/experimental/typescript-projection.js +54 -5
  190. package/dist/projection/experimental/typescript-projection.js.map +1 -1
  191. package/dist/projection/index.cjs +102 -2
  192. package/dist/projection/index.cjs.map +3 -3
  193. package/dist/projection/transform-analysis.cjs +100 -2
  194. package/dist/projection/transform-analysis.cjs.map +2 -2
  195. package/dist/projection/transform-description.d.ts +44 -0
  196. package/dist/projection/transform-description.d.ts.map +1 -0
  197. package/dist/projection/transform-description.js +5 -0
  198. package/dist/projection/transform-description.js.map +1 -0
  199. package/dist/projection/types.d.ts +4 -0
  200. package/dist/projection/types.d.ts.map +1 -1
  201. package/dist/tasks/definitions.d.ts +3 -3
  202. package/dist/tasks/index.cjs +107 -2
  203. package/dist/tasks/index.cjs.map +3 -3
  204. package/dist/tasks/index.d.ts +1 -1
  205. package/dist/tasks/index.d.ts.map +1 -1
  206. package/dist/tasks/map-worker.js +1 -1
  207. package/dist/tasks/map-worker.js.map +1 -1
  208. package/dist/tasks/operations.d.ts +1 -1
  209. package/dist/tasks/operations.d.ts.map +1 -1
  210. package/dist/tasks/projection-worker.js +1 -1
  211. package/dist/tasks/projection-worker.js.map +1 -1
  212. package/dist/terrain/contour-mixed-weld.d.ts +25 -0
  213. package/dist/terrain/contour-mixed-weld.d.ts.map +1 -0
  214. package/dist/terrain/contour-mixed-weld.js +194 -0
  215. package/dist/terrain/contour-mixed-weld.js.map +1 -0
  216. package/dist/terrain/height-field.d.ts.map +1 -1
  217. package/dist/terrain/height-field.js +48 -5
  218. package/dist/terrain/height-field.js.map +1 -1
  219. package/dist/terrain/index.cjs +204 -4
  220. package/dist/terrain/index.cjs.map +3 -3
  221. package/dist/terrain/index.d.ts +2 -0
  222. package/dist/terrain/index.d.ts.map +1 -1
  223. package/dist/terrain/index.js +1 -0
  224. package/dist/terrain/index.js.map +1 -1
  225. package/dist/terrain/tiled.d.ts +10 -2
  226. package/dist/terrain/tiled.d.ts.map +1 -1
  227. package/dist/terrain/tiled.js +5 -1
  228. package/dist/terrain/tiled.js.map +1 -1
  229. package/dist/terrain/types.d.ts +6 -0
  230. package/dist/terrain/types.d.ts.map +1 -1
  231. package/dist/turf.cjs +25 -671
  232. package/dist/turf.cjs.map +3 -3
  233. package/dist/turf.d.ts +1 -1
  234. package/dist/turf.d.ts.map +1 -1
  235. package/dist/turf.js +2 -2
  236. package/dist/turf.js.map +1 -1
  237. package/package.json +15 -19
  238. package/src/expressions.ts +1 -1
  239. package/src/index.ts +5 -123
  240. package/src/projection/experimental/common/adjust_lat.ts +1 -1
  241. package/src/projection/experimental/common/adjust_lon.ts +1 -1
  242. package/src/projection/experimental/common/asinhy.ts +1 -1
  243. package/src/projection/experimental/common/asinz.ts +1 -1
  244. package/src/projection/experimental/common/authlat.ts +1 -1
  245. package/src/projection/experimental/common/authset.ts +1 -1
  246. package/src/projection/experimental/common/clens.ts +1 -1
  247. package/src/projection/experimental/common/clens_cmplx.ts +1 -1
  248. package/src/projection/experimental/common/constants.ts +1 -1
  249. package/src/projection/experimental/common/cosh.ts +1 -1
  250. package/src/projection/experimental/common/e0fn.ts +1 -1
  251. package/src/projection/experimental/common/e1fn.ts +1 -1
  252. package/src/projection/experimental/common/e2fn.ts +1 -1
  253. package/src/projection/experimental/common/e3fn.ts +1 -1
  254. package/src/projection/experimental/common/fL.ts +1 -1
  255. package/src/projection/experimental/common/gN.ts +1 -1
  256. package/src/projection/experimental/common/gatg.ts +1 -1
  257. package/src/projection/experimental/common/hypot.ts +1 -1
  258. package/src/projection/experimental/common/imlfn.ts +1 -1
  259. package/src/projection/experimental/common/invlatiso.ts +1 -1
  260. package/src/projection/experimental/common/iqsfnz.ts +1 -1
  261. package/src/projection/experimental/common/latiso.ts +1 -1
  262. package/src/projection/experimental/common/log1py.ts +1 -1
  263. package/src/projection/experimental/common/mlfn.ts +1 -1
  264. package/src/projection/experimental/common/msfnz.ts +1 -1
  265. package/src/projection/experimental/common/phi2z.ts +1 -1
  266. package/src/projection/experimental/common/pj_enfn.ts +1 -1
  267. package/src/projection/experimental/common/pj_inv_mlfn.ts +1 -1
  268. package/src/projection/experimental/common/pj_mlfn.ts +1 -1
  269. package/src/projection/experimental/common/qsfnz.ts +1 -1
  270. package/src/projection/experimental/common/sign.ts +1 -1
  271. package/src/projection/experimental/common/sinh.ts +1 -1
  272. package/src/projection/experimental/common/srat.ts +1 -1
  273. package/src/projection/experimental/common/tsfnz.ts +1 -1
  274. package/src/projection/experimental/common/vincenty.ts +1 -1
  275. package/src/projection/experimental/core.ts +8 -0
  276. package/src/projection/experimental/crs/datum-table.ts +1 -1
  277. package/src/projection/experimental/crs/ellipsoid-table.ts +1 -1
  278. package/src/projection/experimental/crs/primemeridian-table.ts +1 -1
  279. package/src/projection/experimental/crs/structured.ts +1 -1
  280. package/src/projection/experimental/crs/wkt.ts +1 -1
  281. package/src/projection/experimental/datum.ts +1 -1
  282. package/src/projection/experimental/ellipsoidal-gnomonic.ts +1 -1
  283. package/src/projection/experimental/exact-helmert.ts +1 -1
  284. package/src/projection/experimental/grids/geotiff.ts +1 -1
  285. package/src/projection/experimental/grids/grid.ts +1 -1
  286. package/src/projection/experimental/grids/ntv2.ts +1 -1
  287. package/src/projection/experimental/helmert-flat.ts +1 -1
  288. package/src/projection/experimental/kernels/aea.ts +1 -1
  289. package/src/projection/experimental/kernels/aeqd.ts +1 -1
  290. package/src/projection/experimental/kernels/bonne.ts +1 -1
  291. package/src/projection/experimental/kernels/cass.ts +1 -1
  292. package/src/projection/experimental/kernels/cea.ts +1 -1
  293. package/src/projection/experimental/kernels/eck6.ts +1 -1
  294. package/src/projection/experimental/kernels/eqdc.ts +1 -1
  295. package/src/projection/experimental/kernels/eqearth.ts +1 -1
  296. package/src/projection/experimental/kernels/equi.ts +1 -1
  297. package/src/projection/experimental/kernels/etmerc.ts +1 -1
  298. package/src/projection/experimental/kernels/gauss.ts +1 -1
  299. package/src/projection/experimental/kernels/geos.ts +1 -1
  300. package/src/projection/experimental/kernels/gnom.ts +1 -1
  301. package/src/projection/experimental/kernels/gstmerc.ts +1 -1
  302. package/src/projection/experimental/kernels/krovak.ts +1 -1
  303. package/src/projection/experimental/kernels/laea.ts +1 -1
  304. package/src/projection/experimental/kernels/lcc.ts +1 -1
  305. package/src/projection/experimental/kernels/mill.ts +1 -1
  306. package/src/projection/experimental/kernels/moll.ts +1 -1
  307. package/src/projection/experimental/kernels/nzmg.ts +1 -1
  308. package/src/projection/experimental/kernels/omerc.ts +1 -1
  309. package/src/projection/experimental/kernels/ortho.ts +1 -1
  310. package/src/projection/experimental/kernels/poly.ts +1 -1
  311. package/src/projection/experimental/kernels/qsc.ts +1 -1
  312. package/src/projection/experimental/kernels/robin.ts +1 -1
  313. package/src/projection/experimental/kernels/sinu.ts +1 -1
  314. package/src/projection/experimental/kernels/somerc.ts +1 -1
  315. package/src/projection/experimental/kernels/stere.ts +1 -1
  316. package/src/projection/experimental/kernels/sterea.ts +1 -1
  317. package/src/projection/experimental/kernels/tmerc.ts +1 -1
  318. package/src/projection/experimental/kernels/tpers.ts +1 -1
  319. package/src/projection/experimental/kernels/vandg.ts +1 -1
  320. package/src/projection/experimental/kinematic-helmert-flat.ts +1 -1
  321. package/src/projection/experimental/kinematic-helmert.ts +1 -1
  322. package/src/projection/experimental/projection-pipeline.ts +1 -1
  323. package/src/projection/experimental/projections/equidistant-cylindrical.ts +1 -0
  324. package/src/projection/experimental/projections/mercator.ts +1 -0
  325. package/src/projection/experimental/projections/ob-tran.ts +1 -1
  326. package/src/projection/experimental/transform-description.ts +82 -0
  327. package/src/projection/experimental/types.ts +5 -0
  328. package/src/projection/experimental/typescript-projection.ts +54 -6
  329. package/src/projection/transform-description.ts +69 -0
  330. package/src/projection/types.ts +11 -0
  331. package/src/tasks/definitions.ts +1 -1
  332. package/src/tasks/index.ts +1 -1
  333. package/src/tasks/map-worker.ts +1 -1
  334. package/src/tasks/operations.ts +1 -1
  335. package/src/tasks/projection-worker.ts +1 -1
  336. package/src/terrain/contour-mixed-weld.ts +254 -0
  337. package/src/terrain/height-field.ts +45 -5
  338. package/src/terrain/index.ts +2 -0
  339. package/src/terrain/tiled.ts +16 -3
  340. package/src/terrain/types.ts +9 -1
  341. package/src/turf.ts +7 -3
  342. package/crs/README.md +0 -84
  343. package/crs/schemas/README.md +0 -9
  344. package/dist/geoarrow/builder-entry.d.ts +0 -4
  345. package/dist/geoarrow/builder-entry.d.ts.map +0 -1
  346. package/dist/geoarrow/builder-entry.js +0 -5
  347. package/dist/geoarrow/builder-entry.js.map +0 -1
  348. package/dist/geoarrow/builder.d.ts +0 -106
  349. package/dist/geoarrow/builder.d.ts.map +0 -1
  350. package/dist/geoarrow/builder.js +0 -668
  351. package/dist/geoarrow/builder.js.map +0 -1
  352. package/dist/geoarrow/codecs.d.ts +0 -24
  353. package/dist/geoarrow/codecs.d.ts.map +0 -1
  354. package/dist/geoarrow/codecs.js +0 -916
  355. package/dist/geoarrow/codecs.js.map +0 -1
  356. package/dist/geoarrow/index.cjs +0 -4352
  357. package/dist/geoarrow/index.cjs.map +0 -6
  358. package/dist/geoarrow/index.d.ts +0 -21
  359. package/dist/geoarrow/index.d.ts.map +0 -1
  360. package/dist/geoarrow/index.js +0 -15
  361. package/dist/geoarrow/index.js.map +0 -1
  362. package/dist/geoarrow/kernels.d.ts +0 -56
  363. package/dist/geoarrow/kernels.d.ts.map +0 -1
  364. package/dist/geoarrow/kernels.js +0 -982
  365. package/dist/geoarrow/kernels.js.map +0 -1
  366. package/dist/geoarrow/layout.d.ts +0 -66
  367. package/dist/geoarrow/layout.d.ts.map +0 -1
  368. package/dist/geoarrow/layout.js +0 -723
  369. package/dist/geoarrow/layout.js.map +0 -1
  370. package/dist/geoarrow/stream-tessellate.d.ts +0 -34
  371. package/dist/geoarrow/stream-tessellate.d.ts.map +0 -1
  372. package/dist/geoarrow/stream-tessellate.js +0 -171
  373. package/dist/geoarrow/stream-tessellate.js.map +0 -1
  374. package/dist/geoarrow/stream.d.ts +0 -29
  375. package/dist/geoarrow/stream.d.ts.map +0 -1
  376. package/dist/geoarrow/stream.js +0 -100
  377. package/dist/geoarrow/stream.js.map +0 -1
  378. package/dist/geoarrow/tessellate.d.ts +0 -31
  379. package/dist/geoarrow/tessellate.d.ts.map +0 -1
  380. package/dist/geoarrow/tessellate.js +0 -102
  381. package/dist/geoarrow/tessellate.js.map +0 -1
  382. package/dist/geoarrow/tessellation-entry.d.ts +0 -4
  383. package/dist/geoarrow/tessellation-entry.d.ts.map +0 -1
  384. package/dist/geoarrow/tessellation-entry.js +0 -5
  385. package/dist/geoarrow/tessellation-entry.js.map +0 -1
  386. package/dist/geoarrow/types.d.ts +0 -155
  387. package/dist/geoarrow/types.d.ts.map +0 -1
  388. package/dist/geoarrow/types.js +0 -71
  389. package/dist/geoarrow/types.js.map +0 -1
  390. package/dist/geoarrow/views.d.ts +0 -45
  391. package/dist/geoarrow/views.d.ts.map +0 -1
  392. package/dist/geoarrow/views.js +0 -114
  393. package/dist/geoarrow/views.js.map +0 -1
  394. package/dist/geoarrow/wkb-entry.d.ts +0 -4
  395. package/dist/geoarrow/wkb-entry.d.ts.map +0 -1
  396. package/dist/geoarrow/wkb-entry.js +0 -6
  397. package/dist/geoarrow/wkb-entry.js.map +0 -1
  398. package/dist/geoarrow/worker.d.ts +0 -11
  399. package/dist/geoarrow/worker.d.ts.map +0 -1
  400. package/dist/geoarrow/worker.js +0 -10
  401. package/dist/geoarrow/worker.js.map +0 -1
  402. package/dist/wkb/index.d.ts +0 -11
  403. package/dist/wkb/index.d.ts.map +0 -1
  404. package/dist/wkb/index.js +0 -9
  405. package/dist/wkb/index.js.map +0 -1
  406. package/dist/wkb/types.d.ts +0 -30
  407. package/dist/wkb/types.d.ts.map +0 -1
  408. package/dist/wkb/types.js +0 -34
  409. package/dist/wkb/types.js.map +0 -1
  410. package/dist/wkb/wkb-builder.d.ts +0 -91
  411. package/dist/wkb/wkb-builder.d.ts.map +0 -1
  412. package/dist/wkb/wkb-builder.js +0 -283
  413. package/dist/wkb/wkb-builder.js.map +0 -1
  414. package/dist/wkb/wkb-reader.d.ts +0 -74
  415. package/dist/wkb/wkb-reader.d.ts.map +0 -1
  416. package/dist/wkb/wkb-reader.js +0 -251
  417. package/dist/wkb/wkb-reader.js.map +0 -1
  418. package/dist/wkb/wkb.d.ts +0 -21
  419. package/dist/wkb/wkb.d.ts.map +0 -1
  420. package/dist/wkb/wkb.js +0 -204
  421. package/dist/wkb/wkb.js.map +0 -1
  422. package/dist/wkb/wkt.d.ts +0 -19
  423. package/dist/wkb/wkt.d.ts.map +0 -1
  424. package/dist/wkb/wkt.js +0 -321
  425. package/dist/wkb/wkt.js.map +0 -1
  426. package/projection/THIRD-PARTY-NOTICES.md +0 -210
  427. package/src/discontinuous/elastic/README.md +0 -20
  428. package/src/discontinuous/spherical-clip/README.md +0 -16
  429. package/src/discontinuous/world-kernels/README.md +0 -24
  430. package/src/geoarrow/builder-entry.ts +0 -18
  431. package/src/geoarrow/builder.ts +0 -860
  432. package/src/geoarrow/codecs.ts +0 -1268
  433. package/src/geoarrow/index.ts +0 -111
  434. package/src/geoarrow/kernels.ts +0 -1290
  435. package/src/geoarrow/layout.ts +0 -900
  436. package/src/geoarrow/stream-tessellate.ts +0 -205
  437. package/src/geoarrow/stream.ts +0 -130
  438. package/src/geoarrow/tessellate.ts +0 -133
  439. package/src/geoarrow/tessellation-entry.ts +0 -7
  440. package/src/geoarrow/types.ts +0 -259
  441. package/src/geoarrow/views.ts +0 -150
  442. package/src/geoarrow/wkb-entry.ts +0 -13
  443. package/src/geoarrow/worker.ts +0 -20
  444. package/src/terrain/vendor/README.md +0 -20
  445. package/src/vendor/geographiclib-geodesic/README.md +0 -26
  446. package/src/wkb/index.ts +0 -38
  447. package/src/wkb/types.ts +0 -54
  448. package/src/wkb/wkb-builder.ts +0 -395
  449. package/src/wkb/wkb-reader.ts +0 -401
  450. package/src/wkb/wkb.ts +0 -255
  451. package/src/wkb/wkt.ts +0 -375
  452. /package/{projection/APACHE-2.0-LICENSE.txt → APACHE-2.0-LICENSE.txt} +0 -0
  453. /package/{projection/PROJ-LICENSE.txt → PROJ-LICENSE.txt} +0 -0
  454. /package/{projection/PROJ4-LICENSE.md → PROJ4-LICENSE.md} +0 -0
  455. /package/{crs/schemas → src/crs}/projjson.schema.json +0 -0
@@ -1,900 +0,0 @@
1
- // math.gl
2
- // SPDX-License-Identifier: MIT
3
- // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
-
5
- import type {
6
- GeoArrowArray,
7
- GeoArrowColumn,
8
- GeoArrowCoordinateMapper,
9
- GeoArrowDenseUnion,
10
- GeoArrowEncoding,
11
- GeoArrowGeometryValue,
12
- GeoArrowList,
13
- GeoArrowOffsets,
14
- GeoArrowValidity
15
- } from './types';
16
- import {
17
- getGeoArrowDimensionSize,
18
- getGeoArrowEncodingForGeometry,
19
- getGeoArrowGeometryType
20
- } from './types';
21
-
22
- /** Stable validation diagnostic for a physical GeoArrow descriptor. */
23
- export type GeoArrowValidationIssue = Readonly<{
24
- code:
25
- | 'invalid-length'
26
- | 'invalid-validity'
27
- | 'invalid-offset'
28
- | 'invalid-stride'
29
- | 'invalid-child'
30
- | 'invalid-union'
31
- | 'invalid-layout'
32
- | 'unsafe-offset';
33
- path: string;
34
- message: string;
35
- }>;
36
-
37
- /** Validation result for a physical GeoArrow descriptor. */
38
- export type GeoArrowValidationResult = Readonly<{
39
- valid: boolean;
40
- issues: readonly GeoArrowValidationIssue[];
41
- }>;
42
-
43
- /** Value-independent and inexpensive facts about a GeoArrow column. */
44
- export type GeoArrowColumnInspection = Readonly<{
45
- encoding: GeoArrowEncoding;
46
- rowCount: number;
47
- chunkCount: number;
48
- nullCount: number;
49
- coordinateCount: number;
50
- storageKinds: readonly GeoArrowArray['kind'][];
51
- valid: boolean;
52
- issues: readonly GeoArrowValidationIssue[];
53
- }>;
54
-
55
- /** Returns whether one logical value is valid at a nesting level. */
56
- export function isGeoArrowValueValid(
57
- validity: GeoArrowValidity | undefined,
58
- index: number
59
- ): boolean {
60
- if (!validity) return true;
61
- const bitIndex = (validity.bitOffset || 0) + index;
62
- return Boolean(validity.values[bitIndex >> 3] & (1 << (bitIndex & 7)));
63
- }
64
-
65
- /** Returns the total number of logical rows across chunks. */
66
- export function getGeoArrowRowCount(column: GeoArrowColumn): number {
67
- return column.chunks.reduce((count, chunk) => count + chunk.length, 0);
68
- }
69
-
70
- /** Visits coordinates without materializing row geometry objects. */
71
- export function visitGeoArrowCoordinates(
72
- column: GeoArrowColumn,
73
- visitor: GeoArrowCoordinateMapper
74
- ): void {
75
- let rowOffset = 0;
76
- for (const chunk of column.chunks) {
77
- visitChunkCoordinates(chunk, column.encoding, rowOffset, visitor);
78
- rowOffset += chunk.length;
79
- }
80
- }
81
-
82
- /** Returns a zero-copy logical slice of a column, preserving chunk boundaries. */
83
- export function sliceGeoArrowColumn(
84
- column: GeoArrowColumn,
85
- begin = 0,
86
- end = getGeoArrowRowCount(column)
87
- ): GeoArrowColumn {
88
- const rowCount = getGeoArrowRowCount(column);
89
- const first = normalizeSliceIndex(begin, rowCount);
90
- const last = Math.max(first, normalizeSliceIndex(end, rowCount));
91
- if (first === 0 && last === rowCount) return column;
92
-
93
- const chunks: GeoArrowArray[] = [];
94
- let chunkStart = 0;
95
- for (const chunk of column.chunks) {
96
- const chunkEnd = chunkStart + chunk.length;
97
- const localFirst = Math.max(0, first - chunkStart);
98
- const localLast = Math.min(chunk.length, last - chunkStart);
99
- if (localLast > localFirst) {
100
- chunks.push(sliceGeoArrowArray(chunk, localFirst, localLast));
101
- }
102
- chunkStart = chunkEnd;
103
- if (chunkStart >= last) break;
104
- }
105
- return {...column, chunks};
106
- }
107
-
108
- /** Returns a zero-copy logical slice of one physical array. */
109
- export function sliceGeoArrowArray(
110
- array: GeoArrowArray,
111
- begin: number,
112
- end: number
113
- ): GeoArrowArray {
114
- if (begin === 0 && end === array.length) return array;
115
- const length = end - begin;
116
- const validity = array.validity
117
- ? {...array.validity, bitOffset: (array.validity.bitOffset || 0) + begin}
118
- : undefined;
119
- switch (array.kind) {
120
- case 'primitive':
121
- return {
122
- ...array,
123
- length,
124
- offset: (array.offset || 0) + begin * (array.stride || 1),
125
- validity
126
- };
127
- case 'fixed-size-list':
128
- return {...array, length, offset: (array.offset || 0) + begin, validity};
129
- case 'list':
130
- case 'serialized':
131
- return {...array, length, offset: (array.offset || 0) + begin, validity};
132
- case 'struct':
133
- return {...array, length, offset: (array.offset || 0) + begin, validity};
134
- case 'dense-union':
135
- return {...array, length, offset: (array.offset || 0) + begin, validity};
136
- }
137
- }
138
-
139
- /** Validates physical bounds, list offsets, union dispatch, and declared coordinate layout. */
140
- export function validateGeoArrowColumn(column: GeoArrowColumn): GeoArrowValidationResult {
141
- const issues: GeoArrowValidationIssue[] = [];
142
- for (let chunkIndex = 0; chunkIndex < column.chunks.length; chunkIndex++) {
143
- validateArray(column.chunks[chunkIndex], `chunks[${chunkIndex}]`, issues);
144
- }
145
- validateColumnLayout(column, issues);
146
- return {valid: issues.length === 0, issues};
147
- }
148
-
149
- /** Inspects a column without decoding serialized geometry or creating row objects. */
150
- export function inspectGeoArrowColumn(column: GeoArrowColumn): GeoArrowColumnInspection {
151
- const validation = validateGeoArrowColumn(column);
152
- const storageKinds: GeoArrowArray['kind'][] = [];
153
- let nullCount = 0;
154
- for (const chunk of column.chunks) {
155
- collectStorageKinds(chunk, storageKinds);
156
- for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
157
- if (!isGeoArrowRowValid(chunk, rowIndex)) nullCount++;
158
- }
159
- }
160
- return {
161
- encoding: column.encoding,
162
- rowCount: getGeoArrowRowCount(column),
163
- chunkCount: column.chunks.length,
164
- nullCount,
165
- coordinateCount: getGeoArrowVertexCount(column),
166
- storageKinds,
167
- valid: validation.valid,
168
- issues: validation.issues
169
- };
170
- }
171
-
172
- function isGeoArrowRowValid(array: GeoArrowArray, rowIndex: number): boolean {
173
- if (!isGeoArrowValueValid(array.validity, rowIndex)) return false;
174
- if (array.kind !== 'dense-union') return true;
175
- const physicalIndex = (array.offset || 0) + rowIndex;
176
- const child = array.children.find(candidate => candidate.typeId === array.typeIds[physicalIndex]);
177
- const valueOffset = array.valueOffsets[physicalIndex];
178
- return Boolean(
179
- child &&
180
- valueOffset >= 0 &&
181
- valueOffset < child.data.length &&
182
- isGeoArrowValueValid(child.data.validity, valueOffset)
183
- );
184
- }
185
-
186
- /** Counts coordinate tuples without materializing geometry objects. */
187
- export function getGeoArrowVertexCount(column: GeoArrowColumn): number {
188
- if (
189
- column.encoding === 'geoarrow.wkb' ||
190
- column.encoding === 'geoarrow.wkt' ||
191
- column.encoding === 'geoarrow.box'
192
- ) {
193
- return 0;
194
- }
195
- let count = 0;
196
- visitGeoArrowCoordinates(column, coordinate => {
197
- count++;
198
- return coordinate;
199
- });
200
- return count;
201
- }
202
-
203
- /** Collects unique transferable ArrayBuffers borrowed by a column. */
204
- export function getGeoArrowTransferList(column: GeoArrowColumn): ArrayBuffer[] {
205
- const buffers = new Set<ArrayBuffer>();
206
- for (const chunk of column.chunks) collectArrayBuffers(chunk, buffers);
207
- return [...buffers];
208
- }
209
-
210
- /**
211
- * Materializes native column rows as geometry values in logical chunk and row order.
212
- *
213
- * Null rows remain null. Empty points use an empty coordinate array, including points whose
214
- * ordinates are all non-finite or null. Output geometry objects and coordinate arrays are newly
215
- * allocated; input descriptors and borrowed buffers are never modified.
216
- *
217
- * @param column Native GeoArrow column. Decode WKB/WKT columns before calling this function.
218
- * @returns One geometry value or null per logical row.
219
- * @throws If the column contains serialized WKB or WKT values.
220
- */
221
- export function materializeGeoArrowRows(
222
- column: GeoArrowColumn
223
- ): Array<GeoArrowGeometryValue | null> {
224
- if (column.encoding === 'geoarrow.wkb' || column.encoding === 'geoarrow.wkt') {
225
- throw new Error('Serialized GeoArrow columns must be decoded before materialization');
226
- }
227
- const rows: Array<GeoArrowGeometryValue | null> = [];
228
- for (const chunk of column.chunks) {
229
- for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
230
- rows.push(materializeGeometryRow(chunk, rowIndex, column.encoding));
231
- }
232
- }
233
- return rows;
234
- }
235
-
236
- /** Materializes one row from a physical array. */
237
- export function materializeGeometryRow(
238
- array: GeoArrowArray,
239
- rowIndex: number,
240
- encoding: GeoArrowEncoding
241
- ): GeoArrowGeometryValue | null {
242
- if (!isGeoArrowValueValid(array.validity, rowIndex)) return null;
243
- if (encoding === 'geoarrow.geometry') {
244
- if (array.kind !== 'dense-union') return null;
245
- return materializeUnionRow(array, rowIndex);
246
- }
247
- if (encoding === 'geoarrow.geometrycollection') {
248
- if (array.kind !== 'list') return null;
249
- const [first, last] = getListRange(array, rowIndex);
250
- const geometries: GeoArrowGeometryValue[] = [];
251
- for (let index = first; index < last; index++) {
252
- if (array.child.kind !== 'dense-union') continue;
253
- const geometry = materializeUnionRow(array.child, index);
254
- if (geometry) geometries.push(geometry);
255
- }
256
- return {type: 'GeometryCollection', geometries};
257
- }
258
- const geometryType = getGeoArrowGeometryType(encoding);
259
- if (!geometryType || geometryType === 'GeometryCollection') return null;
260
- const depth = getEncodingDepth(encoding);
261
- const coordinates = readNestedCoordinates(
262
- array,
263
- rowIndex,
264
- depth,
265
- geometryType === 'Point' || geometryType === 'MultiPoint'
266
- );
267
- if (!coordinates) return null;
268
- return {type: geometryType, coordinates} as GeoArrowGeometryValue;
269
- }
270
-
271
- /** Returns a safe numeric offset. */
272
- export function getGeoArrowOffset(offsets: GeoArrowOffsets, index: number): number {
273
- const value = offsets[index];
274
- const numericValue = typeof value === 'bigint' ? Number(value) : value;
275
- if (!Number.isSafeInteger(numericValue)) {
276
- throw new Error(`GeoArrow offset ${String(value)} exceeds JavaScript's safe integer range`);
277
- }
278
- return numericValue;
279
- }
280
-
281
- /** Returns the child range for one list row. */
282
- export function getListRange(list: GeoArrowList, rowIndex: number): [number, number] {
283
- const offsetIndex = (list.offset || 0) + rowIndex;
284
- const baseValue = list.offsetBase ?? 0;
285
- const base = typeof baseValue === 'bigint' ? Number(baseValue) : baseValue;
286
- return [
287
- getGeoArrowOffset(list.offsets, offsetIndex) - base,
288
- getGeoArrowOffset(list.offsets, offsetIndex + 1) - base
289
- ];
290
- }
291
-
292
- function visitChunkCoordinates(
293
- array: GeoArrowArray,
294
- encoding: GeoArrowEncoding,
295
- rowOffset: number,
296
- visitor: GeoArrowCoordinateMapper
297
- ): void {
298
- for (let rowIndex = 0; rowIndex < array.length; rowIndex++) {
299
- if (!isGeoArrowValueValid(array.validity, rowIndex)) continue;
300
- if (encoding === 'geoarrow.geometry' && array.kind === 'dense-union') {
301
- visitUnionRowCoordinates(array, rowIndex, rowOffset + rowIndex, visitor);
302
- continue;
303
- }
304
- if (encoding === 'geoarrow.geometrycollection' && array.kind === 'list') {
305
- const [first, last] = getListRange(array, rowIndex);
306
- if (array.child.kind === 'dense-union') {
307
- for (let index = first; index < last; index++) {
308
- visitUnionRowCoordinates(array.child, index, rowOffset + rowIndex, visitor);
309
- }
310
- }
311
- continue;
312
- }
313
- const depth = getEncodingDepth(encoding);
314
- visitNestedCoordinates(array, rowIndex, depth, rowOffset + rowIndex, visitor);
315
- }
316
- }
317
-
318
- function visitUnionRowCoordinates(
319
- union: GeoArrowDenseUnion,
320
- rowIndex: number,
321
- sourceRowIndex: number,
322
- visitor: GeoArrowCoordinateMapper
323
- ): void {
324
- if (!isGeoArrowValueValid(union.validity, rowIndex)) return;
325
- const physicalIndex = (union.offset || 0) + rowIndex;
326
- const typeId = union.typeIds[physicalIndex];
327
- const valueOffset = union.valueOffsets[physicalIndex];
328
- const child = union.children.find(candidate => candidate.typeId === typeId);
329
- if (!child) return;
330
- const encoding = child.encoding || getEncodingFromChildName(child.name);
331
- if (encoding === 'geoarrow.geometrycollection' && child.data.kind === 'list') {
332
- const [first, last] = getListRange(child.data, valueOffset);
333
- if (child.data.child.kind === 'dense-union') {
334
- for (let index = first; index < last; index++) {
335
- visitUnionRowCoordinates(child.data.child, index, sourceRowIndex, visitor);
336
- }
337
- }
338
- return;
339
- }
340
- visitNestedCoordinates(
341
- child.data,
342
- valueOffset,
343
- getEncodingDepth(encoding),
344
- sourceRowIndex,
345
- visitor
346
- );
347
- }
348
-
349
- function visitNestedCoordinates(
350
- array: GeoArrowArray,
351
- index: number,
352
- depth: number,
353
- rowIndex: number,
354
- visitor: GeoArrowCoordinateMapper
355
- ): void {
356
- if (depth === 0) {
357
- const coordinate = readCoordinate(array, index);
358
- if (coordinate) visitor(coordinate, rowIndex);
359
- return;
360
- }
361
- if (array.kind !== 'list' || !isGeoArrowValueValid(array.validity, index)) return;
362
- const [first, last] = getListRange(array, index);
363
- for (let childIndex = first; childIndex < last; childIndex++) {
364
- visitNestedCoordinates(array.child, childIndex, depth - 1, rowIndex, visitor);
365
- }
366
- }
367
-
368
- function readNestedCoordinates(
369
- array: GeoArrowArray,
370
- index: number,
371
- depth: number,
372
- normalizeEmptyPoints: boolean
373
- ): unknown {
374
- if (depth === 0) {
375
- const coordinate = readCoordinate(array, index);
376
- return normalizeEmptyPoints && coordinate?.every(value => !Number.isFinite(value))
377
- ? []
378
- : coordinate;
379
- }
380
- if (array.kind !== 'list' || !isGeoArrowValueValid(array.validity, index)) return null;
381
- const [first, last] = getListRange(array, index);
382
- const values: unknown[] = [];
383
- for (let childIndex = first; childIndex < last; childIndex++) {
384
- const value = readNestedCoordinates(array.child, childIndex, depth - 1, normalizeEmptyPoints);
385
- if (value !== null) values.push(value);
386
- }
387
- return values;
388
- }
389
-
390
- /** Internal physical coordinate reader shared by buffer-oriented kernels. */
391
- export function readCoordinate(array: GeoArrowArray, index: number): number[] | null {
392
- if (!isGeoArrowValueValid(array.validity, index)) return null;
393
- if (array.kind === 'fixed-size-list') {
394
- const listIndex = (array.offset || 0) + index;
395
- const coordinate: number[] = [];
396
- for (let component = 0; component < array.size; component++) {
397
- coordinate.push(readPrimitive(array.child, listIndex * array.size + component));
398
- }
399
- return coordinate;
400
- }
401
- if (array.kind === 'struct') {
402
- const structIndex = (array.offset || 0) + index;
403
- const coordinate: number[] = [];
404
- for (const name of ['x', 'y', 'z', 'm']) {
405
- const child = array.children[name];
406
- if (child) coordinate.push(readPrimitive(child, structIndex));
407
- }
408
- return coordinate.length >= 2 ? coordinate : null;
409
- }
410
- return null;
411
- }
412
-
413
- function readPrimitive(array: GeoArrowArray, index: number): number {
414
- if (array.kind !== 'primitive') throw new Error('GeoArrow coordinate child must be primitive');
415
- if (!isGeoArrowValueValid(array.validity, index)) return Number.NaN;
416
- const valueIndex = (array.offset || 0) + index * (array.stride || 1);
417
- return Number(array.values[valueIndex]);
418
- }
419
-
420
- function materializeUnionRow(
421
- union: GeoArrowDenseUnion,
422
- rowIndex: number
423
- ): GeoArrowGeometryValue | null {
424
- if (!isGeoArrowValueValid(union.validity, rowIndex)) return null;
425
- const physicalIndex = (union.offset || 0) + rowIndex;
426
- const typeId = union.typeIds[physicalIndex];
427
- const valueOffset = union.valueOffsets[physicalIndex];
428
- const child = union.children.find(candidate => candidate.typeId === typeId);
429
- if (!child || valueOffset < 0 || valueOffset >= child.data.length) return null;
430
- return materializeGeometryRow(
431
- child.data,
432
- valueOffset,
433
- child.encoding || getEncodingFromChildName(child.name)
434
- );
435
- }
436
-
437
- /** Resolves legacy union child names when an explicit encoding is absent. */
438
- export function getEncodingFromChildName(name: string): GeoArrowEncoding {
439
- const normalized = name.replace(/[^a-z]/gi, '').toLowerCase();
440
- switch (normalized) {
441
- case 'point':
442
- return 'geoarrow.point';
443
- case 'linestring':
444
- return 'geoarrow.linestring';
445
- case 'polygon':
446
- return 'geoarrow.polygon';
447
- case 'multipoint':
448
- return 'geoarrow.multipoint';
449
- case 'multilinestring':
450
- return 'geoarrow.multilinestring';
451
- case 'multipolygon':
452
- return 'geoarrow.multipolygon';
453
- case 'geometrycollection':
454
- return 'geoarrow.geometrycollection';
455
- default:
456
- throw new Error(`Unknown GeoArrow dense-union child ${name}`);
457
- }
458
- }
459
-
460
- function getEncodingDepth(encoding: GeoArrowEncoding): 0 | 1 | 2 | 3 {
461
- switch (encoding) {
462
- case 'geoarrow.point':
463
- return 0;
464
- case 'geoarrow.linestring':
465
- case 'geoarrow.multipoint':
466
- return 1;
467
- case 'geoarrow.polygon':
468
- case 'geoarrow.multilinestring':
469
- return 2;
470
- case 'geoarrow.multipolygon':
471
- return 3;
472
- default:
473
- return 0;
474
- }
475
- }
476
-
477
- function validateArray(
478
- array: GeoArrowArray,
479
- path: string,
480
- issues: GeoArrowValidationIssue[]
481
- ): void {
482
- if (!Number.isSafeInteger(array.length) || array.length < 0) {
483
- issues.push({
484
- code: 'invalid-length',
485
- path,
486
- message: 'Length must be a non-negative safe integer.'
487
- });
488
- return;
489
- }
490
- validateValidity(array.validity, array.length, path, issues);
491
- switch (array.kind) {
492
- case 'primitive': {
493
- const stride = array.stride || 1;
494
- const offset = array.offset || 0;
495
- if (!Number.isSafeInteger(stride) || stride < 1) {
496
- issues.push({code: 'invalid-stride', path, message: 'Primitive stride must be positive.'});
497
- }
498
- const requiredLength = array.length === 0 ? offset : offset + (array.length - 1) * stride + 1;
499
- if (offset < 0 || requiredLength > array.values.length) {
500
- issues.push({
501
- code: 'invalid-length',
502
- path,
503
- message: 'Primitive values do not cover the logical range.'
504
- });
505
- }
506
- break;
507
- }
508
- case 'fixed-size-list': {
509
- const offset = array.offset ?? 0;
510
- const validOffset = Number.isSafeInteger(offset) && offset >= 0;
511
- if (!validOffset) {
512
- issues.push({
513
- code: 'invalid-offset',
514
- path,
515
- message: 'Fixed-size list offset must be a non-negative safe integer.'
516
- });
517
- }
518
- if (!Number.isSafeInteger(array.size) || array.size < 1) {
519
- issues.push({
520
- code: 'invalid-length',
521
- path,
522
- message: 'Fixed-size list size must be positive.'
523
- });
524
- }
525
- const childEnd = (offset + array.length) * array.size;
526
- if (validOffset && childEnd > array.child.length) {
527
- issues.push({code: 'invalid-child', path, message: 'Fixed-size list child is too short.'});
528
- }
529
- validateArray(array.child, `${path}.child`, issues);
530
- break;
531
- }
532
- case 'list':
533
- validateList(array, path, issues);
534
- validateArray(array.child, `${path}.child`, issues);
535
- break;
536
- case 'struct':
537
- if (Object.keys(array.children).length === 0) {
538
- issues.push({code: 'invalid-child', path, message: 'Struct must contain children.'});
539
- }
540
- for (const [name, child] of Object.entries(array.children)) {
541
- if ((array.offset || 0) + array.length > child.length) {
542
- issues.push({
543
- code: 'invalid-child',
544
- path: `${path}.${name}`,
545
- message: 'Struct child is too short.'
546
- });
547
- }
548
- validateArray(child, `${path}.${name}`, issues);
549
- }
550
- break;
551
- case 'dense-union': {
552
- const end = (array.offset || 0) + array.length;
553
- if (end > array.typeIds.length || end > array.valueOffsets.length) {
554
- issues.push({
555
- code: 'invalid-union',
556
- path,
557
- message: 'Dense-union dispatch buffers are too short.'
558
- });
559
- }
560
- const childIds = new Set<number>();
561
- for (const child of array.children) {
562
- if (childIds.has(child.typeId)) {
563
- issues.push({
564
- code: 'invalid-union',
565
- path,
566
- message: `Duplicate dense-union type ID ${child.typeId}.`
567
- });
568
- }
569
- childIds.add(child.typeId);
570
- validateArray(child.data, `${path}.${child.name}`, issues);
571
- }
572
- for (let index = array.offset || 0; index < end; index++) {
573
- if (!isGeoArrowValueValid(array.validity, index - (array.offset || 0))) continue;
574
- const child = array.children.find(candidate => candidate.typeId === array.typeIds[index]);
575
- const valueOffset = array.valueOffsets[index];
576
- if (!child || valueOffset < 0 || valueOffset >= child.data.length) {
577
- issues.push({
578
- code: 'invalid-union',
579
- path: `${path}[${index}]`,
580
- message: 'Dense-union row references an invalid child value.'
581
- });
582
- }
583
- }
584
- break;
585
- }
586
- case 'serialized': {
587
- if (array.views) {
588
- const requiredWords = ((array.offset || 0) + array.length) * 4;
589
- if (requiredWords > array.views.length) {
590
- issues.push({
591
- code: 'invalid-length',
592
- path,
593
- message: 'Serialized view records are too short.'
594
- });
595
- }
596
- } else {
597
- validateOffsets(
598
- array.offsets,
599
- array.offset || 0,
600
- array.length,
601
- array.values.length,
602
- array.offsetBase,
603
- path,
604
- issues
605
- );
606
- }
607
- break;
608
- }
609
- }
610
- }
611
-
612
- function validateList(list: GeoArrowList, path: string, issues: GeoArrowValidationIssue[]): void {
613
- validateOffsets(
614
- list.offsets,
615
- list.offset || 0,
616
- list.length,
617
- list.child.length,
618
- list.offsetBase,
619
- path,
620
- issues
621
- );
622
- }
623
-
624
- function validateOffsets(
625
- offsets: GeoArrowOffsets,
626
- offset: number,
627
- length: number,
628
- childLength: number,
629
- offsetBase: number | bigint | undefined,
630
- path: string,
631
- issues: GeoArrowValidationIssue[]
632
- ): void {
633
- if (offset < 0 || offset + length >= offsets.length) {
634
- issues.push({code: 'invalid-offset', path, message: 'Offset buffer is too short.'});
635
- return;
636
- }
637
- const base = typeof offsetBase === 'bigint' ? Number(offsetBase) : offsetBase || 0;
638
- let previous: number;
639
- try {
640
- previous = getGeoArrowOffset(offsets, offset) - base;
641
- } catch (error) {
642
- issues.push({code: 'unsafe-offset', path, message: (error as Error).message});
643
- return;
644
- }
645
- for (let index = 1; index <= length; index++) {
646
- let current: number;
647
- try {
648
- current = getGeoArrowOffset(offsets, offset + index) - base;
649
- } catch (error) {
650
- issues.push({code: 'unsafe-offset', path, message: (error as Error).message});
651
- return;
652
- }
653
- if (current < previous || current < 0 || current > childLength) {
654
- issues.push({
655
- code: 'invalid-offset',
656
- path,
657
- message: 'Offsets must be monotonic and within child storage.'
658
- });
659
- return;
660
- }
661
- previous = current;
662
- }
663
- }
664
-
665
- function validateValidity(
666
- validity: GeoArrowValidity | undefined,
667
- length: number,
668
- path: string,
669
- issues: GeoArrowValidationIssue[]
670
- ): void {
671
- if (!validity) return;
672
- const bitOffset = validity.bitOffset || 0;
673
- if (bitOffset < 0 || bitOffset + length > validity.values.length * 8) {
674
- issues.push({code: 'invalid-validity', path, message: 'Validity bitmap is too short.'});
675
- }
676
- }
677
-
678
- function validateColumnLayout(column: GeoArrowColumn, issues: GeoArrowValidationIssue[]): void {
679
- if (column.encoding === 'geoarrow.wkb' || column.encoding === 'geoarrow.wkt') {
680
- for (const [index, chunk] of column.chunks.entries()) {
681
- const expectedEncoding = column.encoding === 'geoarrow.wkb' ? 'binary' : 'utf8';
682
- if (chunk.kind !== 'serialized' || chunk.encoding !== expectedEncoding) {
683
- issues.push({
684
- code: 'invalid-layout',
685
- path: `chunks[${index}]`,
686
- message: `Serialized encoding requires ${expectedEncoding} storage.`
687
- });
688
- }
689
- }
690
- return;
691
- }
692
- if (column.encoding === 'geoarrow.box') {
693
- for (const [index, chunk] of column.chunks.entries()) {
694
- if (chunk.kind !== 'struct') {
695
- addInvalidLayout(`chunks[${index}]`, 'Box encoding requires struct storage.', issues);
696
- continue;
697
- }
698
- const requiredNames =
699
- column.dimension === 'xy'
700
- ? ['xmin', 'ymin', 'xmax', 'ymax']
701
- : column.dimension === 'xyz'
702
- ? ['xmin', 'ymin', 'zmin', 'xmax', 'ymax', 'zmax']
703
- : column.dimension === 'xym'
704
- ? ['xmin', 'ymin', 'mmin', 'xmax', 'ymax', 'mmax']
705
- : ['xmin', 'ymin', 'zmin', 'mmin', 'xmax', 'ymax', 'zmax', 'mmax'];
706
- for (const name of requiredNames) {
707
- if (chunk.children[name]?.kind !== 'primitive') {
708
- addInvalidLayout(
709
- `chunks[${index}].${name}`,
710
- `Box storage requires primitive ${name}.`,
711
- issues
712
- );
713
- }
714
- }
715
- }
716
- return;
717
- }
718
- if (!column.coordinateLayout) {
719
- addInvalidLayout('coordinateLayout', 'Native geometry requires a coordinate layout.', issues);
720
- return;
721
- }
722
- for (const [index, chunk] of column.chunks.entries()) {
723
- validateGeometryLayout(chunk, column.encoding, column, `chunks[${index}]`, issues);
724
- }
725
- }
726
-
727
- function validateGeometryLayout(
728
- array: GeoArrowArray,
729
- encoding: GeoArrowEncoding,
730
- column: GeoArrowColumn,
731
- path: string,
732
- issues: GeoArrowValidationIssue[]
733
- ): void {
734
- if (encoding === 'geoarrow.geometry') {
735
- if (array.kind !== 'dense-union') {
736
- addInvalidLayout(path, 'Mixed geometry encoding requires dense-union storage.', issues);
737
- return;
738
- }
739
- validateUnionLayouts(array, column, path, issues);
740
- return;
741
- }
742
- if (encoding === 'geoarrow.geometrycollection') {
743
- if (array.kind !== 'list' || array.child.kind !== 'dense-union') {
744
- addInvalidLayout(path, 'GeometryCollection requires list-of-dense-union storage.', issues);
745
- return;
746
- }
747
- validateUnionLayouts(array.child, column, `${path}.child`, issues);
748
- return;
749
- }
750
- let coordinateArray = array;
751
- const depth = getEncodingDepth(encoding);
752
- for (let level = 0; level < depth; level++) {
753
- if (coordinateArray.kind !== 'list') {
754
- addInvalidLayout(path, `${encoding} requires ${depth} variable-list levels.`, issues);
755
- return;
756
- }
757
- coordinateArray = coordinateArray.child;
758
- }
759
- validateCoordinateLayout(coordinateArray, column, path, issues);
760
- }
761
-
762
- function validateUnionLayouts(
763
- union: GeoArrowDenseUnion,
764
- column: GeoArrowColumn,
765
- path: string,
766
- issues: GeoArrowValidationIssue[]
767
- ): void {
768
- for (const child of union.children) {
769
- let encoding: GeoArrowEncoding;
770
- try {
771
- encoding = child.encoding || getEncodingFromChildName(child.name);
772
- } catch (error) {
773
- addInvalidLayout(`${path}.${child.name}`, (error as Error).message, issues);
774
- continue;
775
- }
776
- const childColumn =
777
- child.dimension || child.coordinateLayout
778
- ? {
779
- ...column,
780
- dimension: child.dimension || column.dimension,
781
- coordinateLayout: child.coordinateLayout || column.coordinateLayout
782
- }
783
- : column;
784
- validateGeometryLayout(child.data, encoding, childColumn, `${path}.${child.name}`, issues);
785
- }
786
- }
787
-
788
- function validateCoordinateLayout(
789
- array: GeoArrowArray,
790
- column: GeoArrowColumn,
791
- path: string,
792
- issues: GeoArrowValidationIssue[]
793
- ): void {
794
- const dimensionSize = getGeoArrowDimensionSize(column.dimension);
795
- if (column.coordinateLayout === 'interleaved') {
796
- if (
797
- array.kind !== 'fixed-size-list' ||
798
- array.size !== dimensionSize ||
799
- array.child.kind !== 'primitive'
800
- ) {
801
- addInvalidLayout(
802
- path,
803
- `Interleaved ${column.dimension} coordinates require fixed-size-list<${dimensionSize}> primitive storage.`,
804
- issues
805
- );
806
- }
807
- return;
808
- }
809
- if (array.kind !== 'struct') {
810
- addInvalidLayout(
811
- path,
812
- `Separated ${column.dimension} coordinates require struct storage.`,
813
- issues
814
- );
815
- return;
816
- }
817
- const requiredNames =
818
- column.dimension === 'xy'
819
- ? ['x', 'y']
820
- : column.dimension === 'xyz'
821
- ? ['x', 'y', 'z']
822
- : column.dimension === 'xym'
823
- ? ['x', 'y', 'm']
824
- : ['x', 'y', 'z', 'm'];
825
- for (const name of requiredNames) {
826
- if (array.children[name]?.kind !== 'primitive') {
827
- addInvalidLayout(
828
- `${path}.${name}`,
829
- `Separated coordinates require primitive ${name}.`,
830
- issues
831
- );
832
- }
833
- }
834
- }
835
-
836
- function addInvalidLayout(path: string, message: string, issues: GeoArrowValidationIssue[]): void {
837
- issues.push({code: 'invalid-layout', path, message});
838
- }
839
-
840
- function collectStorageKinds(array: GeoArrowArray, kinds: GeoArrowArray['kind'][]): void {
841
- kinds.push(array.kind);
842
- switch (array.kind) {
843
- case 'fixed-size-list':
844
- case 'list':
845
- collectStorageKinds(array.child, kinds);
846
- break;
847
- case 'struct':
848
- for (const child of Object.values(array.children)) collectStorageKinds(child, kinds);
849
- break;
850
- case 'dense-union':
851
- for (const child of array.children) collectStorageKinds(child.data, kinds);
852
- break;
853
- default:
854
- break;
855
- }
856
- }
857
-
858
- function collectArrayBuffers(array: GeoArrowArray, buffers: Set<ArrayBuffer>): void {
859
- if (array.validity) addBuffer(array.validity.values.buffer, buffers);
860
- switch (array.kind) {
861
- case 'primitive':
862
- addBuffer(array.values.buffer, buffers);
863
- break;
864
- case 'fixed-size-list':
865
- collectArrayBuffers(array.child, buffers);
866
- break;
867
- case 'list':
868
- addBuffer(array.offsets.buffer, buffers);
869
- collectArrayBuffers(array.child, buffers);
870
- break;
871
- case 'struct':
872
- for (const child of Object.values(array.children)) collectArrayBuffers(child, buffers);
873
- break;
874
- case 'dense-union':
875
- addBuffer(array.typeIds.buffer, buffers);
876
- addBuffer(array.valueOffsets.buffer, buffers);
877
- for (const child of array.children) collectArrayBuffers(child.data, buffers);
878
- break;
879
- case 'serialized':
880
- addBuffer(array.offsets.buffer, buffers);
881
- addBuffer(array.values.buffer, buffers);
882
- if (array.views) addBuffer(array.views.buffer, buffers);
883
- for (const data of array.dataBuffers || []) addBuffer(data.buffer, buffers);
884
- break;
885
- }
886
- }
887
-
888
- function addBuffer(buffer: ArrayBufferLike, buffers: Set<ArrayBuffer>): void {
889
- if (buffer instanceof ArrayBuffer) buffers.add(buffer);
890
- }
891
-
892
- function normalizeSliceIndex(index: number, length: number): number {
893
- const normalized = index < 0 ? Math.max(0, length + index) : Math.min(length, index);
894
- return Math.max(0, Math.trunc(normalized));
895
- }
896
-
897
- /** Returns a concrete encoding for a geometry value. */
898
- export function getEncodingForGeometryValue(geometry: GeoArrowGeometryValue): GeoArrowEncoding {
899
- return getGeoArrowEncodingForGeometry(geometry.type);
900
- }