@math.gl/geospatial 5.0.0-beta.3 → 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 (475) 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 +456 -4614
  6. package/dist/index.cjs.map +3 -3
  7. package/dist/index.d.ts +9 -8
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +5 -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-boundary-diagnostics.d.ts +23 -0
  213. package/dist/terrain/contour-boundary-diagnostics.d.ts.map +1 -0
  214. package/dist/terrain/contour-boundary-diagnostics.js +62 -0
  215. package/dist/terrain/contour-boundary-diagnostics.js.map +1 -0
  216. package/dist/terrain/contour-mixed-weld.d.ts +25 -0
  217. package/dist/terrain/contour-mixed-weld.d.ts.map +1 -0
  218. package/dist/terrain/contour-mixed-weld.js +194 -0
  219. package/dist/terrain/contour-mixed-weld.js.map +1 -0
  220. package/dist/terrain/contour-tile-paths.d.ts +7 -0
  221. package/dist/terrain/contour-tile-paths.d.ts.map +1 -0
  222. package/dist/terrain/contour-tile-paths.js +12 -0
  223. package/dist/terrain/contour-tile-paths.js.map +1 -0
  224. package/dist/terrain/contour-tile-weld.d.ts +24 -0
  225. package/dist/terrain/contour-tile-weld.d.ts.map +1 -0
  226. package/dist/terrain/contour-tile-weld.js +147 -0
  227. package/dist/terrain/contour-tile-weld.js.map +1 -0
  228. package/dist/terrain/gradient-pyramid.d.ts +29 -0
  229. package/dist/terrain/gradient-pyramid.d.ts.map +1 -0
  230. package/dist/terrain/gradient-pyramid.js +94 -0
  231. package/dist/terrain/gradient-pyramid.js.map +1 -0
  232. package/dist/terrain/height-field.d.ts.map +1 -1
  233. package/dist/terrain/height-field.js +48 -5
  234. package/dist/terrain/height-field.js.map +1 -1
  235. package/dist/terrain/index.cjs +448 -4
  236. package/dist/terrain/index.cjs.map +3 -3
  237. package/dist/terrain/index.d.ts +9 -0
  238. package/dist/terrain/index.d.ts.map +1 -1
  239. package/dist/terrain/index.js +5 -0
  240. package/dist/terrain/index.js.map +1 -1
  241. package/dist/terrain/tiled.d.ts +10 -2
  242. package/dist/terrain/tiled.d.ts.map +1 -1
  243. package/dist/terrain/tiled.js +5 -1
  244. package/dist/terrain/tiled.js.map +1 -1
  245. package/dist/terrain/types.d.ts +6 -0
  246. package/dist/terrain/types.d.ts.map +1 -1
  247. package/dist/turf.cjs +25 -671
  248. package/dist/turf.cjs.map +3 -3
  249. package/dist/turf.d.ts +1 -1
  250. package/dist/turf.d.ts.map +1 -1
  251. package/dist/turf.js +2 -2
  252. package/dist/turf.js.map +1 -1
  253. package/package.json +15 -19
  254. package/src/expressions.ts +1 -1
  255. package/src/index.ts +15 -123
  256. package/src/projection/experimental/common/adjust_lat.ts +1 -1
  257. package/src/projection/experimental/common/adjust_lon.ts +1 -1
  258. package/src/projection/experimental/common/asinhy.ts +1 -1
  259. package/src/projection/experimental/common/asinz.ts +1 -1
  260. package/src/projection/experimental/common/authlat.ts +1 -1
  261. package/src/projection/experimental/common/authset.ts +1 -1
  262. package/src/projection/experimental/common/clens.ts +1 -1
  263. package/src/projection/experimental/common/clens_cmplx.ts +1 -1
  264. package/src/projection/experimental/common/constants.ts +1 -1
  265. package/src/projection/experimental/common/cosh.ts +1 -1
  266. package/src/projection/experimental/common/e0fn.ts +1 -1
  267. package/src/projection/experimental/common/e1fn.ts +1 -1
  268. package/src/projection/experimental/common/e2fn.ts +1 -1
  269. package/src/projection/experimental/common/e3fn.ts +1 -1
  270. package/src/projection/experimental/common/fL.ts +1 -1
  271. package/src/projection/experimental/common/gN.ts +1 -1
  272. package/src/projection/experimental/common/gatg.ts +1 -1
  273. package/src/projection/experimental/common/hypot.ts +1 -1
  274. package/src/projection/experimental/common/imlfn.ts +1 -1
  275. package/src/projection/experimental/common/invlatiso.ts +1 -1
  276. package/src/projection/experimental/common/iqsfnz.ts +1 -1
  277. package/src/projection/experimental/common/latiso.ts +1 -1
  278. package/src/projection/experimental/common/log1py.ts +1 -1
  279. package/src/projection/experimental/common/mlfn.ts +1 -1
  280. package/src/projection/experimental/common/msfnz.ts +1 -1
  281. package/src/projection/experimental/common/phi2z.ts +1 -1
  282. package/src/projection/experimental/common/pj_enfn.ts +1 -1
  283. package/src/projection/experimental/common/pj_inv_mlfn.ts +1 -1
  284. package/src/projection/experimental/common/pj_mlfn.ts +1 -1
  285. package/src/projection/experimental/common/qsfnz.ts +1 -1
  286. package/src/projection/experimental/common/sign.ts +1 -1
  287. package/src/projection/experimental/common/sinh.ts +1 -1
  288. package/src/projection/experimental/common/srat.ts +1 -1
  289. package/src/projection/experimental/common/tsfnz.ts +1 -1
  290. package/src/projection/experimental/common/vincenty.ts +1 -1
  291. package/src/projection/experimental/core.ts +8 -0
  292. package/src/projection/experimental/crs/datum-table.ts +1 -1
  293. package/src/projection/experimental/crs/ellipsoid-table.ts +1 -1
  294. package/src/projection/experimental/crs/primemeridian-table.ts +1 -1
  295. package/src/projection/experimental/crs/structured.ts +1 -1
  296. package/src/projection/experimental/crs/wkt.ts +1 -1
  297. package/src/projection/experimental/datum.ts +1 -1
  298. package/src/projection/experimental/ellipsoidal-gnomonic.ts +1 -1
  299. package/src/projection/experimental/exact-helmert.ts +1 -1
  300. package/src/projection/experimental/grids/geotiff.ts +1 -1
  301. package/src/projection/experimental/grids/grid.ts +1 -1
  302. package/src/projection/experimental/grids/ntv2.ts +1 -1
  303. package/src/projection/experimental/helmert-flat.ts +1 -1
  304. package/src/projection/experimental/kernels/aea.ts +1 -1
  305. package/src/projection/experimental/kernels/aeqd.ts +1 -1
  306. package/src/projection/experimental/kernels/bonne.ts +1 -1
  307. package/src/projection/experimental/kernels/cass.ts +1 -1
  308. package/src/projection/experimental/kernels/cea.ts +1 -1
  309. package/src/projection/experimental/kernels/eck6.ts +1 -1
  310. package/src/projection/experimental/kernels/eqdc.ts +1 -1
  311. package/src/projection/experimental/kernels/eqearth.ts +1 -1
  312. package/src/projection/experimental/kernels/equi.ts +1 -1
  313. package/src/projection/experimental/kernels/etmerc.ts +1 -1
  314. package/src/projection/experimental/kernels/gauss.ts +1 -1
  315. package/src/projection/experimental/kernels/geos.ts +1 -1
  316. package/src/projection/experimental/kernels/gnom.ts +1 -1
  317. package/src/projection/experimental/kernels/gstmerc.ts +1 -1
  318. package/src/projection/experimental/kernels/krovak.ts +1 -1
  319. package/src/projection/experimental/kernels/laea.ts +1 -1
  320. package/src/projection/experimental/kernels/lcc.ts +1 -1
  321. package/src/projection/experimental/kernels/mill.ts +1 -1
  322. package/src/projection/experimental/kernels/moll.ts +1 -1
  323. package/src/projection/experimental/kernels/nzmg.ts +1 -1
  324. package/src/projection/experimental/kernels/omerc.ts +1 -1
  325. package/src/projection/experimental/kernels/ortho.ts +1 -1
  326. package/src/projection/experimental/kernels/poly.ts +1 -1
  327. package/src/projection/experimental/kernels/qsc.ts +1 -1
  328. package/src/projection/experimental/kernels/robin.ts +1 -1
  329. package/src/projection/experimental/kernels/sinu.ts +1 -1
  330. package/src/projection/experimental/kernels/somerc.ts +1 -1
  331. package/src/projection/experimental/kernels/stere.ts +1 -1
  332. package/src/projection/experimental/kernels/sterea.ts +1 -1
  333. package/src/projection/experimental/kernels/tmerc.ts +1 -1
  334. package/src/projection/experimental/kernels/tpers.ts +1 -1
  335. package/src/projection/experimental/kernels/vandg.ts +1 -1
  336. package/src/projection/experimental/kinematic-helmert-flat.ts +1 -1
  337. package/src/projection/experimental/kinematic-helmert.ts +1 -1
  338. package/src/projection/experimental/projection-pipeline.ts +1 -1
  339. package/src/projection/experimental/projections/equidistant-cylindrical.ts +1 -0
  340. package/src/projection/experimental/projections/mercator.ts +1 -0
  341. package/src/projection/experimental/projections/ob-tran.ts +1 -1
  342. package/src/projection/experimental/transform-description.ts +82 -0
  343. package/src/projection/experimental/types.ts +5 -0
  344. package/src/projection/experimental/typescript-projection.ts +54 -6
  345. package/src/projection/transform-description.ts +69 -0
  346. package/src/projection/types.ts +11 -0
  347. package/src/tasks/definitions.ts +1 -1
  348. package/src/tasks/index.ts +1 -1
  349. package/src/tasks/map-worker.ts +1 -1
  350. package/src/tasks/operations.ts +1 -1
  351. package/src/tasks/projection-worker.ts +1 -1
  352. package/src/terrain/contour-boundary-diagnostics.ts +90 -0
  353. package/src/terrain/contour-mixed-weld.ts +254 -0
  354. package/src/terrain/contour-tile-paths.ts +20 -0
  355. package/src/terrain/contour-tile-weld.ts +182 -0
  356. package/src/terrain/gradient-pyramid.ts +129 -0
  357. package/src/terrain/height-field.ts +45 -5
  358. package/src/terrain/index.ts +12 -0
  359. package/src/terrain/tiled.ts +16 -3
  360. package/src/terrain/types.ts +9 -1
  361. package/src/turf.ts +7 -3
  362. package/crs/README.md +0 -84
  363. package/crs/schemas/README.md +0 -9
  364. package/dist/geoarrow/builder-entry.d.ts +0 -4
  365. package/dist/geoarrow/builder-entry.d.ts.map +0 -1
  366. package/dist/geoarrow/builder-entry.js +0 -5
  367. package/dist/geoarrow/builder-entry.js.map +0 -1
  368. package/dist/geoarrow/builder.d.ts +0 -106
  369. package/dist/geoarrow/builder.d.ts.map +0 -1
  370. package/dist/geoarrow/builder.js +0 -668
  371. package/dist/geoarrow/builder.js.map +0 -1
  372. package/dist/geoarrow/codecs.d.ts +0 -24
  373. package/dist/geoarrow/codecs.d.ts.map +0 -1
  374. package/dist/geoarrow/codecs.js +0 -916
  375. package/dist/geoarrow/codecs.js.map +0 -1
  376. package/dist/geoarrow/index.cjs +0 -4352
  377. package/dist/geoarrow/index.cjs.map +0 -6
  378. package/dist/geoarrow/index.d.ts +0 -21
  379. package/dist/geoarrow/index.d.ts.map +0 -1
  380. package/dist/geoarrow/index.js +0 -15
  381. package/dist/geoarrow/index.js.map +0 -1
  382. package/dist/geoarrow/kernels.d.ts +0 -56
  383. package/dist/geoarrow/kernels.d.ts.map +0 -1
  384. package/dist/geoarrow/kernels.js +0 -982
  385. package/dist/geoarrow/kernels.js.map +0 -1
  386. package/dist/geoarrow/layout.d.ts +0 -66
  387. package/dist/geoarrow/layout.d.ts.map +0 -1
  388. package/dist/geoarrow/layout.js +0 -723
  389. package/dist/geoarrow/layout.js.map +0 -1
  390. package/dist/geoarrow/stream-tessellate.d.ts +0 -34
  391. package/dist/geoarrow/stream-tessellate.d.ts.map +0 -1
  392. package/dist/geoarrow/stream-tessellate.js +0 -171
  393. package/dist/geoarrow/stream-tessellate.js.map +0 -1
  394. package/dist/geoarrow/stream.d.ts +0 -29
  395. package/dist/geoarrow/stream.d.ts.map +0 -1
  396. package/dist/geoarrow/stream.js +0 -100
  397. package/dist/geoarrow/stream.js.map +0 -1
  398. package/dist/geoarrow/tessellate.d.ts +0 -31
  399. package/dist/geoarrow/tessellate.d.ts.map +0 -1
  400. package/dist/geoarrow/tessellate.js +0 -102
  401. package/dist/geoarrow/tessellate.js.map +0 -1
  402. package/dist/geoarrow/tessellation-entry.d.ts +0 -4
  403. package/dist/geoarrow/tessellation-entry.d.ts.map +0 -1
  404. package/dist/geoarrow/tessellation-entry.js +0 -5
  405. package/dist/geoarrow/tessellation-entry.js.map +0 -1
  406. package/dist/geoarrow/types.d.ts +0 -155
  407. package/dist/geoarrow/types.d.ts.map +0 -1
  408. package/dist/geoarrow/types.js +0 -71
  409. package/dist/geoarrow/types.js.map +0 -1
  410. package/dist/geoarrow/views.d.ts +0 -45
  411. package/dist/geoarrow/views.d.ts.map +0 -1
  412. package/dist/geoarrow/views.js +0 -114
  413. package/dist/geoarrow/views.js.map +0 -1
  414. package/dist/geoarrow/wkb-entry.d.ts +0 -4
  415. package/dist/geoarrow/wkb-entry.d.ts.map +0 -1
  416. package/dist/geoarrow/wkb-entry.js +0 -6
  417. package/dist/geoarrow/wkb-entry.js.map +0 -1
  418. package/dist/geoarrow/worker.d.ts +0 -11
  419. package/dist/geoarrow/worker.d.ts.map +0 -1
  420. package/dist/geoarrow/worker.js +0 -10
  421. package/dist/geoarrow/worker.js.map +0 -1
  422. package/dist/wkb/index.d.ts +0 -11
  423. package/dist/wkb/index.d.ts.map +0 -1
  424. package/dist/wkb/index.js +0 -9
  425. package/dist/wkb/index.js.map +0 -1
  426. package/dist/wkb/types.d.ts +0 -30
  427. package/dist/wkb/types.d.ts.map +0 -1
  428. package/dist/wkb/types.js +0 -34
  429. package/dist/wkb/types.js.map +0 -1
  430. package/dist/wkb/wkb-builder.d.ts +0 -91
  431. package/dist/wkb/wkb-builder.d.ts.map +0 -1
  432. package/dist/wkb/wkb-builder.js +0 -283
  433. package/dist/wkb/wkb-builder.js.map +0 -1
  434. package/dist/wkb/wkb-reader.d.ts +0 -74
  435. package/dist/wkb/wkb-reader.d.ts.map +0 -1
  436. package/dist/wkb/wkb-reader.js +0 -251
  437. package/dist/wkb/wkb-reader.js.map +0 -1
  438. package/dist/wkb/wkb.d.ts +0 -21
  439. package/dist/wkb/wkb.d.ts.map +0 -1
  440. package/dist/wkb/wkb.js +0 -204
  441. package/dist/wkb/wkb.js.map +0 -1
  442. package/dist/wkb/wkt.d.ts +0 -19
  443. package/dist/wkb/wkt.d.ts.map +0 -1
  444. package/dist/wkb/wkt.js +0 -321
  445. package/dist/wkb/wkt.js.map +0 -1
  446. package/projection/THIRD-PARTY-NOTICES.md +0 -210
  447. package/src/discontinuous/elastic/README.md +0 -20
  448. package/src/discontinuous/spherical-clip/README.md +0 -16
  449. package/src/discontinuous/world-kernels/README.md +0 -24
  450. package/src/geoarrow/builder-entry.ts +0 -18
  451. package/src/geoarrow/builder.ts +0 -860
  452. package/src/geoarrow/codecs.ts +0 -1268
  453. package/src/geoarrow/index.ts +0 -111
  454. package/src/geoarrow/kernels.ts +0 -1290
  455. package/src/geoarrow/layout.ts +0 -900
  456. package/src/geoarrow/stream-tessellate.ts +0 -205
  457. package/src/geoarrow/stream.ts +0 -130
  458. package/src/geoarrow/tessellate.ts +0 -133
  459. package/src/geoarrow/tessellation-entry.ts +0 -7
  460. package/src/geoarrow/types.ts +0 -259
  461. package/src/geoarrow/views.ts +0 -150
  462. package/src/geoarrow/wkb-entry.ts +0 -13
  463. package/src/geoarrow/worker.ts +0 -20
  464. package/src/terrain/vendor/README.md +0 -20
  465. package/src/vendor/geographiclib-geodesic/README.md +0 -26
  466. package/src/wkb/index.ts +0 -38
  467. package/src/wkb/types.ts +0 -54
  468. package/src/wkb/wkb-builder.ts +0 -395
  469. package/src/wkb/wkb-reader.ts +0 -401
  470. package/src/wkb/wkb.ts +0 -255
  471. package/src/wkb/wkt.ts +0 -375
  472. /package/{projection/APACHE-2.0-LICENSE.txt → APACHE-2.0-LICENSE.txt} +0 -0
  473. /package/{projection/PROJ-LICENSE.txt → PROJ-LICENSE.txt} +0 -0
  474. /package/{projection/PROJ4-LICENSE.md → PROJ4-LICENSE.md} +0 -0
  475. /package/{crs/schemas → src/crs}/projjson.schema.json +0 -0
