@math.gl/geospatial 5.0.0-beta.8 → 5.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/crs/crs-descriptor-types.d.ts +2 -1
- package/dist/crs/crs-descriptor-types.d.ts.map +1 -1
- 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/ellipsoid-helpers/ellipsoid-transform.d.ts +1 -1
- package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts.map +1 -1
- package/dist/ellipsoid-helpers/ellipsoid-transform.js +2 -2
- package/dist/ellipsoid-helpers/ellipsoid-transform.js.map +1 -1
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js +1 -1
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/ellipsoid-helpers/tangent-plane-numerics.d.ts +1 -1
- package/dist/ellipsoid-helpers/tangent-plane-numerics.d.ts.map +1 -1
- package/dist/ellipsoid-tangent-plane.d.ts +2 -2
- package/dist/ellipsoid-tangent-plane.d.ts.map +1 -1
- package/dist/ellipsoid-tangent-plane.js +1 -1
- package/dist/ellipsoid-tangent-plane.js.map +1 -1
- package/dist/ellipsoid-transforms.d.ts +2 -2
- package/dist/ellipsoid-transforms.d.ts.map +1 -1
- package/dist/ellipsoid-transforms.js +1 -1
- package/dist/ellipsoid-transforms.js.map +1 -1
- package/dist/ellipsoid.d.ts +2 -2
- package/dist/ellipsoid.d.ts.map +1 -1
- package/dist/ellipsoid.js +2 -2
- package/dist/ellipsoid.js.map +1 -1
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.d.ts.map +1 -1
- package/dist/expressions.js +1 -1
- package/dist/expressions.js.map +1 -1
- package/dist/geodesic-buffer.d.ts +1 -1
- package/dist/geodesic-buffer.d.ts.map +1 -1
- package/dist/geodesic-path.d.ts +1 -1
- package/dist/geodesic-path.d.ts.map +1 -1
- package/dist/geometry-constructors.d.ts +6 -0
- package/dist/geometry-constructors.d.ts.map +1 -0
- package/dist/geometry-constructors.js +37 -0
- package/dist/geometry-constructors.js.map +1 -0
- package/dist/geometry-inspection.d.ts +8 -0
- package/dist/geometry-inspection.d.ts.map +1 -0
- package/dist/geometry-inspection.js +61 -0
- package/dist/geometry-inspection.js.map +1 -0
- package/dist/index.cjs +3773 -846
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +173 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -1
- package/dist/line-simplification.d.ts +4 -0
- package/dist/line-simplification.d.ts.map +1 -0
- package/dist/line-simplification.js +83 -0
- package/dist/line-simplification.js.map +1 -0
- package/dist/linear-referencing.d.ts +6 -0
- package/dist/linear-referencing.d.ts.map +1 -0
- package/dist/linear-referencing.js +74 -0
- package/dist/linear-referencing.js.map +1 -0
- package/dist/lng-lat-rectangle.d.ts +1 -1
- package/dist/lng-lat-rectangle.d.ts.map +1 -1
- package/dist/lng-lat-rectangle.js +1 -1
- package/dist/lng-lat-rectangle.js.map +1 -1
- package/dist/local-reference-frame.d.ts +3 -3
- package/dist/local-reference-frame.d.ts.map +1 -1
- package/dist/local-reference-frame.js +2 -2
- package/dist/local-reference-frame.js.map +1 -1
- package/dist/make-obb-from-region.d.ts +1 -1
- package/dist/make-obb-from-region.d.ts.map +1 -1
- package/dist/make-obb-from-region.js +1 -1
- package/dist/make-obb-from-region.js.map +1 -1
- package/dist/maps/air-ocean-mesh.js +1 -1
- package/dist/maps/air-ocean-mesh.js.map +1 -1
- package/dist/maps/myriahedral/unfold.d.ts +1 -1
- package/dist/maps/myriahedral/unfold.d.ts.map +1 -1
- package/dist/maps/myriahedral/unfold.js +1 -1
- package/dist/maps/myriahedral/unfold.js.map +1 -1
- package/dist/maps/presets.cjs +6 -6
- package/dist/maps/presets.cjs.map +2 -2
- package/dist/maps.cjs +6 -6
- package/dist/maps.cjs.map +2 -2
- package/dist/projection/deformation.cjs +5 -5
- package/dist/projection/deformation.cjs.map +2 -2
- package/dist/projection/experimental/core.cjs +8 -4
- 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 +1 -1
- package/dist/projection/experimental/crs/types.d.ts.map +1 -1
- package/dist/projection/experimental/crs-rendering-scale.d.ts.map +1 -1
- package/dist/projection/experimental/crs-rendering-scale.js +13 -2
- package/dist/projection/experimental/crs-rendering-scale.js.map +1 -1
- package/dist/projection/experimental/datum.js +1 -1
- package/dist/projection/experimental/datum.js.map +1 -1
- package/dist/projection/experimental/entries/projections/geocent.cjs +3 -3
- package/dist/projection/experimental/entries/projections/geocent.cjs.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 +100 -27
- 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/experimental/spatial-deformation.js +1 -1
- package/dist/projection/experimental/spatial-deformation.js.map +1 -1
- package/dist/projection/index.cjs +8 -4
- 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 +3 -3
- package/dist/projection/pipeline.cjs.map +1 -1
- package/dist/projection/temporal.cjs +5 -5
- package/dist/projection/temporal.cjs.map +2 -2
- package/dist/projection/transform-analysis.cjs +3 -3
- package/dist/projection/transform-analysis.cjs.map +1 -1
- package/dist/rhumb-path.d.ts +1 -1
- package/dist/rhumb-path.d.ts.map +1 -1
- package/dist/spatial-planar-intersects.d.ts +4 -0
- package/dist/spatial-planar-intersects.d.ts.map +1 -0
- package/dist/spatial-planar-intersects.js +108 -0
- package/dist/spatial-planar-intersects.js.map +1 -0
- package/dist/spatial-planar.d.ts +16 -0
- package/dist/spatial-planar.d.ts.map +1 -0
- package/dist/spatial-planar.js +240 -0
- package/dist/spatial-planar.js.map +1 -0
- package/dist/spatial-sql.d.ts +45 -0
- package/dist/spatial-sql.d.ts.map +1 -0
- package/dist/spatial-sql.js +192 -0
- package/dist/spatial-sql.js.map +1 -0
- package/dist/st-functions.cjs +1616 -0
- package/dist/st-functions.cjs.map +6 -0
- package/dist/st-functions.d.ts +307 -0
- package/dist/st-functions.d.ts.map +1 -0
- package/dist/st-functions.js +593 -0
- package/dist/st-functions.js.map +1 -0
- package/dist/subdivide-globe-mesh.js +1 -1
- package/dist/subdivide-globe-mesh.js.map +1 -1
- package/dist/tasks/index.cjs +1266 -155
- package/dist/tasks/index.cjs.map +3 -3
- package/dist/tasks/index.d.ts +12 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +26 -0
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/terrain-coverage-worker.d.ts +2 -0
- package/dist/tasks/terrain-coverage-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage-worker.js +7 -0
- package/dist/tasks/terrain-coverage-worker.js.map +1 -0
- package/dist/tasks/terrain-coverage.d.ts +25 -0
- package/dist/tasks/terrain-coverage.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage.js +15 -0
- package/dist/tasks/terrain-coverage.js.map +1 -0
- package/dist/tasks/terrain-residency-worker.d.ts +2 -0
- package/dist/tasks/terrain-residency-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-residency-worker.js +7 -0
- package/dist/tasks/terrain-residency-worker.js.map +1 -0
- package/dist/tasks/terrain-residency.d.ts +73 -0
- package/dist/tasks/terrain-residency.d.ts.map +1 -0
- package/dist/tasks/terrain-residency.js +203 -0
- package/dist/tasks/terrain-residency.js.map +1 -0
- package/dist/terrain/breakline-mesh.d.ts +18 -0
- package/dist/terrain/breakline-mesh.d.ts.map +1 -0
- package/dist/terrain/breakline-mesh.js +126 -0
- package/dist/terrain/breakline-mesh.js.map +1 -0
- package/dist/terrain/breakline-preprocess.d.ts +11 -0
- package/dist/terrain/breakline-preprocess.d.ts.map +1 -0
- package/dist/terrain/breakline-preprocess.js +94 -0
- package/dist/terrain/breakline-preprocess.js.map +1 -0
- package/dist/terrain/continuous-mesh-error.d.ts +34 -0
- package/dist/terrain/continuous-mesh-error.d.ts.map +1 -0
- package/dist/terrain/continuous-mesh-error.js +221 -0
- package/dist/terrain/continuous-mesh-error.js.map +1 -0
- 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/geographic-lod-seams.d.ts +10 -0
- package/dist/terrain/geographic-lod-seams.d.ts.map +1 -0
- package/dist/terrain/geographic-lod-seams.js +100 -0
- package/dist/terrain/geographic-lod-seams.js.map +1 -0
- package/dist/terrain/geographic-neighbor.d.ts +18 -0
- package/dist/terrain/geographic-neighbor.d.ts.map +1 -0
- package/dist/terrain/geographic-neighbor.js +44 -0
- package/dist/terrain/geographic-neighbor.js.map +1 -0
- package/dist/terrain/geographic-poles.d.ts +24 -0
- package/dist/terrain/geographic-poles.d.ts.map +1 -0
- package/dist/terrain/geographic-poles.js +34 -0
- package/dist/terrain/geographic-poles.js.map +1 -0
- package/dist/terrain/geographic-seam.d.ts +21 -0
- package/dist/terrain/geographic-seam.d.ts.map +1 -0
- package/dist/terrain/geographic-seam.js +52 -0
- package/dist/terrain/geographic-seam.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 +3158 -213
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +32 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +30 -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 +48 -0
- package/dist/terrain/lod-select.d.ts.map +1 -0
- package/dist/terrain/lod-select.js +73 -0
- package/dist/terrain/lod-select.js.map +1 -0
- package/dist/terrain/lod-stitch.d.ts +15 -0
- package/dist/terrain/lod-stitch.d.ts.map +1 -0
- package/dist/terrain/lod-stitch.js +64 -0
- package/dist/terrain/lod-stitch.js.map +1 -0
- package/dist/terrain/mesh-coverage.d.ts +35 -0
- package/dist/terrain/mesh-coverage.d.ts.map +1 -0
- package/dist/terrain/mesh-coverage.js +186 -0
- package/dist/terrain/mesh-coverage.js.map +1 -0
- 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-regions-data.d.ts +2 -2
- package/dist/terrain/mesh-regions-data.d.ts.map +1 -1
- package/dist/terrain/mesh-regions-data.js +20 -10
- package/dist/terrain/mesh-regions-data.js.map +1 -1
- 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 +138 -26
- package/dist/terrain/mixed-halo-update.js.map +1 -1
- package/dist/terrain/mixed-vertex-halos.d.ts +34 -1
- package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -1
- package/dist/terrain/mixed-vertex-halos.js +98 -43
- 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/surface.d.ts +1 -1
- package/dist/terrain/surface.d.ts.map +1 -1
- package/dist/terrain/surface.js +1 -1
- package/dist/terrain/surface.js.map +1 -1
- package/dist/terrain/sweep-capsule.d.ts +27 -0
- package/dist/terrain/sweep-capsule.d.ts.map +1 -0
- package/dist/terrain/sweep-capsule.js +104 -0
- package/dist/terrain/sweep-capsule.js.map +1 -0
- package/dist/terrain/sweep-cylinder.d.ts +16 -0
- package/dist/terrain/sweep-cylinder.d.ts.map +1 -0
- package/dist/terrain/sweep-cylinder.js +52 -0
- package/dist/terrain/sweep-cylinder.js.map +1 -0
- package/dist/terrain/sweep-plane.d.ts +9 -0
- package/dist/terrain/sweep-plane.d.ts.map +1 -0
- package/dist/terrain/sweep-plane.js +52 -0
- package/dist/terrain/sweep-plane.js.map +1 -0
- package/dist/terrain/sweep-polytope.d.ts +42 -0
- package/dist/terrain/sweep-polytope.d.ts.map +1 -0
- package/dist/terrain/sweep-polytope.js +189 -0
- package/dist/terrain/sweep-polytope.js.map +1 -0
- 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/sweep-sphere.d.ts +27 -0
- package/dist/terrain/sweep-sphere.d.ts.map +1 -0
- package/dist/terrain/sweep-sphere.js +69 -0
- package/dist/terrain/sweep-sphere.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/valid-domain-mesh.d.ts +29 -0
- package/dist/terrain/valid-domain-mesh.d.ts.map +1 -0
- package/dist/terrain/valid-domain-mesh.js +183 -0
- package/dist/terrain/valid-domain-mesh.js.map +1 -0
- package/dist/terrain/valid-domain-regions.d.ts +16 -0
- package/dist/terrain/valid-domain-regions.d.ts.map +1 -0
- package/dist/terrain/valid-domain-regions.js +19 -0
- package/dist/terrain/valid-domain-regions.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/triaxial.d.ts +1 -1
- package/dist/triaxial.d.ts.map +1 -1
- package/dist/turf-expressions.cjs +1997 -0
- package/dist/turf-expressions.cjs.map +6 -0
- package/dist/turf-expressions.d.ts +3 -0
- package/dist/turf-expressions.d.ts.map +1 -0
- package/dist/turf-expressions.js +7 -0
- package/dist/turf-expressions.js.map +1 -0
- package/dist/turf-functions.cjs +743 -0
- package/dist/turf-functions.cjs.map +6 -0
- package/dist/turf-functions.d.ts +90 -0
- package/dist/turf-functions.d.ts.map +1 -0
- package/dist/{turf/expressions.js → turf-functions.js} +51 -5
- package/dist/turf-functions.js.map +1 -0
- 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/type-utils.d.ts +1 -1
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/type-utils.js +1 -1
- package/dist/type-utils.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 +35 -462
- package/src/crs/crs-descriptor-types.ts +2 -1
- package/src/crs/index.ts +7 -0
- package/src/crs/spatial-reference-metadata.ts +118 -0
- package/src/ellipsoid-helpers/ellipsoid-transform.ts +3 -3
- package/src/ellipsoid-helpers/scale-to-geodetic-surface.ts +1 -1
- package/src/ellipsoid-helpers/tangent-plane-numerics.ts +1 -1
- package/src/ellipsoid-tangent-plane.ts +2 -2
- package/src/ellipsoid-transforms.ts +2 -2
- package/src/ellipsoid.ts +7 -3
- package/src/expressions.ts +2 -2
- package/src/geodesic-buffer.ts +1 -1
- package/src/geodesic-path.ts +1 -1
- package/src/geometry-constructors.ts +36 -0
- package/src/geometry-inspection.ts +66 -0
- package/src/index.ts +314 -4
- package/src/line-simplification.ts +97 -0
- package/src/linear-referencing.ts +94 -0
- package/src/lng-lat-rectangle.ts +1 -1
- package/src/local-reference-frame.ts +4 -4
- package/src/make-obb-from-region.ts +9 -1
- package/src/maps/air-ocean-mesh.ts +1 -1
- package/src/maps/myriahedral/unfold.ts +1 -1
- package/src/projection/experimental/crs/spatial-reference.ts +1 -6
- package/src/projection/experimental/crs/types.ts +2 -2
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/crs-descriptor.ts +1 -1
- package/src/projection/experimental/crs-rendering-scale.ts +16 -4
- package/src/projection/experimental/datum.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/experimental/spatial-deformation.ts +1 -1
- package/src/projection/index.ts +1 -1
- package/src/projection/lib/projection.ts +1 -1
- package/src/rhumb-path.ts +1 -1
- package/src/spatial-planar-intersects.ts +134 -0
- package/src/spatial-planar.ts +266 -0
- package/src/spatial-sql.ts +276 -0
- package/src/st-functions.ts +852 -0
- package/src/subdivide-globe-mesh.ts +1 -1
- package/src/tasks/index.ts +34 -0
- package/src/tasks/terrain-coverage-worker.ts +6 -0
- package/src/tasks/terrain-coverage.ts +25 -0
- package/src/tasks/terrain-residency-worker.ts +6 -0
- package/src/tasks/terrain-residency.ts +250 -0
- package/src/terrain/breakline-mesh.ts +164 -0
- package/src/terrain/breakline-preprocess.ts +106 -0
- package/src/terrain/cdt2d.d.ts +10 -0
- package/src/terrain/continuous-mesh-error.ts +321 -0
- 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/geographic-lod-seams.ts +109 -0
- package/src/terrain/geographic-neighbor.ts +58 -0
- package/src/terrain/geographic-poles.ts +52 -0
- package/src/terrain/geographic-seam.ts +73 -0
- package/src/terrain/hydrology.ts +149 -0
- package/src/terrain/index.ts +160 -0
- package/src/terrain/lod-screen-error.ts +128 -0
- package/src/terrain/lod-select.ts +129 -0
- package/src/terrain/lod-stitch.ts +88 -0
- package/src/terrain/mesh-coverage.ts +215 -0
- package/src/terrain/mesh-cutout.ts +420 -0
- package/src/terrain/mesh-regions-data.ts +21 -13
- package/src/terrain/mesh-skirts.ts +10 -7
- package/src/terrain/mixed-halo-update.ts +147 -25
- package/src/terrain/mixed-vertex-halos.ts +125 -55
- package/src/terrain/regional-viewshed.ts +177 -0
- package/src/terrain/surface.ts +1 -1
- package/src/terrain/sweep-capsule.ts +148 -0
- package/src/terrain/sweep-cylinder.ts +64 -0
- package/src/terrain/sweep-plane.ts +61 -0
- package/src/terrain/sweep-polytope.ts +253 -0
- package/src/terrain/sweep-rotating-capsule.ts +139 -0
- package/src/terrain/sweep-rotation.ts +149 -0
- package/src/terrain/sweep-sphere.ts +100 -0
- package/src/terrain/tile-cutout-update.ts +293 -0
- package/src/terrain/tile-cutout.ts +123 -0
- package/src/terrain/valid-domain-mesh.ts +221 -0
- package/src/terrain/valid-domain-regions.ts +41 -0
- package/src/terrain/watershed-accumulation.ts +67 -0
- package/src/triaxial.ts +1 -1
- package/src/turf-expressions.ts +7 -0
- package/src/{turf/expressions.ts → turf-functions.ts} +121 -6
- package/src/turf.ts +3 -7
- package/src/type-utils.ts +2 -2
- 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
- package/dist/turf/expressions.cjs +0 -87
- package/dist/turf/expressions.cjs.map +0 -6
- package/dist/turf/expressions.d.ts +0 -24
- package/dist/turf/expressions.d.ts.map +0 -1
- package/dist/turf/expressions.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {HeightField} from './height-field';
|
|
6
|
+
|
|
7
|
+
/** Uniform horizontal finite-volume metrics for an affine cell-centered grid. */
|
|
8
|
+
export type TerrainCellMetrics = {
|
|
9
|
+
/** Horizontal area of one cell, in square meters. */
|
|
10
|
+
area: number;
|
|
11
|
+
/** Face lengths ordered by negative column, positive column, negative row, positive row. */
|
|
12
|
+
faceLengths: readonly [number, number, number, number];
|
|
13
|
+
/** Outward horizontal unit normals in the same order as the face lengths. */
|
|
14
|
+
faceNormals: readonly [
|
|
15
|
+
readonly [number, number],
|
|
16
|
+
readonly [number, number],
|
|
17
|
+
readonly [number, number],
|
|
18
|
+
readonly [number, number]
|
|
19
|
+
];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Derive projected cell area and face geometry, including shear and reflected grids. */
|
|
23
|
+
export function getTerrainCellMetrics(
|
|
24
|
+
field: Pick<HeightField, 'registration' | 'columnStep' | 'rowStep'>
|
|
25
|
+
): TerrainCellMetrics {
|
|
26
|
+
if (field.registration !== 'cell')
|
|
27
|
+
throw new Error('Terrain cell metrics require cell registration');
|
|
28
|
+
const [cx, cy] = field.columnStep;
|
|
29
|
+
const [rx, ry] = field.rowStep;
|
|
30
|
+
const determinant = cx * ry - cy * rx;
|
|
31
|
+
const columnLength = Math.hypot(cx, cy);
|
|
32
|
+
const rowLength = Math.hypot(rx, ry);
|
|
33
|
+
const area = Math.abs(determinant);
|
|
34
|
+
if (!(area > 0 && Number.isFinite(area) && Number.isFinite(columnLength + rowLength)))
|
|
35
|
+
throw new RangeError('Invalid terrain cell geometry');
|
|
36
|
+
const sign = Math.sign(determinant);
|
|
37
|
+
const east = [(sign * ry) / rowLength, (-sign * rx) / rowLength] as const;
|
|
38
|
+
const south = [(-sign * cy) / columnLength, (sign * cx) / columnLength] as const;
|
|
39
|
+
return {
|
|
40
|
+
area,
|
|
41
|
+
faceLengths: [rowLength, rowLength, columnLength, columnLength],
|
|
42
|
+
faceNormals: [[-east[0], -east[1]], east, [-south[0], -south[1]], south]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Drainage options for the unconditioned cell grid. */
|
|
47
|
+
export type TerrainDrainageOptions = {
|
|
48
|
+
/** Valid row-major cell indices where flow terminates, even if lower neighbors exist. */
|
|
49
|
+
outlets?: readonly number[];
|
|
50
|
+
/** Maximum grid cells before allocating drainage buffers. Defaults to 4,194,304. */
|
|
51
|
+
maxCells?: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** Row-major routing, catchments and accumulation for a single affine cell grid. */
|
|
55
|
+
export type TerrainDrainage = {
|
|
56
|
+
/** Receiver index, or -1 for nodata and terminal cells. */
|
|
57
|
+
receiver: Int32Array;
|
|
58
|
+
/** Terminal cell index for the catchment, or -1 for nodata. */
|
|
59
|
+
terminal: Int32Array;
|
|
60
|
+
/** Upstream cell count including the cell itself. Zero denotes nodata. */
|
|
61
|
+
contributingCells: Uint32Array;
|
|
62
|
+
/** Multiply by contributingCells to get contributing area in square meters. */
|
|
63
|
+
cellArea: number;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Route each valid cell to its steepest strictly lower neighbor in projected XY.
|
|
67
|
+
* Equal slopes select the lower row-major index. Diagonal flow requires both
|
|
68
|
+
* intervening side cells to be valid. The exterior and nodata block flow.
|
|
69
|
+
* Flats, pits and declared outlets terminate flow. Accumulation is O(cells).
|
|
70
|
+
*/
|
|
71
|
+
export function createTerrainDrainage(
|
|
72
|
+
field: HeightField,
|
|
73
|
+
{outlets = [], maxCells = 4_194_304}: TerrainDrainageOptions = {}
|
|
74
|
+
): TerrainDrainage {
|
|
75
|
+
const {width, height, columnStep, rowStep} = field;
|
|
76
|
+
const count = width * height;
|
|
77
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 0x7fffffff)
|
|
78
|
+
throw new RangeError('Terrain drainage exceeds its cell budget');
|
|
79
|
+
const {area: cellArea} = getTerrainCellMetrics(field);
|
|
80
|
+
for (const i of outlets) {
|
|
81
|
+
if (
|
|
82
|
+
!Number.isInteger(i) ||
|
|
83
|
+
i < 0 ||
|
|
84
|
+
i >= count ||
|
|
85
|
+
field.getHeight(i % width, Math.floor(i / width)) === undefined
|
|
86
|
+
)
|
|
87
|
+
throw new RangeError('Terrain outlet must identify a valid cell');
|
|
88
|
+
}
|
|
89
|
+
const {heights, validity} = field.copyData();
|
|
90
|
+
const receiver = new Int32Array(count).fill(-1);
|
|
91
|
+
const terminal = new Int32Array(count).fill(-1);
|
|
92
|
+
const contributingCells = new Uint32Array(count);
|
|
93
|
+
const incoming = new Uint8Array(count);
|
|
94
|
+
const queue = new Int32Array(count);
|
|
95
|
+
const outletSet = new Set(outlets);
|
|
96
|
+
const offsets = [];
|
|
97
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
98
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
99
|
+
if (!dx && !dy) continue;
|
|
100
|
+
const distance = Math.hypot(
|
|
101
|
+
dx * columnStep[0] + dy * rowStep[0],
|
|
102
|
+
dx * columnStep[1] + dy * rowStep[1]
|
|
103
|
+
);
|
|
104
|
+
if (!(distance > 0 && Number.isFinite(distance)))
|
|
105
|
+
throw new RangeError('Invalid terrain neighbor distance');
|
|
106
|
+
offsets.push({dx, dy, distance});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (let i = 0; i < count; i++) {
|
|
110
|
+
if (!validity[i]) continue;
|
|
111
|
+
contributingCells[i] = 1;
|
|
112
|
+
if (outletSet.has(i)) continue;
|
|
113
|
+
const col = i % width;
|
|
114
|
+
const row = Math.floor(i / width);
|
|
115
|
+
let steepest = 0;
|
|
116
|
+
for (const {dx, dy, distance} of offsets) {
|
|
117
|
+
if (col + dx < 0 || col + dx >= width || row + dy < 0 || row + dy >= height) continue;
|
|
118
|
+
const j = i + dx + dy * width;
|
|
119
|
+
if (!validity[j] || heights[j] >= heights[i]) continue;
|
|
120
|
+
if (dx && dy && (!validity[i + dx] || !validity[i + dy * width])) continue;
|
|
121
|
+
const slope = (heights[i] - heights[j]) / distance;
|
|
122
|
+
if (!Number.isFinite(slope) || slope === 0)
|
|
123
|
+
throw new RangeError('Terrain drainage slope is outside the representable range');
|
|
124
|
+
// Offsets visit neighbors in ascending row-major order.
|
|
125
|
+
if (slope > steepest) {
|
|
126
|
+
steepest = slope;
|
|
127
|
+
receiver[i] = j;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (receiver[i] >= 0) incoming[receiver[i]]++;
|
|
131
|
+
}
|
|
132
|
+
let end = 0;
|
|
133
|
+
for (let i = 0; i < count; i++) if (validity[i] && !incoming[i]) queue[end++] = i;
|
|
134
|
+
// Strict descent makes the graph acyclic. Topological order permits one
|
|
135
|
+
// accumulation pass and one backward catchment pass without sorting heights.
|
|
136
|
+
for (let cursor = 0; cursor < end; cursor++) {
|
|
137
|
+
const i = queue[cursor];
|
|
138
|
+
const next = receiver[i];
|
|
139
|
+
if (next < 0) continue;
|
|
140
|
+
contributingCells[next] += contributingCells[i];
|
|
141
|
+
if (--incoming[next] === 0) queue[end++] = next;
|
|
142
|
+
}
|
|
143
|
+
for (let cursor = end - 1; cursor >= 0; cursor--) {
|
|
144
|
+
const i = queue[cursor];
|
|
145
|
+
const next = receiver[i];
|
|
146
|
+
terminal[i] = next < 0 ? i : terminal[next];
|
|
147
|
+
}
|
|
148
|
+
return {receiver, terminal, contributingCells, cellArea};
|
|
149
|
+
}
|
package/src/terrain/index.ts
CHANGED
|
@@ -166,3 +166,163 @@ export {coordinateTerrainLodMorphs} from './lod-coordinate';
|
|
|
166
166
|
export {createTerrainMixedIsobands} from './isobands-mixed';
|
|
167
167
|
export type {TerrainLodTile} from './lod-coordinate';
|
|
168
168
|
export type {TerrainMixedSurface, TerrainMixedSurfaceOptions} from './mixed-surface';
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
createValidDomainTerrainMesh,
|
|
172
|
+
type ValidDomainTerrainMesh,
|
|
173
|
+
type ValidDomainMeshOptions
|
|
174
|
+
} from './valid-domain-mesh';
|
|
175
|
+
|
|
176
|
+
export {
|
|
177
|
+
createBreaklineTerrainMesh,
|
|
178
|
+
type TerrainBreaklinePoint,
|
|
179
|
+
type TerrainBreakline,
|
|
180
|
+
type BreaklineTerrainMesh,
|
|
181
|
+
type BreaklineMeshOptions
|
|
182
|
+
} from './breakline-mesh';
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
boundTerrainMeshError,
|
|
186
|
+
type TerrainContinuousMesh,
|
|
187
|
+
type TerrainContinuousError
|
|
188
|
+
} from './continuous-mesh-error';
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
wrapTerrainLongitude,
|
|
192
|
+
measureGeographicTerrainSeam,
|
|
193
|
+
type TerrainGeographicProbe
|
|
194
|
+
} from './geographic-seam';
|
|
195
|
+
export {
|
|
196
|
+
selectTerrainLod,
|
|
197
|
+
type TerrainLodCandidate,
|
|
198
|
+
type TerrainLodCertifiedView,
|
|
199
|
+
type TerrainLodView
|
|
200
|
+
} from './lod-select';
|
|
201
|
+
export {stitchTerrainLodCut, type TerrainLodSeam} from './lod-stitch';
|
|
202
|
+
|
|
203
|
+
export {splitTerrainBreaklines} from './breakline-preprocess';
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
updateTerrainValidDomainMeshRegions,
|
|
207
|
+
type TerrainValidDomainMeshRegions,
|
|
208
|
+
type TerrainValidDomainRegionOptions
|
|
209
|
+
} from './valid-domain-regions';
|
|
210
|
+
|
|
211
|
+
export {certifyTerrainMeshCoverage} from './mesh-coverage';
|
|
212
|
+
export type {TerrainCoverageMesh, TerrainMeshCoverage} from './mesh-coverage';
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
getGeographicTerrainNeighbor,
|
|
216
|
+
type TerrainGeographicEdge,
|
|
217
|
+
type TerrainGeographicNeighbor
|
|
218
|
+
} from './geographic-neighbor';
|
|
219
|
+
|
|
220
|
+
export {
|
|
221
|
+
sweepTerrainSphere,
|
|
222
|
+
type TerrainSphereSweepOptions,
|
|
223
|
+
type TerrainSphereSweepResult
|
|
224
|
+
} from './sweep-sphere';
|
|
225
|
+
|
|
226
|
+
export {
|
|
227
|
+
sweepTerrainCapsule,
|
|
228
|
+
sweepTerrainTaperedCapsule,
|
|
229
|
+
type TerrainCapsuleSweepResult
|
|
230
|
+
} from './sweep-capsule';
|
|
231
|
+
|
|
232
|
+
export {
|
|
233
|
+
sweepTerrainBox,
|
|
234
|
+
sweepTerrainPolytope,
|
|
235
|
+
sweepTerrainTriangleMesh,
|
|
236
|
+
type TerrainPolytope,
|
|
237
|
+
type TerrainPolytopeSweepResult
|
|
238
|
+
} from './sweep-polytope';
|
|
239
|
+
|
|
240
|
+
export {sweepTerrainRotatingCapsule, sweepTerrainRotatingSphere} from './sweep-rotating-capsule';
|
|
241
|
+
export {sweepTerrainCylinder} from './sweep-cylinder';
|
|
242
|
+
|
|
243
|
+
export {sweepTerrainPlane} from './sweep-plane';
|
|
244
|
+
export {discoverGeographicTerrainLodSeams} from './geographic-lod-seams';
|
|
245
|
+
|
|
246
|
+
export {
|
|
247
|
+
discoverGeographicTerrainPoles,
|
|
248
|
+
type TerrainPoleIncidence,
|
|
249
|
+
type TerrainPoleCoverage
|
|
250
|
+
} from './geographic-poles';
|
|
251
|
+
|
|
252
|
+
export {
|
|
253
|
+
sweepTerrainRotatingBox,
|
|
254
|
+
sweepTerrainRotatingPolytope,
|
|
255
|
+
type TerrainRigidMotion,
|
|
256
|
+
type TerrainRotationalSweepResult
|
|
257
|
+
} from './sweep-rotation';
|
|
258
|
+
|
|
259
|
+
export {
|
|
260
|
+
boundTerrainLodScreenError,
|
|
261
|
+
type TerrainLodErrorBounds,
|
|
262
|
+
type TerrainLodProjection
|
|
263
|
+
} from './lod-screen-error';
|
|
264
|
+
|
|
265
|
+
export {
|
|
266
|
+
createTerrainRegionalViewshed,
|
|
267
|
+
TerrainRegionalViewStatus,
|
|
268
|
+
type TerrainRegionalViewshed,
|
|
269
|
+
type TerrainRegionalViewshedOptions,
|
|
270
|
+
type TerrainViewshedGrid
|
|
271
|
+
} from './regional-viewshed';
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
createTerrainDrainage,
|
|
275
|
+
getTerrainCellMetrics,
|
|
276
|
+
type TerrainCellMetrics,
|
|
277
|
+
type TerrainDrainage,
|
|
278
|
+
type TerrainDrainageOptions
|
|
279
|
+
} from './hydrology';
|
|
280
|
+
|
|
281
|
+
export {
|
|
282
|
+
fillTerrainDepressions,
|
|
283
|
+
type TerrainDepressionFill,
|
|
284
|
+
type TerrainDepressionFillOptions
|
|
285
|
+
} from './depression-fill';
|
|
286
|
+
|
|
287
|
+
export {
|
|
288
|
+
splitTerrainMesh,
|
|
289
|
+
type TerrainCutout,
|
|
290
|
+
type TerrainCutoutInput,
|
|
291
|
+
type TerrainCutoutOptions,
|
|
292
|
+
type TerrainCutoutPiece
|
|
293
|
+
} from './mesh-cutout';
|
|
294
|
+
export {
|
|
295
|
+
createTerrainCutoutSkirts,
|
|
296
|
+
type SkirtedTerrainCutout,
|
|
297
|
+
type TerrainCutoutSkirtOptions
|
|
298
|
+
} from './cutout-skirts';
|
|
299
|
+
|
|
300
|
+
export {
|
|
301
|
+
accumulateTerrainWatersheds,
|
|
302
|
+
type TerrainWatershedAccumulation,
|
|
303
|
+
type TerrainWatershedAccumulationOptions
|
|
304
|
+
} from './watershed-accumulation';
|
|
305
|
+
|
|
306
|
+
export {splitTerrainMeshTiles, type TerrainCutoutTile, type TerrainTileCutout} from './tile-cutout';
|
|
307
|
+
|
|
308
|
+
export {
|
|
309
|
+
updateTerrainTileCutouts,
|
|
310
|
+
type TerrainCutoutResident,
|
|
311
|
+
type TerrainTileCutoutUpdateOptions,
|
|
312
|
+
type TerrainTileCutoutCache,
|
|
313
|
+
type TerrainTileCutoutUpdate
|
|
314
|
+
} from './tile-cutout-update';
|
|
315
|
+
export {
|
|
316
|
+
createGeographicTerrainCutoutFrame,
|
|
317
|
+
projectGeographicTerrainCutout,
|
|
318
|
+
unprojectGeographicTerrainCutout,
|
|
319
|
+
type GeographicTerrainCutoutFrame,
|
|
320
|
+
type GeographicTerrainCutoutFrameOptions
|
|
321
|
+
} from './geographic-cutout';
|
|
322
|
+
|
|
323
|
+
export {prepareTerrainCutoutPolygons, type TerrainCutoutPolygonOptions} from './cutout-polygons';
|
|
324
|
+
export type {
|
|
325
|
+
TerrainCutoutPolygon,
|
|
326
|
+
TerrainCutoutPolygonSet,
|
|
327
|
+
TerrainCutoutRegion
|
|
328
|
+
} from './cutout-region';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ProjectionDepthOptions} from '@math.gl/core/matrix';
|
|
6
|
+
|
|
7
|
+
/** Cartesian bounds and a Euclidean bound on displacement from any point in those bounds. */
|
|
8
|
+
export type TerrainLodErrorBounds = {
|
|
9
|
+
/** Lower corner in the input frame of the clip transform. */
|
|
10
|
+
min: readonly [number, number, number];
|
|
11
|
+
/** Upper corner in the input frame of the clip transform. */
|
|
12
|
+
max: readonly [number, number, number];
|
|
13
|
+
/** Maximum Euclidean displacement in input units. */
|
|
14
|
+
geometricError: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Projection parameters for a pixel-error certificate. */
|
|
18
|
+
export type TerrainLodProjection = ProjectionDepthOptions & {
|
|
19
|
+
/** Column-major Cartesian-to-clip matrix. Use a common local frame for matrix and bounds. */
|
|
20
|
+
matrix: ArrayLike<number>;
|
|
21
|
+
/** Viewport width in pixels. */
|
|
22
|
+
width: number;
|
|
23
|
+
/** Viewport height in pixels. */
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Pad outward enough to enclose each binary64 operation, including subnormal results. */
|
|
28
|
+
function slack(value: number): number {
|
|
29
|
+
return Math.abs(value) * (2 * Number.EPSILON) + Number.MIN_VALUE;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Lower enclosure of a rounded operation. */
|
|
33
|
+
function down(value: number): number {
|
|
34
|
+
return value - slack(value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Upper enclosure of a rounded operation. */
|
|
38
|
+
function up(value: number): number {
|
|
39
|
+
return value + slack(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Bound 2D Euclidean pixel displacement under homogeneous projection.
|
|
43
|
+
* Returns Infinity when potentially visible geometry reaches the near plane or W=0,
|
|
44
|
+
* or when arithmetic cannot establish a finite bound. Fully near-clipped pairs
|
|
45
|
+
* and exact zero displacement contribute zero. Side and far clipping are ignored.
|
|
46
|
+
*/
|
|
47
|
+
export function boundTerrainLodScreenError(
|
|
48
|
+
bounds: TerrainLodErrorBounds,
|
|
49
|
+
projection: TerrainLodProjection
|
|
50
|
+
): number {
|
|
51
|
+
if (
|
|
52
|
+
bounds.min.length !== 3 ||
|
|
53
|
+
bounds.max.length !== 3 ||
|
|
54
|
+
!bounds.min.every((value, i) => Number.isFinite(value) && value <= bounds.max[i]) ||
|
|
55
|
+
!bounds.max.every(Number.isFinite) ||
|
|
56
|
+
!Number.isFinite(bounds.geometricError) ||
|
|
57
|
+
bounds.geometricError < 0
|
|
58
|
+
)
|
|
59
|
+
throw new RangeError('Invalid terrain LOD screen-error bounds');
|
|
60
|
+
return prepareTerrainLodScreenError(projection)(bounds);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @internal Validate and snapshot the camera once per resident cut selection. */
|
|
64
|
+
export function prepareTerrainLodScreenError(projection: TerrainLodProjection) {
|
|
65
|
+
const {width, height, depthRange = 'negative-one-to-one', reversedDepth = false} = projection;
|
|
66
|
+
if (projection.matrix.length !== 16) throw new RangeError('Invalid terrain LOD clip matrix');
|
|
67
|
+
const matrix = Array.from(projection.matrix);
|
|
68
|
+
if (
|
|
69
|
+
!matrix.every(Number.isFinite) ||
|
|
70
|
+
!Number.isFinite(width) ||
|
|
71
|
+
width <= 0 ||
|
|
72
|
+
!Number.isFinite(height) ||
|
|
73
|
+
height <= 0 ||
|
|
74
|
+
(depthRange !== 'negative-one-to-one' && depthRange !== 'zero-to-one')
|
|
75
|
+
)
|
|
76
|
+
throw new RangeError('Invalid terrain LOD projection');
|
|
77
|
+
return ({min, max, geometricError: error}: TerrainLodErrorBounds) => {
|
|
78
|
+
if (error === 0) return 0;
|
|
79
|
+
|
|
80
|
+
/** Enclose each clip row over the AABB and bound the row change for a displacement. */
|
|
81
|
+
function row(index: number) {
|
|
82
|
+
let lower = matrix[12 + index];
|
|
83
|
+
let upper = lower;
|
|
84
|
+
let change = 0;
|
|
85
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
86
|
+
const coefficient = matrix[4 * axis + index];
|
|
87
|
+
const a = coefficient * min[axis];
|
|
88
|
+
const b = coefficient * max[axis];
|
|
89
|
+
lower = down(lower + down(Math.min(a, b)));
|
|
90
|
+
upper = up(upper + up(Math.max(a, b)));
|
|
91
|
+
change = up(change + up(Math.abs(coefficient) * error));
|
|
92
|
+
}
|
|
93
|
+
return {lower, upper, change};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const w = row(3);
|
|
97
|
+
const z = row(2);
|
|
98
|
+
// Near clipping uses W-Z for reversed depth, Z for zero-to-one, and Z+W otherwise.
|
|
99
|
+
const nearLow = reversedDepth
|
|
100
|
+
? down(w.lower - z.upper)
|
|
101
|
+
: depthRange === 'zero-to-one'
|
|
102
|
+
? z.lower
|
|
103
|
+
: down(z.lower + w.lower);
|
|
104
|
+
const nearHigh = reversedDepth
|
|
105
|
+
? up(w.upper - z.lower)
|
|
106
|
+
: depthRange === 'zero-to-one'
|
|
107
|
+
? z.upper
|
|
108
|
+
: up(z.upper + w.upper);
|
|
109
|
+
const nearChange =
|
|
110
|
+
!reversedDepth && depthRange === 'zero-to-one' ? z.change : up(z.change + w.change);
|
|
111
|
+
if (up(nearHigh + nearChange) < 0) return 0;
|
|
112
|
+
const denominator = down(w.lower - w.change);
|
|
113
|
+
if (!(down(nearLow - nearChange) > 0 && denominator > 0)) return Infinity;
|
|
114
|
+
|
|
115
|
+
/** Bound (dX - (X/W)dW) / (W+dW), in pixels. */
|
|
116
|
+
function pixelAxis(index: number, extent: number) {
|
|
117
|
+
const coordinate = row(index);
|
|
118
|
+
const magnitude = Math.max(Math.abs(coordinate.lower), Math.abs(coordinate.upper));
|
|
119
|
+
const ndc = up(magnitude / denominator);
|
|
120
|
+
const coupling = up(ndc * w.change);
|
|
121
|
+
const numerator = up(coordinate.change + coupling);
|
|
122
|
+
return up(up(numerator / denominator) * up(extent / 2));
|
|
123
|
+
}
|
|
124
|
+
// The L1 norm bounds the Euclidean norm without assuming the axis maxima coincide.
|
|
125
|
+
const pixels = pixelAxis(0, width) + pixelAxis(1, height);
|
|
126
|
+
return Number.isFinite(pixels) ? up(pixels) : Infinity;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
prepareTerrainLodScreenError,
|
|
7
|
+
type TerrainLodErrorBounds,
|
|
8
|
+
type TerrainLodProjection
|
|
9
|
+
} from './lod-screen-error';
|
|
10
|
+
|
|
11
|
+
/** Cartesian coordinate triple. */
|
|
12
|
+
type XYZ = readonly [number, number, number];
|
|
13
|
+
|
|
14
|
+
/** A tile and its error bound in the selector's Cartesian frame. */
|
|
15
|
+
export type TerrainLodCandidate = TerrainLodErrorBounds & {
|
|
16
|
+
/** Unique tile identifier within the tree. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Whether this tile is available to render. */
|
|
19
|
+
resident: boolean;
|
|
20
|
+
/** Children must completely partition the parent terrain footprint. */
|
|
21
|
+
children?: readonly TerrainLodCandidate[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Controls shared by both LOD selection modes. */
|
|
25
|
+
type TerrainLodSelectionOptions = {
|
|
26
|
+
/** Maximum desired pixel error. */
|
|
27
|
+
targetPixels: number;
|
|
28
|
+
/** Fractional threshold reduction for previously refined tiles. */
|
|
29
|
+
hysteresis?: number;
|
|
30
|
+
/** Tile IDs that refined in the previous selection. */
|
|
31
|
+
previouslyRefined?: ReadonlySet<string>;
|
|
32
|
+
/** Maximum number of candidates visited during selection. */
|
|
33
|
+
maxVisited?: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Camera parameters for the distance-based pixel estimate. */
|
|
37
|
+
export type TerrainLodView = TerrainLodSelectionOptions & {
|
|
38
|
+
/** Camera position in the same frame as tile bounds. */
|
|
39
|
+
position: XYZ;
|
|
40
|
+
/** Vertical field of view in radians. */
|
|
41
|
+
verticalFov: number;
|
|
42
|
+
/** Viewport height in pixels. */
|
|
43
|
+
viewportHeight: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** View using a conservative projection bound for LOD selection. */
|
|
47
|
+
export type TerrainLodCertifiedView = TerrainLodSelectionOptions & {
|
|
48
|
+
/** Cartesian-to-clip transform and viewport. */
|
|
49
|
+
projection: TerrainLodProjection;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Select a resident cut using perspective screen-space error and complete child fallback. */
|
|
53
|
+
export function selectTerrainLod(
|
|
54
|
+
roots: readonly TerrainLodCandidate[],
|
|
55
|
+
view: TerrainLodView | TerrainLodCertifiedView
|
|
56
|
+
) {
|
|
57
|
+
const {targetPixels, hysteresis = 0.2, previouslyRefined, maxVisited = 100_000} = view;
|
|
58
|
+
if (
|
|
59
|
+
!Number.isFinite(targetPixels) ||
|
|
60
|
+
targetPixels <= 0 ||
|
|
61
|
+
!(hysteresis >= 0 && hysteresis < 1) ||
|
|
62
|
+
!Number.isSafeInteger(maxVisited) ||
|
|
63
|
+
maxVisited < 1
|
|
64
|
+
)
|
|
65
|
+
throw new Error('Invalid terrain LOD view');
|
|
66
|
+
const pixelError =
|
|
67
|
+
'projection' in view
|
|
68
|
+
? prepareTerrainLodScreenError(view.projection)
|
|
69
|
+
: createDistanceEstimator(view.position, view.verticalFov, view.viewportHeight);
|
|
70
|
+
const selected: {tile: TerrainLodCandidate; pixels: number}[] = [];
|
|
71
|
+
const refined = new Set<string>();
|
|
72
|
+
const unavailable: string[] = [];
|
|
73
|
+
const seen = new Set<string>();
|
|
74
|
+
const pending = [...roots].reverse();
|
|
75
|
+
while (pending.length) {
|
|
76
|
+
const tile = pending.pop()!;
|
|
77
|
+
if (seen.size >= maxVisited) throw new Error('Terrain LOD visit limit exceeded');
|
|
78
|
+
if (seen.has(tile.id)) throw new Error('Duplicate terrain LOD tile or cycle');
|
|
79
|
+
seen.add(tile.id);
|
|
80
|
+
if (
|
|
81
|
+
tile.min.length !== 3 ||
|
|
82
|
+
tile.max.length !== 3 ||
|
|
83
|
+
![...tile.min, ...tile.max, tile.geometricError].every(Number.isFinite) ||
|
|
84
|
+
tile.geometricError < 0 ||
|
|
85
|
+
tile.min.some((n, i) => n > tile.max[i])
|
|
86
|
+
)
|
|
87
|
+
throw new Error('Invalid terrain LOD tile bounds or error');
|
|
88
|
+
if (!tile.resident) {
|
|
89
|
+
unavailable.push(tile.id);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const pixels = pixelError(tile);
|
|
93
|
+
const threshold = targetPixels * (previouslyRefined?.has(tile.id) ? 1 - hysteresis : 1);
|
|
94
|
+
if (
|
|
95
|
+
pixels > threshold &&
|
|
96
|
+
tile.children?.length &&
|
|
97
|
+
tile.children.every(child => child.resident)
|
|
98
|
+
) {
|
|
99
|
+
if (pending.length + seen.size + tile.children.length > maxVisited)
|
|
100
|
+
throw new Error('Terrain LOD visit limit exceeded');
|
|
101
|
+
refined.add(tile.id);
|
|
102
|
+
for (let i = tile.children.length - 1; i >= 0; i--) pending.push(tile.children[i]);
|
|
103
|
+
} else {
|
|
104
|
+
selected.push({tile, pixels});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {selected, refined, unavailable};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Prepare the legacy distance-based pixel estimate. */
|
|
111
|
+
function createDistanceEstimator(position: XYZ, verticalFov: number, viewportHeight: number) {
|
|
112
|
+
if (
|
|
113
|
+
!position.every(Number.isFinite) ||
|
|
114
|
+
!Number.isFinite(verticalFov) ||
|
|
115
|
+
verticalFov <= 0 ||
|
|
116
|
+
verticalFov >= Math.PI ||
|
|
117
|
+
!Number.isFinite(viewportHeight) ||
|
|
118
|
+
viewportHeight <= 0
|
|
119
|
+
)
|
|
120
|
+
throw new Error('Invalid terrain LOD view');
|
|
121
|
+
const scale = viewportHeight / (2 * Math.tan(verticalFov / 2));
|
|
122
|
+
if (!Number.isFinite(scale)) throw new Error('Terrain LOD projection scale overflow');
|
|
123
|
+
return (tile: TerrainLodCandidate) => {
|
|
124
|
+
const distance = Math.hypot(
|
|
125
|
+
...position.map((n, i) => Math.max(tile.min[i] - n, n - tile.max[i], 0))
|
|
126
|
+
);
|
|
127
|
+
return tile.geometricError === 0 ? 0 : (tile.geometricError / distance) * scale;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {TerrainMeshEdge} from './mesh-data';
|
|
6
|
+
import {
|
|
7
|
+
stitchTerrainMeshEdges,
|
|
8
|
+
type TerrainSeamMesh,
|
|
9
|
+
type TerrainMeshStitchOptions
|
|
10
|
+
} from './mesh-stitch';
|
|
11
|
+
|
|
12
|
+
export type TerrainLodSeam = {
|
|
13
|
+
/** The first tile owns the seam heights. Process coarse owners first. */
|
|
14
|
+
a: number;
|
|
15
|
+
edgeA: TerrainMeshEdge;
|
|
16
|
+
b: number;
|
|
17
|
+
edgeB: TerrainMeshEdge;
|
|
18
|
+
options?: TerrainMeshStitchOptions;
|
|
19
|
+
/** Translate B along X for this seam, then restore its original longitude branch. */
|
|
20
|
+
offsetBX?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Stitch a selected cut by splitting only incident boundary faces. */
|
|
24
|
+
export function stitchTerrainLodCut(
|
|
25
|
+
input: readonly TerrainSeamMesh[],
|
|
26
|
+
seams: readonly TerrainLodSeam[]
|
|
27
|
+
): TerrainSeamMesh[] {
|
|
28
|
+
const meshes = input.slice();
|
|
29
|
+
const paired: {a: number; b: number; idsA: Uint32Array; idsB: Uint32Array; offsetBX: number}[] =
|
|
30
|
+
[];
|
|
31
|
+
for (const {a, edgeA, b, edgeB, options, offsetBX = 0} of seams) {
|
|
32
|
+
if (a === b || !Number.isInteger(a) || !Number.isInteger(b) || !meshes[a] || !meshes[b])
|
|
33
|
+
throw new Error('Invalid terrain LOD seam tile index');
|
|
34
|
+
if (!Number.isFinite(offsetBX)) throw new Error('Invalid terrain LOD seam offset');
|
|
35
|
+
const meshB = meshes[b];
|
|
36
|
+
const shiftedB: TerrainSeamMesh =
|
|
37
|
+
offsetBX === 0
|
|
38
|
+
? meshB
|
|
39
|
+
: {
|
|
40
|
+
...meshB,
|
|
41
|
+
origin: [meshB.origin[0] + offsetBX, meshB.origin[1], meshB.origin[2]]
|
|
42
|
+
};
|
|
43
|
+
const result = stitchTerrainMeshEdges(meshes[a], edgeA, shiftedB, edgeB, options);
|
|
44
|
+
meshes[a] = result.a;
|
|
45
|
+
meshes[b] =
|
|
46
|
+
offsetBX === 0
|
|
47
|
+
? result.b
|
|
48
|
+
: {
|
|
49
|
+
...result.b,
|
|
50
|
+
origin: [result.b.origin[0] - offsetBX, result.b.origin[1], result.b.origin[2]]
|
|
51
|
+
};
|
|
52
|
+
paired.push({a, b, idsA: result.seamA, idsB: result.seamB, offsetBX});
|
|
53
|
+
}
|
|
54
|
+
// Later operations may move shared corners or subdivide an earlier seam.
|
|
55
|
+
// Recheck complete segment chains against the final meshes.
|
|
56
|
+
for (const {a, b, idsA, idsB, offsetBX} of paired) {
|
|
57
|
+
const ma = meshes[a],
|
|
58
|
+
mb = meshes[b];
|
|
59
|
+
const path = (mesh: TerrainSeamMesh, ids: Uint32Array) => {
|
|
60
|
+
const links = new Set<string>();
|
|
61
|
+
for (let i = 1; i < ids.length; i++) {
|
|
62
|
+
links.add(`${Math.min(ids[i - 1], ids[i])},${Math.max(ids[i - 1], ids[i])}`);
|
|
63
|
+
}
|
|
64
|
+
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
65
|
+
for (let j = 0; j < 3; j++) {
|
|
66
|
+
const p = mesh.indices[i + j],
|
|
67
|
+
q = mesh.indices[i + ((j + 1) % 3)];
|
|
68
|
+
links.delete(`${Math.min(p, q)},${Math.max(p, q)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return links.size === 0;
|
|
72
|
+
};
|
|
73
|
+
if (!path(ma, idsA) || !path(mb, idsB))
|
|
74
|
+
throw new Error('Overlapping terrain LOD seam ranges require a common subdivision');
|
|
75
|
+
for (let i = 0; i < idsA.length; i++) {
|
|
76
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
77
|
+
const offset = mb.origin[axis] + (axis === 0 ? offsetBX : 0) - ma.origin[axis];
|
|
78
|
+
const av = ma.positions[3 * idsA[i] + axis],
|
|
79
|
+
bv = mb.positions[3 * idsB[i] + axis];
|
|
80
|
+
const residual = av - bv - offset;
|
|
81
|
+
const roundoff = 8 * Number.EPSILON * (Math.abs(av) + Math.abs(bv) + Math.abs(offset));
|
|
82
|
+
if (!Number.isFinite(residual) || Math.abs(residual) > roundoff)
|
|
83
|
+
throw new Error('Incompatible terrain LOD seam heights or shared corners');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return meshes;
|
|
88
|
+
}
|