@math.gl/geospatial 5.0.0-beta.10 → 5.0.0-beta.12

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 (360) hide show
  1. package/README.md +3 -3
  2. package/dist/crs/index.cjs +54 -0
  3. package/dist/crs/index.cjs.map +2 -2
  4. package/dist/crs/index.d.ts +1 -0
  5. package/dist/crs/index.d.ts.map +1 -1
  6. package/dist/crs/index.js +1 -0
  7. package/dist/crs/index.js.map +1 -1
  8. package/dist/crs/spatial-reference-metadata.d.ts +20 -0
  9. package/dist/crs/spatial-reference-metadata.d.ts.map +1 -0
  10. package/dist/crs/spatial-reference-metadata.js +86 -0
  11. package/dist/crs/spatial-reference-metadata.js.map +1 -0
  12. package/dist/expressions.d.ts +1 -1
  13. package/dist/expressions.d.ts.map +1 -1
  14. package/dist/index.cjs +1738 -316
  15. package/dist/index.cjs.map +3 -3
  16. package/dist/index.d.ts +14 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +12 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/projection/experimental/core.cjs.map +1 -1
  21. package/dist/projection/experimental/crs/spatial-reference.d.ts.map +1 -1
  22. package/dist/projection/experimental/crs/spatial-reference.js.map +1 -1
  23. package/dist/projection/experimental/crs/types.d.ts.map +1 -1
  24. package/dist/projection/experimental/lazy-projections/aea.cjs +4 -1
  25. package/dist/projection/experimental/lazy-projections/aea.cjs.map +1 -1
  26. package/dist/projection/experimental/lazy-projections/aea.d.ts.map +1 -1
  27. package/dist/projection/experimental/lazy-projections/aea.js +4 -1
  28. package/dist/projection/experimental/lazy-projections/aea.js.map +1 -1
  29. package/dist/projection/experimental/lazy-projections/bonne.cjs +4 -1
  30. package/dist/projection/experimental/lazy-projections/bonne.cjs.map +1 -1
  31. package/dist/projection/experimental/lazy-projections/bonne.d.ts.map +1 -1
  32. package/dist/projection/experimental/lazy-projections/bonne.js +4 -1
  33. package/dist/projection/experimental/lazy-projections/bonne.js.map +1 -1
  34. package/dist/projection/experimental/lazy-projections/cass.cjs +4 -1
  35. package/dist/projection/experimental/lazy-projections/cass.cjs.map +1 -1
  36. package/dist/projection/experimental/lazy-projections/cass.d.ts.map +1 -1
  37. package/dist/projection/experimental/lazy-projections/cass.js +4 -1
  38. package/dist/projection/experimental/lazy-projections/cass.js.map +1 -1
  39. package/dist/projection/experimental/lazy-projections/eck6.cjs +4 -1
  40. package/dist/projection/experimental/lazy-projections/eck6.cjs.map +1 -1
  41. package/dist/projection/experimental/lazy-projections/eck6.d.ts.map +1 -1
  42. package/dist/projection/experimental/lazy-projections/eck6.js +4 -1
  43. package/dist/projection/experimental/lazy-projections/eck6.js.map +1 -1
  44. package/dist/projection/experimental/lazy-projections/eqdc.cjs +4 -1
  45. package/dist/projection/experimental/lazy-projections/eqdc.cjs.map +1 -1
  46. package/dist/projection/experimental/lazy-projections/eqdc.d.ts.map +1 -1
  47. package/dist/projection/experimental/lazy-projections/eqdc.js +4 -1
  48. package/dist/projection/experimental/lazy-projections/eqdc.js.map +1 -1
  49. package/dist/projection/experimental/lazy-projections/eqearth.cjs +4 -1
  50. package/dist/projection/experimental/lazy-projections/eqearth.cjs.map +1 -1
  51. package/dist/projection/experimental/lazy-projections/eqearth.d.ts.map +1 -1
  52. package/dist/projection/experimental/lazy-projections/eqearth.js +4 -1
  53. package/dist/projection/experimental/lazy-projections/eqearth.js.map +1 -1
  54. package/dist/projection/experimental/lazy-projections/equi.cjs +4 -1
  55. package/dist/projection/experimental/lazy-projections/equi.cjs.map +1 -1
  56. package/dist/projection/experimental/lazy-projections/equi.d.ts.map +1 -1
  57. package/dist/projection/experimental/lazy-projections/equi.js +4 -1
  58. package/dist/projection/experimental/lazy-projections/equi.js.map +1 -1
  59. package/dist/projection/experimental/lazy-projections/geocent.cjs +4 -1
  60. package/dist/projection/experimental/lazy-projections/geocent.cjs.map +1 -1
  61. package/dist/projection/experimental/lazy-projections/geocent.d.ts.map +1 -1
  62. package/dist/projection/experimental/lazy-projections/geocent.js +4 -1
  63. package/dist/projection/experimental/lazy-projections/geocent.js.map +1 -1
  64. package/dist/projection/experimental/lazy-projections/geos.cjs +4 -1
  65. package/dist/projection/experimental/lazy-projections/geos.cjs.map +1 -1
  66. package/dist/projection/experimental/lazy-projections/geos.d.ts.map +1 -1
  67. package/dist/projection/experimental/lazy-projections/geos.js +4 -1
  68. package/dist/projection/experimental/lazy-projections/geos.js.map +1 -1
  69. package/dist/projection/experimental/lazy-projections/gnom.cjs +4 -1
  70. package/dist/projection/experimental/lazy-projections/gnom.cjs.map +1 -1
  71. package/dist/projection/experimental/lazy-projections/gnom.d.ts.map +1 -1
  72. package/dist/projection/experimental/lazy-projections/gnom.js +4 -1
  73. package/dist/projection/experimental/lazy-projections/gnom.js.map +1 -1
  74. package/dist/projection/experimental/lazy-projections/index.cjs +92 -23
  75. package/dist/projection/experimental/lazy-projections/index.cjs.map +1 -1
  76. package/dist/projection/experimental/lazy-projections/krovak.cjs +4 -1
  77. package/dist/projection/experimental/lazy-projections/krovak.cjs.map +1 -1
  78. package/dist/projection/experimental/lazy-projections/krovak.d.ts.map +1 -1
  79. package/dist/projection/experimental/lazy-projections/krovak.js +4 -1
  80. package/dist/projection/experimental/lazy-projections/krovak.js.map +1 -1
  81. package/dist/projection/experimental/lazy-projections/merc.cjs +4 -1
  82. package/dist/projection/experimental/lazy-projections/merc.cjs.map +1 -1
  83. package/dist/projection/experimental/lazy-projections/merc.d.ts.map +1 -1
  84. package/dist/projection/experimental/lazy-projections/merc.js +4 -1
  85. package/dist/projection/experimental/lazy-projections/merc.js.map +1 -1
  86. package/dist/projection/experimental/lazy-projections/mill.cjs +4 -1
  87. package/dist/projection/experimental/lazy-projections/mill.cjs.map +1 -1
  88. package/dist/projection/experimental/lazy-projections/mill.d.ts.map +1 -1
  89. package/dist/projection/experimental/lazy-projections/mill.js +4 -1
  90. package/dist/projection/experimental/lazy-projections/mill.js.map +1 -1
  91. package/dist/projection/experimental/lazy-projections/moll.cjs +4 -1
  92. package/dist/projection/experimental/lazy-projections/moll.cjs.map +1 -1
  93. package/dist/projection/experimental/lazy-projections/moll.d.ts.map +1 -1
  94. package/dist/projection/experimental/lazy-projections/moll.js +4 -1
  95. package/dist/projection/experimental/lazy-projections/moll.js.map +1 -1
  96. package/dist/projection/experimental/lazy-projections/nzmg.cjs +4 -1
  97. package/dist/projection/experimental/lazy-projections/nzmg.cjs.map +1 -1
  98. package/dist/projection/experimental/lazy-projections/nzmg.d.ts.map +1 -1
  99. package/dist/projection/experimental/lazy-projections/nzmg.js +4 -1
  100. package/dist/projection/experimental/lazy-projections/nzmg.js.map +1 -1
  101. package/dist/projection/experimental/lazy-projections/omerc.cjs +4 -1
  102. package/dist/projection/experimental/lazy-projections/omerc.cjs.map +1 -1
  103. package/dist/projection/experimental/lazy-projections/omerc.d.ts.map +1 -1
  104. package/dist/projection/experimental/lazy-projections/omerc.js +4 -1
  105. package/dist/projection/experimental/lazy-projections/omerc.js.map +1 -1
  106. package/dist/projection/experimental/lazy-projections/ortho.cjs +4 -1
  107. package/dist/projection/experimental/lazy-projections/ortho.cjs.map +1 -1
  108. package/dist/projection/experimental/lazy-projections/ortho.d.ts.map +1 -1
  109. package/dist/projection/experimental/lazy-projections/ortho.js +4 -1
  110. package/dist/projection/experimental/lazy-projections/ortho.js.map +1 -1
  111. package/dist/projection/experimental/lazy-projections/poly.cjs +4 -1
  112. package/dist/projection/experimental/lazy-projections/poly.cjs.map +1 -1
  113. package/dist/projection/experimental/lazy-projections/poly.d.ts.map +1 -1
  114. package/dist/projection/experimental/lazy-projections/poly.js +4 -1
  115. package/dist/projection/experimental/lazy-projections/poly.js.map +1 -1
  116. package/dist/projection/experimental/lazy-projections/robin.cjs +4 -1
  117. package/dist/projection/experimental/lazy-projections/robin.cjs.map +1 -1
  118. package/dist/projection/experimental/lazy-projections/robin.d.ts.map +1 -1
  119. package/dist/projection/experimental/lazy-projections/robin.js +4 -1
  120. package/dist/projection/experimental/lazy-projections/robin.js.map +1 -1
  121. package/dist/projection/experimental/lazy-projections/sinu.cjs +4 -1
  122. package/dist/projection/experimental/lazy-projections/sinu.cjs.map +1 -1
  123. package/dist/projection/experimental/lazy-projections/sinu.d.ts.map +1 -1
  124. package/dist/projection/experimental/lazy-projections/sinu.js +4 -1
  125. package/dist/projection/experimental/lazy-projections/sinu.js.map +1 -1
  126. package/dist/projection/experimental/lazy-projections/stere.cjs +4 -1
  127. package/dist/projection/experimental/lazy-projections/stere.cjs.map +1 -1
  128. package/dist/projection/experimental/lazy-projections/stere.d.ts.map +1 -1
  129. package/dist/projection/experimental/lazy-projections/stere.js +4 -1
  130. package/dist/projection/experimental/lazy-projections/stere.js.map +1 -1
  131. package/dist/projection/experimental/lazy-projections/tpers.cjs +4 -1
  132. package/dist/projection/experimental/lazy-projections/tpers.cjs.map +1 -1
  133. package/dist/projection/experimental/lazy-projections/tpers.d.ts.map +1 -1
  134. package/dist/projection/experimental/lazy-projections/tpers.js +4 -1
  135. package/dist/projection/experimental/lazy-projections/tpers.js.map +1 -1
  136. package/dist/projection/experimental/lazy-projections/vandg.cjs +4 -1
  137. package/dist/projection/experimental/lazy-projections/vandg.cjs.map +1 -1
  138. package/dist/projection/experimental/lazy-projections/vandg.d.ts.map +1 -1
  139. package/dist/projection/experimental/lazy-projections/vandg.js +4 -1
  140. package/dist/projection/experimental/lazy-projections/vandg.js.map +1 -1
  141. package/dist/projection/index.cjs.map +1 -1
  142. package/dist/projection/index.d.ts.map +1 -1
  143. package/dist/projection/index.js.map +1 -1
  144. package/dist/projection/lib/projection.js.map +1 -1
  145. package/dist/projection/pipeline.cjs.map +1 -1
  146. package/dist/projection/transform-analysis.cjs.map +1 -1
  147. package/dist/tasks/index.cjs +181 -84
  148. package/dist/tasks/index.cjs.map +2 -2
  149. package/dist/tasks/terrain-residency.d.ts.map +1 -1
  150. package/dist/tasks/terrain-residency.js +80 -18
  151. package/dist/tasks/terrain-residency.js.map +1 -1
  152. package/dist/terrain/cutout-polygons.d.ts +21 -0
  153. package/dist/terrain/cutout-polygons.d.ts.map +1 -0
  154. package/dist/terrain/cutout-polygons.js +172 -0
  155. package/dist/terrain/cutout-polygons.js.map +1 -0
  156. package/dist/terrain/cutout-region.d.ts +34 -0
  157. package/dist/terrain/cutout-region.d.ts.map +1 -0
  158. package/dist/terrain/cutout-region.js +33 -0
  159. package/dist/terrain/cutout-region.js.map +1 -0
  160. package/dist/terrain/cutout-skirts.d.ts +34 -0
  161. package/dist/terrain/cutout-skirts.d.ts.map +1 -0
  162. package/dist/terrain/cutout-skirts.js +29 -0
  163. package/dist/terrain/cutout-skirts.js.map +1 -0
  164. package/dist/terrain/depression-fill.d.ts +25 -0
  165. package/dist/terrain/depression-fill.d.ts.map +1 -0
  166. package/dist/terrain/depression-fill.js +106 -0
  167. package/dist/terrain/depression-fill.js.map +1 -0
  168. package/dist/terrain/geographic-cutout.d.ts +38 -0
  169. package/dist/terrain/geographic-cutout.d.ts.map +1 -0
  170. package/dist/terrain/geographic-cutout.js +120 -0
  171. package/dist/terrain/geographic-cutout.js.map +1 -0
  172. package/dist/terrain/hydrology.d.ts +42 -0
  173. package/dist/terrain/hydrology.d.ts.map +1 -0
  174. package/dist/terrain/hydrology.js +112 -0
  175. package/dist/terrain/hydrology.js.map +1 -0
  176. package/dist/terrain/index.cjs +1529 -107
  177. package/dist/terrain/index.cjs.map +3 -3
  178. package/dist/terrain/index.d.ts +15 -1
  179. package/dist/terrain/index.d.ts.map +1 -1
  180. package/dist/terrain/index.js +13 -0
  181. package/dist/terrain/index.js.map +1 -1
  182. package/dist/terrain/lod-screen-error.d.ts +28 -0
  183. package/dist/terrain/lod-screen-error.d.ts.map +1 -0
  184. package/dist/terrain/lod-screen-error.js +95 -0
  185. package/dist/terrain/lod-screen-error.js.map +1 -0
  186. package/dist/terrain/lod-select.d.ts +26 -10
  187. package/dist/terrain/lod-select.d.ts.map +1 -1
  188. package/dist/terrain/lod-select.js +27 -14
  189. package/dist/terrain/lod-select.js.map +1 -1
  190. package/dist/terrain/mesh-cutout.d.ts +45 -0
  191. package/dist/terrain/mesh-cutout.d.ts.map +1 -0
  192. package/dist/terrain/mesh-cutout.js +336 -0
  193. package/dist/terrain/mesh-cutout.js.map +1 -0
  194. package/dist/terrain/mesh-skirts.d.ts +8 -2
  195. package/dist/terrain/mesh-skirts.d.ts.map +1 -1
  196. package/dist/terrain/mesh-skirts.js +5 -4
  197. package/dist/terrain/mesh-skirts.js.map +1 -1
  198. package/dist/terrain/mixed-halo-update.d.ts.map +1 -1
  199. package/dist/terrain/mixed-halo-update.js +58 -23
  200. package/dist/terrain/mixed-halo-update.js.map +1 -1
  201. package/dist/terrain/mixed-vertex-halos.d.ts +24 -1
  202. package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -1
  203. package/dist/terrain/mixed-vertex-halos.js +75 -58
  204. package/dist/terrain/mixed-vertex-halos.js.map +1 -1
  205. package/dist/terrain/regional-viewshed.d.ts +55 -0
  206. package/dist/terrain/regional-viewshed.d.ts.map +1 -0
  207. package/dist/terrain/regional-viewshed.js +119 -0
  208. package/dist/terrain/regional-viewshed.js.map +1 -0
  209. package/dist/terrain/sweep-polytope.d.ts +4 -0
  210. package/dist/terrain/sweep-polytope.d.ts.map +1 -1
  211. package/dist/terrain/sweep-polytope.js +15 -5
  212. package/dist/terrain/sweep-polytope.js.map +1 -1
  213. package/dist/terrain/sweep-rotating-capsule.d.ts +17 -0
  214. package/dist/terrain/sweep-rotating-capsule.d.ts.map +1 -0
  215. package/dist/terrain/sweep-rotating-capsule.js +118 -0
  216. package/dist/terrain/sweep-rotating-capsule.js.map +1 -0
  217. package/dist/terrain/sweep-rotation.d.ts +35 -0
  218. package/dist/terrain/sweep-rotation.d.ts.map +1 -0
  219. package/dist/terrain/sweep-rotation.js +114 -0
  220. package/dist/terrain/sweep-rotation.js.map +1 -0
  221. package/dist/terrain/tile-cutout-update.d.ts +73 -0
  222. package/dist/terrain/tile-cutout-update.d.ts.map +1 -0
  223. package/dist/terrain/tile-cutout-update.js +181 -0
  224. package/dist/terrain/tile-cutout-update.js.map +1 -0
  225. package/dist/terrain/tile-cutout.d.ts +33 -0
  226. package/dist/terrain/tile-cutout.d.ts.map +1 -0
  227. package/dist/terrain/tile-cutout.js +93 -0
  228. package/dist/terrain/tile-cutout.js.map +1 -0
  229. package/dist/terrain/watershed-accumulation.d.ts +20 -0
  230. package/dist/terrain/watershed-accumulation.d.ts.map +1 -0
  231. package/dist/terrain/watershed-accumulation.js +53 -0
  232. package/dist/terrain/watershed-accumulation.js.map +1 -0
  233. package/dist/turf/expressions.cjs +4 -4
  234. package/dist/turf/expressions.cjs.map +2 -2
  235. package/dist/turf/expressions.d.ts +2 -2
  236. package/dist/turf/expressions.d.ts.map +1 -1
  237. package/dist/turf/expressions.js +2 -2
  238. package/dist/turf/expressions.js.map +1 -1
  239. package/dist/turf.cjs +25 -25
  240. package/dist/turf.cjs.map +2 -2
  241. package/dist/turf.d.ts +1 -1
  242. package/dist/turf.d.ts.map +1 -1
  243. package/dist/turf.js +2 -2
  244. package/dist/turf.js.map +1 -1
  245. package/dist/web-mercator/assert.d.ts +2 -0
  246. package/dist/web-mercator/assert.d.ts.map +1 -0
  247. package/dist/web-mercator/assert.js +12 -0
  248. package/dist/web-mercator/assert.js.map +1 -0
  249. package/dist/web-mercator/fit-bounds.d.ts +52 -0
  250. package/dist/web-mercator/fit-bounds.d.ts.map +1 -0
  251. package/dist/web-mercator/fit-bounds.js +70 -0
  252. package/dist/web-mercator/fit-bounds.js.map +1 -0
  253. package/dist/web-mercator/fly-to-viewport.d.ts +19 -0
  254. package/dist/web-mercator/fly-to-viewport.d.ts.map +1 -0
  255. package/dist/web-mercator/fly-to-viewport.js +94 -0
  256. package/dist/web-mercator/fly-to-viewport.js.map +1 -0
  257. package/dist/web-mercator/get-bounds.d.ts +3 -0
  258. package/dist/web-mercator/get-bounds.d.ts.map +1 -0
  259. package/dist/web-mercator/get-bounds.js +56 -0
  260. package/dist/web-mercator/get-bounds.js.map +1 -0
  261. package/dist/web-mercator/index.cjs +705 -0
  262. package/dist/web-mercator/index.cjs.map +6 -0
  263. package/dist/web-mercator/index.d.ts +14 -0
  264. package/dist/web-mercator/index.d.ts.map +1 -0
  265. package/dist/web-mercator/index.js +14 -0
  266. package/dist/web-mercator/index.js.map +1 -0
  267. package/dist/web-mercator/math-utils.d.ts +7 -0
  268. package/dist/web-mercator/math-utils.d.ts.map +1 -0
  269. package/dist/web-mercator/math-utils.js +30 -0
  270. package/dist/web-mercator/math-utils.js.map +1 -0
  271. package/dist/web-mercator/mercator-meters.d.ts +29 -0
  272. package/dist/web-mercator/mercator-meters.d.ts.map +1 -0
  273. package/dist/web-mercator/mercator-meters.js +61 -0
  274. package/dist/web-mercator/mercator-meters.js.map +1 -0
  275. package/dist/web-mercator/normalize-viewport-props.d.ts +16 -0
  276. package/dist/web-mercator/normalize-viewport-props.d.ts.map +1 -0
  277. package/dist/web-mercator/normalize-viewport-props.js +45 -0
  278. package/dist/web-mercator/normalize-viewport-props.js.map +1 -0
  279. package/dist/web-mercator/web-mercator-utils.d.ts +192 -0
  280. package/dist/web-mercator/web-mercator-utils.d.ts.map +1 -0
  281. package/dist/web-mercator/web-mercator-utils.js +321 -0
  282. package/dist/web-mercator/web-mercator-utils.js.map +1 -0
  283. package/dist/web-mercator/web-mercator-viewport.d.ts +177 -0
  284. package/dist/web-mercator/web-mercator-viewport.d.ts.map +1 -0
  285. package/dist/web-mercator/web-mercator-viewport.js +276 -0
  286. package/dist/web-mercator/web-mercator-viewport.js.map +1 -0
  287. package/dist/web-mercator.d.ts +1 -1
  288. package/dist/web-mercator.d.ts.map +1 -1
  289. package/dist/web-mercator.js +1 -1
  290. package/dist/web-mercator.js.map +1 -1
  291. package/package.json +19 -458
  292. package/src/crs/index.ts +7 -0
  293. package/src/crs/spatial-reference-metadata.ts +118 -0
  294. package/src/expressions.ts +1 -1
  295. package/src/index.ts +92 -4
  296. package/src/projection/experimental/crs/spatial-reference.ts +1 -6
  297. package/src/projection/experimental/crs/types.ts +1 -1
  298. package/src/projection/experimental/crs/wkt.ts +1 -1
  299. package/src/projection/experimental/crs-descriptor.ts +1 -1
  300. package/src/projection/experimental/lazy-projections/aea.ts +4 -1
  301. package/src/projection/experimental/lazy-projections/bonne.ts +4 -1
  302. package/src/projection/experimental/lazy-projections/cass.ts +4 -1
  303. package/src/projection/experimental/lazy-projections/eck6.ts +4 -1
  304. package/src/projection/experimental/lazy-projections/eqdc.ts +4 -1
  305. package/src/projection/experimental/lazy-projections/eqearth.ts +4 -1
  306. package/src/projection/experimental/lazy-projections/equi.ts +4 -1
  307. package/src/projection/experimental/lazy-projections/geocent.ts +4 -1
  308. package/src/projection/experimental/lazy-projections/geos.ts +4 -1
  309. package/src/projection/experimental/lazy-projections/gnom.ts +4 -1
  310. package/src/projection/experimental/lazy-projections/krovak.ts +4 -1
  311. package/src/projection/experimental/lazy-projections/merc.ts +4 -1
  312. package/src/projection/experimental/lazy-projections/mill.ts +4 -1
  313. package/src/projection/experimental/lazy-projections/moll.ts +4 -1
  314. package/src/projection/experimental/lazy-projections/nzmg.ts +4 -1
  315. package/src/projection/experimental/lazy-projections/omerc.ts +4 -1
  316. package/src/projection/experimental/lazy-projections/ortho.ts +4 -1
  317. package/src/projection/experimental/lazy-projections/poly.ts +4 -1
  318. package/src/projection/experimental/lazy-projections/robin.ts +4 -1
  319. package/src/projection/experimental/lazy-projections/sinu.ts +4 -1
  320. package/src/projection/experimental/lazy-projections/stere.ts +4 -1
  321. package/src/projection/experimental/lazy-projections/tpers.ts +4 -1
  322. package/src/projection/experimental/lazy-projections/vandg.ts +4 -1
  323. package/src/projection/index.ts +1 -1
  324. package/src/projection/lib/projection.ts +1 -1
  325. package/src/tasks/terrain-residency.ts +86 -21
  326. package/src/terrain/cutout-polygons.ts +202 -0
  327. package/src/terrain/cutout-region.ts +54 -0
  328. package/src/terrain/cutout-skirts.ts +52 -0
  329. package/src/terrain/depression-fill.ts +125 -0
  330. package/src/terrain/geographic-cutout.ts +154 -0
  331. package/src/terrain/hydrology.ts +149 -0
  332. package/src/terrain/index.ts +85 -1
  333. package/src/terrain/lod-screen-error.ts +128 -0
  334. package/src/terrain/lod-select.ts +65 -31
  335. package/src/terrain/mesh-cutout.ts +420 -0
  336. package/src/terrain/mesh-skirts.ts +10 -7
  337. package/src/terrain/mixed-halo-update.ts +54 -20
  338. package/src/terrain/mixed-vertex-halos.ts +94 -78
  339. package/src/terrain/regional-viewshed.ts +177 -0
  340. package/src/terrain/sweep-polytope.ts +49 -25
  341. package/src/terrain/sweep-rotating-capsule.ts +139 -0
  342. package/src/terrain/sweep-rotation.ts +149 -0
  343. package/src/terrain/tile-cutout-update.ts +293 -0
  344. package/src/terrain/tile-cutout.ts +123 -0
  345. package/src/terrain/watershed-accumulation.ts +67 -0
  346. package/src/turf/expressions.ts +3 -3
  347. package/src/turf.ts +3 -7
  348. package/src/web-mercator/assert.ts +11 -0
  349. package/src/web-mercator/fit-bounds.ts +132 -0
  350. package/src/web-mercator/fly-to-viewport.ts +157 -0
  351. package/src/web-mercator/get-bounds.ts +62 -0
  352. package/src/web-mercator/index.ts +49 -0
  353. package/src/web-mercator/math-utils.ts +35 -0
  354. package/src/web-mercator/mercator-meters.ts +83 -0
  355. package/src/web-mercator/normalize-viewport-props.ts +58 -0
  356. package/src/web-mercator/web-mercator-utils.ts +468 -0
  357. package/src/web-mercator/web-mercator-viewport.ts +406 -0
  358. package/src/web-mercator.ts +1 -1
  359. package/dist/projection/experimental/index.cjs +0 -11707
  360. package/dist/projection/experimental/index.cjs.map +0 -6