@@ -1,860 +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
- GeoArrowCoordinateLayout,
9
- GeoArrowDenseUnion,
10
- GeoArrowDimension,
11
- GeoArrowEncoding,
12
- GeoArrowGeometryValue,
13
- GeoArrowOffsets,
14
- GeoArrowStruct
15
- } from './types';
16
- import {
17
- getGeoArrowDimensionSize,
18
- getGeoArrowEncodingForGeometry,
19
- getGeoArrowGeometryType
20
- } from './types';
21
-
22
- /** Concrete native encodings accepted by {@link GeoArrowBuilder}. */
23
- export type GeoArrowBuilderEncoding = Exclude<
24
- GeoArrowEncoding,
25
- | 'geoarrow.geometry'
26
- | 'geoarrow.geometrycollection'
27
- | 'geoarrow.box'
28
- | 'geoarrow.wkb'
29
- | 'geoarrow.wkt'
30
- >;
31
-
32
- /** Buffer counts produced by a measure pass. */
33
- export type GeoArrowBuilderMeasurement = Readonly<{
34
- length: number;
35
- nullCount: number;
36
- coordinateCount: number;
37
- geometryOffsetCount: number;
38
- partOffsetCount: number;
39
- ringOffsetCount: number;
40
- }>;
41
-
42
- /** Caller-owned buffers filled by a builder write pass. */
43
- export type GeoArrowBuilderTarget = {
44
- validity: Uint8Array;
45
- coordinates:
46
- | Float32Array
47
- | Float64Array
48
- | {
49
- x: Float32Array | Float64Array;
50
- y: Float32Array | Float64Array;
51
- z?: Float32Array | Float64Array;
52
- m?: Float32Array | Float64Array;
53
- };
54
- geometryOffsets?: GeoArrowOffsets;
55
- partOffsets?: GeoArrowOffsets;
56
- ringOffsets?: GeoArrowOffsets;
57
- };
58
-
59
- /** Common builder options. */
60
- export type GeoArrowBuilderOptions = Readonly<{
61
- encoding: GeoArrowBuilderEncoding;
62
- dimension?: GeoArrowDimension;
63
- coordinateLayout?: GeoArrowCoordinateLayout;
64
- offsetType?: 'int32' | 'int64';
65
- coordinateType?: 'float32' | 'float64';
66
- }>;
67
-
68
- /** Options for materializing a column from geometry values. */
69
- export type GeoArrowColumnFromRowsOptions = Omit<GeoArrowBuilderOptions, 'encoding'> &
70
- Readonly<{
71
- /** Forces homogeneous values into a dense-union column. */
72
- encoding?: 'geoarrow.geometry';
73
- }>;
74
-
75
- /** Measure-pass options. */
76
- export type GeoArrowBuilderMeasureOptions = GeoArrowBuilderOptions & Readonly<{mode: 'measure'}>;
77
-
78
- /** Write-pass options. */
79
- export type GeoArrowBuilderWriteOptions = GeoArrowBuilderOptions &
80
- Readonly<{mode: 'write'; target: GeoArrowBuilderTarget}>;
81
-
82
- /** Options accepted by the incremental builder. */
83
- export type GeoArrowBuilderModeOptions =
84
- | GeoArrowBuilderMeasureOptions
85
- | GeoArrowBuilderWriteOptions;
86
-
87
- /**
88
- * Two-pass writer for homogeneous native GeoArrow geometry columns.
89
- *
90
- * Feed the same rows to a measure builder, allocate its target, and then feed them to a write
91
- * builder. The write result borrows the supplied target buffers.
92
- */
93
- export class GeoArrowBuilder {
94
- readonly encoding: GeoArrowBuilderEncoding;
95
- readonly dimension: GeoArrowDimension;
96
- readonly coordinateLayout: GeoArrowCoordinateLayout;
97
- readonly offsetType: 'int32' | 'int64';
98
- readonly coordinateType: 'float32' | 'float64';
99
- private readonly mode: 'measure' | 'write';
100
- private readonly target?: GeoArrowBuilderTarget;
101
- private length = 0;
102
- private nullCount = 0;
103
- private coordinateCount = 0;
104
- private partCount = 0;
105
- private ringCount = 0;
106
- private readonly eventStack: Array<{
107
- type: GeoArrowGeometryValue['type'];
108
- dimension: GeoArrowDimension;
109
- direct: boolean;
110
- rowIndex: number;
111
- ringStarted: boolean;
112
- polygonStarted: boolean;
113
- rings?: number[][][];
114
- polygons?: number[][][][];
115
- currentPolygon?: number[][][];
116
- currentRing?: number[][];
117
- children?: GeoArrowGeometryValue[];
118
- }> = [];
119
-
120
- constructor(options: GeoArrowBuilderModeOptions) {
121
- this.mode = options.mode;
122
- this.encoding = options.encoding;
123
- this.dimension = options.dimension || 'xy';
124
- this.coordinateLayout = options.coordinateLayout || 'interleaved';
125
- this.offsetType = options.offsetType || 'int32';
126
- this.coordinateType = options.coordinateType || 'float64';
127
- this.target = options.mode === 'write' ? options.target : undefined;
128
- if (this.target) this.initializeTargetOffsets(this.target);
129
- }
130
-
131
- /** Appends one geometry row or null. */
132
- append(geometry: GeoArrowGeometryValue | null | undefined): this {
133
- const rowIndex = this.length++;
134
- if (!geometry) {
135
- this.nullCount++;
136
- this.appendNull(rowIndex);
137
- return this;
138
- }
139
- const expectedType = getGeoArrowGeometryType(this.encoding);
140
- if (geometry.type !== expectedType) {
141
- throw new Error(`GeoArrowBuilder for ${this.encoding} cannot append ${geometry.type}`);
142
- }
143
- if (geometry.type === 'GeometryCollection') {
144
- throw new Error('GeoArrowBuilder only accepts concrete geometry families');
145
- }
146
- if (this.target) setValidityBit(this.target.validity, rowIndex);
147
-
148
- const depth = getBuilderDepth(this.encoding);
149
- const coordinates = geometry.coordinates as readonly unknown[];
150
- if (depth === 0) {
151
- this.writeCoordinateValues(coordinates as readonly number[]);
152
- } else if (depth === 1) {
153
- this.writeCoordinateList(coordinates as readonly (readonly number[])[]);
154
- this.writeOffset(this.target?.geometryOffsets, rowIndex + 1, this.coordinateCount);
155
- } else if (depth === 2) {
156
- for (const part of coordinates as readonly (readonly (readonly number[])[])[]) {
157
- this.writeCoordinateList(part);
158
- this.partCount++;
159
- this.writeOffset(this.target?.partOffsets, this.partCount, this.coordinateCount);
160
- }
161
- this.writeOffset(this.target?.geometryOffsets, rowIndex + 1, this.partCount);
162
- } else {
163
- for (const polygon of coordinates as readonly (readonly (readonly (readonly number[])[])[])[]) {
164
- for (const ring of polygon) {
165
- this.writeCoordinateList(ring);
166
- this.ringCount++;
167
- this.writeOffset(this.target?.ringOffsets, this.ringCount, this.coordinateCount);
168
- }
169
- this.partCount++;
170
- this.writeOffset(this.target?.partOffsets, this.partCount, this.ringCount);
171
- }
172
- this.writeOffset(this.target?.geometryOffsets, rowIndex + 1, this.partCount);
173
- }
174
- return this;
175
- }
176
-
177
- /** Returns current exact allocation counts. */
178
- getMeasurement(): GeoArrowBuilderMeasurement {
179
- const depth = getBuilderDepth(this.encoding);
180
- return {
181
- length: this.length,
182
- nullCount: this.nullCount,
183
- coordinateCount: this.coordinateCount,
184
- geometryOffsetCount: depth >= 1 ? this.length + 1 : 0,
185
- partOffsetCount: depth >= 2 ? this.partCount + 1 : 0,
186
- ringOffsetCount: depth >= 3 ? this.ringCount + 1 : 0
187
- };
188
- }
189
-
190
- /** Allocates a write target from the current measure pass. */
191
- allocateTarget(): GeoArrowBuilderTarget {
192
- if (this.mode !== 'measure') throw new Error('Only a measure builder can allocate a target');
193
- return allocateGeoArrowBuilderTarget(this.getMeasurement(), {
194
- encoding: this.encoding,
195
- dimension: this.dimension,
196
- coordinateLayout: this.coordinateLayout,
197
- offsetType: this.offsetType,
198
- coordinateType: this.coordinateType
199
- });
200
- }
201
-
202
- /** Finishes a write pass and returns a one-chunk borrowed column. */
203
- finish(): GeoArrowColumn {
204
- if (!this.target) throw new Error('A measure builder has no finished column');
205
- const measurement = this.getMeasurement();
206
- assertTargetCapacity(this.target, measurement, getGeoArrowDimensionSize(this.dimension));
207
- const coordinates = makeCoordinateArray(
208
- this.target.coordinates,
209
- measurement.coordinateCount,
210
- this.dimension,
211
- this.coordinateLayout
212
- );
213
- const depth = getBuilderDepth(this.encoding);
214
- let chunk: GeoArrowArray = coordinates;
215
- if (depth >= 3) {
216
- chunk = {
217
- kind: 'list',
218
- length: this.ringCount,
219
- offsets: this.target.ringOffsets!,
220
- child: chunk
221
- };
222
- }
223
- if (depth >= 2) {
224
- chunk = {
225
- kind: 'list',
226
- length: this.partCount,
227
- offsets: this.target.partOffsets!,
228
- child: chunk
229
- };
230
- }
231
- if (depth >= 1) {
232
- chunk = {
233
- kind: 'list',
234
- length: this.length,
235
- offsets: this.target.geometryOffsets!,
236
- child: chunk,
237
- validity: {values: this.target.validity}
238
- };
239
- } else {
240
- chunk = {...chunk, validity: {values: this.target.validity}};
241
- }
242
- return {
243
- encoding: this.encoding,
244
- dimension: this.dimension,
245
- coordinateLayout: this.coordinateLayout,
246
- chunks: [chunk]
247
- };
248
- }
249
-
250
- /** Builds a homogeneous column using an internal measure/write pair. */
251
- static build(
252
- rows: readonly (GeoArrowGeometryValue | null | undefined)[],
253
- options: GeoArrowBuilderOptions
254
- ): GeoArrowColumn {
255
- const measure = new GeoArrowBuilder({...options, mode: 'measure'});
256
- for (const row of rows) measure.append(row);
257
- const write = new GeoArrowBuilder({
258
- ...options,
259
- mode: 'write',
260
- target: measure.allocateTarget()
261
- });
262
- for (const row of rows) write.append(row);
263
- return write.finish();
264
- }
265
-
266
- private appendNull(rowIndex: number): void {
267
- const depth = getBuilderDepth(this.encoding);
268
- if (depth === 0) {
269
- this.writeCoordinateValues(new Array(getGeoArrowDimensionSize(this.dimension)).fill(0));
270
- } else {
271
- this.writeOffset(
272
- this.target?.geometryOffsets,
273
- rowIndex + 1,
274
- depth === 1 ? this.coordinateCount : this.partCount
275
- );
276
- }
277
- }
278
-
279
- private writeCoordinateList(coordinates: readonly (readonly number[])[]): void {
280
- for (const coordinate of coordinates) this.writeCoordinateValues(coordinate);
281
- }
282
-
283
- private writeCoordinateValues(coordinate: readonly number[]): void {
284
- const size = getGeoArrowDimensionSize(this.dimension);
285
- if (
286
- coordinate.length === 0 &&
287
- (this.encoding === 'geoarrow.point' || this.encoding === 'geoarrow.multipoint')
288
- ) {
289
- coordinate = new Array(size).fill(Number.NaN);
290
- }
291
- if (coordinate.length !== size) {
292
- throw new Error(`Expected ${size} coordinate values for ${this.dimension}`);
293
- }
294
- if (this.target)
295
- writeCoordinate(this.target.coordinates, this.coordinateCount, coordinate, this.dimension);
296
- this.coordinateCount++;
297
- }
298
-
299
- private writeCoordinateComponents(
300
- x: number,
301
- y: number,
302
- z: number | undefined,
303
- m: number | undefined,
304
- sourceDimension: GeoArrowDimension
305
- ): void {
306
- const targetZ = sourceDimension === 'xyz' || sourceDimension === 'xyzm' ? (z ?? 0) : 0;
307
- const targetM = sourceDimension === 'xym' || sourceDimension === 'xyzm' ? (m ?? 0) : 0;
308
- if (this.target) {
309
- writeCoordinateComponents(
310
- this.target.coordinates,
311
- this.coordinateCount,
312
- x,
313
- y,
314
- targetZ,
315
- targetM,
316
- this.dimension
317
- );
318
- }
319
- this.coordinateCount++;
320
- }
321
-
322
- /** Begins an event-driven geometry. Events are accepted by both measure and write builders. */
323
- beginGeometry(
324
- type: GeoArrowGeometryValue['type'],
325
- dimension = this.dimension,
326
- _count?: number
327
- ): this {
328
- const direct = getGeoArrowGeometryType(this.encoding) === type;
329
- const rowIndex = direct ? this.length++ : -1;
330
- this.eventStack.push({
331
- type,
332
- dimension,
333
- direct,
334
- rowIndex,
335
- ringStarted: false,
336
- polygonStarted: false,
337
- ...(direct ? {} : {rings: [], polygons: []}),
338
- ...(direct ? {} : {children: []})
339
- });
340
- return this;
341
- }
342
-
343
- /** Begins a polygon part inside an event-built MultiPolygon. */
344
- beginPolygon(): this {
345
- const state = this.eventStack[this.eventStack.length - 1];
346
- if (!state || state.type !== 'MultiPolygon') {
347
- throw new Error("beginPolygon must follow beginGeometry('MultiPolygon')");
348
- }
349
- if (state.direct) {
350
- this.finishEventRing(state);
351
- this.finishEventPolygon(state);
352
- state.polygonStarted = true;
353
- return this;
354
- }
355
- state.currentPolygon = [];
356
- state.polygons!.push(state.currentPolygon);
357
- state.currentRing = undefined;
358
- return this;
359
- }
360
-
361
- /** Begins a ring/part in the current event geometry. */
362
- beginRing(_count?: number): this {
363
- const state = this.eventStack[this.eventStack.length - 1];
364
- if (!state) throw new Error('beginRing must follow beginGeometry');
365
- if (state.direct) {
366
- this.finishEventRing(state);
367
- state.ringStarted = true;
368
- return this;
369
- }
370
- state.currentRing = [];
371
- if (state.type === 'MultiPolygon') {
372
- if (!state.currentPolygon) this.beginPolygon();
373
- state.currentPolygon!.push(state.currentRing);
374
- } else {
375
- state.rings!.push(state.currentRing);
376
- }
377
- return this;
378
- }
379
-
380
- /** Writes one coordinate into the current event ring or point. */
381
- writeCoordinate(x: number | readonly number[], y?: number, z?: number, m?: number): this {
382
- const state = this.eventStack[this.eventStack.length - 1];
383
- if (!state) throw new Error('writeCoordinate must follow beginGeometry');
384
- if (typeof x === 'number' && state.direct) {
385
- this.writeCoordinateComponents(x, y!, z, m, state.dimension);
386
- return this;
387
- }
388
- const coordinate = Array.isArray(x)
389
- ? [...x]
390
- : [x, y!, ...(z === undefined ? [] : [z]), ...(m === undefined ? [] : [m])];
391
- const size = getGeoArrowDimensionSize(state.dimension);
392
- if (coordinate.length !== size)
393
- throw new Error(`Expected ${size} coordinate values for ${state.dimension}`);
394
- if (state.direct) {
395
- this.writeCoordinateValues(
396
- resizeEventCoordinate(coordinate, state.dimension, this.dimension)
397
- );
398
- return this;
399
- }
400
- if (state.type === 'Point') {
401
- state.rings = [[coordinate]];
402
- return this;
403
- }
404
- if (!state.currentRing) this.beginRing();
405
- state.currentRing!.push(coordinate);
406
- return this;
407
- }
408
-
409
- /** Writes scalar ordinates tagged with their source dimension without allocating a tuple. */
410
- writeCoordinateFromDimension(
411
- x: number,
412
- y: number,
413
- z: number | undefined,
414
- m: number | undefined,
415
- sourceDimension: GeoArrowDimension
416
- ): this {
417
- const state = this.eventStack[this.eventStack.length - 1];
418
- if (!state) throw new Error('writeCoordinateFromDimension must follow beginGeometry');
419
- if (state.direct) {
420
- this.writeCoordinateComponents(x, y, z, m, sourceDimension);
421
- return this;
422
- }
423
- const coordinate = getDimensionNames(state.dimension).map(name => {
424
- if (name === 'x') return x;
425
- if (name === 'y') return y;
426
- if (name === 'z')
427
- return sourceDimension === 'xyz' || sourceDimension === 'xyzm' ? (z ?? 0) : 0;
428
- return sourceDimension === 'xym' || sourceDimension === 'xyzm' ? (m ?? 0) : 0;
429
- });
430
- return this.writeCoordinate(coordinate);
431
- }
432
-
433
- /** Ends the current event geometry and appends it to the builder/parent. */
434
- endGeometry(): this {
435
- const state = this.eventStack.pop();
436
- if (!state) throw new Error('endGeometry without beginGeometry');
437
- if (state.direct) {
438
- this.finishEventRing(state);
439
- this.finishEventPolygon(state);
440
- const depth = getBuilderDepth(this.encoding);
441
- if (depth >= 1) {
442
- this.writeOffset(
443
- this.target?.geometryOffsets,
444
- state.rowIndex + 1,
445
- depth === 1 ? this.coordinateCount : this.partCount
446
- );
447
- }
448
- if (this.target) setValidityBit(this.target.validity, state.rowIndex);
449
- return this;
450
- }
451
- const coordinates = state.rings || [];
452
- let geometry: GeoArrowGeometryValue;
453
- switch (state.type) {
454
- case 'Point':
455
- geometry = {type: 'Point', coordinates: coordinates[0]?.[0] || []};
456
- break;
457
- case 'LineString':
458
- geometry = {type: 'LineString', coordinates: coordinates[0] || []};
459
- break;
460
- case 'MultiPoint':
461
- geometry = {type: 'MultiPoint', coordinates: coordinates.flat()};
462
- break;
463
- case 'Polygon':
464
- geometry = {type: 'Polygon', coordinates};
465
- break;
466
- case 'MultiLineString':
467
- geometry = {type: 'MultiLineString', coordinates};
468
- break;
469
- case 'MultiPolygon':
470
- geometry = {
471
- type: 'MultiPolygon',
472
- coordinates: state.polygons?.length ? state.polygons : [coordinates]
473
- };
474
- break;
475
- case 'GeometryCollection':
476
- geometry = {type: 'GeometryCollection', geometries: state.children || []};
477
- break;
478
- }
479
- const parent = this.eventStack[this.eventStack.length - 1];
480
- if (parent?.type === 'GeometryCollection') parent.children!.push(geometry);
481
- else this.append(geometry);
482
- return this;
483
- }
484
-
485
- private writeOffset(target: GeoArrowOffsets | undefined, index: number, value: number): void {
486
- if (!target) return;
487
- if (target instanceof BigInt64Array) target[index] = BigInt(value);
488
- else target[index] = value;
489
- }
490
-
491
- private finishEventRing(state: (typeof this.eventStack)[number]): void {
492
- if (!state.direct || !state.ringStarted) return;
493
- if (this.encoding === 'geoarrow.multipolygon') {
494
- this.ringCount++;
495
- this.writeOffset(this.target?.ringOffsets, this.ringCount, this.coordinateCount);
496
- } else if (getBuilderDepth(this.encoding) >= 2) {
497
- this.partCount++;
498
- this.writeOffset(this.target?.partOffsets, this.partCount, this.coordinateCount);
499
- }
500
- state.ringStarted = false;
501
- }
502
-
503
- private finishEventPolygon(state: (typeof this.eventStack)[number]): void {
504
- if (!state.direct || !state.polygonStarted) return;
505
- if (this.encoding === 'geoarrow.multipolygon') {
506
- this.partCount++;
507
- this.writeOffset(this.target?.partOffsets, this.partCount, this.ringCount);
508
- }
509
- state.polygonStarted = false;
510
- }
511
-
512
- private initializeTargetOffsets(target: GeoArrowBuilderTarget): void {
513
- this.writeOffset(target.geometryOffsets, 0, 0);
514
- this.writeOffset(target.partOffsets, 0, 0);
515
- this.writeOffset(target.ringOffsets, 0, 0);
516
- }
517
- }
518
-
519
- /** Allocates exact buffers for one measured builder pass. */
520
- export function allocateGeoArrowBuilderTarget(
521
- measurement: GeoArrowBuilderMeasurement,
522
- options: GeoArrowBuilderOptions
523
- ): GeoArrowBuilderTarget {
524
- const dimension = options.dimension || 'xy';
525
- const size = getGeoArrowDimensionSize(dimension);
526
- const FloatArray = options.coordinateType === 'float32' ? Float32Array : Float64Array;
527
- const coordinateLayout = options.coordinateLayout || 'interleaved';
528
- const coordinates =
529
- coordinateLayout === 'interleaved'
530
- ? new FloatArray(measurement.coordinateCount * size)
531
- : makeSeparatedCoordinateTarget(FloatArray, measurement.coordinateCount, dimension);
532
- const OffsetArray = options.offsetType === 'int64' ? BigInt64Array : Int32Array;
533
- return {
534
- validity: new Uint8Array(Math.ceil(measurement.length / 8)),
535
- coordinates,
536
- geometryOffsets: measurement.geometryOffsetCount
537
- ? new OffsetArray(measurement.geometryOffsetCount)
538
- : undefined,
539
- partOffsets: measurement.partOffsetCount
540
- ? new OffsetArray(measurement.partOffsetCount)
541
- : undefined,
542
- ringOffsets: measurement.ringOffsetCount
543
- ? new OffsetArray(measurement.ringOffsetCount)
544
- : undefined
545
- };
546
- }
547
-
548
- /** Builds a concrete or dense-union column from materialized rows. */
549
- export function makeGeoArrowColumnFromGeometryRows(
550
- rows: readonly (GeoArrowGeometryValue | null)[],
551
- options: GeoArrowColumnFromRowsOptions = {}
552
- ): GeoArrowColumn {
553
- const geometryTypes = [...new Set(rows.filter(Boolean).map(row => row!.type))];
554
- const dimension = options.dimension || inferRowsDimension(rows);
555
- if (options.encoding === 'geoarrow.geometry') {
556
- return {
557
- encoding: 'geoarrow.geometry',
558
- dimension,
559
- coordinateLayout: options.coordinateLayout || 'interleaved',
560
- chunks: [makeDenseUnionArray(rows, options, dimension)]
561
- };
562
- }
563
- if (geometryTypes.length === 0) {
564
- return GeoArrowBuilder.build(rows, {...options, dimension, encoding: 'geoarrow.point'});
565
- }
566
- if (geometryTypes.length === 1 && geometryTypes[0] !== 'GeometryCollection') {
567
- return GeoArrowBuilder.build(rows, {
568
- ...options,
569
- dimension,
570
- encoding: getGeoArrowEncodingForGeometry(geometryTypes[0]) as GeoArrowBuilderEncoding
571
- });
572
- }
573
- if (geometryTypes.length === 1 && geometryTypes[0] === 'GeometryCollection') {
574
- return {
575
- encoding: 'geoarrow.geometrycollection',
576
- dimension,
577
- coordinateLayout: options.coordinateLayout || 'interleaved',
578
- chunks: [makeGeometryCollectionArray(rows, options, dimension)]
579
- };
580
- }
581
- return {
582
- encoding: 'geoarrow.geometry',
583
- dimension,
584
- coordinateLayout: options.coordinateLayout || 'interleaved',
585
- chunks: [makeDenseUnionArray(rows, options, dimension)]
586
- };
587
- }
588
-
589
- function makeDenseUnionArray(
590
- rows: readonly (GeoArrowGeometryValue | null)[],
591
- options: GeoArrowColumnFromRowsOptions,
592
- dimension: GeoArrowDimension
593
- ): GeoArrowDenseUnion {
594
- const nonNullTypes = [...new Set(rows.filter(Boolean).map(row => row!.type))];
595
- const fallbackType = nonNullTypes[0] || 'Point';
596
- const childRows = new Map<GeoArrowGeometryValue['type'], Array<GeoArrowGeometryValue | null>>();
597
- for (const type of nonNullTypes.length ? nonNullTypes : [fallbackType]) childRows.set(type, []);
598
- const typeIds = new Int8Array(rows.length);
599
- const valueOffsets = new Int32Array(rows.length);
600
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
601
- const geometry = rows[rowIndex];
602
- const type = geometry?.type || fallbackType;
603
- const values = childRows.get(type) || [];
604
- typeIds[rowIndex] = getGeometryTypeId(type, dimension);
605
- valueOffsets[rowIndex] = values.length;
606
- values.push(geometry);
607
- childRows.set(type, values);
608
- }
609
- const children = [...childRows.entries()]
610
- .sort(
611
- ([left], [right]) => getGeometryTypeId(left, dimension) - getGeometryTypeId(right, dimension)
612
- )
613
- .map(([type, values]) => {
614
- const data =
615
- type === 'GeometryCollection'
616
- ? makeGeometryCollectionArray(values, options, dimension)
617
- : GeoArrowBuilder.build(values, {
618
- ...options,
619
- dimension,
620
- encoding: getGeoArrowEncodingForGeometry(type) as GeoArrowBuilderEncoding
621
- }).chunks[0];
622
- return {
623
- name: type,
624
- typeId: getGeometryTypeId(type, dimension),
625
- encoding: getGeoArrowEncodingForGeometry(type),
626
- dimension,
627
- coordinateLayout: options.coordinateLayout || 'interleaved',
628
- data
629
- };
630
- });
631
- return {
632
- kind: 'dense-union',
633
- length: rows.length,
634
- typeIds,
635
- valueOffsets,
636
- children
637
- };
638
- }
639
-
640
- function makeGeometryCollectionArray(
641
- rows: readonly (GeoArrowGeometryValue | null)[],
642
- options: GeoArrowColumnFromRowsOptions,
643
- dimension: GeoArrowDimension
644
- ): GeoArrowArray {
645
- const offsets = new Int32Array(rows.length + 1);
646
- const validity = new Uint8Array(Math.ceil(rows.length / 8));
647
- const flattened: GeoArrowGeometryValue[] = [];
648
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
649
- const row = rows[rowIndex];
650
- if (row?.type === 'GeometryCollection') {
651
- flattened.push(...row.geometries);
652
- setValidityBit(validity, rowIndex);
653
- }
654
- offsets[rowIndex + 1] = flattened.length;
655
- }
656
- return {
657
- kind: 'list',
658
- length: rows.length,
659
- offsets,
660
- child: makeDenseUnionArray(flattened, options, dimension),
661
- validity: {values: validity}
662
- };
663
- }
664
-
665
- function makeCoordinateArray(
666
- coordinates: GeoArrowBuilderTarget['coordinates'],
667
- coordinateCount: number,
668
- dimension: GeoArrowDimension,
669
- layout: GeoArrowCoordinateLayout
670
- ): GeoArrowArray {
671
- const size = getGeoArrowDimensionSize(dimension);
672
- if (layout === 'interleaved') {
673
- const values = coordinates as Float32Array | Float64Array;
674
- return {
675
- kind: 'fixed-size-list',
676
- length: coordinateCount,
677
- size,
678
- child: {kind: 'primitive', length: coordinateCount * size, values}
679
- };
680
- }
681
- const separated = coordinates as Exclude<
682
- GeoArrowBuilderTarget['coordinates'],
683
- Float32Array | Float64Array
684
- >;
685
- const children: Record<string, GeoArrowArray> = {
686
- x: {kind: 'primitive', length: coordinateCount, values: separated.x},
687
- y: {kind: 'primitive', length: coordinateCount, values: separated.y}
688
- };
689
- if (separated.z) {
690
- children['z'] = {kind: 'primitive', length: coordinateCount, values: separated.z};
691
- }
692
- if (separated.m) {
693
- children['m'] = {kind: 'primitive', length: coordinateCount, values: separated.m};
694
- }
695
- return {kind: 'struct', length: coordinateCount, children} as GeoArrowStruct;
696
- }
697
-
698
- function makeSeparatedCoordinateTarget(
699
- FloatArray: Float32ArrayConstructor | Float64ArrayConstructor,
700
- count: number,
701
- dimension: GeoArrowDimension
702
- ): Exclude<GeoArrowBuilderTarget['coordinates'], Float32Array | Float64Array> {
703
- return {
704
- x: new FloatArray(count),
705
- y: new FloatArray(count),
706
- z: dimension === 'xyz' || dimension === 'xyzm' ? new FloatArray(count) : undefined,
707
- m: dimension === 'xym' || dimension === 'xyzm' ? new FloatArray(count) : undefined
708
- };
709
- }
710
-
711
- function writeCoordinate(
712
- target: GeoArrowBuilderTarget['coordinates'],
713
- coordinateIndex: number,
714
- coordinate: readonly number[],
715
- dimension: GeoArrowDimension
716
- ): void {
717
- if (target instanceof Float32Array || target instanceof Float64Array) {
718
- target.set(coordinate, coordinateIndex * coordinate.length);
719
- return;
720
- }
721
- target.x[coordinateIndex] = coordinate[0];
722
- target.y[coordinateIndex] = coordinate[1];
723
- if (dimension === 'xyz') target.z![coordinateIndex] = coordinate[2];
724
- else if (dimension === 'xym') target.m![coordinateIndex] = coordinate[2];
725
- else if (dimension === 'xyzm') {
726
- target.z![coordinateIndex] = coordinate[2];
727
- target.m![coordinateIndex] = coordinate[3];
728
- }
729
- }
730
-
731
- function writeCoordinateComponents(
732
- target: GeoArrowBuilderTarget['coordinates'],
733
- coordinateIndex: number,
734
- x: number,
735
- y: number,
736
- z: number,
737
- m: number,
738
- dimension: GeoArrowDimension
739
- ): void {
740
- if (target instanceof Float32Array || target instanceof Float64Array) {
741
- const size = getGeoArrowDimensionSize(dimension);
742
- const offset = coordinateIndex * size;
743
- target[offset] = x;
744
- target[offset + 1] = y;
745
- if (dimension === 'xyz') target[offset + 2] = z;
746
- else if (dimension === 'xym') target[offset + 2] = m;
747
- else if (dimension === 'xyzm') {
748
- target[offset + 2] = z;
749
- target[offset + 3] = m;
750
- }
751
- return;
752
- }
753
- target.x[coordinateIndex] = x;
754
- target.y[coordinateIndex] = y;
755
- if (dimension === 'xyz') target.z![coordinateIndex] = z;
756
- else if (dimension === 'xym') target.m![coordinateIndex] = m;
757
- else if (dimension === 'xyzm') {
758
- target.z![coordinateIndex] = z;
759
- target.m![coordinateIndex] = m;
760
- }
761
- }
762
-
763
- function resizeEventCoordinate(
764
- coordinate: readonly number[],
765
- sourceDimension: GeoArrowDimension,
766
- targetDimension: GeoArrowDimension
767
- ): number[] {
768
- if (sourceDimension === targetDimension) return [...coordinate];
769
- const sourceNames = getDimensionNames(sourceDimension);
770
- return getDimensionNames(targetDimension).map(name => {
771
- const index = sourceNames.indexOf(name);
772
- return index >= 0 ? (coordinate[index] ?? 0) : 0;
773
- });
774
- }
775
-
776
- function getDimensionNames(dimension: GeoArrowDimension): Array<'x' | 'y' | 'z' | 'm'> {
777
- switch (dimension) {
778
- case 'xy':
779
- return ['x', 'y'];
780
- case 'xyz':
781
- return ['x', 'y', 'z'];
782
- case 'xym':
783
- return ['x', 'y', 'm'];
784
- case 'xyzm':
785
- return ['x', 'y', 'z', 'm'];
786
- }
787
- }
788
-
789
- function setValidityBit(validity: Uint8Array, index: number): void {
790
- validity[index >> 3] |= 1 << (index & 7);
791
- }
792
-
793
- function getBuilderDepth(encoding: GeoArrowBuilderEncoding): 0 | 1 | 2 | 3 {
794
- switch (encoding) {
795
- case 'geoarrow.point':
796
- return 0;
797
- case 'geoarrow.linestring':
798
- case 'geoarrow.multipoint':
799
- return 1;
800
- case 'geoarrow.polygon':
801
- case 'geoarrow.multilinestring':
802
- return 2;
803
- case 'geoarrow.multipolygon':
804
- return 3;
805
- }
806
- }
807
-
808
- function getGeometryTypeId(
809
- type: GeoArrowGeometryValue['type'],
810
- dimension: GeoArrowDimension = 'xy'
811
- ): number {
812
- const family = [
813
- 'Point',
814
- 'LineString',
815
- 'Polygon',
816
- 'MultiPoint',
817
- 'MultiLineString',
818
- 'MultiPolygon',
819
- 'GeometryCollection'
820
- ].indexOf(type);
821
- const dimensionIndex = ['xy', 'xyz', 'xym', 'xyzm'].indexOf(dimension);
822
- return family < 0 || dimensionIndex < 0 ? 1 : family * 4 + dimensionIndex + 1;
823
- }
824
-
825
- function inferRowsDimension(rows: readonly (GeoArrowGeometryValue | null)[]): GeoArrowDimension {
826
- let size = 2;
827
- const visit = (value: unknown): void => {
828
- if (!Array.isArray(value) || value.length === 0) return;
829
- if (typeof value[0] === 'number') size = Math.max(size, value.length);
830
- else for (const child of value) visit(child);
831
- };
832
- const visitGeometry = (geometry: GeoArrowGeometryValue): void => {
833
- if (geometry.type === 'GeometryCollection') {
834
- for (const child of geometry.geometries) visitGeometry(child);
835
- } else {
836
- visit(geometry.coordinates);
837
- }
838
- };
839
- for (const row of rows) {
840
- if (row) visitGeometry(row);
841
- }
842
- return size >= 4 ? 'xyzm' : size === 3 ? 'xyz' : 'xy';
843
- }
844
-
845
- function assertTargetCapacity(
846
- target: GeoArrowBuilderTarget,
847
- measurement: GeoArrowBuilderMeasurement,
848
- size: number
849
- ): void {
850
- const coordinateLength =
851
- target.coordinates instanceof Float32Array || target.coordinates instanceof Float64Array
852
- ? target.coordinates.length / size
853
- : target.coordinates.x.length;
854
- if (
855
- coordinateLength < measurement.coordinateCount ||
856
- target.validity.length * 8 < measurement.length
857
- ) {
858
- throw new Error('GeoArrowBuilder target is smaller than its measured output');
859
- }
860
- }