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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/README.md +6 -6
  2. package/dist/coordinates.cjs +2523 -0
  3. package/dist/coordinates.cjs.map +6 -0
  4. package/dist/coordinates.d.ts +4 -0
  5. package/dist/coordinates.d.ts.map +1 -1
  6. package/dist/coordinates.js +2 -0
  7. package/dist/coordinates.js.map +1 -1
  8. package/dist/entries/ellipsoid.cjs +1209 -0
  9. package/dist/entries/ellipsoid.cjs.map +6 -0
  10. package/dist/entries/ellipsoid.d.ts +3 -19
  11. package/dist/entries/ellipsoid.d.ts.map +1 -1
  12. package/dist/entries/ellipsoid.js +1 -9
  13. package/dist/entries/ellipsoid.js.map +1 -1
  14. package/dist/expressions.cjs +726 -0
  15. package/dist/expressions.cjs.map +6 -0
  16. package/dist/geodesics.cjs +3195 -0
  17. package/dist/geodesics.cjs.map +6 -0
  18. package/dist/geodesics.d.ts +18 -0
  19. package/dist/geodesics.d.ts.map +1 -0
  20. package/dist/geodesics.js +13 -0
  21. package/dist/geodesics.js.map +1 -0
  22. package/dist/geographic-atlas/sampling.d.ts +1 -1
  23. package/dist/geographic-atlas/sampling.d.ts.map +1 -1
  24. package/dist/geographic-atlas/sampling.js +1 -1
  25. package/dist/geographic-atlas/sampling.js.map +1 -1
  26. package/dist/geographic-cuts.cjs +4160 -0
  27. package/dist/geographic-cuts.cjs.map +6 -0
  28. package/dist/geographic-cuts.d.ts +2 -0
  29. package/dist/geographic-cuts.d.ts.map +1 -1
  30. package/dist/geographic-cuts.js +1 -0
  31. package/dist/geographic-cuts.js.map +1 -1
  32. package/dist/geographic-seams/subdivide-cut.d.ts +1 -1
  33. package/dist/geographic-seams/subdivide-cut.d.ts.map +1 -1
  34. package/dist/geographic-seams/subdivide-cut.js +1 -1
  35. package/dist/geographic-seams/subdivide-cut.js.map +1 -1
  36. package/dist/geographic-seams/types.shared.cjs +32 -0
  37. package/dist/geographic-seams/types.shared.cjs.map +6 -0
  38. package/dist/globe.cjs +4223 -0
  39. package/dist/globe.cjs.map +6 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +2 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/line-simplification.d.ts +7 -0
  45. package/dist/line-simplification.d.ts.map +1 -1
  46. package/dist/line-simplification.js +4 -13
  47. package/dist/line-simplification.js.map +1 -1
  48. package/dist/linear-referencing.d.ts +13 -1
  49. package/dist/linear-referencing.d.ts.map +1 -1
  50. package/dist/linear-referencing.js +29 -9
  51. package/dist/linear-referencing.js.map +1 -1
  52. package/dist/maps/map-transition.shared.cjs +364 -0
  53. package/dist/maps/map-transition.shared.cjs.map +6 -0
  54. package/dist/maps/myriahedral/unfold.d.ts +1 -1
  55. package/dist/maps/myriahedral/unfold.d.ts.map +1 -1
  56. package/dist/maps/myriahedral/unfold.js +1 -1
  57. package/dist/maps/myriahedral/unfold.js.map +1 -1
  58. package/dist/maps/presets.cjs +2 -2
  59. package/dist/maps/presets.cjs.map +2 -2
  60. package/dist/maps/transitions.cjs +3 -342
  61. package/dist/maps/transitions.cjs.map +3 -3
  62. package/dist/maps.cjs +15 -319
  63. package/dist/maps.cjs.map +3 -3
  64. package/dist/measure-referencing.d.ts +16 -0
  65. package/dist/measure-referencing.d.ts.map +1 -0
  66. package/dist/measure-referencing.js +143 -0
  67. package/dist/measure-referencing.js.map +1 -0
  68. package/dist/polygon-simplification.d.ts +6 -0
  69. package/dist/polygon-simplification.d.ts.map +1 -0
  70. package/dist/polygon-simplification.js +141 -0
  71. package/dist/polygon-simplification.js.map +1 -0
  72. package/dist/projection/experimental/core.cjs +63 -1317
  73. package/dist/projection/experimental/core.cjs.map +3 -3
  74. package/dist/projection/experimental/core.d.ts +1 -1
  75. package/dist/projection/experimental/core.d.ts.map +1 -1
  76. package/dist/projection/experimental/crs/projjson.cjs +26 -45
  77. package/dist/projection/experimental/crs/projjson.cjs.map +3 -3
  78. package/dist/projection/experimental/crs/types.shared.cjs +44 -0
  79. package/dist/projection/experimental/crs/types.shared.cjs.map +6 -0
  80. package/dist/projection/experimental/crs/wkt.cjs +36 -52
  81. package/dist/projection/experimental/crs/wkt.cjs.map +3 -3
  82. package/dist/projection/experimental/entries/projections/ob_tran.cjs +9 -23
  83. package/dist/projection/experimental/entries/projections/ob_tran.cjs.map +3 -3
  84. package/dist/projection/experimental/lazy-projections/aea.cjs +1 -1
  85. package/dist/projection/experimental/lazy-projections/aea.js +1 -1
  86. package/dist/projection/experimental/lazy-projections/aeqd.cjs +1 -1
  87. package/dist/projection/experimental/lazy-projections/aeqd.js +1 -1
  88. package/dist/projection/experimental/lazy-projections/bonne.cjs +1 -1
  89. package/dist/projection/experimental/lazy-projections/bonne.js +1 -1
  90. package/dist/projection/experimental/lazy-projections/cass.cjs +1 -1
  91. package/dist/projection/experimental/lazy-projections/cass.js +1 -1
  92. package/dist/projection/experimental/lazy-projections/cea.cjs +1 -1
  93. package/dist/projection/experimental/lazy-projections/cea.js +1 -1
  94. package/dist/projection/experimental/lazy-projections/eck6.cjs +1 -1
  95. package/dist/projection/experimental/lazy-projections/eck6.js +1 -1
  96. package/dist/projection/experimental/lazy-projections/eqc.cjs +1 -1
  97. package/dist/projection/experimental/lazy-projections/eqc.js +1 -1
  98. package/dist/projection/experimental/lazy-projections/eqdc.cjs +1 -1
  99. package/dist/projection/experimental/lazy-projections/eqdc.js +1 -1
  100. package/dist/projection/experimental/lazy-projections/eqearth.cjs +1 -1
  101. package/dist/projection/experimental/lazy-projections/eqearth.js +1 -1
  102. package/dist/projection/experimental/lazy-projections/equi.cjs +1 -1
  103. package/dist/projection/experimental/lazy-projections/equi.js +1 -1
  104. package/dist/projection/experimental/lazy-projections/etmerc.cjs +1 -1
  105. package/dist/projection/experimental/lazy-projections/etmerc.js +1 -1
  106. package/dist/projection/experimental/lazy-projections/geocent.cjs +1 -1
  107. package/dist/projection/experimental/lazy-projections/geocent.js +1 -1
  108. package/dist/projection/experimental/lazy-projections/geos.cjs +1 -1
  109. package/dist/projection/experimental/lazy-projections/geos.js +1 -1
  110. package/dist/projection/experimental/lazy-projections/gnom.cjs +1 -1
  111. package/dist/projection/experimental/lazy-projections/gnom.js +1 -1
  112. package/dist/projection/experimental/lazy-projections/gstmerc.cjs +1 -1
  113. package/dist/projection/experimental/lazy-projections/gstmerc.js +1 -1
  114. package/dist/projection/experimental/lazy-projections/index.cjs +60 -903
  115. package/dist/projection/experimental/lazy-projections/index.cjs.map +3 -3
  116. package/dist/projection/experimental/lazy-projections/krovak.cjs +1 -1
  117. package/dist/projection/experimental/lazy-projections/krovak.js +1 -1
  118. package/dist/projection/experimental/lazy-projections/laea.cjs +1 -1
  119. package/dist/projection/experimental/lazy-projections/laea.js +1 -1
  120. package/dist/projection/experimental/lazy-projections/lcc.cjs +1 -1
  121. package/dist/projection/experimental/lazy-projections/lcc.js +1 -1
  122. package/dist/projection/experimental/lazy-projections/merc.cjs +1 -1
  123. package/dist/projection/experimental/lazy-projections/merc.js +1 -1
  124. package/dist/projection/experimental/lazy-projections/mill.cjs +1 -1
  125. package/dist/projection/experimental/lazy-projections/mill.js +1 -1
  126. package/dist/projection/experimental/lazy-projections/moll.cjs +1 -1
  127. package/dist/projection/experimental/lazy-projections/moll.js +1 -1
  128. package/dist/projection/experimental/lazy-projections/nzmg.cjs +1 -1
  129. package/dist/projection/experimental/lazy-projections/nzmg.js +1 -1
  130. package/dist/projection/experimental/lazy-projections/ob_tran.cjs +1 -1
  131. package/dist/projection/experimental/lazy-projections/ob_tran.js +1 -1
  132. package/dist/projection/experimental/lazy-projections/omerc.cjs +1 -1
  133. package/dist/projection/experimental/lazy-projections/omerc.js +1 -1
  134. package/dist/projection/experimental/lazy-projections/ortho.cjs +1 -1
  135. package/dist/projection/experimental/lazy-projections/ortho.js +1 -1
  136. package/dist/projection/experimental/lazy-projections/poly.cjs +1 -1
  137. package/dist/projection/experimental/lazy-projections/poly.js +1 -1
  138. package/dist/projection/experimental/lazy-projections/qsc.cjs +1 -1
  139. package/dist/projection/experimental/lazy-projections/qsc.js +1 -1
  140. package/dist/projection/experimental/lazy-projections/robin.cjs +1 -1
  141. package/dist/projection/experimental/lazy-projections/robin.js +1 -1
  142. package/dist/projection/experimental/lazy-projections/sinu.cjs +1 -1
  143. package/dist/projection/experimental/lazy-projections/sinu.js +1 -1
  144. package/dist/projection/experimental/lazy-projections/somerc.cjs +1 -1
  145. package/dist/projection/experimental/lazy-projections/somerc.js +1 -1
  146. package/dist/projection/experimental/lazy-projections/stere.cjs +1 -1
  147. package/dist/projection/experimental/lazy-projections/stere.js +1 -1
  148. package/dist/projection/experimental/lazy-projections/sterea.cjs +1 -1
  149. package/dist/projection/experimental/lazy-projections/sterea.js +1 -1
  150. package/dist/projection/experimental/lazy-projections/tmerc.cjs +1 -1
  151. package/dist/projection/experimental/lazy-projections/tmerc.js +1 -1
  152. package/dist/projection/experimental/lazy-projections/tpers.cjs +1 -1
  153. package/dist/projection/experimental/lazy-projections/tpers.js +1 -1
  154. package/dist/projection/experimental/lazy-projections/utm.cjs +1 -1
  155. package/dist/projection/experimental/lazy-projections/utm.js +1 -1
  156. package/dist/projection/experimental/lazy-projections/vandg.cjs +1 -1
  157. package/dist/projection/experimental/lazy-projections/vandg.js +1 -1
  158. package/dist/projection/experimental/projection-engine.shared.cjs +1184 -0
  159. package/dist/projection/experimental/projection-engine.shared.cjs.map +6 -0
  160. package/dist/projection/experimental/typescript-projection.shared.cjs +1703 -0
  161. package/dist/projection/experimental/typescript-projection.shared.cjs.map +6 -0
  162. package/dist/projection/index.cjs +622 -1535
  163. package/dist/projection/index.cjs.map +3 -3
  164. package/dist/projection/pipeline.cjs +44 -58
  165. package/dist/projection/pipeline.cjs.map +3 -3
  166. package/dist/projection/transform-analysis.cjs +20 -936
  167. package/dist/projection/transform-analysis.cjs.map +3 -3
  168. package/dist/spatial-box-clipping.d.ts +9 -0
  169. package/dist/spatial-box-clipping.d.ts.map +1 -0
  170. package/dist/spatial-box-clipping.js +123 -0
  171. package/dist/spatial-box-clipping.js.map +1 -0
  172. package/dist/spatial-dwithin.d.ts +19 -0
  173. package/dist/spatial-dwithin.d.ts.map +1 -0
  174. package/dist/spatial-dwithin.js +107 -0
  175. package/dist/spatial-dwithin.js.map +1 -0
  176. package/dist/spatial-hulls.d.ts +6 -0
  177. package/dist/spatial-hulls.d.ts.map +1 -0
  178. package/dist/spatial-hulls.js +176 -0
  179. package/dist/spatial-hulls.js.map +1 -0
  180. package/dist/spatial-line-intersection-result.d.ts +4 -0
  181. package/dist/spatial-line-intersection-result.d.ts.map +1 -0
  182. package/dist/spatial-line-intersection-result.js +79 -0
  183. package/dist/spatial-line-intersection-result.js.map +1 -0
  184. package/dist/spatial-line-polygon-intersection.d.ts +4 -0
  185. package/dist/spatial-line-polygon-intersection.d.ts.map +1 -0
  186. package/dist/spatial-line-polygon-intersection.js +130 -0
  187. package/dist/spatial-line-polygon-intersection.js.map +1 -0
  188. package/dist/spatial-planar-intersects.d.ts +11 -0
  189. package/dist/spatial-planar-intersects.d.ts.map +1 -1
  190. package/dist/spatial-planar-intersects.js +20 -12
  191. package/dist/spatial-planar-intersects.js.map +1 -1
  192. package/dist/spatial-planar.d.ts +9 -0
  193. package/dist/spatial-planar.d.ts.map +1 -1
  194. package/dist/spatial-planar.js +13 -1
  195. package/dist/spatial-planar.js.map +1 -1
  196. package/dist/spatial-polygon-overlay.d.ts +5 -0
  197. package/dist/spatial-polygon-overlay.d.ts.map +1 -0
  198. package/dist/spatial-polygon-overlay.js +23 -0
  199. package/dist/spatial-polygon-overlay.js.map +1 -0
  200. package/dist/spatial-sql.d.ts +13 -2
  201. package/dist/spatial-sql.d.ts.map +1 -1
  202. package/dist/spatial-sql.js +30 -12
  203. package/dist/spatial-sql.js.map +1 -1
  204. package/dist/spatial-subdivision.d.ts +9 -0
  205. package/dist/spatial-subdivision.d.ts.map +1 -0
  206. package/dist/spatial-subdivision.js +61 -0
  207. package/dist/spatial-subdivision.js.map +1 -0
  208. package/dist/spatial-touches.d.ts +13 -0
  209. package/dist/spatial-touches.d.ts.map +1 -0
  210. package/dist/spatial-touches.js +192 -0
  211. package/dist/spatial-touches.js.map +1 -0
  212. package/dist/st-functions.cjs +2411 -112
  213. package/dist/st-functions.cjs.map +3 -3
  214. package/dist/st-functions.d.ts +67 -2
  215. package/dist/st-functions.d.ts.map +1 -1
  216. package/dist/st-functions.js +195 -12
  217. package/dist/st-functions.js.map +1 -1
  218. package/dist/st-geodesic-functions.d.ts +33 -0
  219. package/dist/st-geodesic-functions.d.ts.map +1 -0
  220. package/dist/st-geodesic-functions.js +84 -0
  221. package/dist/st-geodesic-functions.js.map +1 -0
  222. package/dist/st-hull-functions.cjs +386 -0
  223. package/dist/st-hull-functions.cjs.map +6 -0
  224. package/dist/st-hull-functions.d.ts +17 -0
  225. package/dist/st-hull-functions.d.ts.map +1 -0
  226. package/dist/st-hull-functions.js +14 -0
  227. package/dist/st-hull-functions.js.map +1 -0
  228. package/dist/st-overlay-functions.cjs +621 -0
  229. package/dist/st-overlay-functions.cjs.map +6 -0
  230. package/dist/st-overlay-functions.d.ts +36 -0
  231. package/dist/st-overlay-functions.d.ts.map +1 -0
  232. package/dist/st-overlay-functions.js +183 -0
  233. package/dist/st-overlay-functions.js.map +1 -0
  234. package/dist/st-viewport-functions.cjs +481 -0
  235. package/dist/st-viewport-functions.cjs.map +6 -0
  236. package/dist/st-viewport-functions.d.ts +13 -0
  237. package/dist/st-viewport-functions.d.ts.map +1 -0
  238. package/dist/st-viewport-functions.js +81 -0
  239. package/dist/st-viewport-functions.js.map +1 -0
  240. package/dist/subdivide-geodesic-polyline.d.ts +1 -1
  241. package/dist/subdivide-geodesic-polyline.d.ts.map +1 -1
  242. package/dist/subdivide-geodesic-polyline.js +1 -1
  243. package/dist/subdivide-geodesic-polyline.js.map +1 -1
  244. package/dist/subdivide-globe-mesh.d.ts +1 -1
  245. package/dist/subdivide-globe-mesh.d.ts.map +1 -1
  246. package/dist/subdivide-globe-mesh.js +1 -1
  247. package/dist/subdivide-globe-mesh.js.map +1 -1
  248. package/dist/subdivide-rhumb-polyline.d.ts +1 -1
  249. package/dist/subdivide-rhumb-polyline.d.ts.map +1 -1
  250. package/dist/subdivide-rhumb-polyline.js +1 -1
  251. package/dist/subdivide-rhumb-polyline.js.map +1 -1
  252. package/dist/tasks/index.cjs +808 -2993
  253. package/dist/tasks/index.cjs.map +3 -3
  254. package/dist/terrain/geometry.d.ts +1 -1
  255. package/dist/terrain/geometry.d.ts.map +1 -1
  256. package/dist/terrain/geometry.js +1 -1
  257. package/dist/terrain/geometry.js.map +1 -1
  258. package/dist/terrain/index.cjs +95 -22
  259. package/dist/terrain/index.cjs.map +3 -3
  260. package/dist/terrain/index.d.ts +1 -0
  261. package/dist/terrain/index.d.ts.map +1 -1
  262. package/dist/terrain/index.js +1 -0
  263. package/dist/terrain/index.js.map +1 -1
  264. package/dist/terrain/regional-watersheds.d.ts +44 -0
  265. package/dist/terrain/regional-watersheds.d.ts.map +1 -0
  266. package/dist/terrain/regional-watersheds.js +108 -0
  267. package/dist/terrain/regional-watersheds.js.map +1 -0
  268. package/dist/terrain/tile-cutout-update.d.ts.map +1 -1
  269. package/dist/terrain/tile-cutout-update.js +28 -22
  270. package/dist/terrain/tile-cutout-update.js.map +1 -1
  271. package/dist/tiles.cjs +354 -0
  272. package/dist/tiles.cjs.map +6 -0
  273. package/dist/turf-functions.cjs +16 -9
  274. package/dist/turf-functions.cjs.map +1 -1
  275. package/package.json +154 -117
  276. package/src/coordinates.ts +5 -0
  277. package/src/entries/ellipsoid.ts +7 -32
  278. package/src/geodesics.ts +40 -0
  279. package/src/geographic-atlas/sampling.ts +1 -1
  280. package/src/geographic-cuts.ts +21 -0
  281. package/src/geographic-seams/subdivide-cut.ts +1 -1
  282. package/src/index.ts +2 -0
  283. package/src/line-simplification.ts +4 -16
  284. package/src/linear-referencing.ts +44 -16
  285. package/src/maps/myriahedral/unfold.ts +1 -1
  286. package/src/measure-referencing.ts +165 -0
  287. package/src/polygon-simplification.ts +185 -0
  288. package/src/projection/experimental/core.ts +1 -1
  289. package/src/projection/experimental/lazy-projections/aea.ts +1 -1
  290. package/src/projection/experimental/lazy-projections/aeqd.ts +1 -1
  291. package/src/projection/experimental/lazy-projections/bonne.ts +1 -1
  292. package/src/projection/experimental/lazy-projections/cass.ts +1 -1
  293. package/src/projection/experimental/lazy-projections/cea.ts +1 -1
  294. package/src/projection/experimental/lazy-projections/eck6.ts +1 -1
  295. package/src/projection/experimental/lazy-projections/eqc.ts +1 -1
  296. package/src/projection/experimental/lazy-projections/eqdc.ts +1 -1
  297. package/src/projection/experimental/lazy-projections/eqearth.ts +1 -1
  298. package/src/projection/experimental/lazy-projections/equi.ts +1 -1
  299. package/src/projection/experimental/lazy-projections/etmerc.ts +1 -1
  300. package/src/projection/experimental/lazy-projections/geocent.ts +1 -1
  301. package/src/projection/experimental/lazy-projections/geos.ts +1 -1
  302. package/src/projection/experimental/lazy-projections/gnom.ts +1 -1
  303. package/src/projection/experimental/lazy-projections/gstmerc.ts +1 -1
  304. package/src/projection/experimental/lazy-projections/krovak.ts +1 -1
  305. package/src/projection/experimental/lazy-projections/laea.ts +1 -1
  306. package/src/projection/experimental/lazy-projections/lcc.ts +1 -1
  307. package/src/projection/experimental/lazy-projections/merc.ts +1 -1
  308. package/src/projection/experimental/lazy-projections/mill.ts +1 -1
  309. package/src/projection/experimental/lazy-projections/moll.ts +1 -1
  310. package/src/projection/experimental/lazy-projections/nzmg.ts +1 -1
  311. package/src/projection/experimental/lazy-projections/ob_tran.ts +1 -1
  312. package/src/projection/experimental/lazy-projections/omerc.ts +1 -1
  313. package/src/projection/experimental/lazy-projections/ortho.ts +1 -1
  314. package/src/projection/experimental/lazy-projections/poly.ts +1 -1
  315. package/src/projection/experimental/lazy-projections/qsc.ts +1 -1
  316. package/src/projection/experimental/lazy-projections/robin.ts +1 -1
  317. package/src/projection/experimental/lazy-projections/sinu.ts +1 -1
  318. package/src/projection/experimental/lazy-projections/somerc.ts +1 -1
  319. package/src/projection/experimental/lazy-projections/stere.ts +1 -1
  320. package/src/projection/experimental/lazy-projections/sterea.ts +1 -1
  321. package/src/projection/experimental/lazy-projections/tmerc.ts +1 -1
  322. package/src/projection/experimental/lazy-projections/tpers.ts +1 -1
  323. package/src/projection/experimental/lazy-projections/utm.ts +1 -1
  324. package/src/projection/experimental/lazy-projections/vandg.ts +1 -1
  325. package/src/spatial-box-clipping.ts +140 -0
  326. package/src/spatial-dwithin.ts +135 -0
  327. package/src/spatial-hulls.ts +203 -0
  328. package/src/spatial-line-intersection-result.ts +93 -0
  329. package/src/spatial-line-polygon-intersection.ts +147 -0
  330. package/src/spatial-planar-intersects.ts +21 -15
  331. package/src/spatial-planar.ts +20 -1
  332. package/src/spatial-polygon-overlay.ts +30 -0
  333. package/src/spatial-sql.ts +47 -12
  334. package/src/spatial-subdivision.ts +75 -0
  335. package/src/spatial-touches.ts +218 -0
  336. package/src/st-functions.ts +283 -15
  337. package/src/st-geodesic-functions.ts +121 -0
  338. package/src/st-hull-functions.ts +25 -0
  339. package/src/st-overlay-functions.ts +244 -0
  340. package/src/st-viewport-functions.ts +98 -0
  341. package/src/subdivide-geodesic-polyline.ts +2 -2
  342. package/src/subdivide-globe-mesh.ts +2 -2
  343. package/src/subdivide-rhumb-polyline.ts +2 -2
  344. package/src/terrain/geometry.ts +1 -1
  345. package/src/terrain/index.ts +7 -0
  346. package/src/terrain/regional-watersheds.ts +153 -0
  347. package/src/terrain/tile-cutout-update.ts +32 -26
  348. package/dist/index.cjs +0 -18674
  349. package/dist/index.cjs.map +0 -6
  350. package/dist/turf-expressions.cjs +0 -1997
  351. package/dist/turf-expressions.cjs.map +0 -6
  352. package/dist/turf-expressions.d.ts +0 -3
  353. package/dist/turf-expressions.d.ts.map +0 -1
  354. package/dist/turf-expressions.js +0 -7
  355. package/dist/turf-expressions.js.map +0 -1
  356. package/src/turf-expressions.ts +0 -7
