@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.
- package/README.md +3 -3
- package/dist/crs/index.cjs +54 -0
- package/dist/crs/index.cjs.map +2 -2
- package/dist/crs/index.d.ts +1 -0
- package/dist/crs/index.d.ts.map +1 -1
- package/dist/crs/index.js +1 -0
- package/dist/crs/index.js.map +1 -1
- package/dist/crs/spatial-reference-metadata.d.ts +20 -0
- package/dist/crs/spatial-reference-metadata.d.ts.map +1 -0
- package/dist/crs/spatial-reference-metadata.js +86 -0
- package/dist/crs/spatial-reference-metadata.js.map +1 -0
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.d.ts.map +1 -1
- package/dist/index.cjs +1738 -316
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/projection/experimental/core.cjs.map +1 -1
- package/dist/projection/experimental/crs/spatial-reference.d.ts.map +1 -1
- package/dist/projection/experimental/crs/spatial-reference.js.map +1 -1
- package/dist/projection/experimental/crs/types.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/aea.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.js +4 -1
- package/dist/projection/experimental/lazy-projections/aea.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.js +4 -1
- package/dist/projection/experimental/lazy-projections/bonne.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.js +4 -1
- package/dist/projection/experimental/lazy-projections/cass.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.js +4 -1
- package/dist/projection/experimental/lazy-projections/eck6.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js +4 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js +4 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.js +4 -1
- package/dist/projection/experimental/lazy-projections/equi.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.js +4 -1
- package/dist/projection/experimental/lazy-projections/geocent.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.js +4 -1
- package/dist/projection/experimental/lazy-projections/geos.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.js +4 -1
- package/dist/projection/experimental/lazy-projections/gnom.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +92 -23
- package/dist/projection/experimental/lazy-projections/index.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/krovak.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.js +4 -1
- package/dist/projection/experimental/lazy-projections/krovak.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.js +4 -1
- package/dist/projection/experimental/lazy-projections/merc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.js +4 -1
- package/dist/projection/experimental/lazy-projections/mill.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.js +4 -1
- package/dist/projection/experimental/lazy-projections/moll.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js +4 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.js +4 -1
- package/dist/projection/experimental/lazy-projections/omerc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.js +4 -1
- package/dist/projection/experimental/lazy-projections/ortho.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.js +4 -1
- package/dist/projection/experimental/lazy-projections/poly.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.js +4 -1
- package/dist/projection/experimental/lazy-projections/robin.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.js +4 -1
- package/dist/projection/experimental/lazy-projections/sinu.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.js +4 -1
- package/dist/projection/experimental/lazy-projections/stere.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.js +4 -1
- package/dist/projection/experimental/lazy-projections/tpers.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.js +4 -1
- package/dist/projection/experimental/lazy-projections/vandg.js.map +1 -1
- package/dist/projection/index.cjs.map +1 -1
- package/dist/projection/index.d.ts.map +1 -1
- package/dist/projection/index.js.map +1 -1
- package/dist/projection/lib/projection.js.map +1 -1
- package/dist/projection/pipeline.cjs.map +1 -1
- package/dist/projection/transform-analysis.cjs.map +1 -1
- package/dist/tasks/index.cjs +181 -84
- package/dist/tasks/index.cjs.map +2 -2
- package/dist/tasks/terrain-residency.d.ts.map +1 -1
- package/dist/tasks/terrain-residency.js +80 -18
- package/dist/tasks/terrain-residency.js.map +1 -1
- package/dist/terrain/cutout-polygons.d.ts +21 -0
- package/dist/terrain/cutout-polygons.d.ts.map +1 -0
- package/dist/terrain/cutout-polygons.js +172 -0
- package/dist/terrain/cutout-polygons.js.map +1 -0
- package/dist/terrain/cutout-region.d.ts +34 -0
- package/dist/terrain/cutout-region.d.ts.map +1 -0
- package/dist/terrain/cutout-region.js +33 -0
- package/dist/terrain/cutout-region.js.map +1 -0
- package/dist/terrain/cutout-skirts.d.ts +34 -0
- package/dist/terrain/cutout-skirts.d.ts.map +1 -0
- package/dist/terrain/cutout-skirts.js +29 -0
- package/dist/terrain/cutout-skirts.js.map +1 -0
- package/dist/terrain/depression-fill.d.ts +25 -0
- package/dist/terrain/depression-fill.d.ts.map +1 -0
- package/dist/terrain/depression-fill.js +106 -0
- package/dist/terrain/depression-fill.js.map +1 -0
- package/dist/terrain/geographic-cutout.d.ts +38 -0
- package/dist/terrain/geographic-cutout.d.ts.map +1 -0
- package/dist/terrain/geographic-cutout.js +120 -0
- package/dist/terrain/geographic-cutout.js.map +1 -0
- package/dist/terrain/hydrology.d.ts +42 -0
- package/dist/terrain/hydrology.d.ts.map +1 -0
- package/dist/terrain/hydrology.js +112 -0
- package/dist/terrain/hydrology.js.map +1 -0
- package/dist/terrain/index.cjs +1529 -107
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +15 -1
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +13 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/lod-screen-error.d.ts +28 -0
- package/dist/terrain/lod-screen-error.d.ts.map +1 -0
- package/dist/terrain/lod-screen-error.js +95 -0
- package/dist/terrain/lod-screen-error.js.map +1 -0
- package/dist/terrain/lod-select.d.ts +26 -10
- package/dist/terrain/lod-select.d.ts.map +1 -1
- package/dist/terrain/lod-select.js +27 -14
- package/dist/terrain/lod-select.js.map +1 -1
- package/dist/terrain/mesh-cutout.d.ts +45 -0
- package/dist/terrain/mesh-cutout.d.ts.map +1 -0
- package/dist/terrain/mesh-cutout.js +336 -0
- package/dist/terrain/mesh-cutout.js.map +1 -0
- package/dist/terrain/mesh-skirts.d.ts +8 -2
- package/dist/terrain/mesh-skirts.d.ts.map +1 -1
- package/dist/terrain/mesh-skirts.js +5 -4
- package/dist/terrain/mesh-skirts.js.map +1 -1
- package/dist/terrain/mixed-halo-update.d.ts.map +1 -1
- package/dist/terrain/mixed-halo-update.js +58 -23
- package/dist/terrain/mixed-halo-update.js.map +1 -1
- package/dist/terrain/mixed-vertex-halos.d.ts +24 -1
- package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -1
- package/dist/terrain/mixed-vertex-halos.js +75 -58
- package/dist/terrain/mixed-vertex-halos.js.map +1 -1
- package/dist/terrain/regional-viewshed.d.ts +55 -0
- package/dist/terrain/regional-viewshed.d.ts.map +1 -0
- package/dist/terrain/regional-viewshed.js +119 -0
- package/dist/terrain/regional-viewshed.js.map +1 -0
- package/dist/terrain/sweep-polytope.d.ts +4 -0
- package/dist/terrain/sweep-polytope.d.ts.map +1 -1
- package/dist/terrain/sweep-polytope.js +15 -5
- package/dist/terrain/sweep-polytope.js.map +1 -1
- package/dist/terrain/sweep-rotating-capsule.d.ts +17 -0
- package/dist/terrain/sweep-rotating-capsule.d.ts.map +1 -0
- package/dist/terrain/sweep-rotating-capsule.js +118 -0
- package/dist/terrain/sweep-rotating-capsule.js.map +1 -0
- package/dist/terrain/sweep-rotation.d.ts +35 -0
- package/dist/terrain/sweep-rotation.d.ts.map +1 -0
- package/dist/terrain/sweep-rotation.js +114 -0
- package/dist/terrain/sweep-rotation.js.map +1 -0
- package/dist/terrain/tile-cutout-update.d.ts +73 -0
- package/dist/terrain/tile-cutout-update.d.ts.map +1 -0
- package/dist/terrain/tile-cutout-update.js +181 -0
- package/dist/terrain/tile-cutout-update.js.map +1 -0
- package/dist/terrain/tile-cutout.d.ts +33 -0
- package/dist/terrain/tile-cutout.d.ts.map +1 -0
- package/dist/terrain/tile-cutout.js +93 -0
- package/dist/terrain/tile-cutout.js.map +1 -0
- package/dist/terrain/watershed-accumulation.d.ts +20 -0
- package/dist/terrain/watershed-accumulation.d.ts.map +1 -0
- package/dist/terrain/watershed-accumulation.js +53 -0
- package/dist/terrain/watershed-accumulation.js.map +1 -0
- package/dist/turf/expressions.cjs +4 -4
- package/dist/turf/expressions.cjs.map +2 -2
- package/dist/turf/expressions.d.ts +2 -2
- package/dist/turf/expressions.d.ts.map +1 -1
- package/dist/turf/expressions.js +2 -2
- package/dist/turf/expressions.js.map +1 -1
- package/dist/turf.cjs +25 -25
- package/dist/turf.cjs.map +2 -2
- package/dist/turf.d.ts +1 -1
- package/dist/turf.d.ts.map +1 -1
- package/dist/turf.js +2 -2
- package/dist/turf.js.map +1 -1
- package/dist/web-mercator/assert.d.ts +2 -0
- package/dist/web-mercator/assert.d.ts.map +1 -0
- package/dist/web-mercator/assert.js +12 -0
- package/dist/web-mercator/assert.js.map +1 -0
- package/dist/web-mercator/fit-bounds.d.ts +52 -0
- package/dist/web-mercator/fit-bounds.d.ts.map +1 -0
- package/dist/web-mercator/fit-bounds.js +70 -0
- package/dist/web-mercator/fit-bounds.js.map +1 -0
- package/dist/web-mercator/fly-to-viewport.d.ts +19 -0
- package/dist/web-mercator/fly-to-viewport.d.ts.map +1 -0
- package/dist/web-mercator/fly-to-viewport.js +94 -0
- package/dist/web-mercator/fly-to-viewport.js.map +1 -0
- package/dist/web-mercator/get-bounds.d.ts +3 -0
- package/dist/web-mercator/get-bounds.d.ts.map +1 -0
- package/dist/web-mercator/get-bounds.js +56 -0
- package/dist/web-mercator/get-bounds.js.map +1 -0
- package/dist/web-mercator/index.cjs +705 -0
- package/dist/web-mercator/index.cjs.map +6 -0
- package/dist/web-mercator/index.d.ts +14 -0
- package/dist/web-mercator/index.d.ts.map +1 -0
- package/dist/web-mercator/index.js +14 -0
- package/dist/web-mercator/index.js.map +1 -0
- package/dist/web-mercator/math-utils.d.ts +7 -0
- package/dist/web-mercator/math-utils.d.ts.map +1 -0
- package/dist/web-mercator/math-utils.js +30 -0
- package/dist/web-mercator/math-utils.js.map +1 -0
- package/dist/web-mercator/mercator-meters.d.ts +29 -0
- package/dist/web-mercator/mercator-meters.d.ts.map +1 -0
- package/dist/web-mercator/mercator-meters.js +61 -0
- package/dist/web-mercator/mercator-meters.js.map +1 -0
- package/dist/web-mercator/normalize-viewport-props.d.ts +16 -0
- package/dist/web-mercator/normalize-viewport-props.d.ts.map +1 -0
- package/dist/web-mercator/normalize-viewport-props.js +45 -0
- package/dist/web-mercator/normalize-viewport-props.js.map +1 -0
- package/dist/web-mercator/web-mercator-utils.d.ts +192 -0
- package/dist/web-mercator/web-mercator-utils.d.ts.map +1 -0
- package/dist/web-mercator/web-mercator-utils.js +321 -0
- package/dist/web-mercator/web-mercator-utils.js.map +1 -0
- package/dist/web-mercator/web-mercator-viewport.d.ts +177 -0
- package/dist/web-mercator/web-mercator-viewport.d.ts.map +1 -0
- package/dist/web-mercator/web-mercator-viewport.js +276 -0
- package/dist/web-mercator/web-mercator-viewport.js.map +1 -0
- package/dist/web-mercator.d.ts +1 -1
- package/dist/web-mercator.d.ts.map +1 -1
- package/dist/web-mercator.js +1 -1
- package/dist/web-mercator.js.map +1 -1
- package/package.json +19 -458
- package/src/crs/index.ts +7 -0
- package/src/crs/spatial-reference-metadata.ts +118 -0
- package/src/expressions.ts +1 -1
- package/src/index.ts +92 -4
- package/src/projection/experimental/crs/spatial-reference.ts +1 -6
- package/src/projection/experimental/crs/types.ts +1 -1
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/crs-descriptor.ts +1 -1
- package/src/projection/experimental/lazy-projections/aea.ts +4 -1
- package/src/projection/experimental/lazy-projections/bonne.ts +4 -1
- package/src/projection/experimental/lazy-projections/cass.ts +4 -1
- package/src/projection/experimental/lazy-projections/eck6.ts +4 -1
- package/src/projection/experimental/lazy-projections/eqdc.ts +4 -1
- package/src/projection/experimental/lazy-projections/eqearth.ts +4 -1
- package/src/projection/experimental/lazy-projections/equi.ts +4 -1
- package/src/projection/experimental/lazy-projections/geocent.ts +4 -1
- package/src/projection/experimental/lazy-projections/geos.ts +4 -1
- package/src/projection/experimental/lazy-projections/gnom.ts +4 -1
- package/src/projection/experimental/lazy-projections/krovak.ts +4 -1
- package/src/projection/experimental/lazy-projections/merc.ts +4 -1
- package/src/projection/experimental/lazy-projections/mill.ts +4 -1
- package/src/projection/experimental/lazy-projections/moll.ts +4 -1
- package/src/projection/experimental/lazy-projections/nzmg.ts +4 -1
- package/src/projection/experimental/lazy-projections/omerc.ts +4 -1
- package/src/projection/experimental/lazy-projections/ortho.ts +4 -1
- package/src/projection/experimental/lazy-projections/poly.ts +4 -1
- package/src/projection/experimental/lazy-projections/robin.ts +4 -1
- package/src/projection/experimental/lazy-projections/sinu.ts +4 -1
- package/src/projection/experimental/lazy-projections/stere.ts +4 -1
- package/src/projection/experimental/lazy-projections/tpers.ts +4 -1
- package/src/projection/experimental/lazy-projections/vandg.ts +4 -1
- package/src/projection/index.ts +1 -1
- package/src/projection/lib/projection.ts +1 -1
- package/src/tasks/terrain-residency.ts +86 -21
- package/src/terrain/cutout-polygons.ts +202 -0
- package/src/terrain/cutout-region.ts +54 -0
- package/src/terrain/cutout-skirts.ts +52 -0
- package/src/terrain/depression-fill.ts +125 -0
- package/src/terrain/geographic-cutout.ts +154 -0
- package/src/terrain/hydrology.ts +149 -0
- package/src/terrain/index.ts +85 -1
- package/src/terrain/lod-screen-error.ts +128 -0
- package/src/terrain/lod-select.ts +65 -31
- package/src/terrain/mesh-cutout.ts +420 -0
- package/src/terrain/mesh-skirts.ts +10 -7
- package/src/terrain/mixed-halo-update.ts +54 -20
- package/src/terrain/mixed-vertex-halos.ts +94 -78
- package/src/terrain/regional-viewshed.ts +177 -0
- package/src/terrain/sweep-polytope.ts +49 -25
- package/src/terrain/sweep-rotating-capsule.ts +139 -0
- package/src/terrain/sweep-rotation.ts +149 -0
- package/src/terrain/tile-cutout-update.ts +293 -0
- package/src/terrain/tile-cutout.ts +123 -0
- package/src/terrain/watershed-accumulation.ts +67 -0
- package/src/turf/expressions.ts +3 -3
- package/src/turf.ts +3 -7
- package/src/web-mercator/assert.ts +11 -0
- package/src/web-mercator/fit-bounds.ts +132 -0
- package/src/web-mercator/fly-to-viewport.ts +157 -0
- package/src/web-mercator/get-bounds.ts +62 -0
- package/src/web-mercator/index.ts +49 -0
- package/src/web-mercator/math-utils.ts +35 -0
- package/src/web-mercator/mercator-meters.ts +83 -0
- package/src/web-mercator/normalize-viewport-props.ts +58 -0
- package/src/web-mercator/web-mercator-utils.ts +468 -0
- package/src/web-mercator/web-mercator-viewport.ts +406 -0
- package/src/web-mercator.ts +1 -1
- package/dist/projection/experimental/index.cjs +0 -11707
- package/dist/projection/experimental/index.cjs.map +0 -6
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { HeightField } from "./height-field.js";
|
|
5
|
+
/**
|
|
6
|
+
* Raise each outlet-connected cell to the lowest spill elevation needed to reach
|
|
7
|
+
* a declared outlet by face neighbors. The returned forest routes across flats.
|
|
8
|
+
* Nodata blocks flow and disconnected components retain their source heights.
|
|
9
|
+
* The source is immutable. Time is O(cells log cells) and storage is O(cells).
|
|
10
|
+
*/
|
|
11
|
+
export function fillTerrainDepressions(field, { outlets, maxCells = 4194304 }) {
|
|
12
|
+
if (field.registration !== 'cell')
|
|
13
|
+
throw new Error('Terrain depression fill requires cell registration');
|
|
14
|
+
const { width, height } = field;
|
|
15
|
+
const count = width * height;
|
|
16
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 0x7fffffff)
|
|
17
|
+
throw new RangeError('Terrain depression fill exceeds its cell budget');
|
|
18
|
+
if (!outlets.length)
|
|
19
|
+
throw new RangeError('Terrain depression fill requires an outlet');
|
|
20
|
+
for (const i of outlets) {
|
|
21
|
+
if (!Number.isInteger(i) ||
|
|
22
|
+
i < 0 ||
|
|
23
|
+
i >= count ||
|
|
24
|
+
field.getHeight(i % width, Math.floor(i / width)) === undefined)
|
|
25
|
+
throw new RangeError('Terrain outlet must identify a valid cell');
|
|
26
|
+
}
|
|
27
|
+
const { heights, validity } = field.copyData();
|
|
28
|
+
const receiver = new Int32Array(count).fill(-2);
|
|
29
|
+
const heap = new Int32Array(count);
|
|
30
|
+
let size = 0;
|
|
31
|
+
let disconnectedCells = field.validCount;
|
|
32
|
+
/** Sort by spill elevation, then by cell index for reproducible flat routing. */
|
|
33
|
+
const before = (a, b) => heights[a] < heights[b] || (heights[a] === heights[b] && a < b);
|
|
34
|
+
/** Insert a newly reached cell. Its finalized spill height never changes. */
|
|
35
|
+
function push(cell) {
|
|
36
|
+
let slot = size++;
|
|
37
|
+
while (slot > 0) {
|
|
38
|
+
const parent = Math.floor((slot - 1) / 2);
|
|
39
|
+
if (!before(cell, heap[parent]))
|
|
40
|
+
break;
|
|
41
|
+
heap[slot] = heap[parent];
|
|
42
|
+
slot = parent;
|
|
43
|
+
}
|
|
44
|
+
heap[slot] = cell;
|
|
45
|
+
}
|
|
46
|
+
/** Remove the cell with the lowest known spill elevation. */
|
|
47
|
+
function pop() {
|
|
48
|
+
const first = heap[0];
|
|
49
|
+
const tail = heap[--size];
|
|
50
|
+
let slot = 0;
|
|
51
|
+
let child = 1;
|
|
52
|
+
while (child < size) {
|
|
53
|
+
if (child + 1 < size && before(heap[child + 1], heap[child]))
|
|
54
|
+
child++;
|
|
55
|
+
if (!before(heap[child], tail))
|
|
56
|
+
break;
|
|
57
|
+
heap[slot] = heap[child];
|
|
58
|
+
slot = child;
|
|
59
|
+
child = slot * 2 + 1;
|
|
60
|
+
}
|
|
61
|
+
if (size)
|
|
62
|
+
heap[slot] = tail;
|
|
63
|
+
return first;
|
|
64
|
+
}
|
|
65
|
+
/** First discovery from the minimum frontier finalizes the minimax path cost. */
|
|
66
|
+
function visit(cell, parent) {
|
|
67
|
+
if (!validity[cell] || receiver[cell] !== -2)
|
|
68
|
+
return;
|
|
69
|
+
receiver[cell] = parent;
|
|
70
|
+
disconnectedCells--;
|
|
71
|
+
if (parent >= 0)
|
|
72
|
+
heights[cell] = Math.max(heights[cell], heights[parent]);
|
|
73
|
+
push(cell);
|
|
74
|
+
}
|
|
75
|
+
for (const outlet of outlets)
|
|
76
|
+
visit(outlet, -1);
|
|
77
|
+
while (size) {
|
|
78
|
+
const cell = pop();
|
|
79
|
+
const column = cell % width;
|
|
80
|
+
if (column > 0)
|
|
81
|
+
visit(cell - 1, cell);
|
|
82
|
+
if (column + 1 < width)
|
|
83
|
+
visit(cell + 1, cell);
|
|
84
|
+
if (cell >= width)
|
|
85
|
+
visit(cell - width, cell);
|
|
86
|
+
if (cell < count - width)
|
|
87
|
+
visit(cell + width, cell);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
field: new HeightField({
|
|
91
|
+
width,
|
|
92
|
+
height,
|
|
93
|
+
heights,
|
|
94
|
+
validity,
|
|
95
|
+
origin: field.origin,
|
|
96
|
+
columnStep: field.columnStep,
|
|
97
|
+
rowStep: field.rowStep,
|
|
98
|
+
registration: field.registration,
|
|
99
|
+
diagonal: field.diagonal,
|
|
100
|
+
heightReference: field.heightReference
|
|
101
|
+
}),
|
|
102
|
+
receiver,
|
|
103
|
+
disconnectedCells
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=depression-fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depression-fill.js","sourceRoot":"","sources":["../../src/terrain/depression-fill.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAoB3C;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAkB,EAClB,EAAC,OAAO,EAAE,QAAQ,GAAG,OAAS,EAA+B;IAE7D,IAAI,KAAK,CAAC,YAAY,KAAK,MAAM;QAC/B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,MAAM,EAAC,KAAK,EAAE,MAAM,EAAC,GAAG,KAAK,CAAC;IAC9B,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,IAAI,KAAK,GAAG,QAAQ,IAAI,KAAK,GAAG,UAAU;QAC3F,MAAM,IAAI,UAAU,CAAC,iDAAiD,CAAC,CAAC;IAC1E,IAAI,CAAC,OAA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as the third ordinate. */
|
|
2
|
+
export type GeographicTerrainCutoutFrame = {
|
|
3
|
+
/** Central longitude/latitude in degrees. Longitude is normalized to [-180,180). */
|
|
4
|
+
center: readonly [number, number];
|
|
5
|
+
/** Sphere radius in meters; default WGS84 semi-major axis (6378137). */
|
|
6
|
+
radius: number;
|
|
7
|
+
/** Maximum angular distance from the center in degrees; must be below 90. */
|
|
8
|
+
maxAngularRadius: number;
|
|
9
|
+
};
|
|
10
|
+
/** Explicit chart choice for regional terrain cutting. */
|
|
11
|
+
export type GeographicTerrainCutoutFrameOptions = {
|
|
12
|
+
/** Center longitude/latitude in degrees; polar centers are supported. */
|
|
13
|
+
center: readonly [number, number];
|
|
14
|
+
/** Spherical radius in meters. This is not an ellipsoidal distance certificate. */
|
|
15
|
+
radius?: number;
|
|
16
|
+
/** Angular cap in degrees, default 30; positive and at most 80. */
|
|
17
|
+
maxAngularRadius?: number;
|
|
18
|
+
};
|
|
19
|
+
/** Create a bounded chart that has no antimeridian cut and supports either pole.
|
|
20
|
+
* Great-circle segments project to straight lines. Mesh connectivity must
|
|
21
|
+
* already describe the intended local surface (polar fans rather than duplicate
|
|
22
|
+
* pole rows). Heights retain their input datum; Z is not ECEF or tangent-plane up.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createGeographicTerrainCutoutFrame(options: GeographicTerrainCutoutFrameOptions): GeographicTerrainCutoutFrame;
|
|
25
|
+
/** Project packed longitude/latitude/height to chart X/Y/height in Float64.
|
|
26
|
+
* Longitude aliases are normalized relative to the chart center. Vertices at
|
|
27
|
+
* the same pole project identically regardless of longitude. No connectivity,
|
|
28
|
+
* height filling, edge densification or geographic winding repair is performed.
|
|
29
|
+
* Triangle edges and cut edges mean straight segments in this chart (minor
|
|
30
|
+
* great-circle arcs horizontally); interpolate terrain height in chart space.
|
|
31
|
+
*/
|
|
32
|
+
export declare function projectGeographicTerrainCutout(positions: Float32Array | Float64Array, frame: GeographicTerrainCutoutFrame): Float64Array;
|
|
33
|
+
/** Invert chart X/Y/height to canonical longitude/latitude/height.
|
|
34
|
+
* Points outside the declared cap are rejected. At the exact pole, longitude
|
|
35
|
+
* is the chart center's longitude. Height and vertical datum are unchanged.
|
|
36
|
+
*/
|
|
37
|
+
export declare function unprojectGeographicTerrainCutout(positions: Float32Array | Float64Array, frame: GeographicTerrainCutoutFrame): Float64Array;
|
|
38
|
+
//# sourceMappingURL=geographic-cutout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geographic-cutout.d.ts","sourceRoot":"","sources":["../../src/terrain/geographic-cutout.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,MAAM,MAAM,4BAA4B,GAAG;IACzC,oFAAoF;IACpF,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AACF,0DAA0D;AAC1D,MAAM,MAAM,mCAAmC,GAAG;IAChD,yEAAyE;IACzE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,4BAA4B,CAS9B;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,YAAY,GAAG,YAAY,EACtC,KAAK,EAAE,4BAA4B,GAClC,YAAY,CA2Bd;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,YAAY,GAAG,YAAY,EACtC,KAAK,EAAE,4BAA4B,GAClC,YAAY,CAuBd"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
/** Degrees to radians. */
|
|
5
|
+
const RAD = Math.PI / 180;
|
|
6
|
+
/** Create a bounded chart that has no antimeridian cut and supports either pole.
|
|
7
|
+
* Great-circle segments project to straight lines. Mesh connectivity must
|
|
8
|
+
* already describe the intended local surface (polar fans rather than duplicate
|
|
9
|
+
* pole rows). Heights retain their input datum; Z is not ECEF or tangent-plane up.
|
|
10
|
+
*/
|
|
11
|
+
export function createGeographicTerrainCutoutFrame(options) {
|
|
12
|
+
if (options.center.length !== 2)
|
|
13
|
+
throw new RangeError('Invalid geographic terrain cutout center');
|
|
14
|
+
const frame = {
|
|
15
|
+
center: [wrap(options.center[0]), options.center[1]],
|
|
16
|
+
radius: options.radius ?? 6378137,
|
|
17
|
+
maxAngularRadius: options.maxAngularRadius ?? 30
|
|
18
|
+
};
|
|
19
|
+
validateFrame(frame);
|
|
20
|
+
return Object.freeze({ ...frame, center: Object.freeze(frame.center) });
|
|
21
|
+
}
|
|
22
|
+
/** Project packed longitude/latitude/height to chart X/Y/height in Float64.
|
|
23
|
+
* Longitude aliases are normalized relative to the chart center. Vertices at
|
|
24
|
+
* the same pole project identically regardless of longitude. No connectivity,
|
|
25
|
+
* height filling, edge densification or geographic winding repair is performed.
|
|
26
|
+
* Triangle edges and cut edges mean straight segments in this chart (minor
|
|
27
|
+
* great-circle arcs horizontally); interpolate terrain height in chart space.
|
|
28
|
+
*/
|
|
29
|
+
export function projectGeographicTerrainCutout(positions, frame) {
|
|
30
|
+
var _a;
|
|
31
|
+
validateFrame(frame);
|
|
32
|
+
validatePositions(positions);
|
|
33
|
+
const result = new Float64Array(positions.length);
|
|
34
|
+
const [sin0, cos0] = latitude(frame.center[1]);
|
|
35
|
+
const maximum = chartLimit(frame);
|
|
36
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
37
|
+
const lon = positions[i], lat = positions[i + 1];
|
|
38
|
+
if (lat < -90 || lat > 90)
|
|
39
|
+
throw new RangeError('Invalid geographic terrain latitude');
|
|
40
|
+
const sin = Math.sin(lat * RAD);
|
|
41
|
+
const cos = Math.abs(lat) === 90 ? 0 : Math.cos(lat * RAD);
|
|
42
|
+
const delta = wrap(wrap(lon) - frame.center[0]) * RAD;
|
|
43
|
+
const dot = sin0 * sin + cos0 * cos * Math.cos(delta);
|
|
44
|
+
const x = (cos * Math.sin(delta)) / dot;
|
|
45
|
+
const y = (cos0 * sin - sin0 * cos * Math.cos(delta)) / dot;
|
|
46
|
+
if (!(dot > 0) || Math.hypot(x, y) > maximum)
|
|
47
|
+
throw new RangeError('Terrain coordinate exceeds geographic cutout chart');
|
|
48
|
+
result[i] = frame.radius * x;
|
|
49
|
+
result[i + 1] = frame.radius * y;
|
|
50
|
+
result[i] || (result[i] = 0);
|
|
51
|
+
result[_a = i + 1] || (result[_a] = 0);
|
|
52
|
+
result[i + 2] = positions[i + 2];
|
|
53
|
+
}
|
|
54
|
+
if (!result.every(Number.isFinite))
|
|
55
|
+
throw new RangeError('Geographic terrain projection overflow');
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
/** Invert chart X/Y/height to canonical longitude/latitude/height.
|
|
59
|
+
* Points outside the declared cap are rejected. At the exact pole, longitude
|
|
60
|
+
* is the chart center's longitude. Height and vertical datum are unchanged.
|
|
61
|
+
*/
|
|
62
|
+
export function unprojectGeographicTerrainCutout(positions, frame) {
|
|
63
|
+
validateFrame(frame);
|
|
64
|
+
validatePositions(positions);
|
|
65
|
+
const result = new Float64Array(positions.length);
|
|
66
|
+
const [sin0, cos0] = latitude(frame.center[1]);
|
|
67
|
+
const maximum = chartLimit(frame);
|
|
68
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
69
|
+
const x = positions[i] / frame.radius, y = positions[i + 1] / frame.radius;
|
|
70
|
+
const distance = Math.hypot(x, y);
|
|
71
|
+
if (!Number.isFinite(distance) || distance > maximum)
|
|
72
|
+
throw new RangeError('Terrain coordinate exceeds geographic cutout chart');
|
|
73
|
+
const horizontal = cos0 - y * sin0;
|
|
74
|
+
const vertical = sin0 + y * cos0;
|
|
75
|
+
const lat = Math.atan2(vertical, Math.hypot(horizontal, x)) / RAD;
|
|
76
|
+
result[i] =
|
|
77
|
+
Math.abs(lat) === 90
|
|
78
|
+
? frame.center[0]
|
|
79
|
+
: wrap(frame.center[0] + Math.atan2(x, horizontal) / RAD);
|
|
80
|
+
result[i + 1] = lat;
|
|
81
|
+
result[i + 2] = positions[i + 2];
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
/** Normalize aliases before subtraction to avoid overflow and inconsistent seams. */
|
|
86
|
+
function wrap(longitude) {
|
|
87
|
+
const result = longitude % 360;
|
|
88
|
+
return result >= 180 ? result - 360 : result < -180 ? result + 360 : result;
|
|
89
|
+
}
|
|
90
|
+
/** Exact pole cosines prevent longitude-dependent roundoff at the poles. */
|
|
91
|
+
function latitude(degrees) {
|
|
92
|
+
return [Math.sin(degrees * RAD), Math.abs(degrees) === 90 ? 0 : Math.cos(degrees * RAD)];
|
|
93
|
+
}
|
|
94
|
+
/** Validate frames even when callers supply a structural object. */
|
|
95
|
+
function validateFrame(frame) {
|
|
96
|
+
if (frame.center.length !== 2 ||
|
|
97
|
+
!frame.center.every(Number.isFinite) ||
|
|
98
|
+
frame.center[0] < -180 ||
|
|
99
|
+
frame.center[0] >= 180 ||
|
|
100
|
+
Math.abs(frame.center[1]) > 90 ||
|
|
101
|
+
!Number.isFinite(frame.radius) ||
|
|
102
|
+
frame.radius <= 0 ||
|
|
103
|
+
!Number.isFinite(frame.maxAngularRadius) ||
|
|
104
|
+
frame.maxAngularRadius <= 0 ||
|
|
105
|
+
frame.maxAngularRadius > 80)
|
|
106
|
+
throw new RangeError('Invalid geographic terrain cutout frame');
|
|
107
|
+
}
|
|
108
|
+
/** Reject malformed or nonfinite packed XYZ before allocating output. */
|
|
109
|
+
function validatePositions(positions) {
|
|
110
|
+
if (!(positions instanceof Float32Array || positions instanceof Float64Array) ||
|
|
111
|
+
positions.length % 3 ||
|
|
112
|
+
!positions.every(Number.isFinite))
|
|
113
|
+
throw new RangeError('Invalid geographic terrain cutout positions');
|
|
114
|
+
}
|
|
115
|
+
/** Shared roundoff allowance for inclusive forward/inverse angular caps. */
|
|
116
|
+
function chartLimit(frame) {
|
|
117
|
+
const distance = Math.tan(frame.maxAngularRadius * RAD);
|
|
118
|
+
return distance + 16 * Number.EPSILON * (1 + distance);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=geographic-cutout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geographic-cutout.js","sourceRoot":"","sources":["../../src/terrain/geographic-cutout.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAoB5D,0BAA0B;AAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAE1B;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAChD,OAA4C;IAE5C,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,0CAA0C,CAAC,CAAC;IAClG,MAAM,KAAK,GAAG;QACZ,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAU;QAC7D,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO;QACjC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,EAAE;KACjD,CAAC;IACF,aAAa,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAC,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;GAMG;AAC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I,UAAU,CAAC,yCAAyC,CAAC,CAAC;AACpE,CAAC;AACD,yEAAyE;AACzE,SAAS,iBAAiB,CAAC,SAAsC;IAC/D,IACE,CAAC,CAAC,SAAS,YAAY,YAAY,IAAI,SAAS,YAAY,YAAY,CAAC;QACzE,SAAS,CAAC,MAAM,GAAG,CAAC;QACpB,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAEjC,MAAM,IAAI,UAAU,CAAC,6CAA6C,CAAC,CAAC;AACxE,CAAC;AAED,4EAA4E;AAC5E,SAAS,UAAU,CAAC,KAAmC;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC;IACxD,OAAO,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HeightField } from "./height-field.js";
|
|
2
|
+
/** Uniform horizontal finite-volume metrics for an affine cell-centered grid. */
|
|
3
|
+
export type TerrainCellMetrics = {
|
|
4
|
+
/** Horizontal area of one cell, in square meters. */
|
|
5
|
+
area: number;
|
|
6
|
+
/** Face lengths ordered by negative column, positive column, negative row, positive row. */
|
|
7
|
+
faceLengths: readonly [number, number, number, number];
|
|
8
|
+
/** Outward horizontal unit normals in the same order as the face lengths. */
|
|
9
|
+
faceNormals: readonly [
|
|
10
|
+
readonly [number, number],
|
|
11
|
+
readonly [number, number],
|
|
12
|
+
readonly [number, number],
|
|
13
|
+
readonly [number, number]
|
|
14
|
+
];
|
|
15
|
+
};
|
|
16
|
+
/** Derive projected cell area and face geometry, including shear and reflected grids. */
|
|
17
|
+
export declare function getTerrainCellMetrics(field: Pick<HeightField, 'registration' | 'columnStep' | 'rowStep'>): TerrainCellMetrics;
|
|
18
|
+
/** Drainage options for the unconditioned cell grid. */
|
|
19
|
+
export type TerrainDrainageOptions = {
|
|
20
|
+
/** Valid row-major cell indices where flow terminates, even if lower neighbors exist. */
|
|
21
|
+
outlets?: readonly number[];
|
|
22
|
+
/** Maximum grid cells before allocating drainage buffers. Defaults to 4,194,304. */
|
|
23
|
+
maxCells?: number;
|
|
24
|
+
};
|
|
25
|
+
/** Row-major routing, catchments and accumulation for a single affine cell grid. */
|
|
26
|
+
export type TerrainDrainage = {
|
|
27
|
+
/** Receiver index, or -1 for nodata and terminal cells. */
|
|
28
|
+
receiver: Int32Array;
|
|
29
|
+
/** Terminal cell index for the catchment, or -1 for nodata. */
|
|
30
|
+
terminal: Int32Array;
|
|
31
|
+
/** Upstream cell count including the cell itself. Zero denotes nodata. */
|
|
32
|
+
contributingCells: Uint32Array;
|
|
33
|
+
/** Multiply by contributingCells to get contributing area in square meters. */
|
|
34
|
+
cellArea: number;
|
|
35
|
+
};
|
|
36
|
+
/** Route each valid cell to its steepest strictly lower neighbor in projected XY.
|
|
37
|
+
* Equal slopes select the lower row-major index. Diagonal flow requires both
|
|
38
|
+
* intervening side cells to be valid. The exterior and nodata block flow.
|
|
39
|
+
* Flats, pits and declared outlets terminate flow. Accumulation is O(cells).
|
|
40
|
+
*/
|
|
41
|
+
export declare function createTerrainDrainage(field: HeightField, { outlets, maxCells }?: TerrainDrainageOptions): TerrainDrainage;
|
|
42
|
+
//# sourceMappingURL=hydrology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrology.d.ts","sourceRoot":"","sources":["../../src/terrain/hydrology.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,0BAAuB;AAEhD,iFAAiF;AACjF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,WAAW,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACvD,6EAA6E;IAC7E,WAAW,EAAE,SAAS;QACpB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,yFAAyF;AACzF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,GAClE,kBAAkB,CAmBpB;AAED,wDAAwD;AACxD,MAAM,MAAM,sBAAsB,GAAG;IACnC,yFAAyF;IACzF,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oFAAoF;AACpF,MAAM,MAAM,eAAe,GAAG;IAC5B,2DAA2D;IAC3D,QAAQ,EAAE,UAAU,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,EAAE,UAAU,CAAC;IACrB,0EAA0E;IAC1E,iBAAiB,EAAE,WAAW,CAAC;IAC/B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,EAClB,EAAC,OAAY,EAAE,QAAoB,EAAC,GAAE,sBAA2B,GAChE,eAAe,CA2EjB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
/** Derive projected cell area and face geometry, including shear and reflected grids. */
|
|
5
|
+
export function getTerrainCellMetrics(field) {
|
|
6
|
+
if (field.registration !== 'cell')
|
|
7
|
+
throw new Error('Terrain cell metrics require cell registration');
|
|
8
|
+
const [cx, cy] = field.columnStep;
|
|
9
|
+
const [rx, ry] = field.rowStep;
|
|
10
|
+
const determinant = cx * ry - cy * rx;
|
|
11
|
+
const columnLength = Math.hypot(cx, cy);
|
|
12
|
+
const rowLength = Math.hypot(rx, ry);
|
|
13
|
+
const area = Math.abs(determinant);
|
|
14
|
+
if (!(area > 0 && Number.isFinite(area) && Number.isFinite(columnLength + rowLength)))
|
|
15
|
+
throw new RangeError('Invalid terrain cell geometry');
|
|
16
|
+
const sign = Math.sign(determinant);
|
|
17
|
+
const east = [(sign * ry) / rowLength, (-sign * rx) / rowLength];
|
|
18
|
+
const south = [(-sign * cy) / columnLength, (sign * cx) / columnLength];
|
|
19
|
+
return {
|
|
20
|
+
area,
|
|
21
|
+
faceLengths: [rowLength, rowLength, columnLength, columnLength],
|
|
22
|
+
faceNormals: [[-east[0], -east[1]], east, [-south[0], -south[1]], south]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Route each valid cell to its steepest strictly lower neighbor in projected XY.
|
|
26
|
+
* Equal slopes select the lower row-major index. Diagonal flow requires both
|
|
27
|
+
* intervening side cells to be valid. The exterior and nodata block flow.
|
|
28
|
+
* Flats, pits and declared outlets terminate flow. Accumulation is O(cells).
|
|
29
|
+
*/
|
|
30
|
+
export function createTerrainDrainage(field, { outlets = [], maxCells = 4194304 } = {}) {
|
|
31
|
+
const { width, height, columnStep, rowStep } = field;
|
|
32
|
+
const count = width * height;
|
|
33
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 0x7fffffff)
|
|
34
|
+
throw new RangeError('Terrain drainage exceeds its cell budget');
|
|
35
|
+
const { area: cellArea } = getTerrainCellMetrics(field);
|
|
36
|
+
for (const i of outlets) {
|
|
37
|
+
if (!Number.isInteger(i) ||
|
|
38
|
+
i < 0 ||
|
|
39
|
+
i >= count ||
|
|
40
|
+
field.getHeight(i % width, Math.floor(i / width)) === undefined)
|
|
41
|
+
throw new RangeError('Terrain outlet must identify a valid cell');
|
|
42
|
+
}
|
|
43
|
+
const { heights, validity } = field.copyData();
|
|
44
|
+
const receiver = new Int32Array(count).fill(-1);
|
|
45
|
+
const terminal = new Int32Array(count).fill(-1);
|
|
46
|
+
const contributingCells = new Uint32Array(count);
|
|
47
|
+
const incoming = new Uint8Array(count);
|
|
48
|
+
const queue = new Int32Array(count);
|
|
49
|
+
const outletSet = new Set(outlets);
|
|
50
|
+
const offsets = [];
|
|
51
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
52
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
53
|
+
if (!dx && !dy)
|
|
54
|
+
continue;
|
|
55
|
+
const distance = Math.hypot(dx * columnStep[0] + dy * rowStep[0], dx * columnStep[1] + dy * rowStep[1]);
|
|
56
|
+
if (!(distance > 0 && Number.isFinite(distance)))
|
|
57
|
+
throw new RangeError('Invalid terrain neighbor distance');
|
|
58
|
+
offsets.push({ dx, dy, distance });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (let i = 0; i < count; i++) {
|
|
62
|
+
if (!validity[i])
|
|
63
|
+
continue;
|
|
64
|
+
contributingCells[i] = 1;
|
|
65
|
+
if (outletSet.has(i))
|
|
66
|
+
continue;
|
|
67
|
+
const col = i % width;
|
|
68
|
+
const row = Math.floor(i / width);
|
|
69
|
+
let steepest = 0;
|
|
70
|
+
for (const { dx, dy, distance } of offsets) {
|
|
71
|
+
if (col + dx < 0 || col + dx >= width || row + dy < 0 || row + dy >= height)
|
|
72
|
+
continue;
|
|
73
|
+
const j = i + dx + dy * width;
|
|
74
|
+
if (!validity[j] || heights[j] >= heights[i])
|
|
75
|
+
continue;
|
|
76
|
+
if (dx && dy && (!validity[i + dx] || !validity[i + dy * width]))
|
|
77
|
+
continue;
|
|
78
|
+
const slope = (heights[i] - heights[j]) / distance;
|
|
79
|
+
if (!Number.isFinite(slope) || slope === 0)
|
|
80
|
+
throw new RangeError('Terrain drainage slope is outside the representable range');
|
|
81
|
+
// Offsets visit neighbors in ascending row-major order.
|
|
82
|
+
if (slope > steepest) {
|
|
83
|
+
steepest = slope;
|
|
84
|
+
receiver[i] = j;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (receiver[i] >= 0)
|
|
88
|
+
incoming[receiver[i]]++;
|
|
89
|
+
}
|
|
90
|
+
let end = 0;
|
|
91
|
+
for (let i = 0; i < count; i++)
|
|
92
|
+
if (validity[i] && !incoming[i])
|
|
93
|
+
queue[end++] = i;
|
|
94
|
+
// Strict descent makes the graph acyclic. Topological order permits one
|
|
95
|
+
// accumulation pass and one backward catchment pass without sorting heights.
|
|
96
|
+
for (let cursor = 0; cursor < end; cursor++) {
|
|
97
|
+
const i = queue[cursor];
|
|
98
|
+
const next = receiver[i];
|
|
99
|
+
if (next < 0)
|
|
100
|
+
continue;
|
|
101
|
+
contributingCells[next] += contributingCells[i];
|
|
102
|
+
if (--incoming[next] === 0)
|
|
103
|
+
queue[end++] = next;
|
|
104
|
+
}
|
|
105
|
+
for (let cursor = end - 1; cursor >= 0; cursor--) {
|
|
106
|
+
const i = queue[cursor];
|
|
107
|
+
const next = receiver[i];
|
|
108
|
+
terminal[i] = next < 0 ? i : terminal[next];
|
|
109
|
+
}
|
|
110
|
+
return { receiver, terminal, contributingCells, cellArea };
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=hydrology.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrology.js","sourceRoot":"","sources":["../../src/terrain/hydrology.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAmB5D,yFAAyF;AACzF,MAAM,UAAU,qBAAqB,CACnC,KAAmE;IAEnE,IAAI,KAAK,CAAC,YAAY,KAAK,MAAM;QAC/B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;IAClC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,O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