@@ -0,0 +1,149 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {
6
+ createSweepBox,
7
+ queryTerrainPolytope,
8
+ type TerrainPolytope,
9
+ type TerrainPolytopeSweepResult
10
+ } from './sweep-polytope';
11
+ import type {TerrainSurface} from './surface';
12
+
13
+ type Point = readonly [number, number, number];
14
+ type Surface = Pick<TerrainSurface, 'copyData' | 'origin'>;
15
+
16
+ export type TerrainRigidMotion = {
17
+ /** Pivot in the same Cartesian frame as the collider vertices. */
18
+ pivot: Point;
19
+ translation: Point;
20
+ /** Quaternion [x,y,z,w] relative to the initial pose. The shortest arc is used. */
21
+ rotation: readonly [number, number, number, number];
22
+ };
23
+
24
+ export type TerrainRotationalSweepResult =
25
+ | {status: 'miss' | 'incomplete'; work: number}
26
+ | (Extract<TerrainPolytopeSweepResult, {status: 'hit'}> & {lowerFraction: number});
27
+
28
+ /**
29
+ * Sweep a convex hull along linear translation and shortest-arc rotation.
30
+ * An expanded midpoint SAT can exclude an interval. An unexpanded pose supplies
31
+ * a hit witness. Unresolved grazing or exhausted work yields incomplete.
32
+ */
33
+ export function sweepTerrainRotatingPolytope(
34
+ surface: Surface,
35
+ collider: TerrainPolytope,
36
+ {pivot, translation, rotation}: TerrainRigidMotion,
37
+ {maxWork = 100_000, fractionTolerance = 1e-5}: {maxWork?: number; fractionTolerance?: number} = {}
38
+ ): TerrainRotationalSweepResult {
39
+ const norm = Math.hypot(...rotation);
40
+ if (
41
+ pivot.length !== 3 ||
42
+ translation.length !== 3 ||
43
+ rotation.length !== 4 ||
44
+ !pivot.every(Number.isFinite) ||
45
+ !translation.every(Number.isFinite) ||
46
+ !(norm > 0 && Number.isFinite(norm)) ||
47
+ !Number.isSafeInteger(maxWork) ||
48
+ maxWork < 0 ||
49
+ !(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1)
50
+ )
51
+ throw new RangeError('Invalid terrain rigid motion');
52
+
53
+ // Work in the surface frame before interpolating to preserve small offsets.
54
+ const localPivot = pivot.map((v, i) => v - surface.origin[i]);
55
+ const offsets = collider.vertices.map(v => v.map((x, i) => x - pivot[i]));
56
+ const radius = offsets.reduce((r, v) => Math.max(r, Math.hypot(...v)), 0);
57
+ const sign = rotation[3] < 0 ? -1 : 1;
58
+ const vectorNorm = Math.hypot(rotation[0], rotation[1], rotation[2]);
59
+ const angle = 2 * Math.atan2(vectorNorm, Math.abs(rotation[3]));
60
+ const speed = Math.hypot(...translation) + angle * radius;
61
+ if (!Number.isFinite(speed)) throw new RangeError('Terrain rigid motion overflow');
62
+
63
+ const data = surface.copyData();
64
+ if (angle === 0) {
65
+ const result = queryTerrainPolytope(data, surface.origin, collider, translation, maxWork);
66
+ return result.status === 'hit' ? {...result, lowerFraction: result.fraction} : result;
67
+ }
68
+
69
+ const [x, y, z] = rotation.slice(0, 3).map(v => (v / vectorNorm) * sign);
70
+ const zero = [0, 0, 0] as const;
71
+ let work = 0;
72
+ const pose = (t: number): TerrainPolytope => {
73
+ const sin = Math.sin(angle * t);
74
+ const cos = Math.cos(angle * t);
75
+ return {
76
+ faces: collider.faces,
77
+ vertices: offsets.map(([a, b, c]): Point => {
78
+ const projection = (x * a + y * b + z * c) * (1 - cos);
79
+ return [
80
+ localPivot[0] + translation[0] * t + a * cos + (y * c - z * b) * sin + x * projection,
81
+ localPivot[1] + translation[1] * t + b * cos + (z * a - x * c) * sin + y * projection,
82
+ localPivot[2] + translation[2] * t + c * cos + (x * b - y * a) * sin + z * projection
83
+ ];
84
+ })
85
+ };
86
+ };
87
+ const probe = (shape: TerrainPolytope, padding = 0) => {
88
+ if (work >= maxWork) return {status: 'incomplete', work: 0} as const;
89
+ work++;
90
+ const result = queryTerrainPolytope(data, zero, shape, zero, maxWork - work, padding);
91
+ work += result.work;
92
+ return result;
93
+ };
94
+ const initial = probe(pose(0));
95
+ if (initial.status === 'hit') return {...initial, lowerFraction: 0, work};
96
+ if (initial.status === 'incomplete') return {status: 'incomplete', work};
97
+
98
+ let clearUntil = 0;
99
+ let witness: Extract<TerrainPolytopeSweepResult, {status: 'hit'}> | undefined;
100
+ const pending: [number, number][] = [[0, 1]];
101
+ while (pending.length) {
102
+ if (witness && witness.fraction - clearUntil <= fractionTolerance)
103
+ return {...witness, lowerFraction: clearUntil, work};
104
+ const [lo, hi] = pending.pop()!;
105
+ const mid = lo + (hi - lo) / 2;
106
+ const shape = pose(mid);
107
+ const padding = speed * Math.max(mid - lo, hi - mid);
108
+ const expanded = probe(shape, padding + 8 * Number.EPSILON * (radius + padding));
109
+ if (expanded.status === 'miss') {
110
+ clearUntil = hi;
111
+ continue;
112
+ }
113
+ if (expanded.status === 'incomplete') return {status: 'incomplete', work};
114
+ const hit = probe(shape);
115
+ if (hit.status === 'incomplete') return {status: 'incomplete', work};
116
+ if (hit.status === 'hit') {
117
+ witness = {...hit, fraction: mid};
118
+ if (mid - clearUntil <= fractionTolerance)
119
+ return {...witness, lowerFraction: clearUntil, work};
120
+ pending.push([lo, mid]);
121
+ } else if (hi - clearUntil <= fractionTolerance) {
122
+ const end = witness?.fraction === hi ? witness : probe(pose(hi));
123
+ if (end?.status === 'hit') return {...end, fraction: hi, lowerFraction: clearUntil, work};
124
+ if (hi - lo <= fractionTolerance / 4) return {status: 'incomplete', work};
125
+ pending.push([mid, hi], [lo, mid]);
126
+ } else {
127
+ if (mid === lo || mid === hi || hi - lo <= fractionTolerance / 4)
128
+ return {status: 'incomplete', work};
129
+ pending.push([mid, hi], [lo, mid]);
130
+ }
131
+ }
132
+ return witness ? {...witness, lowerFraction: clearUntil, work} : {status: 'miss', work};
133
+ }
134
+
135
+ /** Rotational sweep of a box that starts axis-aligned. */
136
+ export function sweepTerrainRotatingBox(
137
+ surface: Surface,
138
+ center: Point,
139
+ halfExtents: Point,
140
+ motion: TerrainRigidMotion,
141
+ options?: {maxWork?: number; fractionTolerance?: number}
142
+ ): TerrainRotationalSweepResult {
143
+ return sweepTerrainRotatingPolytope(
144
+ surface,
145
+ createSweepBox(center, halfExtents),
146
+ motion,
147
+ options
148
+ );
149
+ }
@@ -0,0 +1,293 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {
6
+ copyTerrainCutoutRegion,
7
+ sameTerrainCutoutRegion,
8
+ type TerrainCutoutRegion
9
+ } from './cutout-region';
10
+
11
+ import {
12
+ splitTerrainMesh,
13
+ validateTerrainCutoutTopology,
14
+ type TerrainCutout,
15
+ type TerrainCutoutInput,
16
+ type TerrainCutoutOptions,
17
+ type TerrainCutoutPiece
18
+ } from './mesh-cutout';
19
+ import {assembleTerrainCutoutTiles} from './tile-cutout';
20
+
21
+ /** Stable resident identity and an explicit revision for in-place buffer edits. */
22
+ export type TerrainCutoutResident = {
23
+ /** Unique resident tile ID. */
24
+ id: string;
25
+ /** Nonnegative safe integer; increment after changing any mesh buffer. */
26
+ revision: number;
27
+ /** Conforming terrain in one shared Cartesian frame. Treat as immutable within a revision. */
28
+ mesh: TerrainCutoutInput;
29
+ };
30
+ /** Per-tile clipping limits plus bounds on resident-set reconciliation. */
31
+ export type TerrainTileCutoutUpdateOptions = TerrainCutoutOptions & {
32
+ /** Maximum residents. Default 512. */
33
+ maxTiles?: number;
34
+ /** Maximum tile-pair broad-phase checks per update. Default 131072. */
35
+ maxPairChecks?: number;
36
+ /** Maximum exposed piece edges across all residents. Default 1000000. */
37
+ maxBoundaryEdges?: number;
38
+ };
39
+ /** Directed boundary edge with exact coordinate keys and local vertex IDs. */
40
+ type Boundary = {
41
+ /** Incident face polygon index; remainder faces use the Uint32 sentinel 0xffffffff. */
42
+ polygon: number;
43
+ key: string;
44
+ start: string;
45
+ end: string;
46
+ a: number;
47
+ b: number;
48
+ side: 0 | 1;
49
+ };
50
+ /** Cached clipping and boundary summaries for one immutable tile revision. */
51
+ type Entry = {
52
+ resident: TerrainCutoutResident;
53
+ split: TerrainCutout;
54
+ displayed: TerrainCutout;
55
+ bounds: readonly [number, number, number, number];
56
+ edges: Boundary[];
57
+ };
58
+ /** Private cache brand; the cache is local to this module instance. */
59
+ const CACHE = Symbol('terrain-cutout-cache');
60
+ /** Opaque reusable cache. Do not mutate cached results or resident buffers without a new revision. */
61
+ export type TerrainTileCutoutCache = {
62
+ readonly [CACHE]: {
63
+ polygon: TerrainCutoutRegion;
64
+ options: Required<TerrainTileCutoutUpdateOptions>;
65
+ entries: ReadonlyMap<string, Entry>;
66
+ };
67
+ };
68
+ /** Detached update result, with unchanged surface buffers retained by identity. */
69
+ export type TerrainTileCutoutUpdate = {
70
+ /** Pass to the next update; no state is committed if an update throws. */
71
+ cache: TerrainTileCutoutCache;
72
+ /** Resident cuts. Source triangle references are local to the corresponding input tile. */
73
+ tiles: ReadonlyMap<string, TerrainCutout>;
74
+ /** Tiles whose surfaces or exposed cut edges changed. */
75
+ changed: string[];
76
+ /** Tiles removed from the previous resident set. */
77
+ removed: string[];
78
+ /** Tiles actually clipped in this update; unchanged tiles are not reclipped. */
79
+ rebuilt: string[];
80
+ };
81
+
82
+ /** Clip changed tiles independently and pair their exposed boundaries.
83
+ * Mixed-level inputs must already be reconciled. Cached source buffers and
84
+ * returned arrays are read-only by contract. Change revision after in-place
85
+ * edits; replacing the mesh object also invalidates its cache. Polygon or
86
+ * option changes invalidate all clips. Limits maxWork/maxVertices/maxTriangles
87
+ * apply per clip and per adjacent-pair validation, not to the entire update.
88
+ * Arrival/eviction can change a neighbor's cutEdges without rebuilding its mesh.
89
+ */
90
+ export function updateTerrainTileCutouts(
91
+ residents: readonly TerrainCutoutResident[],
92
+ polygon: TerrainCutoutRegion,
93
+ previous?: TerrainTileCutoutCache,
94
+ options: TerrainTileCutoutUpdateOptions = {}
95
+ ): TerrainTileCutoutUpdate {
96
+ const limits: Required<TerrainTileCutoutUpdateOptions> = {
97
+ maxTiles: options.maxTiles ?? 512,
98
+ maxPairChecks: options.maxPairChecks ?? 131072,
99
+ maxBoundaryEdges: options.maxBoundaryEdges ?? 1000000,
100
+ maxWork: options.maxWork ?? 4000000,
101
+ maxVertices: options.maxVertices ?? 500000,
102
+ maxTriangles: options.maxTriangles ?? 500000
103
+ };
104
+ if (
105
+ Object.values(limits).some(n => !Number.isSafeInteger(n) || n < 0) ||
106
+ limits.maxVertices > 0xffffffff ||
107
+ limits.maxTriangles > 0xffffffff ||
108
+ residents.length > limits.maxTiles
109
+ )
110
+ throw new RangeError('Invalid terrain cutout update limits');
111
+ const prior = previous?.[CACHE];
112
+ const compatible =
113
+ prior &&
114
+ sameTerrainCutoutRegion(prior.polygon, polygon) &&
115
+ (Object.keys(limits) as (keyof typeof limits)[]).every(
116
+ key => prior.options[key] === limits[key]
117
+ );
118
+ // Validate the ring even for an empty resident set.
119
+ if (!compatible)
120
+ splitTerrainMesh({positions: new Float64Array(), indices: new Uint32Array()}, polygon, limits);
121
+ const entries = new Map<string, Entry>();
122
+ const rebuilt: string[] = [];
123
+ let boundaryCount = 0;
124
+ for (const resident of residents) {
125
+ if (
126
+ !resident.id ||
127
+ typeof resident.id !== 'string' ||
128
+ entries.has(resident.id) ||
129
+ !Number.isSafeInteger(resident.revision) ||
130
+ resident.revision < 0
131
+ )
132
+ throw new RangeError('Invalid or duplicate terrain cutout resident');
133
+ const old = compatible ? prior.entries.get(resident.id) : undefined;
134
+ let entry: Entry;
135
+ if (old && old.resident.mesh === resident.mesh && old.resident.revision === resident.revision)
136
+ entry = old;
137
+ else {
138
+ const split = splitTerrainMesh(resident.mesh, polygon, limits);
139
+ const edges = [...boundaryEdges(split.patch, 0), ...boundaryEdges(split.remainder, 1)];
140
+ const bounds: [number, number, number, number] = [Infinity, Infinity, -Infinity, -Infinity];
141
+ for (const id of resident.mesh.indices) {
142
+ const x = resident.mesh.positions[id * 3],
143
+ y = resident.mesh.positions[id * 3 + 1];
144
+ bounds[0] = Math.min(bounds[0], x);
145
+ bounds[1] = Math.min(bounds[1], y);
146
+ bounds[2] = Math.max(bounds[2], x);
147
+ bounds[3] = Math.max(bounds[3], y);
148
+ }
149
+ entry = {resident: {...resident}, split, displayed: split, bounds, edges};
150
+ rebuilt.push(resident.id);
151
+ }
152
+ boundaryCount += entry.edges.length;
153
+ if (boundaryCount > limits.maxBoundaryEdges)
154
+ throw new RangeError('Terrain cutout boundary budget exceeded');
155
+ entries.set(resident.id, entry);
156
+ }
157
+ const values = [...entries.values()];
158
+ let pairs = 0;
159
+ for (let i = 0; i < values.length; i++)
160
+ for (let j = i + 1; j < values.length; j++) {
161
+ if (++pairs > limits.maxPairChecks)
162
+ throw new RangeError('Terrain cutout pair budget exceeded');
163
+ const a = values[i],
164
+ b = values[j];
165
+ if (
166
+ a.bounds[2] < b.bounds[0] ||
167
+ b.bounds[2] < a.bounds[0] ||
168
+ a.bounds[3] < b.bounds[1] ||
169
+ b.bounds[3] < a.bounds[1]
170
+ )
171
+ continue;
172
+ if (
173
+ compatible &&
174
+ prior.entries.get(a.resident.id) === a &&
175
+ prior.entries.get(b.resident.id) === b
176
+ )
177
+ continue;
178
+ const combined = assembleTerrainCutoutTiles([a.resident.mesh, b.resident.mesh], limits);
179
+ validateTerrainCutoutTopology(combined.mesh, combined.remainingWork);
180
+ }
181
+ const boundaries = new Map<string, {edge: Boundary; paired: boolean}>();
182
+ const cutKeys = new Map<string, number>();
183
+ for (let tile = 0; tile < values.length; tile++)
184
+ for (const edge of values[tile].edges) {
185
+ const other = boundaries.get(edge.key);
186
+ if (!other) {
187
+ boundaries.set(edge.key, {edge, paired: false});
188
+ continue;
189
+ }
190
+ if (other.paired || other.edge.start !== edge.end || other.edge.end !== edge.start)
191
+ throw new RangeError('Nonconforming terrain cutout tile boundary');
192
+ other.paired = true;
193
+ if (other.edge.side !== edge.side) {
194
+ cutKeys.set(edge.key, edge.side === 0 ? edge.polygon : other.edge.polygon);
195
+ }
196
+ }
197
+ const tiles = new Map<string, TerrainCutout>();
198
+ const changed: string[] = [];
199
+ for (let i = 0; i < values.length; i++) {
200
+ const entry = values[i];
201
+ const old = prior?.entries.get(entry.resident.id);
202
+ // Emit in cached tile-local order, independent of resident visitation order.
203
+ const cuts: [number[], number[]] = [[], []];
204
+ const polygons: [number[], number[]] = [[], []];
205
+ for (const edge of entry.edges) {
206
+ const polygonIndex = cutKeys.get(edge.key);
207
+ if (polygonIndex !== undefined) {
208
+ cuts[edge.side].push(edge.a, edge.b);
209
+ polygons[edge.side].push(polygonIndex);
210
+ }
211
+ }
212
+ const patch = withEdges(entry.split.patch, cuts[0], polygons[0], old?.displayed.patch);
213
+ const remainder = withEdges(
214
+ entry.split.remainder,
215
+ cuts[1],
216
+ polygons[1],
217
+ old?.displayed.remainder
218
+ );
219
+ const displayed =
220
+ old && patch === old.displayed.patch && remainder === old.displayed.remainder
221
+ ? old.displayed
222
+ : {patch, remainder};
223
+ if (displayed !== old?.displayed) changed.push(entry.resident.id);
224
+ entries.set(entry.resident.id, displayed === entry.displayed ? entry : {...entry, displayed});
225
+ tiles.set(entry.resident.id, displayed);
226
+ }
227
+ return {
228
+ cache: {[CACHE]: {polygon: copyTerrainCutoutRegion(polygon), options: limits, entries}},
229
+ tiles,
230
+ changed,
231
+ rebuilt,
232
+ removed: prior ? [...prior.entries.keys()].filter(id => !entries.has(id)) : []
233
+ };
234
+ }
235
+
236
+ /** Reuse surface buffers and unchanged boundary descriptors. */
237
+ function withEdges(
238
+ piece: TerrainCutoutPiece,
239
+ edges: number[],
240
+ polygons: number[],
241
+ old?: TerrainCutoutPiece
242
+ ) {
243
+ const same =
244
+ old &&
245
+ old.positions === piece.positions &&
246
+ old.cutEdges.length === edges.length &&
247
+ old.cutEdges.every((id, i) => id === edges[i]) &&
248
+ old.cutPolygonIndices.every((id, i) => id === polygons[i]);
249
+ return same
250
+ ? old
251
+ : {...piece, cutEdges: Uint32Array.from(edges), cutPolygonIndices: Uint32Array.from(polygons)};
252
+ }
253
+ /** Cache only exposed edges; interior triangulation edges never become walls. */
254
+ function boundaryEdges(piece: TerrainCutoutPiece, side: 0 | 1): Boundary[] {
255
+ const edges = new Map<
256
+ string,
257
+ {
258
+ a: number;
259
+ b: number;
260
+ count: number;
261
+ /** Incident face polygon index, including the remainder sentinel 0xffffffff. */
262
+ polygon: number;
263
+ }
264
+ >();
265
+ for (let i = 0; i < piece.indices.length; i += 3)
266
+ for (let j = 0; j < 3; j++) {
267
+ const a = piece.indices[i + j],
268
+ b = piece.indices[i + ((j + 1) % 3)];
269
+ const key = a < b ? `${a},${b}` : `${b},${a}`;
270
+ const old = edges.get(key);
271
+ if (old) old.count++;
272
+ else edges.set(key, {a, b, count: 1, polygon: piece.polygonIndices[i / 3]});
273
+ }
274
+ const result: Boundary[] = [];
275
+ /** Encode exact XYZ; no snapping or tolerance-based topology decisions. */
276
+ const point = (id: number) =>
277
+ `${piece.positions[id * 3]},${piece.positions[id * 3 + 1]},${piece.positions[id * 3 + 2]}`;
278
+ for (const {a, b, count, polygon} of edges.values())
279
+ if (count === 1) {
280
+ const start = point(a),
281
+ end = point(b);
282
+ result.push({
283
+ polygon,
284
+ a,
285
+ b,
286
+ side,
287
+ start,
288
+ end,
289
+ key: start < end ? `${start}/${end}` : `${end}/${start}`
290
+ });
291
+ }
292
+ return result;
293
+ }
@@ -0,0 +1,123 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {TerrainCutoutRegion} from './cutout-region';
6
+
7
+ import {
8
+ splitTerrainMesh,
9
+ type TerrainCutout,
10
+ type TerrainCutoutInput,
11
+ type TerrainCutoutOptions
12
+ } from './mesh-cutout';
13
+
14
+ /** A resident tile expressed in the same local Cartesian frame as its neighbors. */
15
+ export type TerrainCutoutTile = TerrainCutoutInput;
16
+
17
+ /** A resident-set cut and its input-face provenance. */
18
+ export type TerrainTileCutout = TerrainCutout & {
19
+ /** Tile-array index for each input face referenced by either piece. */
20
+ sourceTiles: Uint32Array;
21
+ /** Original tile triangle index for each input face referenced by either piece. */
22
+ sourceTileFaces: Uint32Array;
23
+ };
24
+
25
+ /** Split a conforming resident tile set, with paired walls only along the cut.
26
+ *
27
+ * Vertices with identical XYZ are welded before clipping. Mixed-level neighbors
28
+ * must first be reconciled with stitchTerrainMeshEdges or stitchTerrainLodCut;
29
+ * hanging vertices, overlapping tiles and conflicting elevations are rejected.
30
+ * No snapping, height adjustment, missing-tile filling or tile caching occurs.
31
+ * Recompute from the new resident set after arrival or eviction. Source triangle
32
+ * and barycentric references retain the original tile face's corner order.
33
+ * Limits apply to the total input (including duplicate vertices) and the splitter.
34
+ */
35
+ export function splitTerrainMeshTiles(
36
+ tiles: readonly TerrainCutoutTile[],
37
+ polygon: TerrainCutoutRegion,
38
+ options: TerrainCutoutOptions = {}
39
+ ): TerrainTileCutout {
40
+ const assembled = assembleTerrainCutoutTiles(tiles, options);
41
+ return {
42
+ ...splitTerrainMesh(assembled.mesh, polygon, {...options, maxWork: assembled.remainingWork}),
43
+ sourceTiles: assembled.sourceTiles,
44
+ sourceTileFaces: assembled.sourceTileFaces
45
+ };
46
+ }
47
+
48
+ /** @internal Assemble a bounded, exact-welded mesh without clipping it. */
49
+ export function assembleTerrainCutoutTiles(
50
+ tiles: readonly TerrainCutoutInput[],
51
+ options: TerrainCutoutOptions = {}
52
+ ) {
53
+ const maxVertices = options.maxVertices ?? 500_000;
54
+ const maxTriangles = options.maxTriangles ?? 500_000;
55
+ const maxWork = options.maxWork ?? 4_000_000;
56
+ if (
57
+ ![maxVertices, maxTriangles, maxWork].every(n => Number.isSafeInteger(n) && n >= 0) ||
58
+ maxVertices > 0xffffffff ||
59
+ maxTriangles > 0xffffffff
60
+ )
61
+ throw new RangeError('Invalid terrain tile cutout limits');
62
+ let vertexCount = 0;
63
+ let faceCount = 0;
64
+ let work = 0;
65
+ for (const tile of tiles) {
66
+ if (
67
+ !(tile.positions instanceof Float32Array || tile.positions instanceof Float64Array) ||
68
+ !(tile.indices instanceof Uint16Array || tile.indices instanceof Uint32Array) ||
69
+ tile.positions.length % 3 ||
70
+ tile.indices.length % 3
71
+ )
72
+ throw new RangeError('Invalid terrain tile cutout mesh');
73
+ vertexCount += tile.positions.length / 3;
74
+ faceCount += tile.indices.length / 3;
75
+ work += 1 + tile.positions.length / 3 + tile.indices.length;
76
+ if (vertexCount > maxVertices || faceCount > maxTriangles || work > maxWork)
77
+ throw new RangeError('Terrain tile cutout input budget exceeded');
78
+ }
79
+ const positions = new Float64Array(vertexCount * 3);
80
+ const indices = new Uint32Array(faceCount * 3);
81
+ const sourceTiles = new Uint32Array(faceCount);
82
+ const sourceTileFaces = new Uint32Array(faceCount);
83
+ const vertices = new Map<string, number>();
84
+ let vertexOffset = 0;
85
+ let faceOffset = 0;
86
+ for (let tileIndex = 0; tileIndex < tiles.length; tileIndex++) {
87
+ const tile = tiles[tileIndex];
88
+ const remap = new Uint32Array(tile.positions.length / 3);
89
+ for (let i = 0; i < remap.length; i++) {
90
+ const x = tile.positions[i * 3];
91
+ const y = tile.positions[i * 3 + 1];
92
+ const z = tile.positions[i * 3 + 2];
93
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))
94
+ throw new RangeError('Invalid terrain tile cutout coordinate');
95
+ const key = `${x},${y},${z}`;
96
+ let id = vertices.get(key);
97
+ if (id === undefined) {
98
+ id = vertexOffset++;
99
+ vertices.set(key, id);
100
+ positions[id * 3] = x;
101
+ positions[id * 3 + 1] = y;
102
+ positions[id * 3 + 2] = z;
103
+ }
104
+ remap[i] = id;
105
+ }
106
+ for (let i = 0; i < tile.indices.length; i++) {
107
+ const id = tile.indices[i];
108
+ if (id >= remap.length) throw new RangeError('Invalid terrain tile cutout index');
109
+ indices[faceOffset * 3 + i] = remap[id];
110
+ }
111
+ for (let i = 0; i < tile.indices.length / 3; i++) {
112
+ sourceTiles[faceOffset + i] = tileIndex;
113
+ sourceTileFaces[faceOffset + i] = i;
114
+ }
115
+ faceOffset += tile.indices.length / 3;
116
+ }
117
+ return {
118
+ mesh: {positions: positions.subarray(0, vertexOffset * 3), indices},
119
+ sourceTiles,
120
+ sourceTileFaces,
121
+ remainingWork: maxWork - work
122
+ };
123
+ }
@@ -0,0 +1,67 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ /** Outlet labels and upstream counts for a terrain receiver forest. */
6
+ export type TerrainWatershedAccumulation = {
7
+ /** Row-major outlet index, or -1 for excluded cells. */
8
+ terminal: Int32Array;
9
+ /** Number of contributing cells, including the cell itself. Excluded cells have zero. */
10
+ contributingCells: Uint32Array;
11
+ };
12
+
13
+ /** Controls allocation for watershed accumulation. */
14
+ export type TerrainWatershedAccumulationOptions = {
15
+ /** Limit before allocating working buffers. */
16
+ maxCells?: number;
17
+ };
18
+
19
+ /**
20
+ * Accumulates a receiver forest such as that returned by fillTerrainDepressions.
21
+ * Each entry is a receiver index, -1 for an outlet, or -2 for an excluded cell.
22
+ * createTerrainDrainage uses -1 for nodata. Map nodata cells to -2 before calling.
23
+ * Rejects cycles and links to excluded cells. Time and storage are O(cell count).
24
+ */
25
+ export function accumulateTerrainWatersheds(
26
+ receiver: Int32Array,
27
+ {maxCells = 4_194_304}: TerrainWatershedAccumulationOptions = {}
28
+ ): TerrainWatershedAccumulation {
29
+ const count = receiver.length;
30
+ if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 0x7fffffff)
31
+ throw new RangeError('Terrain watershed accumulation exceeds its cell budget');
32
+
33
+ const incoming = new Uint32Array(count);
34
+ const contributingCells = new Uint32Array(count);
35
+ const terminal = new Int32Array(count).fill(-1);
36
+ const queue = new Int32Array(count);
37
+ let active = 0;
38
+ for (let i = 0; i < count; i++) {
39
+ const next = receiver[i];
40
+ if (next === -2) continue;
41
+ if (next < -1 || next >= count || (next >= 0 && receiver[next] === -2))
42
+ throw new RangeError('Invalid terrain watershed receiver');
43
+ active++;
44
+ contributingCells[i] = 1;
45
+ if (next >= 0) incoming[next]++;
46
+ }
47
+
48
+ let end = 0;
49
+ for (let i = 0; i < count; i++) {
50
+ if (contributingCells[i] && !incoming[i]) queue[end++] = i;
51
+ }
52
+ for (let cursor = 0; cursor < end; cursor++) {
53
+ const i = queue[cursor];
54
+ const next = receiver[i];
55
+ if (next < 0) continue;
56
+ contributingCells[next] += contributingCells[i];
57
+ if (--incoming[next] === 0) queue[end++] = next;
58
+ }
59
+ if (end !== active) throw new RangeError('Terrain watershed receiver graph contains a cycle');
60
+
61
+ for (let cursor = end - 1; cursor >= 0; cursor--) {
62
+ const i = queue[cursor];
63
+ const next = receiver[i];
64
+ terminal[i] = next < 0 ? i : terminal[next];
65
+ }
66
+ return {terminal, contributingCells};
67
+ }
@@ -3,9 +3,9 @@
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
5
  import {DataType, Precision, makeData, makeVector, type Field} from 'apache-arrow';