@@ -0,0 +1,1703 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // dist/projection/experimental/typescript-projection.js
20
+ var typescript_projection_exports = {};
21
+ __export(typescript_projection_exports, {
22
+ ProjectionTransform: () => ProjectionTransform,
23
+ checkProjectionCompatibility: () => checkProjectionCompatibility
24
+ });
25
+ module.exports = __toCommonJS(typescript_projection_exports);
26
+
27
+ // dist/projection/experimental/rendering-profile/geographic-bounds.js
28
+ var RADIANS = Math.PI / 180;
29
+ function createAngularRanges(west, south, east, north) {
30
+ return [
31
+ [west, south],
32
+ [east, north]
33
+ ];
34
+ }
35
+ function normalizeLongitude(longitude) {
36
+ return longitude >= -180 && longitude < 180 ? longitude : ((longitude + 180) % 360 + 360) % 360 - 180;
37
+ }
38
+ function getLongitudeSpan(bounds) {
39
+ const span = bounds[2] - bounds[0];
40
+ return span < 0 ? span + 360 : span;
41
+ }
42
+ function containsGeographicPoint(bounds, point) {
43
+ const [west, south, east, north] = bounds;
44
+ const longitude = normalizeLongitude(point[0]);
45
+ return point[1] >= south && point[1] <= north && (west <= east ? longitude >= west && longitude <= east || longitude === -180 && east === 180 : longitude >= west || longitude <= east);
46
+ }
47
+ function clampGeographicPoint(bounds, point) {
48
+ let longitude = normalizeLongitude(point[0]);
49
+ const latitude = Math.max(bounds[1], Math.min(bounds[3], point[1]));
50
+ if (!containsGeographicPoint(bounds, [longitude, latitude])) {
51
+ const westDistance = Math.abs(normalizeLongitude(longitude - bounds[0]));
52
+ const eastDistance = Math.abs(normalizeLongitude(longitude - bounds[2]));
53
+ longitude = westDistance <= eastDistance ? bounds[0] : bounds[2];
54
+ }
55
+ return [longitude, latitude];
56
+ }
57
+ function getAngularRanges(bounds, primeMeridian2 = 0, origin = 0) {
58
+ const width = getLongitudeSpan(bounds);
59
+ const west = bounds[0] * RADIANS - primeMeridian2;
60
+ const middle = west + width * RADIANS / 2;
61
+ const shift = Math.round((origin - middle) / (2 * Math.PI)) * 2 * Math.PI;
62
+ return createAngularRanges(width === 360 ? origin - Math.PI : west + shift, bounds[1] * RADIANS, width === 360 ? origin + Math.PI : west + shift + width * RADIANS, bounds[3] * RADIANS);
63
+ }
64
+
65
+ // dist/projection/experimental/rendering-profile/rendering-profile.js
66
+ function resolveRenderingProfile(getRenderingProfile, coverage) {
67
+ if (coverage) {
68
+ try {
69
+ const profile2 = getRenderingProfile(coverage);
70
+ return resolveBounds(profile2);
71
+ } catch {
72
+ }
73
+ }
74
+ const profile = getRenderingProfile();
75
+ return resolveBounds(profile);
76
+ }
77
+ function resolveBounds(profile) {
78
+ var _a;
79
+ const bounds = profile.bounds;
80
+ if (bounds.some((corner) => corner.some((value) => !Number.isFinite(value))))
81
+ throw new Error("Projection rendering bounds must be finite");
82
+ return { bounds, normalize: (_a = profile.normalize) == null ? void 0 : _a.bind(profile) };
83
+ }
84
+
85
+ // dist/projection/experimental/rendering-profile/identity-rendering-profile.js
86
+ function getIdentityRenderingProfile() {
87
+ return {
88
+ bounds: [
89
+ [-1, -1, 0],
90
+ [1, 1, 0]
91
+ ]
92
+ };
93
+ }
94
+
95
+ // dist/projection/experimental/projection-descriptor.js
96
+ var CACHE_KEY = /* @__PURE__ */ Symbol.for("@math.gl/projection/projection-implementations");
97
+ function cache() {
98
+ const scope = globalThis;
99
+ scope[CACHE_KEY] || (scope[CACHE_KEY] = /* @__PURE__ */ new WeakMap());
100
+ return scope[CACHE_KEY];
101
+ }
102
+ function getLoadedProjection(projection) {
103
+ var _a;
104
+ return "create" in projection ? projection : (_a = cache().get(projection)) == null ? void 0 : _a.implementation;
105
+ }
106
+ function preloadProjection(projection) {
107
+ if ("create" in projection)
108
+ return Promise.resolve(projection);
109
+ let state = cache().get(projection);
110
+ if (!state) {
111
+ state = { load: () => projection.preload() };
112
+ cache().set(projection, state);
113
+ }
114
+ if (state.implementation)
115
+ return Promise.resolve(state.implementation);
116
+ const entry = state;
117
+ entry.pending || (entry.pending = Promise.resolve().then(entry.load).then((plugin) => {
118
+ const key = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
119
+ const supported = new Set([plugin.name, ...plugin.aliases || []].map(key));
120
+ if (typeof plugin.create !== "function" || ![projection.name, ...projection.aliases || []].every((name) => supported.has(key(name))))
121
+ throw new Error("Loaded projection does not match descriptor: " + projection.name);
122
+ entry.implementation = plugin;
123
+ return plugin;
124
+ }).catch((error) => {
125
+ entry.pending = void 0;
126
+ throw error;
127
+ }));
128
+ return entry.pending;
129
+ }
130
+
131
+ // dist/projection/experimental/projection-scratch.js
132
+ function createPoint() {
133
+ return { x: 0, y: 0, z: 0 };
134
+ }
135
+ var ProjectionScratch = class {
136
+ constructor() {
137
+ this.point = createPoint();
138
+ this.points = [this.point];
139
+ this.active = 0;
140
+ }
141
+ get depth() {
142
+ return this.active;
143
+ }
144
+ acquire() {
145
+ var _a;
146
+ const index = this.active++;
147
+ (_a = this.points)[index] || (_a[index] = createPoint());
148
+ return this.points[index];
149
+ }
150
+ release(point) {
151
+ if (this.active > 0 && this.points[this.active - 1] === point)
152
+ this.active--;
153
+ }
154
+ };
155
+
156
+ // dist/projection/experimental/mutable-projection.js
157
+ function projectionOperation(implementation, inverse, geocentric = false) {
158
+ const mutable = inverse ? implementation.inverseInPlace : implementation.forwardInPlace;
159
+ if (mutable)
160
+ return mutable.bind(implementation);
161
+ if (geocentric) {
162
+ const operation2 = inverse ? implementation.inverse3D : implementation.forward3D;
163
+ return (point) => {
164
+ const output = operation2.call(implementation, [point.x, point.y, point.z]);
165
+ point.x = output[0];
166
+ point.y = output[1];
167
+ point.z = output[2];
168
+ };
169
+ }
170
+ const operation = inverse ? implementation.inverse : implementation.forward;
171
+ return (point) => {
172
+ const output = operation.call(implementation, point.x, point.y);
173
+ point.x = output[0];
174
+ point.y = output[1];
175
+ };
176
+ }
177
+
178
+ // dist/projection/experimental/scalar-output.js
179
+ var FLOAT32_MAX = 34028234663852886e22;
180
+ function validateScalarOutput(coordinate, output, length) {
181
+ if (!(Array.isArray(coordinate) || coordinate instanceof Float32Array || coordinate instanceof Float64Array))
182
+ throw new Error("Scalar input requires a number array, Float32Array or Float64Array");
183
+ if (!(Array.isArray(output) || output instanceof Float32Array || output instanceof Float64Array) || output.length < length)
184
+ throw new Error("Scalar output requires a preallocated number array, Float32Array or Float64Array with sufficient capacity");
185
+ if (coordinate === output || Array.isArray(coordinate) || Array.isArray(output))
186
+ return;
187
+ const input = coordinate;
188
+ const result = output;
189
+ const shared = typeof SharedArrayBuffer !== "undefined" && input.buffer instanceof SharedArrayBuffer && result.buffer instanceof SharedArrayBuffer;
190
+ if ((input.buffer === result.buffer || shared) && input.byteOffset < result.byteOffset + length * result.BYTES_PER_ELEMENT && result.byteOffset < input.byteOffset + input.byteLength)
191
+ throw new Error("Scalar input/output views overlap; use the same view for in-place projection");
192
+ }
193
+ function writeScalarOutput(coordinate, output, point, length) {
194
+ if (output instanceof Float32Array) {
195
+ if (Math.abs(point.x) > FLOAT32_MAX || Math.abs(point.y) > FLOAT32_MAX || length >= 3 && Math.abs(point.z) > FLOAT32_MAX)
196
+ throw new Error("Projected coordinate exceeds Float32 range");
197
+ for (let i = 3; i < coordinate.length; i++) {
198
+ const value = coordinate[i];
199
+ if (Number.isFinite(value) && Math.abs(value) > FLOAT32_MAX)
200
+ throw new Error("Trailing ordinate exceeds Float32 range");
201
+ }
202
+ }
203
+ for (let i = 3; i < coordinate.length; i++)
204
+ output[i] = coordinate[i];
205
+ output[0] = point.x;
206
+ output[1] = point.y;
207
+ if (length >= 3)
208
+ output[2] = point.z;
209
+ return output;
210
+ }
211
+
212
+ // dist/crs/spatial-reference.js
213
+ function inferCRSRepresentation(definition) {
214
+ if (typeof definition === "object") {
215
+ return "projjson";
216
+ }
217
+ const text = definition.trim();
218
+ if (/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(text)) {
219
+ return "wkt";
220
+ }
221
+ if (/(?:^|\s)\+?proj=/i.test(text)) {
222
+ return "proj-string";
223
+ }
224
+ if (/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(text) || /^urn:ogc:def:crs:/i.test(text) || /^https?:\/\//i.test(text) || /^[A-Z][A-Z0-9._-]*$/i.test(text)) {
225
+ return "identifier";
226
+ }
227
+ return "opaque";
228
+ }
229
+
230
+ // dist/crs/proj-string.js
231
+ var PROJStringSyntaxError = class extends SyntaxError {
232
+ /** Create a PROJ string syntax error at a source location. */
233
+ constructor(message, source, offset) {
234
+ const location = getSourceLocation(source, offset);
235
+ super(`${message} at ${location.line}:${location.column}`);
236
+ this.name = "PROJStringSyntaxError";
237
+ this.offset = offset;
238
+ this.line = location.line;
239
+ this.column = location.column;
240
+ }
241
+ };
242
+ function parsePROJString(text) {
243
+ const tokens = tokenizePROJString(text);
244
+ if (tokens.length === 0) {
245
+ throw new PROJStringSyntaxError("PROJ string is empty", text, 0);
246
+ }
247
+ const parameters = tokens.map((token) => parseParameter(token.raw, token.offset, text));
248
+ return { type: "proj-string", parameters };
249
+ }
250
+ var DMS_VALUE = /^[+-]?\d+(?:\.\d*)?d(?:\d+(?:\.\d*)?'(?:\d+(?:\.\d*)?")?)?[NSEW]?$/i;
251
+ function parseParameter(rawToken, offset, source) {
252
+ const token = rawToken.startsWith("+") ? rawToken.slice(1) : rawToken;
253
+ if (!token) {
254
+ throw new PROJStringSyntaxError("Expected a parameter after '+'", source, offset);
255
+ }
256
+ const equalsIndex = token.indexOf("=");
257
+ const name = equalsIndex < 0 ? token : token.slice(0, equalsIndex);
258
+ if (!name || /[\s+=]/.test(name)) {
259
+ throw new PROJStringSyntaxError(`Invalid PROJ parameter name '${name}'`, source, offset);
260
+ }
261
+ if (equalsIndex < 0) {
262
+ return { type: "parameter", name };
263
+ }
264
+ const rawValue = token.slice(equalsIndex + 1);
265
+ const value = decodeParameterValue(rawValue, source, offset + equalsIndex + 1);
266
+ return { type: "parameter", name, value, rawValue };
267
+ }
268
+ function tokenizePROJString(source) {
269
+ const tokens = [];
270
+ let offset = 0;
271
+ while (offset < source.length) {
272
+ while (offset < source.length && /\s/.test(source[offset])) {
273
+ offset++;
274
+ }
275
+ if (offset >= source.length) {
276
+ break;
277
+ }
278
+ const start = offset;
279
+ let quote = null;
280
+ let escaped = false;
281
+ while (offset < source.length) {
282
+ const character = source[offset];
283
+ if (escaped) {
284
+ escaped = false;
285
+ offset++;
286
+ continue;
287
+ }
288
+ if (character === "\\" && quote) {
289
+ escaped = true;
290
+ offset++;
291
+ continue;
292
+ }
293
+ if (quote) {
294
+ if (character === quote) {
295
+ quote = null;
296
+ }
297
+ offset++;
298
+ continue;
299
+ }
300
+ if ((character === '"' || character === "'") && source[offset - 1] === "=") {
301
+ quote = character;
302
+ offset++;
303
+ continue;
304
+ }
305
+ if (/\s/.test(character)) {
306
+ break;
307
+ }
308
+ offset++;
309
+ }
310
+ if (quote) {
311
+ throw new PROJStringSyntaxError("Unterminated quoted PROJ value", source, start);
312
+ }
313
+ tokens.push({ raw: source.slice(start, offset), offset: start });
314
+ }
315
+ return tokens;
316
+ }
317
+ function decodeParameterValue(rawValue, source, offset) {
318
+ if (!rawValue) {
319
+ return "";
320
+ }
321
+ const first = rawValue[0];
322
+ if (first !== '"' && first !== "'") {
323
+ if ((rawValue.includes('"') || rawValue.includes("'")) && !DMS_VALUE.test(rawValue)) {
324
+ throw new PROJStringSyntaxError("Quote must begin a PROJ parameter value", source, offset);
325
+ }
326
+ return rawValue;
327
+ }
328
+ if (rawValue[rawValue.length - 1] !== first) {
329
+ throw new PROJStringSyntaxError("Unterminated quoted PROJ value", source, offset);
330
+ }
331
+ let value = "";
332
+ for (let index = 1; index < rawValue.length - 1; index++) {
333
+ const character = rawValue[index];
334
+ if (character === "\\" && index + 1 < rawValue.length - 1) {
335
+ value += rawValue[++index];
336
+ } else {
337
+ value += character;
338
+ }
339
+ }
340
+ return value;
341
+ }
342
+ function getSourceLocation(source, offset) {
343
+ let line = 1;
344
+ let column = 1;
345
+ for (let index = 0; index < offset && index < source.length; index++) {
346
+ if (source[index] === "\n") {
347
+ line++;
348
+ column = 1;
349
+ } else {
350
+ column++;
351
+ }
352
+ }
353
+ return { line, column };
354
+ }
355
+
356
+ // dist/projection/experimental/crs/spatial-reference.js
357
+ var import_types = require("./crs/types.shared.cjs");
358
+ function resolveCRSInput(input, options) {
359
+ if (typeof input === "string" || "type" in input)
360
+ return { definition: input, lossy: false };
361
+ const metadata = input;
362
+ const spatialReference = "crs" in metadata ? metadata : void 0;
363
+ const reference = "crs" in metadata ? metadata.crs : metadata;
364
+ if (reference.state !== "explicit" && reference.state !== "default")
365
+ throw new import_types.TypeScriptCRSError("unknown-syntax", "Cannot transform an " + reference.state + " CRS reference");
366
+ let lossy = false;
367
+ if ((spatialReference == null ? void 0 : spatialReference.coordinateEpoch) !== void 0)
368
+ (0, import_types.unsupportedStage)("Coordinate epochs require a time-dependent transformation");
369
+ if ((spatialReference == null ? void 0 : spatialReference.vertical) && spatialReference.vertical.state !== "absent") {
370
+ if (options.mode !== "horizontal")
371
+ (0, import_types.unsupportedStage)("A separately declared vertical CRS requires explicit horizontal extraction");
372
+ lossy = true;
373
+ }
374
+ return { definition: reference.definition, spatialReference, lossy };
375
+ }
376
+ function applySpatialReference(crs, reference) {
377
+ var _a;
378
+ if (!reference)
379
+ return crs;
380
+ if (reference.coordinateFrame !== "unknown" && reference.coordinateFrame !== crs.kind)
381
+ throw new Error("SpatialReference coordinate frame disagrees with its CRS");
382
+ const order = reference.coordinateOrder;
383
+ const names = crs.kind === "geocentric" ? { x: "e", y: "n", z: "u" } : {
384
+ longitude: "e",
385
+ lon: "e",
386
+ latitude: "n",
387
+ lat: "n",
388
+ easting: "e",
389
+ northing: "n",
390
+ height: "u",
391
+ altitude: "u",
392
+ x: "e",
393
+ y: "n",
394
+ z: "u"
395
+ };
396
+ let storedAxis;
397
+ if (order.length) {
398
+ storedAxis = order.slice(0, 3).map((name) => names[name.toLowerCase()] || "?").join("");
399
+ if (storedAxis.length === 2)
400
+ storedAxis += "u";
401
+ if (storedAxis.length !== 3 || !storedAxis.includes("e") || !storedAxis.includes("n") || !storedAxis.includes("u"))
402
+ (0, import_types.unsupportedStage)("Unsupported SpatialReference coordinate order");
403
+ if (order.length > 4 || order.length > 3 && !["m", "measure"].includes(order[3]))
404
+ (0, import_types.unsupportedStage)("Unsupported fourth coordinate component");
405
+ }
406
+ if ((_a = reference.units) == null ? void 0 : _a.length) {
407
+ const units = {
408
+ m: 1,
409
+ meter: 1,
410
+ metre: 1,
411
+ meters: 1,
412
+ metres: 1,
413
+ km: 1e3,
414
+ ft: 0.3048,
415
+ "us-ft": 1200 / 3937,
416
+ degree: Math.PI / 180,
417
+ degrees: Math.PI / 180,
418
+ radian: 1,
419
+ radians: 1,
420
+ grad: Math.PI / 200
421
+ };
422
+ for (let i = 0; i < Math.min(reference.units.length, 3); i++) {
423
+ const vertical = (storedAxis || "enu")[i] === "u";
424
+ const expected = crs.kind === "geocentric" ? crs.toMeter : vertical ? crs.verticalUnit : crs.kind === "geographic" ? crs.angularUnit : crs.toMeter;
425
+ if (Math.abs((units[reference.units[i]] ?? NaN) - expected) > 1e-12 || units[reference.units[i]] === void 0)
426
+ (0, import_types.unsupportedStage)("SpatialReference units disagree with its CRS");
427
+ }
428
+ }
429
+ return Object.freeze({ ...crs, storedAxis });
430
+ }
431
+
432
+ // dist/projection/experimental/parameters.js
433
+ var DEGREES_TO_RADIANS = Math.PI / 180;
434
+ function numberParameter(parameters, name, fallback) {
435
+ if (!Object.prototype.hasOwnProperty.call(parameters, name))
436
+ return fallback;
437
+ const value = parameters[name];
438
+ if (typeof value !== "string" || !/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i.test(value)) {
439
+ throw new Error(`Invalid numeric PROJ parameter: +${name}`);
440
+ }
441
+ const number = Number(value);
442
+ if (!Number.isFinite(number))
443
+ throw new Error(`Invalid numeric PROJ parameter: +${name}`);
444
+ return number;
445
+ }
446
+ function wrapLongitude(longitude, over = false) {
447
+ if (over || Math.abs(longitude) <= Math.PI)
448
+ return longitude;
449
+ const circle = 2 * Math.PI;
450
+ return ((longitude + Math.PI) % circle + circle) % circle - Math.PI;
451
+ }
452
+
453
+ // dist/projection/experimental/crs/datum-catalog.js
454
+ var wgs84 = { towgs84: "0,0,0", ellipse: "WGS84" };
455
+ var nad83 = { towgs84: "0,0,0", ellipse: "GRS80" };
456
+ var builtins = {
457
+ wgs84,
458
+ WGS84: wgs84,
459
+ nad83,
460
+ North_American_Datum_1983: nad83
461
+ };
462
+ var resolved = /* @__PURE__ */ new WeakMap();
463
+ var datumNameKey = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
464
+ function getDatumDefinitions(options) {
465
+ var _a;
466
+ if (!((_a = options.datumCatalogs) == null ? void 0 : _a.length))
467
+ return builtins;
468
+ const cached = resolved.get(options);
469
+ if ((cached == null ? void 0 : cached.catalogs) === options.datumCatalogs)
470
+ return cached.definitions;
471
+ const definitions = Object.assign(/* @__PURE__ */ Object.create(null), builtins);
472
+ const names = new Map(Object.entries(builtins).map(([name, definition]) => [
473
+ datumNameKey(name),
474
+ { definition, owner: -1 }
475
+ ]));
476
+ options.datumCatalogs.forEach((catalog, owner) => {
477
+ if (!catalog.name || !catalog.datums)
478
+ throw new Error("Invalid datum catalogue plugin");
479
+ for (const [name, definition] of Object.entries(catalog.datums)) {
480
+ const key = datumNameKey(name);
481
+ if (!key || key === "none" || !definition || ["ellipse", "towgs84", "nadgrids"].some((field) => definition[field] !== void 0 && typeof definition[field] !== "string"))
482
+ throw new Error("Invalid datum definition: " + name);
483
+ const previous = names.get(key);
484
+ if (previous && (previous.owner !== owner || previous.definition.ellipse !== definition.ellipse || previous.definition.towgs84 !== definition.towgs84 || previous.definition.nadgrids !== definition.nadgrids))
485
+ throw new Error("Conflicting datum registration: " + name);
486
+ names.set(key, { definition, owner });
487
+ definitions[name] = definition;
488
+ }
489
+ });
490
+ resolved.set(options, { catalogs: options.datumCatalogs, definitions });
491
+ return definitions;
492
+ }
493
+
494
+ // dist/projection/experimental/crs/ellipsoid-table.js
495
+ var ellipsoids = {
496
+ MERIT: {
497
+ a: 6378137,
498
+ rf: 298.257,
499
+ ellipseName: "MERIT 1983"
500
+ },
501
+ SGS85: {
502
+ a: 6378136,
503
+ rf: 298.257,
504
+ ellipseName: "Soviet Geodetic System 85"
505
+ },
506
+ GRS80: {
507
+ a: 6378137,
508
+ rf: 298.257222101,
509
+ ellipseName: "GRS 1980(IUGG, 1980)"
510
+ },
511
+ IAU76: {
512
+ a: 6378140,
513
+ rf: 298.257,
514
+ ellipseName: "IAU 1976"
515
+ },
516
+ airy: {
517
+ a: 6377563396e-3,
518
+ b: 635625691e-2,
519
+ ellipseName: "Airy 1830"
520
+ },
521
+ APL4: {
522
+ a: 6378137,
523
+ rf: 298.25,
524
+ ellipseName: "Appl. Physics. 1965"
525
+ },
526
+ NWL9D: {
527
+ a: 6378145,
528
+ rf: 298.25,
529
+ ellipseName: "Naval Weapons Lab., 1965"
530
+ },
531
+ mod_airy: {
532
+ a: 6377340189e-3,
533
+ b: 6356034446e-3,
534
+ ellipseName: "Modified Airy"
535
+ },
536
+ andrae: {
537
+ a: 637710443e-2,
538
+ rf: 300,
539
+ ellipseName: "Andrae 1876 (Den., Iclnd.)"
540
+ },
541
+ aust_SA: {
542
+ a: 6378160,
543
+ rf: 298.25,
544
+ ellipseName: "Australian Natl & S. Amer. 1969"
545
+ },
546
+ GRS67: {
547
+ a: 6378160,
548
+ rf: 298.247167427,
549
+ ellipseName: "GRS 67(IUGG 1967)"
550
+ },
551
+ bessel: {
552
+ a: 6377397155e-3,
553
+ rf: 299.1528128,
554
+ ellipseName: "Bessel 1841"
555
+ },
556
+ bess_nam: {
557
+ a: 6377483865e-3,
558
+ rf: 299.1528128,
559
+ ellipseName: "Bessel 1841 (Namibia)"
560
+ },
561
+ clrk66: {
562
+ a: 63782064e-1,
563
+ b: 63565838e-1,
564
+ ellipseName: "Clarke 1866"
565
+ },
566
+ clrk80: {
567
+ a: 6378249145e-3,
568
+ rf: 293.4663,
569
+ ellipseName: "Clarke 1880 mod."
570
+ },
571
+ clrk80ign: {
572
+ a: 63782492e-1,
573
+ b: 6356515,
574
+ rf: 293.4660213,
575
+ ellipseName: "Clarke 1880 (IGN)"
576
+ },
577
+ clrk58: {
578
+ a: 6378293645208759e-9,
579
+ rf: 294.2606763692654,
580
+ ellipseName: "Clarke 1858"
581
+ },
582
+ CPM: {
583
+ a: 63757387e-1,
584
+ rf: 334.29,
585
+ ellipseName: "Comm. des Poids et Mesures 1799"
586
+ },
587
+ delmbr: {
588
+ a: 6376428,
589
+ rf: 311.5,
590
+ ellipseName: "Delambre 1810 (Belgium)"
591
+ },
592
+ engelis: {
593
+ a: 637813605e-2,
594
+ rf: 298.2566,
595
+ ellipseName: "Engelis 1985"
596
+ },
597
+ evrst30: {
598
+ a: 6377276345e-3,
599
+ rf: 300.8017,
600
+ ellipseName: "Everest 1830"
601
+ },
602
+ evrst48: {
603
+ a: 6377304063e-3,
604
+ rf: 300.8017,
605
+ ellipseName: "Everest 1948"
606
+ },
607
+ evrst56: {
608
+ a: 6377301243e-3,
609
+ rf: 300.8017,
610
+ ellipseName: "Everest 1956"
611
+ },
612
+ evrst69: {
613
+ a: 6377295664e-3,
614
+ rf: 300.8017,
615
+ ellipseName: "Everest 1969"
616
+ },
617
+ evrstSS: {
618
+ a: 6377298556e-3,
619
+ rf: 300.8017,
620
+ ellipseName: "Everest (Sabah & Sarawak)"
621
+ },
622
+ fschr60: {
623
+ a: 6378166,
624
+ rf: 298.3,
625
+ ellipseName: "Fischer (Mercury Datum) 1960"
626
+ },
627
+ fschr60m: {
628
+ a: 6378155,
629
+ rf: 298.3,
630
+ ellipseName: "Fischer 1960"
631
+ },
632
+ fschr68: {
633
+ a: 6378150,
634
+ rf: 298.3,
635
+ ellipseName: "Fischer 1968"
636
+ },
637
+ helmert: {
638
+ a: 6378200,
639
+ rf: 298.3,
640
+ ellipseName: "Helmert 1906"
641
+ },
642
+ hough: {
643
+ a: 6378270,
644
+ rf: 297,
645
+ ellipseName: "Hough"
646
+ },
647
+ intl: {
648
+ a: 6378388,
649
+ rf: 297,
650
+ ellipseName: "International 1909 (Hayford)"
651
+ },
652
+ kaula: {
653
+ a: 6378163,
654
+ rf: 298.24,
655
+ ellipseName: "Kaula 1961"
656
+ },
657
+ lerch: {
658
+ a: 6378139,
659
+ rf: 298.257,
660
+ ellipseName: "Lerch 1979"
661
+ },
662
+ mprts: {
663
+ a: 6397300,
664
+ rf: 191,
665
+ ellipseName: "Maupertius 1738"
666
+ },
667
+ new_intl: {
668
+ a: 63781575e-1,
669
+ b: 63567722e-1,
670
+ ellipseName: "New International 1967"
671
+ },
672
+ plessis: {
673
+ a: 6376523,
674
+ b: 6355863,
675
+ ellipseName: "Plessis 1817 (France)"
676
+ },
677
+ krass: {
678
+ a: 6378245,
679
+ rf: 298.3,
680
+ ellipseName: "Krassovsky, 1942"
681
+ },
682
+ SEasia: {
683
+ a: 6378155,
684
+ b: 63567733205e-4,
685
+ ellipseName: "Southeast Asia"
686
+ },
687
+ walbeck: {
688
+ a: 6376896,
689
+ b: 63558348467e-4,
690
+ ellipseName: "Walbeck"
691
+ },
692
+ WGS60: {
693
+ a: 6378165,
694
+ rf: 298.3,
695
+ ellipseName: "WGS 60"
696
+ },
697
+ WGS66: {
698
+ a: 6378145,
699
+ rf: 298.25,
700
+ ellipseName: "WGS 66"
701
+ },
702
+ WGS72: {
703
+ a: 6378135,
704
+ rf: 298.26,
705
+ ellipseName: "WGS 72"
706
+ },
707
+ WGS84: {
708
+ a: 6378137,
709
+ rf: 298.257223563,
710
+ ellipseName: "WGS 84"
711
+ },
712
+ sphere: {
713
+ a: 6370997,
714
+ b: 6370997,
715
+ ellipseName: "Normal Sphere (r=6370997)"
716
+ }
717
+ };
718
+ var ellipsoid_table_default = ellipsoids;
719
+
720
+ // dist/projection/experimental/crs/primemeridian-table.js
721
+ var primeMeridian = {};
722
+ primeMeridian["greenwich"] = 0;
723
+ primeMeridian["lisbon"] = -9.131906111111;
724
+ primeMeridian["paris"] = 2.337229166667;
725
+ primeMeridian["bogota"] = -74.080916666667;
726
+ primeMeridian["madrid"] = -3.687938888889;
727
+ primeMeridian["rome"] = 12.452333333333;
728
+ primeMeridian["bern"] = 7.439583333333;
729
+ primeMeridian["jakarta"] = 106.807719444444;
730
+ primeMeridian["ferro"] = -17.666666666667;
731
+ primeMeridian["brussels"] = 4.367975;
732
+ primeMeridian["stockholm"] = 18.058277777778;
733
+ primeMeridian["athens"] = 23.7163375;
734
+ primeMeridian["oslo"] = 10.722916666667;
735
+ var primemeridian_table_default = primeMeridian;
736
+
737
+ // dist/crs/units-table.js
738
+ var linearUnits = {
739
+ m: { name: "meters", metersPerUnit: 1 },
740
+ mm: { name: "millimeters", metersPerUnit: 1e-3 },
741
+ cm: { name: "centimeters", metersPerUnit: 0.01 },
742
+ ft: { name: "feet", metersPerUnit: 0.3048 },
743
+ "us-ft": { name: "us-survey-feet", metersPerUnit: 1200 / 3937 },
744
+ fath: { name: "fathoms", metersPerUnit: 1.8288 },
745
+ kmi: { name: "nautical-miles", metersPerUnit: 1852 },
746
+ "us-ch": { name: "us-survey-chains", metersPerUnit: 20.1168402336805 },
747
+ "us-mi": { name: "us-survey-miles", metersPerUnit: 1609.34721869444 },
748
+ km: { name: "kilometers", metersPerUnit: 1e3 },
749
+ "ind-ft": { name: "indian-feet", metersPerUnit: 0.30479841 },
750
+ "ind-yd": { name: "indian-yards", metersPerUnit: 0.91439523 },
751
+ mi: { name: "miles", metersPerUnit: 1609.344 },
752
+ yd: { name: "yards", metersPerUnit: 0.9144 },
753
+ ch: { name: "chains", metersPerUnit: 20.1168 },
754
+ link: { name: "links", metersPerUnit: 0.201168 },
755
+ dm: { name: "decimeters", metersPerUnit: 0.1 },
756
+ in: { name: "inches", metersPerUnit: 0.0254 },
757
+ "ind-ch": { name: "indian-chains", metersPerUnit: 20.11669506 },
758
+ "us-in": { name: "us-survey-inches", metersPerUnit: 0.025400050800101 },
759
+ "us-yd": { name: "us-survey-yards", metersPerUnit: 0.914401828803658 }
760
+ };
761
+
762
+ // dist/projection/experimental/crs/normalize.js
763
+ var import_types2 = require("./crs/types.shared.cjs");
764
+ var ALIASES = {
765
+ WGS84: "+proj=longlat +datum=WGS84",
766
+ "EPSG:4326": "+proj=longlat +datum=WGS84",
767
+ "EPSG:4269": "+proj=longlat +datum=NAD83",
768
+ "EPSG:4978": "+proj=geocent +datum=WGS84",
769
+ "EPSG:4979": "+proj=longlat +datum=WGS84",
770
+ "EPSG:3857": "+proj=merc +a=6378137 +b=6378137 +nadgrids=@null +units=m",
771
+ "EPSG:3785": "EPSG:3857",
772
+ GOOGLE: "EPSG:3857",
773
+ "EPSG:900913": "EPSG:3857",
774
+ "EPSG:102113": "EPSG:3857"
775
+ };
776
+ var CORE_PARAMETERS = [
777
+ "proj",
778
+ "datum",
779
+ "ellps",
780
+ "a",
781
+ "b",
782
+ "rf",
783
+ "f",
784
+ "R",
785
+ "units",
786
+ "to_meter",
787
+ "vunits",
788
+ "vto_meter",
789
+ "no_defs",
790
+ "type",
791
+ "title",
792
+ "towgs84",
793
+ "nadgrids",
794
+ "geoidgrids",
795
+ "axis",
796
+ "pm",
797
+ "over",
798
+ "lon_wrap"
799
+ ];
800
+ var CORE_FLAGS = ["no_defs", "over"];
801
+ var own = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
802
+ var keyOf = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
803
+ function lookup(table, name) {
804
+ const key = Object.keys(table).find((key2) => keyOf(key2) === keyOf(name));
805
+ return key === void 0 ? void 0 : table[key];
806
+ }
807
+ function parseAngle(text) {
808
+ if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(text)) {
809
+ const value = Number(text);
810
+ if (Number.isFinite(value))
811
+ return value;
812
+ }
813
+ if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?r$/i.test(text)) {
814
+ const value = Number(text.slice(0, -1)) / DEGREES_TO_RADIANS;
815
+ if (Number.isFinite(value))
816
+ return value;
817
+ }
818
+ const dms = /^([+-]?)(\d+(?:\.\d*)?)(?:d(?:(\d+(?:\.\d*)?)'(?:(\d+(?:\.\d*)?)")?)?)?([NSEW])?$/i.exec(text);
819
+ if (dms && (/d/i.test(text) || dms[5])) {
820
+ const minutes = Number(dms[3] || 0), seconds = Number(dms[4] || 0);
821
+ if (minutes < 60 && seconds < 60) {
822
+ const sign = dms[1] === "-" ? -1 : 1;
823
+ const direction = /[SW]/i.test(dms[5] || "") ? -1 : 1;
824
+ const value = sign * direction * (Number(dms[2]) + minutes / 60 + seconds / 3600);
825
+ if (Number.isFinite(value))
826
+ return value;
827
+ }
828
+ }
829
+ throw new Error("Invalid angular parameter: " + text);
830
+ }
831
+ function resolveLocalCRSDefinition(input, options = {}) {
832
+ let definition = input;
833
+ const aliases = options.aliases || {};
834
+ const visited = /* @__PURE__ */ new Set();
835
+ while (typeof definition === "string" && (own(aliases, definition) || own(ALIASES, definition))) {
836
+ if (visited.has(definition))
837
+ throw new Error("Circular CRS alias: " + definition);
838
+ visited.add(definition);
839
+ definition = own(aliases, definition) ? aliases[definition] : ALIASES[definition];
840
+ }
841
+ if (typeof definition === "string") {
842
+ const utm = /^EPSG:(326|327)(\d{2})$/.exec(definition);
843
+ if (utm && Number(utm[2]) >= 1 && Number(utm[2]) <= 60) {
844
+ definition = "+proj=utm +datum=WGS84 +zone=" + Number(utm[2]) + (utm[1] === "327" ? " +south" : "");
845
+ }
846
+ if (definition === "EPSG:5041" || definition === "EPSG:5042") {
847
+ definition = "+proj=stere +datum=WGS84 +lat_0=" + (definition === "EPSG:5041" ? 90 : -90) + " +k_0=0.994 +x_0=2000000 +y_0=2000000";
848
+ }
849
+ }
850
+ return definition;
851
+ }
852
+ function normalizeCRS(input, options = {}) {
853
+ var _a;
854
+ const datums = getDatumDefinitions(options);
855
+ const resolved2 = resolveCRSInput(input, options);
856
+ const definition = resolveLocalCRSDefinition(resolved2.definition, options);
857
+ let parsed;
858
+ if (inferCRSRepresentation(definition) === "proj-string" && typeof definition === "string") {
859
+ const parameters2 = /* @__PURE__ */ Object.create(null);
860
+ for (const parameter of parsePROJString(definition).parameters) {
861
+ if (own(parameters2, parameter.name))
862
+ throw new Error("Duplicate PROJ parameter: +" + parameter.name);
863
+ parameters2[parameter.name] = parameter.value;
864
+ }
865
+ parsed = { parameters: parameters2 };
866
+ } else {
867
+ const parser = (_a = options.parsers) == null ? void 0 : _a.find((candidate) => candidate.canParse(definition));
868
+ if (!parser) {
869
+ const serialized = ["wkt", "projjson"].includes(inferCRSRepresentation(definition));
870
+ throw new import_types2.TypeScriptCRSError(serialized ? "missing-parser" : "unknown-syntax", inferCRSRepresentation(definition) === "identifier" ? "Unsupported CRS definition: " + definition + "; resolve it first" : "Unsupported CRS definition; register a WKT or PROJJSON parser for structured definitions");
871
+ }
872
+ parsed = parser.parse(definition, options);
873
+ }
874
+ const parameters = { ...parsed.parameters };
875
+ for (const name2 of [
876
+ "lon_0",
877
+ "lat_0",
878
+ "lat_1",
879
+ "lat_2",
880
+ "lat_ts",
881
+ "lon_wrap",
882
+ "lon_1",
883
+ "lon_2",
884
+ "lonc",
885
+ "alpha",
886
+ "gamma",
887
+ "tilt",
888
+ "azi",
889
+ "o_alpha",
890
+ "o_lon_c",
891
+ "o_lat_c",
892
+ "o_lon_p",
893
+ "o_lat_p",
894
+ "o_lon_1",
895
+ "o_lat_1",
896
+ "o_lon_2",
897
+ "o_lat_2"
898
+ ]) {
899
+ if (parameters[name2] !== void 0)
900
+ parameters[name2] = String(parseAngle(parameters[name2]));
901
+ }
902
+ const suppliedName = parameters["proj"];
903
+ const lowerName = suppliedName == null ? void 0 : suppliedName.toLowerCase();
904
+ const name = lowerName === "geocentric" ? "geocent" : ["longlat", "latlong", "latlon", "lonlat", "identity", "geocent"].includes(lowerName) ? lowerName : suppliedName;
905
+ if (!name)
906
+ throw new Error("CRS requires +proj");
907
+ const kind = ["longlat", "latlong", "latlon", "lonlat"].includes(name) ? "geographic" : name === "geocent" ? "geocentric" : name === "identity" ? "identity" : "projected";
908
+ const datumName = parameters["datum"];
909
+ const datum = datumName && datumName !== "none" ? lookup(datums, datumName) : void 0;
910
+ if (datumName && datumName !== "none" && !datum)
911
+ (0, import_types2.unsupportedStage)("Unknown datum: " + datumName + "; register a datumCatalogs plugin");
912
+ const ellipsoid = getEllipsoid(parameters, datum == null ? void 0 : datum.ellipse);
913
+ const grids = parameters["nadgrids"] ?? (datum == null ? void 0 : datum.nadgrids);
914
+ const gridReferences = grids === void 0 ? void 0 : grids.split(",").map((entry) => {
915
+ const optional = entry.startsWith("@");
916
+ const name2 = optional ? entry.slice(1) : entry;
917
+ if (!name2 || /\s/.test(name2))
918
+ throw new Error("Invalid datum grid name");
919
+ return Object.freeze({ name: name2, optional });
920
+ });
921
+ const rawShift = parameters["towgs84"] ?? (datum == null ? void 0 : datum.towgs84);
922
+ let shift;
923
+ if (rawShift !== void 0) {
924
+ shift = rawShift.split(",").map((value) => numberParameter({ value }, "value", NaN));
925
+ if (![3, 7].includes(shift.length) || shift.some((value) => !Number.isFinite(value)) || shift.length === 7 && shift[6] <= -1e6) {
926
+ throw new Error("+towgs84 requires three or seven finite values and positive scale");
927
+ }
928
+ }
929
+ if (datumName === "none")
930
+ shift = void 0;
931
+ if (gridReferences && datumName !== "none")
932
+ shift = [0, 0, 0];
933
+ const datumEllipsoid = grids === "@null" || grids === "null" ? getEllipsoid({ ellps: "WGS84" }) : ellipsoid;
934
+ const axis = parameters["axis"] || "enu";
935
+ if (axis.length !== 3 || !/[ew]/.test(axis) || !/[ns]/.test(axis) || !/[ud]/.test(axis))
936
+ throw new Error("Invalid axis: " + axis);
937
+ const angularUnit = parsed.angularUnit ?? DEGREES_TO_RADIANS;
938
+ if (kind === "geographic" && (parameters["units"] && parameters["units"] !== "degrees" || own(parameters, "to_meter")))
939
+ throw new Error("Geographic coordinates must use angular units");
940
+ if (kind !== "geographic" && parameters["units"] === "degrees")
941
+ throw new Error("Linear coordinates require linear units");
942
+ const toMeter = unitFactor(parameters, "units", "to_meter");
943
+ const verticalUnit = parsed.verticalUnit ?? unitFactor(parameters, "vunits", "vto_meter");
944
+ if (!(verticalUnit > 0) || !Number.isFinite(verticalUnit))
945
+ throw new Error("Invalid vertical unit");
946
+ if (!(angularUnit > 0) || !Number.isFinite(angularUnit))
947
+ throw new Error("Invalid angular unit");
948
+ const pm = parameters["pm"];
949
+ const primeMeridian2 = pm === void 0 ? 0 : (lookup(primemeridian_table_default, pm) ?? parseAngle(pm)) * DEGREES_TO_RADIANS;
950
+ return applySpatialReference(Object.freeze({
951
+ kind,
952
+ projection: name,
953
+ parameters: Object.freeze(parameters),
954
+ ellipsoid,
955
+ datum: Object.freeze({
956
+ ellipsoid: datumEllipsoid,
957
+ towgs84: shift && Object.freeze(shift),
958
+ grids: datumName === "none" || grids === "@null" || grids === "null" ? void 0 : gridReferences && Object.freeze(gridReferences)
959
+ }),
960
+ areaOfUse: parsed.areaOfUse,
961
+ angularUnit,
962
+ toMeter,
963
+ verticalUnit,
964
+ primeMeridian: primeMeridian2,
965
+ axis,
966
+ longitudeWrap: parameters["lon_wrap"] === void 0 ? void 0 : Number(parameters["lon_wrap"]) * DEGREES_TO_RADIANS,
967
+ lossy: Boolean(parsed.lossy || resolved2.lossy)
968
+ }), resolved2.spatialReference);
969
+ }
970
+ function unitFactor(parameters, unitKey, factorKey) {
971
+ const unit = parameters[unitKey];
972
+ const table = linearUnits;
973
+ if (unitKey === "vunits" && unit === "degrees")
974
+ throw new Error("Height requires linear units");
975
+ if (unit && !["m", "degrees"].includes(unit) && !own(table, unit))
976
+ throw new Error("Unsupported units: " + unit);
977
+ const factor = numberParameter(parameters, factorKey, unit && table[unit] ? table[unit].metersPerUnit : 1);
978
+ if (!(factor > 0))
979
+ throw new Error("+" + factorKey + " must be positive");
980
+ return factor;
981
+ }
982
+ function getEllipsoid(parameters, datumEllipsoid) {
983
+ const name = datumEllipsoid || parameters["ellps"] || "WGS84";
984
+ const definition = lookup(ellipsoid_table_default, name);
985
+ if (!definition)
986
+ throw new Error("Unsupported ellipsoid: " + name);
987
+ const a = numberParameter(parameters, "a", definition.a);
988
+ const f = numberParameter(parameters, "f", NaN);
989
+ const rf = numberParameter(parameters, "rf", Number.isNaN(f) ? definition.rf || 0 : f === 0 ? 0 : 1 / f);
990
+ const b = numberParameter(parameters, "b", rf ? a * (1 - 1 / rf) : own(parameters, "f") || own(parameters, "rf") || own(parameters, "a") ? a : definition.b || a);
991
+ const radius = numberParameter(parameters, "R", 0);
992
+ if (a <= 0 || b <= 0 || b > a || rf < 0 || rf > 0 && rf <= 1 || own(parameters, "R") && radius <= 0 || !Number.isNaN(f) && (f < 0 || f >= 1))
993
+ throw new Error("Invalid ellipsoid dimensions");
994
+ return Object.freeze({
995
+ semiMajorAxis: radius || a,
996
+ semiMinorAxis: radius || b,
997
+ eccentricitySquared: radius ? 0 : 1 - (b / a) ** 2
998
+ });
999
+ }
1000
+
1001
+ // dist/projection/experimental/typescript-projection.js
1002
+ var import_types4 = require("./crs/types.shared.cjs");
1003
+
1004
+ // dist/projection/experimental/datum.js
1005
+ var import_matrix = require("@math.gl/core/matrix");
1006
+ var ARC_SECOND = Math.PI / (180 * 3600);
1007
+ var WGS84 = {
1008
+ ellipsoid: {
1009
+ semiMajorAxis: 6378137,
1010
+ semiMinorAxis: 6356752314245179e-9,
1011
+ eccentricitySquared: 0.0066943799901413165
1012
+ },
1013
+ towgs84: [0, 0, 0]
1014
+ };
1015
+ function geodeticToGeocentricInPlace(point, ellipsoid) {
1016
+ if (Math.abs(point.y) > Math.PI / 2)
1017
+ throw new Error("Latitude outside geocentric domain");
1018
+ if (!(0, import_matrix.spheroidToCartesian)(point, ellipsoid))
1019
+ throw new Error("Geocentric coordinate must be finite");
1020
+ }
1021
+ function geocentricToGeodeticInPlace(point, ellipsoid) {
1022
+ const x = point.x, y = point.y, z = point.z;
1023
+ const { semiMajorAxis: a, semiMinorAxis: b, eccentricitySquared: es } = ellipsoid;
1024
+ if (x === 0 && y === 0 && z === 0)
1025
+ throw new Error("Geodetic coordinates are undefined at the Earth center");
1026
+ if (es !== 0 && Math.abs(x) < 1e-12 * a && Math.abs(y) < 1e-12 * a && Math.hypot(x, y) < 1e-12 * a) {
1027
+ if (!Number.isFinite(Math.hypot(x, y, z)))
1028
+ throw new Error("Geocentric radius must be finite");
1029
+ point.x = 0;
1030
+ point.y = Math.sign(z) * Math.PI / 2;
1031
+ point.z = Math.abs(z) - b;
1032
+ return;
1033
+ }
1034
+ if (!(0, import_matrix.cartesianToSpheroid)(point, ellipsoid)) {
1035
+ if (!Number.isFinite(Math.hypot(x, y, z)))
1036
+ throw new Error("Geocentric radius must be finite");
1037
+ throw new Error("Geocentric inverse did not converge");
1038
+ }
1039
+ }
1040
+ function createHelmert(values, inverse) {
1041
+ const dx = values[0], dy = values[1], dz = values[2];
1042
+ const rx = (values[3] || 0) * ARC_SECOND, ry = (values[4] || 0) * ARC_SECOND, rz = (values[5] || 0) * ARC_SECOND;
1043
+ const scale = 1 + (values[6] || 0) / 1e6;
1044
+ return inverse ? (point) => {
1045
+ const x = (point.x - dx) / scale, y = (point.y - dy) / scale, z = (point.z - dz) / scale;
1046
+ point.x = x + rz * y - ry * z;
1047
+ point.y = -rz * x + y + rx * z;
1048
+ point.z = ry * x - rx * y + z;
1049
+ } : (point) => {
1050
+ const x = point.x, y = point.y, z = point.z;
1051
+ point.x = scale * (x - rz * y + ry * z) + dx;
1052
+ point.y = scale * (rz * x + y - rx * z) + dy;
1053
+ point.z = scale * (-ry * x + rx * y + z) + dz;
1054
+ };
1055
+ }
1056
+ function shifted(datum) {
1057
+ var _a;
1058
+ return Boolean((_a = datum.towgs84) == null ? void 0 : _a.some((value) => value !== 0));
1059
+ }
1060
+ function createDatumTransform(source, destination) {
1061
+ if (!source.towgs84 || !destination.towgs84)
1062
+ return void 0;
1063
+ if (source.grids || destination.grids) {
1064
+ if (source.grids && destination.grids && source.ellipsoid.semiMajorAxis === destination.ellipsoid.semiMajorAxis && source.ellipsoid.eccentricitySquared === destination.ellipsoid.eccentricitySquared && source.grids.length === destination.grids.length && source.grids.every((entry, i) => entry.name === destination.grids[i].name && entry.optional === destination.grids[i].optional && entry.grid === destination.grids[i].grid))
1065
+ return void 0;
1066
+ const middle = createDatumTransform(source.grids ? WGS84 : source, destination.grids ? WGS84 : destination);
1067
+ return (point) => {
1068
+ if (source.grids)
1069
+ applyDatumGrids(point, source, false);
1070
+ middle == null ? void 0 : middle(point);
1071
+ if (destination.grids)
1072
+ applyDatumGrids(point, destination, true);
1073
+ };
1074
+ }
1075
+ if (shifted(source) || shifted(destination)) {
1076
+ const first = convertDatum(source, WGS84), second = convertDatum(WGS84, destination);
1077
+ return (point) => {
1078
+ first == null ? void 0 : first(point);
1079
+ second == null ? void 0 : second(point);
1080
+ };
1081
+ }
1082
+ return convertDatum(source, destination);
1083
+ }
1084
+ function convertDatum(from, to) {
1085
+ if (!from.towgs84 || !to.towgs84)
1086
+ return void 0;
1087
+ const a = from.ellipsoid, b = to.ellipsoid;
1088
+ let sameParameters = true;
1089
+ for (let i = 0; i < 7; i++)
1090
+ if ((from.towgs84[i] || 0) !== (to.towgs84[i] || 0))
1091
+ sameParameters = false;
1092
+ if (a.semiMajorAxis === b.semiMajorAxis && Math.abs(a.eccentricitySquared - b.eccentricitySquared) <= 5e-11 && sameParameters)
1093
+ return void 0;
1094
+ const sourceShift = shifted(from) ? createHelmert(from.towgs84, false) : void 0, targetShift = shifted(to) ? createHelmert(to.towgs84, true) : void 0;
1095
+ return (point) => {
1096
+ geodeticToGeocentricInPlace(point, a);
1097
+ sourceShift == null ? void 0 : sourceShift(point);
1098
+ targetShift == null ? void 0 : targetShift(point);
1099
+ geocentricToGeodeticInPlace(point, b);
1100
+ };
1101
+ }
1102
+ function applyDatumGrids(point, datum, inverse) {
1103
+ for (const reference of datum.grids) {
1104
+ if (reference.name === "null")
1105
+ return;
1106
+ if (!reference.grid) {
1107
+ if (reference.optional)
1108
+ continue;
1109
+ throw new Error("Required datum grid is not registered: " + reference.name);
1110
+ }
1111
+ let found = false;
1112
+ if (reference.grid.shiftInPlace)
1113
+ found = reference.grid.shiftInPlace(point, inverse);
1114
+ else {
1115
+ const output = reference.grid.shift(point.x, point.y, inverse);
1116
+ if (output) {
1117
+ point.x = output[0];
1118
+ point.y = output[1];
1119
+ found = true;
1120
+ }
1121
+ }
1122
+ if (found) {
1123
+ if (!Number.isFinite(point.x) || !Number.isFinite(point.y) || Math.abs(point.y) > Math.PI / 2)
1124
+ throw new Error("Datum grid produced a coordinate outside the geographic domain");
1125
+ return;
1126
+ }
1127
+ }
1128
+ throw new Error("No datum grid covers coordinate: " + datum.grids.map((grid) => grid.name).join(","));
1129
+ }
1130
+
1131
+ // dist/projection/experimental/rendering-profile/rectangular-rendering-profile.js
1132
+ function normalizeCoverage(point, coverage, center = 0, over = false) {
1133
+ const span = getLongitudeSpan(coverage);
1134
+ const west = span === 360 ? center - 180 : coverage[0] + Math.round((center - coverage[0] - span / 2) / 360) * 360;
1135
+ const east = west + span;
1136
+ if (over) {
1137
+ point.x = Math.max(west, Math.min(east, point.x));
1138
+ point.y = Math.max(coverage[1], Math.min(coverage[3], point.y));
1139
+ return;
1140
+ }
1141
+ const best = clampGeographicPoint(coverage, [point.x, point.y]);
1142
+ let longitude = best[0];
1143
+ if (best[0] === normalizeLongitude(point.x) && point.x >= west && point.x <= east)
1144
+ longitude = point.x;
1145
+ else if (longitude < west || longitude > east)
1146
+ longitude += Math.round(((west + east) / 2 - longitude) / 360) * 360;
1147
+ const offset = longitude - center;
1148
+ point.x = Math.abs(offset) <= 180 ? longitude : center + normalizeLongitude(offset);
1149
+ point.y = best[1];
1150
+ }
1151
+ function createRectangleRenderingProfile(resolveBounds2, coverage, origin = 0, primeMeridian2 = 0, over = false) {
1152
+ const center = (origin + primeMeridian2) * 180 / Math.PI;
1153
+ return {
1154
+ get bounds() {
1155
+ return resolveBounds2(getAngularRanges(coverage, primeMeridian2, origin));
1156
+ },
1157
+ normalize(point) {
1158
+ normalizeCoverage(point, coverage, center, over);
1159
+ }
1160
+ };
1161
+ }
1162
+
1163
+ // dist/projection/experimental/rendering-profile/rendering-bounds.js
1164
+ function longitudeRange(parameters, origin, over = false) {
1165
+ const low = parameters[0][0] - origin, high = parameters[1][0] - origin;
1166
+ if (over)
1167
+ return [low, high];
1168
+ const span = high - low;
1169
+ if (span >= 2 * Math.PI - 1e-12)
1170
+ return [-Math.PI, Math.PI];
1171
+ let west = wrapLongitude(low);
1172
+ if (span > 0 && Math.abs(west - Math.PI) < 1e-12)
1173
+ west = -Math.PI;
1174
+ const east = west + span;
1175
+ return east > Math.PI + 1e-12 ? [-Math.PI, Math.PI] : [west, Math.min(east, Math.PI)];
1176
+ }
1177
+
1178
+ // dist/projection/experimental/rendering-profile/geographic-rendering-profile.js
1179
+ function createGeographicProfile(parameters, primeMeridian2 = 0) {
1180
+ const center = numberParameter(parameters, "lon_wrap", 0) * DEGREES_TO_RADIANS;
1181
+ return (coverage) => createRectangleRenderingProfile((ranges) => {
1182
+ const longitude = longitudeRange(ranges, center);
1183
+ return [
1184
+ [center + longitude[0], ranges[0][1], 0],
1185
+ [center + longitude[1], ranges[1][1], 0]
1186
+ ];
1187
+ }, coverage ?? [-180, -90, 180, 90], center, primeMeridian2);
1188
+ }
1189
+
1190
+ // dist/projection/experimental/vertical-datum.js
1191
+ var import_types3 = require("./crs/types.shared.cjs");
1192
+ function compileVerticalGrid(names, grids = {}) {
1193
+ if (names === void 0)
1194
+ return void 0;
1195
+ const entries = [];
1196
+ for (const entry of names.split(",")) {
1197
+ const optional = entry.startsWith("@");
1198
+ const name = optional ? entry.slice(1) : entry;
1199
+ if (!name || /\s/.test(name))
1200
+ throw new Error("Invalid vertical grid name");
1201
+ if (name === "null") {
1202
+ entries.push(null);
1203
+ break;
1204
+ }
1205
+ const grid = Object.prototype.hasOwnProperty.call(grids, name) ? grids[name] : void 0;
1206
+ if (grid) {
1207
+ if (typeof grid.getOffset !== "function")
1208
+ throw new Error("Invalid vertical grid: " + name);
1209
+ entries.push(grid.getOffset.bind(grid));
1210
+ } else if (!optional)
1211
+ (0, import_types3.unsupportedStage)("Required vertical grid is not registered: " + name);
1212
+ }
1213
+ return (longitude, latitude) => {
1214
+ for (const sample of entries) {
1215
+ if (!sample)
1216
+ return 0;
1217
+ const offset = sample(longitude, latitude);
1218
+ if (offset === void 0)
1219
+ continue;
1220
+ if (!Number.isFinite(offset))
1221
+ throw new Error("Vertical grid returned a non-finite offset");
1222
+ return offset;
1223
+ }
1224
+ throw new Error("No vertical grid covers this coordinate");
1225
+ };
1226
+ }
1227
+
1228
+ // dist/projection/experimental/transform-description.js
1229
+ function describeCRS(crs) {
1230
+ const ellipsoid = Object.freeze({ ...crs.ellipsoid });
1231
+ return Object.freeze({
1232
+ kind: crs.kind,
1233
+ projection: crs.projection,
1234
+ parameters: Object.freeze(Object.fromEntries(Object.entries(crs.parameters).map(([name, value]) => [name, value ?? null]))),
1235
+ ellipsoid,
1236
+ datum: Object.freeze({
1237
+ ellipsoid: Object.freeze({ ...crs.datum.ellipsoid }),
1238
+ towgs84: crs.datum.towgs84 && Object.freeze([...crs.datum.towgs84]),
1239
+ grids: crs.datum.grids && Object.freeze(crs.datum.grids.map((reference) => Object.freeze({
1240
+ name: reference.name,
1241
+ optional: reference.optional,
1242
+ loaded: Boolean(reference.grid)
1243
+ })))
1244
+ }),
1245
+ angularUnit: crs.angularUnit,
1246
+ toMeter: crs.toMeter,
1247
+ verticalUnit: crs.verticalUnit,
1248
+ primeMeridian: crs.primeMeridian,
1249
+ axis: crs.axis,
1250
+ storedAxis: crs.storedAxis,
1251
+ longitudeWrap: crs.longitudeWrap,
1252
+ areaOfUse: crs.areaOfUse && Object.freeze([...crs.areaOfUse]),
1253
+ lossy: crs.lossy,
1254
+ algorithm: crs.algorithm && Object.freeze({ ...crs.algorithm })
1255
+ });
1256
+ }
1257
+ function describeTransform(source, target, forward, inverse) {
1258
+ const opaqueReasons = [];
1259
+ if (!source.algorithm)
1260
+ opaqueReasons.push("source-algorithm");
1261
+ if (!target.algorithm)
1262
+ opaqueReasons.push("target-algorithm");
1263
+ if (source.datum.grids || target.datum.grids || source.parameters["geoidgrids"] || target.parameters["geoidgrids"])
1264
+ opaqueReasons.push("grid-resource");
1265
+ return Object.freeze({
1266
+ version: 1,
1267
+ source,
1268
+ target,
1269
+ forward,
1270
+ inverse,
1271
+ lossy: source.lossy || target.lossy,
1272
+ complete: opaqueReasons.length === 0,
1273
+ opaqueReasons: Object.freeze(opaqueReasons)
1274
+ });
1275
+ }
1276
+
1277
+ // dist/projection/experimental/typescript-projection.js
1278
+ var ProjectionTransform = class _ProjectionTransform {
1279
+ /** Resolve required descriptors once, then return an ordinary synchronous instance. */
1280
+ static async create(options = {}) {
1281
+ const projections = await Promise.all(requiredProjections(options).map(preloadProjection));
1282
+ return new _ProjectionTransform({ ...options, projections });
1283
+ }
1284
+ get targetProfile() {
1285
+ return this.getTargetRenderingProfile(this.targetCoverage);
1286
+ }
1287
+ /** Resolve target rendering policy independently from coordinate conversion. @internal */
1288
+ getTargetRenderingProfile(coverage) {
1289
+ return this.targetRenderingProfile && resolveRenderingProfile(this.targetRenderingProfile, coverage);
1290
+ }
1291
+ /** Deferred transforms expose metadata only once their implementations are prepared. */
1292
+ get description() {
1293
+ var _a, _b;
1294
+ return ((_b = (_a = this.deferred) == null ? void 0 : _a.implementation) == null ? void 0 : _b.description) ?? this.resolvedDescription;
1295
+ }
1296
+ constructor(options = {}) {
1297
+ var _a, _b, _c;
1298
+ this.coordinateScratch = new ProjectionScratch();
1299
+ this.targetLongitudeOrigin = 0;
1300
+ const registrations = options.projections || [];
1301
+ const plugins = registry(registrations);
1302
+ if (registrations.some((projection) => !("create" in projection))) {
1303
+ const from = normalizeCRS(options.from ?? "WGS84", options);
1304
+ const to = normalizeCRS(options.to ?? "WGS84", options);
1305
+ this.lossy = from.lossy || to.lossy;
1306
+ this.deferred = { options: { ...options, projections: [...registrations] } };
1307
+ } else {
1308
+ const eager = options;
1309
+ const eagerPlugins = plugins;
1310
+ const from = compileCRS(eager.from ?? "WGS84", eagerPlugins, eager);
1311
+ const to = compileCRS(eager.to ?? "WGS84", eagerPlugins, eager);
1312
+ this.targetRenderingProfile = ((_b = (_a = to.implementation) == null ? void 0 : _a.getRenderingProfile) == null ? void 0 : _b.bind(to.implementation)) ?? (to.kind === "geographic" ? createGeographicProfile(to.parameters, to.primeMeridian) : to.kind === "identity" ? getIdentityRenderingProfile : void 0);
1313
+ this.targetCoverage = to.areaOfUse;
1314
+ this.targetLongitudeOrigin = ((_c = to.implementation) == null ? void 0 : _c.longitudeOrigin) ?? (to.kind === "geographic" ? to.longitudeWrap ?? 0 : 0);
1315
+ this.lossy = from.lossy || to.lossy;
1316
+ if (this.lossy && (from.kind === "geocentric" || to.kind === "geocentric"))
1317
+ (0, import_types4.unsupportedStage)("Horizontal extraction cannot supply ellipsoidal height for geocentric coordinates");
1318
+ if (this.lossy && (from.verticalGrid || to.verticalGrid))
1319
+ (0, import_types4.unsupportedStage)("Horizontal extraction cannot be combined with vertical grids");
1320
+ this.forwardTransform = compileTransform(from, to, Boolean(options.enforceAxis));
1321
+ this.inverseTransform = compileTransform(to, from, Boolean(options.enforceAxis));
1322
+ this.resolvedDescription = describeTransform(describeCRS(from), describeCRS(to), this.forwardTransform.description, this.inverseTransform.description);
1323
+ }
1324
+ this.project = this.project.bind(this);
1325
+ this.unproject = this.unproject.bind(this);
1326
+ this.projectTo = this.projectTo.bind(this);
1327
+ this.unprojectTo = this.unprojectTo.bind(this);
1328
+ this.projectToSync = this.projectToSync.bind(this);
1329
+ this.unprojectToSync = this.unprojectToSync.bind(this);
1330
+ this.projectFlat = this.projectFlat.bind(this);
1331
+ this.unprojectFlat = this.unprojectFlat.bind(this);
1332
+ this.projectSync = this.projectSync.bind(this);
1333
+ this.unprojectSync = this.unprojectSync.bind(this);
1334
+ this.projectFlatSync = this.projectFlatSync.bind(this);
1335
+ this.unprojectFlatSync = this.unprojectFlatSync.bind(this);
1336
+ }
1337
+ load() {
1338
+ const state = this.deferred;
1339
+ if (!state)
1340
+ return Promise.resolve(this);
1341
+ if (state.implementation)
1342
+ return Promise.resolve(state.implementation);
1343
+ state.pending || (state.pending = _ProjectionTransform.create(state.options).then((projection) => {
1344
+ state.implementation = projection;
1345
+ return projection;
1346
+ }).catch((error) => {
1347
+ state.pending = void 0;
1348
+ throw error;
1349
+ }));
1350
+ return state.pending;
1351
+ }
1352
+ loadSync() {
1353
+ const state = this.deferred;
1354
+ if (!state)
1355
+ return this;
1356
+ if (!state.implementation) {
1357
+ const projections = requiredProjections(state.options).map((descriptor) => {
1358
+ const plugin = getLoadedProjection(descriptor);
1359
+ if (!plugin)
1360
+ throw new Error("Projection is not preloaded: " + descriptor.name + ". Call preload() first.");
1361
+ return plugin;
1362
+ });
1363
+ state.implementation = new _ProjectionTransform({ ...state.options, projections });
1364
+ }
1365
+ return state.implementation;
1366
+ }
1367
+ /** Synchronous variants never import algorithms; descriptors must be preloaded. */
1368
+ projectSync(coordinate) {
1369
+ return this.deferred ? this.loadSync().project(coordinate) : transformScalar(coordinate, this.forwardTransform, this.coordinateScratch);
1370
+ }
1371
+ unprojectSync(coordinate) {
1372
+ return this.deferred ? this.loadSync().unproject(coordinate) : transformScalar(coordinate, this.inverseTransform, this.coordinateScratch);
1373
+ }
1374
+ projectFlatSync(coordinates, dimension = 2) {
1375
+ return this.deferred ? this.loadSync().projectFlat(coordinates, dimension) : transformInPlace(coordinates, dimension, this.forwardTransform, this.coordinateScratch);
1376
+ }
1377
+ unprojectFlatSync(coordinates, dimension = 2) {
1378
+ return this.deferred ? this.loadSync().unprojectFlat(coordinates, dimension) : transformInPlace(coordinates, dimension, this.inverseTransform, this.coordinateScratch);
1379
+ }
1380
+ /** Optional warm-up. Coordinate methods also load automatically on first use. */
1381
+ async preload() {
1382
+ await this.load();
1383
+ }
1384
+ /** Eager plugins return arrays; descriptor-backed instances return promises. */
1385
+ project(coordinate) {
1386
+ const result = this.deferred ? this.projectLoaded(coordinate, false) : transformScalar(coordinate, this.forwardTransform, this.coordinateScratch);
1387
+ return result;
1388
+ }
1389
+ unproject(coordinate) {
1390
+ const result = this.deferred ? this.projectLoaded(coordinate, true) : transformScalar(coordinate, this.inverseTransform, this.coordinateScratch);
1391
+ return result;
1392
+ }
1393
+ /** Write one coordinate into caller-owned storage; return that same output. */
1394
+ projectTo(coordinate, output) {
1395
+ return this.deferred ? this.projectToLoaded(coordinate, output, false) : this.projectToSync(coordinate, output);
1396
+ }
1397
+ unprojectTo(coordinate, output) {
1398
+ return this.deferred ? this.projectToLoaded(coordinate, output, true) : this.unprojectToSync(coordinate, output);
1399
+ }
1400
+ projectToSync(coordinate, output) {
1401
+ if (this.deferred)
1402
+ return this.loadSync().projectTo(coordinate, output);
1403
+ validateScalarOutput(coordinate, output, Math.max(coordinate.length, this.forwardTransform.geocentricOutput ? 3 : 2));
1404
+ return transformScalar(coordinate, this.forwardTransform, this.coordinateScratch, output);
1405
+ }
1406
+ unprojectToSync(coordinate, output) {
1407
+ if (this.deferred)
1408
+ return this.loadSync().unprojectTo(coordinate, output);
1409
+ validateScalarOutput(coordinate, output, Math.max(coordinate.length, this.inverseTransform.geocentricOutput ? 3 : 2));
1410
+ return transformScalar(coordinate, this.inverseTransform, this.coordinateScratch, output);
1411
+ }
1412
+ projectToLoaded(coordinate, output, inverse) {
1413
+ validateScalarOutput(coordinate, output, coordinate.length);
1414
+ const input = coordinate.slice();
1415
+ return this.load().then((projection) => inverse ? projection.unprojectTo(input, output) : projection.projectTo(input, output));
1416
+ }
1417
+ projectLoaded(coordinate, inverse) {
1418
+ const input = coordinate.slice();
1419
+ return this.load().then((projection) => inverse ? projection.unproject(input) : projection.project(input));
1420
+ }
1421
+ /** In-place; descriptor callers must await completion before reusing the buffer. */
1422
+ projectFlat(coordinates, dimension = 2) {
1423
+ const result = this.deferred ? this.load().then((projection) => projection.projectFlat(coordinates, dimension)) : transformInPlace(coordinates, dimension, this.forwardTransform, this.coordinateScratch);
1424
+ return result;
1425
+ }
1426
+ unprojectFlat(coordinates, dimension = 2) {
1427
+ const result = this.deferred ? this.load().then((projection) => projection.unprojectFlat(coordinates, dimension)) : transformInPlace(coordinates, dimension, this.inverseTransform, this.coordinateScratch);
1428
+ return result;
1429
+ }
1430
+ };
1431
+ function requiredProjections(options) {
1432
+ const available = registry(options.projections || []);
1433
+ const required = /* @__PURE__ */ new Set();
1434
+ for (const definition of [options.from ?? "WGS84", options.to ?? "WGS84"]) {
1435
+ const crs = normalizeCRS(definition, options);
1436
+ if (["geographic", "identity"].includes(crs.kind))
1437
+ continue;
1438
+ const projection = available.get(pluginKey(crs.projection));
1439
+ if (!projection)
1440
+ throw new import_types4.TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
1441
+ required.add(projection);
1442
+ }
1443
+ return [...required];
1444
+ }
1445
+ function checkProjectionCompatibility(definition, options = {}) {
1446
+ try {
1447
+ const crs = compileCRS(definition, registry(options.projections || []), options);
1448
+ return { status: "supported", lossy: crs.lossy };
1449
+ } catch (error) {
1450
+ const reason = error instanceof import_types4.TypeScriptCRSError ? error.reason : "invalid-definition";
1451
+ return {
1452
+ status: reason === "unknown-syntax" ? "unknown" : "unsupported",
1453
+ lossy: false,
1454
+ reason,
1455
+ message: error instanceof Error ? error.message : String(error)
1456
+ };
1457
+ }
1458
+ }
1459
+ var pluginKey = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
1460
+ function registry(projections) {
1461
+ const plugins = /* @__PURE__ */ new Map();
1462
+ for (const plugin of projections) {
1463
+ for (const name of new Set([plugin.name, ...plugin.aliases || []].map(pluginKey))) {
1464
+ if (!name || ["longlat", "latlong", "latlon", "lonlat", "identity"].includes(name) || plugins.has(name))
1465
+ throw new Error("Duplicate or reserved projection plugin: " + name);
1466
+ plugins.set(name, plugin);
1467
+ }
1468
+ }
1469
+ return plugins;
1470
+ }
1471
+ function compileCRS(definition, plugins, options) {
1472
+ var _a;
1473
+ const crs = normalizeCRS(definition, options);
1474
+ const plugin = plugins.get(pluginKey(crs.projection));
1475
+ if (!["geographic", "identity"].includes(crs.kind) && !plugin)
1476
+ throw new import_types4.TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
1477
+ const allowed = /* @__PURE__ */ new Set([...CORE_PARAMETERS, ...(plugin == null ? void 0 : plugin.parameters) || []]);
1478
+ for (const key of Object.keys(crs.parameters)) {
1479
+ if (!allowed.has(key))
1480
+ throw new import_types4.TypeScriptCRSError("missing-transform-stage", "Unsupported PROJ parameter: +" + key);
1481
+ const flag = CORE_FLAGS.includes(key) || ((_a = plugin == null ? void 0 : plugin.flags) == null ? void 0 : _a.includes(key));
1482
+ if (flag && crs.parameters[key] !== void 0)
1483
+ throw new Error("Expected a flag without a value: +" + key);
1484
+ if (!flag && !crs.parameters[key])
1485
+ throw new Error("PROJ parameter requires a value: +" + key);
1486
+ }
1487
+ if (crs.parameters["type"] && crs.parameters["type"] !== "crs")
1488
+ throw new Error("Only +type=crs is supported");
1489
+ const parameters = pluginKey(crs.projection) === "fasttransversemercator" ? Object.freeze({ ...crs.parameters, approx: void 0 }) : crs.parameters;
1490
+ const implementation = plugin == null ? void 0 : plugin.create({
1491
+ ...crs.ellipsoid,
1492
+ parameters,
1493
+ primeMeridian: crs.primeMeridian
1494
+ });
1495
+ if (crs.kind === "geocentric" && (!(implementation == null ? void 0 : implementation.forward3D) || !(implementation == null ? void 0 : implementation.inverse3D)))
1496
+ throw new Error("Geocentric plugin must implement 3D operations");
1497
+ const references = crs.datum.grids;
1498
+ const nullIndex = (references == null ? void 0 : references.findIndex((reference) => reference.name === "null")) ?? -1;
1499
+ const grids = references == null ? void 0 : references.slice(0, nullIndex < 0 ? void 0 : nullIndex + 1).map((reference) => {
1500
+ const grid = Object.prototype.hasOwnProperty.call(options.datumGrids || {}, reference.name) ? options.datumGrids[reference.name] : void 0;
1501
+ if (grid && typeof grid.shift !== "function")
1502
+ throw new Error("Invalid prepared datum grid: " + reference.name);
1503
+ return Object.freeze({ ...reference, grid });
1504
+ });
1505
+ for (const reference of grids || []) {
1506
+ if (reference.name === "null")
1507
+ break;
1508
+ if (!reference.optional && !reference.grid)
1509
+ (0, import_types4.unsupportedStage)("Required datum grid is not registered: " + reference.name);
1510
+ }
1511
+ const datum = grids ? Object.freeze({ ...crs.datum, grids: Object.freeze(grids) }) : crs.datum;
1512
+ const verticalGrid = compileVerticalGrid(crs.parameters["geoidgrids"], options.verticalGrids);
1513
+ if (verticalGrid && (crs.kind === "geocentric" || crs.kind === "identity" || crs.lossy))
1514
+ (0, import_types4.unsupportedStage)("Vertical grids require a non-lossy geographic or projected CRS");
1515
+ const algorithm = plugin ? plugin.semantics : { id: "@math.gl/geospatial/" + crs.kind, version: 1 };
1516
+ return { ...crs, datum, implementation, verticalGrid, algorithm };
1517
+ }
1518
+ function finite(point) {
1519
+ return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z);
1520
+ }
1521
+ function compileAxis(axis, inverse) {
1522
+ if (axis === "enu")
1523
+ return void 0;
1524
+ const indexes = [0, 0, 0], signs = [0, 0, 0];
1525
+ for (let i = 0; i < 3; i++) {
1526
+ const char = axis[i], component = "ew".includes(char) ? 0 : "ns".includes(char) ? 1 : 2;
1527
+ indexes[inverse ? i : component] = inverse ? component : i;
1528
+ signs[inverse ? i : component] = "wsd".includes(char) ? -1 : 1;
1529
+ }
1530
+ return (point) => {
1531
+ const x = point.x, y = point.y, z = point.z;
1532
+ point.x = signs[0] * (indexes[0] === 0 ? x : indexes[0] === 1 ? y : z);
1533
+ point.y = signs[1] * (indexes[1] === 0 ? x : indexes[1] === 1 ? y : z);
1534
+ point.z = signs[2] * (indexes[2] === 0 ? x : indexes[2] === 1 ? y : z);
1535
+ };
1536
+ }
1537
+ function compileTransform(from, to, enforceAxis) {
1538
+ var _a, _b, _c, _d;
1539
+ const fromAxis = from.storedAxis || (enforceAxis ? from.axis : "enu");
1540
+ const toAxis = to.storedAxis || (enforceAxis ? to.axis : "enu");
1541
+ const inputAxis = compileAxis(fromAxis, false), outputAxis = compileAxis(toAxis, true);
1542
+ const source = from.implementation && projectionOperation(from.implementation, true, from.kind === "geocentric");
1543
+ const target = to.implementation && projectionOperation(to.implementation, false, to.kind === "geocentric");
1544
+ const datum = createDatumTransform(from.datum, to.datum);
1545
+ const horizontalOnly = from.lossy || to.lossy;
1546
+ const fromGeocentric = from.kind === "geocentric";
1547
+ const inputScale = from.kind === "geographic" ? from.angularUnit : from.toMeter;
1548
+ const outputScale = to.kind === "geographic" ? to.angularUnit : to.toMeter;
1549
+ const inputVerticalScale = fromGeocentric ? 1 : from.verticalUnit, outputVerticalScale = to.kind === "geocentric" ? outputScale : to.verticalUnit;
1550
+ const fromPrime = from.primeMeridian, toPrime = to.primeMeridian;
1551
+ const longitudeWrap = to.kind === "geographic" ? to.longitudeWrap : void 0;
1552
+ let flat;
1553
+ if (!datum && !from.verticalGrid && !to.verticalGrid && !horizontalOnly && !inputAxis && !outputAxis && !fromPrime && !toPrime && from.verticalUnit === 1 && to.verticalUnit === 1 && longitudeWrap === void 0) {
1554
+ const context = Object.freeze({ inputScale, outputScale });
1555
+ if (from.kind === "geographic" && to.kind === "projected")
1556
+ flat = (_b = (_a = to.implementation) == null ? void 0 : _a.createForwardFlat) == null ? void 0 : _b.call(_a, context);
1557
+ if (from.kind === "projected" && to.kind === "geographic")
1558
+ flat = (_d = (_c = from.implementation) == null ? void 0 : _c.createInverseFlat) == null ? void 0 : _d.call(_c, context);
1559
+ }
1560
+ const requiresInputZ = Boolean(from.verticalGrid || to.verticalGrid) || from.kind === "geocentric" || /[ud]/.test(fromAxis.slice(0, 2)) || /[ud]/.test(toAxis.slice(0, 2));
1561
+ const stages = [];
1562
+ if (inputAxis)
1563
+ stages.push("input-axis");
1564
+ if (horizontalOnly)
1565
+ stages.push("discard-height");
1566
+ if (inputScale !== 1)
1567
+ stages.push("input-scale");
1568
+ if (source)
1569
+ stages.push("source-inverse");
1570
+ if (inputVerticalScale !== 1)
1571
+ stages.push("input-height-scale");
1572
+ stages.push("geographic-domain-check");
1573
+ if (fromPrime)
1574
+ stages.push("source-prime-meridian");
1575
+ if (from.verticalGrid)
1576
+ stages.push("source-vertical-grid");
1577
+ if (datum)
1578
+ stages.push("datum");
1579
+ if (to.verticalGrid)
1580
+ stages.push("target-vertical-grid");
1581
+ if (toPrime)
1582
+ stages.push("target-prime-meridian");
1583
+ if (longitudeWrap !== void 0)
1584
+ stages.push("longitude-wrap");
1585
+ if (target)
1586
+ stages.push("target-forward");
1587
+ if (outputScale !== 1)
1588
+ stages.push("output-scale");
1589
+ if (outputVerticalScale !== 1)
1590
+ stages.push("output-height-scale");
1591
+ if (horizontalOnly)
1592
+ stages.push("restore-height");
1593
+ if (outputAxis)
1594
+ stages.push("output-axis");
1595
+ return {
1596
+ description: Object.freeze({
1597
+ inputAxis: fromAxis,
1598
+ outputAxis: toAxis,
1599
+ requiresInputZ,
1600
+ geocentricOutput: to.kind === "geocentric",
1601
+ stages: Object.freeze(stages)
1602
+ }),
1603
+ flat,
1604
+ requiresInputZ,
1605
+ geocentricOutput: to.kind === "geocentric",
1606
+ run(point) {
1607
+ if (!finite(point))
1608
+ throw new Error("Coordinates must contain finite x, y and optional z values");
1609
+ inputAxis == null ? void 0 : inputAxis(point);
1610
+ const preservedHeight = point.z;
1611
+ if (horizontalOnly)
1612
+ point.z = 0;
1613
+ if (inputScale !== 1) {
1614
+ point.x *= inputScale;
1615
+ point.y *= inputScale;
1616
+ if (fromGeocentric)
1617
+ point.z *= inputScale;
1618
+ }
1619
+ source == null ? void 0 : source(point);
1620
+ if (inputVerticalScale !== 1)
1621
+ point.z *= inputVerticalScale;
1622
+ if (Math.abs(point.y) > Math.PI / 2 || !finite(point))
1623
+ throw new Error("Coordinate is outside the geographic domain");
1624
+ point.x += fromPrime;
1625
+ if (from.verticalGrid)
1626
+ point.z += from.verticalGrid(point.x, point.y);
1627
+ datum == null ? void 0 : datum(point);
1628
+ if (to.verticalGrid)
1629
+ point.z -= to.verticalGrid(point.x, point.y);
1630
+ point.x -= toPrime;
1631
+ if (longitudeWrap !== void 0)
1632
+ point.x = longitudeWrap + wrapLongitude(point.x - longitudeWrap);
1633
+ target == null ? void 0 : target(point);
1634
+ if (outputScale !== 1) {
1635
+ point.x /= outputScale;
1636
+ point.y /= outputScale;
1637
+ }
1638
+ if (outputVerticalScale !== 1)
1639
+ point.z /= outputVerticalScale;
1640
+ if (horizontalOnly)
1641
+ point.z = preservedHeight;
1642
+ outputAxis == null ? void 0 : outputAxis(point);
1643
+ if (!finite(point))
1644
+ throw new Error("Projection produced non-finite coordinates");
1645
+ }
1646
+ };
1647
+ }
1648
+ function transformScalar(coordinate, operation, scratch, output) {
1649
+ if (coordinate.length < 2)
1650
+ throw new Error("Coordinates must contain finite x, y and optional z values");
1651
+ if (coordinate.length < 3 && operation.requiresInputZ)
1652
+ throw new Error("This transform requires three ordinates");
1653
+ const length = Math.max(coordinate.length, operation.geocentricOutput ? 3 : 2);
1654
+ const point = scratch.acquire();
1655
+ try {
1656
+ point.x = coordinate[0];
1657
+ point.y = coordinate[1];
1658
+ point.z = coordinate.length >= 3 ? coordinate[2] : 0;
1659
+ operation.run(point);
1660
+ if (output)
1661
+ return writeScalarOutput(coordinate, output, point, length);
1662
+ const result = coordinate.slice();
1663
+ result[0] = point.x;
1664
+ result[1] = point.y;
1665
+ if (coordinate.length >= 3 || operation.geocentricOutput)
1666
+ result[2] = point.z;
1667
+ return result;
1668
+ } finally {
1669
+ scratch.release(point);
1670
+ }
1671
+ }
1672
+ function transformInPlace(coordinates, dimension, operation, scratch) {
1673
+ if (!(coordinates instanceof Float32Array || coordinates instanceof Float64Array))
1674
+ throw new Error("In-place projection requires a Float32Array or Float64Array");
1675
+ if (!Number.isSafeInteger(dimension) || dimension < 2 || coordinates.length % dimension !== 0)
1676
+ throw new Error("Dimension must be an integer >= 2 and divide the typed array length");
1677
+ if (dimension < 3 && (operation.requiresInputZ || operation.geocentricOutput))
1678
+ throw new Error("This transform requires a dimension of at least 3");
1679
+ if (operation.flat) {
1680
+ operation.flat(coordinates, dimension);
1681
+ return coordinates;
1682
+ }
1683
+ const point = scratch.acquire();
1684
+ try {
1685
+ const float32 = coordinates instanceof Float32Array;
1686
+ for (let offset = 0; offset < coordinates.length; offset += dimension) {
1687
+ point.x = coordinates[offset];
1688
+ point.y = coordinates[offset + 1];
1689
+ point.z = dimension >= 3 ? coordinates[offset + 2] : 0;
1690
+ operation.run(point);
1691
+ if (float32 && (Math.abs(point.x) > 34028234663852886e22 || Math.abs(point.y) > 34028234663852886e22 || dimension >= 3 && Math.abs(point.z) > 34028234663852886e22))
1692
+ throw new Error("Projected coordinate exceeds Float32 range");
1693
+ coordinates[offset] = point.x;
1694
+ coordinates[offset + 1] = point.y;
1695
+ if (dimension >= 3)
1696
+ coordinates[offset + 2] = point.z;
1697
+ }
1698
+ return coordinates;
1699
+ } finally {
1700
+ scratch.release(point);
1701
+ }
1702
+ }
1703
+ //# sourceMappingURL=typescript-projection.shared.cjs.map