6
- import type {ArrowTableFunction} from '@math.gl/expressions/arrow';
7
- import {makeGeoArrowColumnFromArrowVector} from '@math.gl/arrow/geoarrow';
8
- import {isGeoArrowValueValid, type GeoArrowColumn} from '@math.gl/arrow/geoarrow-utils';
6
+ import type {ArrowTableFunction} from '@math.gl/sql/arrow';
7
+ import {makeGeoArrowColumnFromArrowVector} from '@math.gl/core/arrow';
8
+ import {isGeoArrowValueValid, type GeoArrowColumn} from '@math.gl/core/arrow';
9
9
  import type {TurfBatchResult} from '../turf';
10
10
 
11
11
  /** Adapter for row-preserving numeric/Boolean functions from @math.gl/geospatial/turf. */
package/src/turf.ts CHANGED
@@ -2,13 +2,9 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
4
 
5
- import type {GeoArrowArray, GeoArrowColumn} from '@math.gl/arrow/geoarrow-utils';
6
- import {isGeoArrowValueValid} from '@math.gl/arrow/geoarrow-utils';
7
- import {
8
- getGeoArrowRowBounds,
9
- mapGeoArrowCoordinates,
10
- rewindGeoArrow
11
- } from '@math.gl/arrow/geoarrow-utils';
5
+ import type {GeoArrowArray, GeoArrowColumn} from '@math.gl/core/arrow';
6
+ import {isGeoArrowValueValid} from '@math.gl/core/arrow';
7
+ import {getGeoArrowRowBounds, mapGeoArrowCoordinates, rewindGeoArrow} from '@math.gl/core/arrow';
12
8
 
13
9
  /** A nullable, row-aligned numeric or boolean result. Validity is an Arrow bitmap. */
14
10
  export type TurfBatchResult<T extends Float64Array | Uint8Array> = {
@@ -0,0 +1,11 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ // Replacement for the external assert method to reduce bundle size
5
+ // Note: We don't use the second "message" argument in calling code,
6
+ // so no need to support it here
7
+ export function assert(condition: unknown, message?: string): void {
8
+ if (!condition) {
9
+ throw new Error(message || '@math.gl/geospatial/web-mercator: assertion failed.');
10
+ }
11
+ }