@math.gl/geospatial 5.0.0-beta.9 → 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 +2514 -558
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +164 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +106 -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 +216 -98
- package/dist/tasks/index.cjs.map +2 -2
- package/dist/tasks/terrain-residency.d.ts +9 -0
- package/dist/tasks/terrain-residency.d.ts.map +1 -1
- package/dist/tasks/terrain-residency.js +98 -19
- 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/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/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 +2135 -161
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +23 -1
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +21 -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/lod-stitch.d.ts +2 -0
- package/dist/terrain/lod-stitch.d.ts.map +1 -1
- package/dist/terrain/lod-stitch.js +21 -6
- package/dist/terrain/lod-stitch.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/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/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 +34 -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 +271 -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/terrain-residency.ts +120 -24
- 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/hydrology.ts +149 -0
- package/src/terrain/index.ts +122 -1
- package/src/terrain/lod-screen-error.ts +128 -0
- package/src/terrain/lod-select.ts +65 -31
- package/src/terrain/lod-stitch.ts +25 -7
- 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/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/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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Original adapter over math.gl subdivision and spheroid kernels. Motivation only: https://github.com/keplergl/kepler.gl/pull/3548 (closed, unmerged). No implementation copied.
|
|
5
5
|
|
|
6
|
-
import {spheroidToCartesian} from '@math.gl/core';
|
|
6
|
+
import {spheroidToCartesian} from '@math.gl/core/matrix';
|
|
7
7
|
import {
|
|
8
8
|
subdivideTriangleMesh,
|
|
9
9
|
type TriangleMesh,
|
|
@@ -5,8 +5,15 @@
|
|
|
5
5
|
import type {Task} from '@math.gl/tasks';
|
|
6
6
|
import type {TerrainMixedHaloSnapshot} from '../terrain/mixed-halo-update';
|
|
7
7
|
import type {TerrainMixedVertexTile} from '../terrain/mixed-vertex-halos';
|
|
8
|
+
import type {HeightFieldProps, TerrainArray} from '../terrain/types';
|
|
8
9
|
|
|
9
10
|
type TileAddress = Pick<TerrainMixedVertexTile, 'column' | 'row' | 'spacing'>;
|
|
11
|
+
type TerrainResidencyTimings = {
|
|
12
|
+
applyEditsMs: number;
|
|
13
|
+
updateHalosMs: number;
|
|
14
|
+
prepareDeltaMs: number;
|
|
15
|
+
processMs: number;
|
|
16
|
+
};
|
|
10
17
|
type ResidentHalo = TerrainMixedHaloSnapshot['tiles'][number];
|
|
11
18
|
export type TerrainResidencyEdit =
|
|
12
19
|
| {type: 'upsert'; tile: TerrainMixedVertexTile}
|
|
@@ -25,10 +32,21 @@ export type TerrainResidencyTypes = {
|
|
|
25
32
|
snapshot: TerrainMixedHaloSnapshot | null;
|
|
26
33
|
revision: number;
|
|
27
34
|
};
|
|
28
|
-
input:
|
|
29
|
-
|
|
35
|
+
input:
|
|
36
|
+
| {revision: number; edits: readonly TerrainResidencyEdit[]; measureStages?: boolean}
|
|
37
|
+
| {type: 'snapshot'};
|
|
38
|
+
output: {
|
|
39
|
+
revision: number;
|
|
40
|
+
tiles: ResidentHalo[];
|
|
41
|
+
removed: string[];
|
|
42
|
+
error?: string;
|
|
43
|
+
timings?: TerrainResidencyTimings;
|
|
44
|
+
};
|
|
30
45
|
};
|
|
31
46
|
|
|
47
|
+
/** Address lookup retained with an immutable source layout, not rebuilt per sample batch. */
|
|
48
|
+
const sourceIndexes = new WeakMap<TerrainMixedHaloSnapshot, Map<string, number>>();
|
|
49
|
+
|
|
32
50
|
const addressKey = ({spacing, column, row}: TileAddress) => `${spacing}/${column}/${row}`;
|
|
33
51
|
|
|
34
52
|
function sameArray(a: ArrayLike<number>, b: ArrayLike<number>): boolean {
|
|
@@ -54,6 +72,50 @@ function sameHalo(a: ResidentHalo, b: ResidentHalo): boolean {
|
|
|
54
72
|
);
|
|
55
73
|
}
|
|
56
74
|
|
|
75
|
+
/** Copy already validated resident samples once, preserving precision and nodata normalization. */
|
|
76
|
+
function copyResidentSamples(field: HeightFieldProps): {
|
|
77
|
+
heights: TerrainArray;
|
|
78
|
+
validity: Uint8Array;
|
|
79
|
+
} {
|
|
80
|
+
const {width, height, offset = 0, stride = width} = field;
|
|
81
|
+
const heights =
|
|
82
|
+
field.heights instanceof Float64Array
|
|
83
|
+
? new Float64Array(width * height)
|
|
84
|
+
: new Float32Array(width * height);
|
|
85
|
+
const validity = new Uint8Array(heights.length);
|
|
86
|
+
for (let y = 0; y < height; y++) {
|
|
87
|
+
for (let x = 0; x < width; x++) {
|
|
88
|
+
const input = offset + y * stride + x;
|
|
89
|
+
const output = y * width + x;
|
|
90
|
+
const value = field.heights[input];
|
|
91
|
+
if (Number.isFinite(value) && (!field.validity || field.validity[input] !== 0)) {
|
|
92
|
+
heights[output] = value;
|
|
93
|
+
validity[output] = 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {heights, validity};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Compare halo addresses in the order used by the incremental builder. */
|
|
101
|
+
function compareAddress(a: TileAddress, b: TileAddress): number {
|
|
102
|
+
return a.spacing - b.spacing || a.column - b.column || a.row - b.row;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Compute changed outputs with a linear merge over sorted snapshots. */
|
|
106
|
+
function changedHalos(previous: readonly ResidentHalo[], next: readonly ResidentHalo[]) {
|
|
107
|
+
const changed: ResidentHalo[] = [];
|
|
108
|
+
let index = 0;
|
|
109
|
+
for (let i = 0; i < next.length; i++) {
|
|
110
|
+
const tile = next[i];
|
|
111
|
+
while (index < previous.length && compareAddress(previous[index], tile) < 0) index++;
|
|
112
|
+
const prior = previous[index];
|
|
113
|
+
if (!prior || (prior !== tile && (compareAddress(prior, tile) !== 0 || !sameHalo(prior, tile))))
|
|
114
|
+
changed.push(tile);
|
|
115
|
+
}
|
|
116
|
+
return changed;
|
|
117
|
+
}
|
|
118
|
+
|
|
57
119
|
/** Keep mixed halo sources and outputs resident across serialized edit batches. */
|
|
58
120
|
export const TerrainResidencyTask = {
|
|
59
121
|
id: 'terrain-residency',
|
|
@@ -70,40 +132,63 @@ export const TerrainResidencyTask = {
|
|
|
70
132
|
removed: []
|
|
71
133
|
};
|
|
72
134
|
}
|
|
135
|
+
const start = input.measureStages ? performance.now() : 0;
|
|
73
136
|
try {
|
|
74
137
|
if (input.revision !== state.revision) throw new Error('Stale terrain residency revision');
|
|
75
138
|
|
|
76
|
-
const
|
|
77
|
-
import('../terrain/mixed-halo-update'),
|
|
78
|
-
import('../terrain/height-field')
|
|
79
|
-
]);
|
|
139
|
+
const {updateTerrainMixedVertexTileHalos} = await import('../terrain/mixed-halo-update');
|
|
80
140
|
context.throwIfAborted();
|
|
81
|
-
const
|
|
141
|
+
const priorSources = state.snapshot?.sources ?? [];
|
|
142
|
+
let sourceIndex = state.snapshot && sourceIndexes.get(state.snapshot);
|
|
143
|
+
if (!sourceIndex) {
|
|
144
|
+
sourceIndex = new Map();
|
|
145
|
+
for (let i = 0; i < priorSources.length; i++)
|
|
146
|
+
sourceIndex.set(addressKey(priorSources[i]), i);
|
|
147
|
+
}
|
|
148
|
+
// Sample-only transactions copy one reference array. Structural edits lazily
|
|
149
|
+
// create a map; neither path mutates the committed snapshot on rejection.
|
|
150
|
+
const resident = priorSources.slice();
|
|
151
|
+
let structural: Map<string, TerrainMixedVertexTile> | undefined;
|
|
152
|
+
const getSource = (key: string) =>
|
|
153
|
+
structural ? structural.get(key) : resident[sourceIndex.get(key)!];
|
|
154
|
+
const setSource = (key: string, tile: TerrainMixedVertexTile) => {
|
|
155
|
+
if (structural) structural.set(key, tile);
|
|
156
|
+
else resident[sourceIndex.get(key)!] = tile;
|
|
157
|
+
};
|
|
158
|
+
const editLayout = () => {
|
|
159
|
+
if (!structural) {
|
|
160
|
+
structural = new Map();
|
|
161
|
+
for (const tile of resident) structural.set(addressKey(tile), tile);
|
|
162
|
+
}
|
|
163
|
+
return structural;
|
|
164
|
+
};
|
|
82
165
|
// Several edits to a tile in one batch share one private copy.
|
|
83
|
-
const writable = new Map<string, ReturnType<
|
|
166
|
+
const writable = new Map<string, ReturnType<typeof copyResidentSamples>>();
|
|
84
167
|
for (const edit of input.edits) {
|
|
85
168
|
if (edit.type === 'upsert') {
|
|
86
169
|
const key = addressKey(edit.tile);
|
|
87
|
-
|
|
170
|
+
editLayout().set(key, structuredClone(edit.tile));
|
|
88
171
|
writable.delete(key);
|
|
89
172
|
continue;
|
|
90
173
|
}
|
|
91
174
|
const key = addressKey(edit.address);
|
|
92
175
|
if (edit.type === 'remove') {
|
|
93
|
-
|
|
176
|
+
editLayout().delete(key);
|
|
94
177
|
writable.delete(key);
|
|
95
178
|
continue;
|
|
96
179
|
}
|
|
97
180
|
if (edit.type !== 'samples') throw new Error('Unknown terrain residency edit');
|
|
98
|
-
const source =
|
|
181
|
+
const source = getSource(key);
|
|
99
182
|
if (!source) throw new Error('Terrain sample edit requires a resident tile');
|
|
100
183
|
if (!edit.samples.length) continue;
|
|
101
184
|
let data = writable.get(key);
|
|
102
185
|
if (!data) {
|
|
103
|
-
|
|
104
|
-
data =
|
|
186
|
+
// Upserts in this transaction have not passed halo validation yet.
|
|
187
|
+
data = structural
|
|
188
|
+
? new (await import('../terrain/height-field')).HeightField(source.field).copyData()
|
|
189
|
+
: copyResidentSamples(source.field);
|
|
105
190
|
writable.set(key, data);
|
|
106
|
-
|
|
191
|
+
setSource(key, {
|
|
107
192
|
...source,
|
|
108
193
|
field: {...source.field, ...data, offset: 0, stride: source.field.width}
|
|
109
194
|
});
|
|
@@ -123,23 +208,34 @@ export const TerrainResidencyTask = {
|
|
|
123
208
|
data.validity[index] = height === null ? 0 : 1;
|
|
124
209
|
}
|
|
125
210
|
}
|
|
211
|
+
const applied = input.measureStages ? performance.now() : 0;
|
|
126
212
|
const next = updateTerrainMixedVertexTileHalos(
|
|
127
213
|
state.snapshot,
|
|
128
|
-
[...
|
|
214
|
+
structural ? [...structural.values()] : resident,
|
|
129
215
|
state.limits
|
|
130
216
|
);
|
|
131
|
-
const
|
|
132
|
-
//
|
|
133
|
-
const tiles = structuredClone(
|
|
134
|
-
next.tiles.filter(tile => {
|
|
135
|
-
const prior = old.get(addressKey(tile));
|
|
136
|
-
return !prior || !sameHalo(prior, tile);
|
|
137
|
-
})
|
|
138
|
-
);
|
|
217
|
+
const updated = input.measureStages ? performance.now() : 0;
|
|
218
|
+
// Both snapshots are in address order. Unchanged halos retain object identity.
|
|
219
|
+
const tiles = structuredClone(changedHalos(state.snapshot?.tiles ?? [], next.tiles));
|
|
139
220
|
context.throwIfAborted();
|
|
221
|
+
if (!structural) sourceIndexes.set(next, sourceIndex);
|
|
140
222
|
state.snapshot = next;
|
|
141
223
|
state.revision++;
|
|
142
|
-
|
|
224
|
+
const result: TerrainResidencyTypes['output'] = {
|
|
225
|
+
revision: state.revision,
|
|
226
|
+
tiles,
|
|
227
|
+
removed: next.removed
|
|
228
|
+
};
|
|
229
|
+
if (input.measureStages) {
|
|
230
|
+
const finish = performance.now();
|
|
231
|
+
result.timings = {
|
|
232
|
+
applyEditsMs: applied - start,
|
|
233
|
+
updateHalosMs: updated - applied,
|
|
234
|
+
prepareDeltaMs: finish - updated,
|
|
235
|
+
processMs: finish - start
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
143
239
|
} catch (error) {
|
|
144
240
|
context.throwIfAborted();
|
|
145
241
|
// A rejected transaction preserves the initialized handle on both task transports.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
createTerrainCutoutPlan,
|
|
7
|
+
type CutoutPoint,
|
|
8
|
+
type TerrainCutoutPolygon,
|
|
9
|
+
type TerrainCutoutPolygonSet
|
|
10
|
+
} from './cutout-region';
|
|
11
|
+
|
|
12
|
+
/** Limits for validating and preparing a reusable polygon arrangement. */
|
|
13
|
+
export type TerrainCutoutPolygonOptions = {
|
|
14
|
+
/** Maximum total ring edges. Default 2048. */
|
|
15
|
+
maxEdges?: number;
|
|
16
|
+
/** Maximum validation, containment and line-comparison operations. Default 4000000. */
|
|
17
|
+
maxWork?: number;
|
|
18
|
+
};
|
|
19
|
+
/** Prepare concave polygons, holes and disjoint regions for all terrain cut APIs.
|
|
20
|
+
* Copies inputs. Ring winding is unrestricted. Rings must be simple and finite,
|
|
21
|
+
* with no repeated closing point. Holes are strictly contained and disjoint;
|
|
22
|
+
* separate polygon domains must not overlap or touch. Islands inside another
|
|
23
|
+
* polygon's hole are allowed. Polygon IDs are zero-based input array indices.
|
|
24
|
+
*
|
|
25
|
+
* The immutable descriptor contains CPU functions: reuse it for cache hits,
|
|
26
|
+
* and prepare a new descriptor inside each worker instead of transferring it.
|
|
27
|
+
* Supporting-line arrangements can grow quadratically; split-time budgets
|
|
28
|
+
* remain necessary in addition to these preparation limits.
|
|
29
|
+
*/
|
|
30
|
+
export function prepareTerrainCutoutPolygons(
|
|
31
|
+
polygons: readonly TerrainCutoutPolygon[],
|
|
32
|
+
{maxEdges = 2048, maxWork = 4000000}: TerrainCutoutPolygonOptions = {}
|
|
33
|
+
): TerrainCutoutPolygonSet {
|
|
34
|
+
if (![maxEdges, maxWork].every(n => Number.isSafeInteger(n) && n >= 0) || !polygons.length)
|
|
35
|
+
throw new RangeError('Invalid terrain cutout polygon limits or empty set');
|
|
36
|
+
let work = 0,
|
|
37
|
+
edgeCount = 0;
|
|
38
|
+
/** Bound preprocessing before expensive pair comparisons. */
|
|
39
|
+
const charge = (amount: number) => {
|
|
40
|
+
work += amount;
|
|
41
|
+
if (work > maxWork) throw new RangeError('Terrain cutout polygon work budget exceeded');
|
|
42
|
+
};
|
|
43
|
+
if (polygons.length > Math.floor(maxEdges / 3))
|
|
44
|
+
throw new RangeError('Terrain cutout polygon edge budget exceeded');
|
|
45
|
+
const regions = polygons.map(p => {
|
|
46
|
+
if (1 + (p.holes?.length ?? 0) > Math.floor((maxEdges - edgeCount) / 3))
|
|
47
|
+
throw new RangeError('Terrain cutout polygon edge budget exceeded');
|
|
48
|
+
return [p.outer, ...(p.holes ?? [])].map(ring => {
|
|
49
|
+
edgeCount += ring.length;
|
|
50
|
+
if (edgeCount > maxEdges) throw new RangeError('Terrain cutout polygon edge budget exceeded');
|
|
51
|
+
charge(ring.length);
|
|
52
|
+
if (ring.length < 3 || ring.some(p => p.length !== 2 || !p.every(Number.isFinite)))
|
|
53
|
+
throw new RangeError('Invalid terrain cutout polygon ring');
|
|
54
|
+
return ring.map(p => Object.freeze([p[0], p[1]] as const));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
const rings = regions.flat();
|
|
58
|
+
for (const ring of rings) {
|
|
59
|
+
let area = 0;
|
|
60
|
+
for (let i = 0; i < ring.length; i++) {
|
|
61
|
+
charge(1);
|
|
62
|
+
const a = ring[i],
|
|
63
|
+
b = ring[(i + 1) % ring.length],
|
|
64
|
+
c = ring[(i + 2) % ring.length];
|
|
65
|
+
if (equal(a, b)) throw new RangeError('Duplicate terrain cutout ring vertex');
|
|
66
|
+
area += orient(ring[0], a, b);
|
|
67
|
+
if (
|
|
68
|
+
orient(a, b, c) === 0 &&
|
|
69
|
+
(a[0] - b[0]) * (c[0] - b[0]) + (a[1] - b[1]) * (c[1] - b[1]) >= 0
|
|
70
|
+
)
|
|
71
|
+
throw new RangeError('Backtracking terrain cutout ring edge');
|
|
72
|
+
for (let j = i + 1; j < ring.length; j++) {
|
|
73
|
+
if (j === i + 1 || (i === 0 && j === ring.length - 1)) continue;
|
|
74
|
+
charge(1);
|
|
75
|
+
if (intersects(a, b, ring[j], ring[(j + 1) % ring.length]))
|
|
76
|
+
throw new RangeError('Self-intersecting terrain cutout ring');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!Number.isFinite(area) || area === 0)
|
|
80
|
+
throw new RangeError('Degenerate terrain cutout ring');
|
|
81
|
+
}
|
|
82
|
+
for (let i = 0; i < rings.length; i++)
|
|
83
|
+
for (let j = i + 1; j < rings.length; j++) {
|
|
84
|
+
const a = rings[i],
|
|
85
|
+
b = rings[j];
|
|
86
|
+
for (let x = 0; x < a.length; x++)
|
|
87
|
+
for (let y = 0; y < b.length; y++) {
|
|
88
|
+
charge(1);
|
|
89
|
+
if (intersects(a[x], a[(x + 1) % a.length], b[y], b[(y + 1) % b.length]))
|
|
90
|
+
throw new RangeError('Terrain cutout rings must not touch or intersect');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const region of regions)
|
|
94
|
+
for (let i = 1; i < region.length; i++) {
|
|
95
|
+
if (contains(region[0], region[i][0], charge) !== 1)
|
|
96
|
+
throw new RangeError('Terrain cutout hole must be strictly inside its outer ring');
|
|
97
|
+
for (let j = 1; j < i; j++)
|
|
98
|
+
if (
|
|
99
|
+
contains(region[j], region[i][0], charge) === 1 ||
|
|
100
|
+
contains(region[i], region[j][0], charge) === 1
|
|
101
|
+
)
|
|
102
|
+
throw new RangeError('Nested terrain cutout holes are not supported');
|
|
103
|
+
}
|
|
104
|
+
/** Test the interior of a polygon, excluding every hole. */
|
|
105
|
+
function inRegion(
|
|
106
|
+
region: readonly (readonly CutoutPoint[])[],
|
|
107
|
+
point: CutoutPoint,
|
|
108
|
+
budget: (n: number) => void
|
|
109
|
+
) {
|
|
110
|
+
const outer = contains(region[0], point, budget);
|
|
111
|
+
if (outer !== 1) return outer;
|
|
112
|
+
for (let i = 1; i < region.length; i++) {
|
|
113
|
+
const hole = contains(region[i], point, budget);
|
|
114
|
+
if (hole === 0) return 0;
|
|
115
|
+
if (hole === 1) return -1;
|
|
116
|
+
}
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
for (let i = 0; i < regions.length; i++)
|
|
120
|
+
for (let j = i + 1; j < regions.length; j++) {
|
|
121
|
+
if (
|
|
122
|
+
inRegion(regions[i], regions[j][0][0], charge) === 1 ||
|
|
123
|
+
inRegion(regions[j], regions[i][0][0], charge) === 1
|
|
124
|
+
)
|
|
125
|
+
throw new RangeError('Overlapping terrain cutout polygon domains');
|
|
126
|
+
}
|
|
127
|
+
const lines: (readonly [CutoutPoint, CutoutPoint])[] = [];
|
|
128
|
+
for (const ring of rings)
|
|
129
|
+
for (let i = 0; i < ring.length; i++) {
|
|
130
|
+
const a = ring[i],
|
|
131
|
+
b = ring[(i + 1) % ring.length];
|
|
132
|
+
// Avoid splitting twice by the same supporting line (including collinear vertices).
|
|
133
|
+
if (
|
|
134
|
+
lines.some(([u, v]) => {
|
|
135
|
+
charge(1);
|
|
136
|
+
return orient(u, v, a) === 0 && orient(u, v, b) === 0;
|
|
137
|
+
})
|
|
138
|
+
)
|
|
139
|
+
continue;
|
|
140
|
+
lines.push(a[0] < b[0] || (a[0] === b[0] && a[1] < b[1]) ? [a, b] : [b, a]);
|
|
141
|
+
}
|
|
142
|
+
return createTerrainCutoutPlan({
|
|
143
|
+
lines: Object.freeze(lines.map(line => Object.freeze(line))),
|
|
144
|
+
classify(point, budget) {
|
|
145
|
+
for (let i = 0; i < regions.length; i++) {
|
|
146
|
+
const result = inRegion(regions[i], point, budget);
|
|
147
|
+
if (result === 0) throw new RangeError('Unrepresentable terrain cutout fragment interior');
|
|
148
|
+
if (result === 1) return i;
|
|
149
|
+
}
|
|
150
|
+
return -1;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Exact coordinate equality for duplicate endpoints. */
|
|
156
|
+
function equal(a: CutoutPoint, b: CutoutPoint) {
|
|
157
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
158
|
+
}
|
|
159
|
+
/** Signed twice-area with explicit overflow rejection. */
|
|
160
|
+
function orient(a: CutoutPoint, b: CutoutPoint, c: CutoutPoint) {
|
|
161
|
+
const value = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
162
|
+
if (!Number.isFinite(value)) throw new RangeError('Terrain cutout polygon coordinate overflow');
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
/** Inclusive segment membership after collinearity has been established. */
|
|
166
|
+
function onSegment(a: CutoutPoint, b: CutoutPoint, p: CutoutPoint) {
|
|
167
|
+
return (
|
|
168
|
+
p[0] >= Math.min(a[0], b[0]) &&
|
|
169
|
+
p[0] <= Math.max(a[0], b[0]) &&
|
|
170
|
+
p[1] >= Math.min(a[1], b[1]) &&
|
|
171
|
+
p[1] <= Math.max(a[1], b[1])
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
/** Detect crossings, overlapping edges and mere touches during ring validation. */
|
|
175
|
+
function intersects(a: CutoutPoint, b: CutoutPoint, c: CutoutPoint, d: CutoutPoint) {
|
|
176
|
+
const abC = orient(a, b, c),
|
|
177
|
+
abD = orient(a, b, d),
|
|
178
|
+
cdA = orient(c, d, a),
|
|
179
|
+
cdB = orient(c, d, b);
|
|
180
|
+
return (
|
|
181
|
+
(abC === 0 && onSegment(a, b, c)) ||
|
|
182
|
+
(abD === 0 && onSegment(a, b, d)) ||
|
|
183
|
+
(cdA === 0 && onSegment(c, d, a)) ||
|
|
184
|
+
(cdB === 0 && onSegment(c, d, b)) ||
|
|
185
|
+
(((abC > 0 && abD < 0) || (abC < 0 && abD > 0)) &&
|
|
186
|
+
((cdA > 0 && cdB < 0) || (cdA < 0 && cdB > 0)))
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
/** Winding classification: interior 1, exterior -1, boundary 0. */
|
|
190
|
+
function contains(ring: readonly CutoutPoint[], p: CutoutPoint, charge: (n: number) => void) {
|
|
191
|
+
let winding = 0;
|
|
192
|
+
for (let i = 0; i < ring.length; i++) {
|
|
193
|
+
charge(1);
|
|
194
|
+
const a = ring[i],
|
|
195
|
+
b = ring[(i + 1) % ring.length],
|
|
196
|
+
cross = orient(a, b, p);
|
|
197
|
+
if (cross === 0 && onSegment(a, b, p)) return 0;
|
|
198
|
+
if (a[1] <= p[1] && b[1] > p[1] && cross > 0) winding++;
|
|
199
|
+
if (a[1] > p[1] && b[1] <= p[1] && cross < 0) winding--;
|
|
200
|
+
}
|
|
201
|
+
return winding === 0 ? -1 : 1;
|
|
202
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** A finite local XY coordinate. */
|
|
6
|
+
export type CutoutPoint = readonly [number, number];
|
|
7
|
+
/** One simple outer ring with strictly contained, disjoint hole rings. */
|
|
8
|
+
export type TerrainCutoutPolygon = {
|
|
9
|
+
/** Either winding; omit the repeated closing point. */
|
|
10
|
+
outer: readonly CutoutPoint[];
|
|
11
|
+
/** Either winding; holes must not touch or intersect any other ring. */
|
|
12
|
+
holes?: readonly (readonly CutoutPoint[])[];
|
|
13
|
+
};
|
|
14
|
+
/** Internal prepared partition contract, shared without importing polygon algorithms. */
|
|
15
|
+
export type TerrainCutoutPlan = {
|
|
16
|
+
/** Supporting lines shared by every independently clipped tile. */
|
|
17
|
+
lines: readonly (readonly [CutoutPoint, CutoutPoint])[];
|
|
18
|
+
/** Return polygon index or -1 for the remainder; charge classification work. */
|
|
19
|
+
classify: (point: CutoutPoint, charge: (amount: number) => void) => number;
|
|
20
|
+
};
|
|
21
|
+
/** Versioned brand shared by ESM/CJS and both public entry-point bundles. */
|
|
22
|
+
const PLAN = Symbol.for('@math.gl/geospatial/terrain-cutout-polygons/v1');
|
|
23
|
+
/** Immutable prepared polygon set; create with prepareTerrainCutoutPolygons. */
|
|
24
|
+
export type TerrainCutoutPolygonSet = {readonly [PLAN]: TerrainCutoutPlan};
|
|
25
|
+
/** A strictly convex ring or an opt-in prepared concave/multi-polygon cut. */
|
|
26
|
+
export type TerrainCutoutRegion = readonly CutoutPoint[] | TerrainCutoutPolygonSet;
|
|
27
|
+
|
|
28
|
+
/** @internal Brand a validated plan without exposing its mutable preparation state. */
|
|
29
|
+
export function createTerrainCutoutPlan(plan: TerrainCutoutPlan): TerrainCutoutPolygonSet {
|
|
30
|
+
return Object.freeze({[PLAN]: Object.freeze(plan)});
|
|
31
|
+
}
|
|
32
|
+
/** @internal Read only genuine prepared inputs; arrays use the convex fast path. */
|
|
33
|
+
export function getTerrainCutoutPlan(region: TerrainCutoutRegion): TerrainCutoutPlan | undefined {
|
|
34
|
+
if (Array.isArray(region)) return undefined;
|
|
35
|
+
const plan = (region as TerrainCutoutPolygonSet | undefined)?.[PLAN];
|
|
36
|
+
if (!plan) throw new RangeError('Invalid prepared terrain cutout polygons');
|
|
37
|
+
return plan;
|
|
38
|
+
}
|
|
39
|
+
/** @internal Snapshot raw rings; immutable descriptors retain their identity. */
|
|
40
|
+
export function copyTerrainCutoutRegion(region: TerrainCutoutRegion): TerrainCutoutRegion {
|
|
41
|
+
return getTerrainCutoutPlan(region)
|
|
42
|
+
? region
|
|
43
|
+
: (region as readonly CutoutPoint[]).map(p => [p[0], p[1]] as const);
|
|
44
|
+
}
|
|
45
|
+
/** @internal Prepared shapes compare by identity; raw rings compare by value. */
|
|
46
|
+
export function sameTerrainCutoutRegion(a: TerrainCutoutRegion, b: TerrainCutoutRegion): boolean {
|
|
47
|
+
if (getTerrainCutoutPlan(a) || getTerrainCutoutPlan(b)) return a === b;
|
|
48
|
+
const aa = a as readonly CutoutPoint[],
|
|
49
|
+
bb = b as readonly CutoutPoint[];
|
|
50
|
+
return (
|
|
51
|
+
aa.length === bb.length &&
|
|
52
|
+
aa.every((p, i) => bb[i].length === 2 && p[0] === bb[i][0] && p[1] === bb[i][1])
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {TerrainCutout, TerrainCutoutPiece} from './mesh-cutout';
|
|
6
|
+
import {createTerrainSkirt, type TerrainSkirtMesh, type TerrainSkirtOptions} from './mesh-skirts';
|
|
7
|
+
|
|
8
|
+
/** Select wall height or a local base, without allowing arbitrary edge selection. */
|
|
9
|
+
type WallOptions = Pick<TerrainSkirtOptions, 'maxVertices' | 'maxTriangles'> &
|
|
10
|
+
({height: number; baseZ?: never} | {baseZ: number; height?: never});
|
|
11
|
+
|
|
12
|
+
/** Lift and wall settings for a terrain split. */
|
|
13
|
+
export type TerrainCutoutSkirtOptions = {
|
|
14
|
+
/** Amount added to the patch's local Z coordinates. Defaults to zero. */
|
|
15
|
+
lift?: number;
|
|
16
|
+
/** Wall options for the lifted patch. */
|
|
17
|
+
patch: WallOptions;
|
|
18
|
+
/** Wall options for the unchanged remainder. */
|
|
19
|
+
remainder: WallOptions;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Raised and stationary surfaces with optional visual skirts. */
|
|
23
|
+
export type SkirtedTerrainCutout = {
|
|
24
|
+
patch: {surface: TerrainCutoutPiece; skirt?: TerrainSkirtMesh};
|
|
25
|
+
remainder: {surface: TerrainCutoutPiece; skirt?: TerrainSkirtMesh};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Translate the patch and build both walls from the paired cut edges only. */
|
|
29
|
+
export function createTerrainCutoutSkirts(
|
|
30
|
+
cutout: TerrainCutout,
|
|
31
|
+
{lift = 0, patch, remainder}: TerrainCutoutSkirtOptions
|
|
32
|
+
): SkirtedTerrainCutout {
|
|
33
|
+
if (!Number.isFinite(lift)) throw new RangeError('Invalid terrain cutout lift');
|
|
34
|
+
const positions = cutout.patch.positions.slice();
|
|
35
|
+
for (let i = 2; i < positions.length; i += 3) {
|
|
36
|
+
positions[i] += lift;
|
|
37
|
+
if (!Number.isFinite(positions[i])) throw new RangeError('Terrain cutout lift overflow');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
patch: skirtPiece({...cutout.patch, positions}, patch),
|
|
41
|
+
remainder: skirtPiece(cutout.remainder, remainder)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Compose on a nonempty paired boundary only. */
|
|
46
|
+
function skirtPiece(surface: TerrainCutoutPiece, options: WallOptions) {
|
|
47
|
+
if (!surface.cutEdges.length) return {surface};
|
|
48
|
+
return {
|
|
49
|
+
surface,
|
|
50
|
+
skirt: createTerrainSkirt(surface, {...options, edges: surface.cutEdges})
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {HeightField} from './height-field';
|
|
6
|
+
|
|
7
|
+
/** Outlet and allocation policy for four-neighbor terrain conditioning. */
|
|
8
|
+
export type TerrainDepressionFillOptions = {
|
|
9
|
+
/** Valid row-major cell indices that can drain. Exterior and nodata are closed. */
|
|
10
|
+
outlets: readonly number[];
|
|
11
|
+
/** Maximum grid cells before allocating buffers. Defaults to 4,194,304. */
|
|
12
|
+
maxCells?: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Conditioned terrain and its outlet-connected drainage forest. */
|
|
16
|
+
export type TerrainDepressionFill = {
|
|
17
|
+
/** Derived field, including the original heights of outlet-disconnected cells. */
|
|
18
|
+
field: HeightField;
|
|
19
|
+
/** Next face neighbor toward an outlet, -1 at outlets, -2 for nodata or disconnected cells. */
|
|
20
|
+
receiver: Int32Array;
|
|
21
|
+
/** Number of valid cells with no face-connected path to an outlet. */
|
|
22
|
+
disconnectedCells: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Raise each outlet-connected cell to the lowest spill elevation needed to reach
|
|
27
|
+
* a declared outlet by face neighbors. The returned forest routes across flats.
|
|
28
|
+
* Nodata blocks flow and disconnected components retain their source heights.
|
|
29
|
+
* The source is immutable. Time is O(cells log cells) and storage is O(cells).
|
|
30
|
+
*/
|
|
31
|
+
export function fillTerrainDepressions(
|
|
32
|
+
field: HeightField,
|
|
33
|
+
{outlets, maxCells = 4_194_304}: TerrainDepressionFillOptions
|
|
34
|
+
): TerrainDepressionFill {
|
|
35
|
+
if (field.registration !== 'cell')
|
|
36
|
+
throw new Error('Terrain depression fill requires cell registration');
|
|
37
|
+
const {width, height} = field;
|
|
38
|
+
const count = width * height;
|
|
39
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 0x7fffffff)
|
|
40
|
+
throw new RangeError('Terrain depression fill exceeds its cell budget');
|
|
41
|
+
if (!outlets.length) throw new RangeError('Terrain depression fill requires an outlet');
|
|
42
|
+
for (const i of outlets) {
|
|
43
|
+
if (
|
|
44
|
+
!Number.isInteger(i) ||
|
|
45
|
+
i < 0 ||
|
|
46
|
+
i >= count ||
|
|
47
|
+
field.getHeight(i % width, Math.floor(i / width)) === undefined
|
|
48
|
+
)
|
|
49
|
+
throw new RangeError('Terrain outlet must identify a valid cell');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const {heights, validity} = field.copyData();
|
|
53
|
+
const receiver = new Int32Array(count).fill(-2);
|
|
54
|
+
const heap = new Int32Array(count);
|
|
55
|
+
let size = 0;
|
|
56
|
+
let disconnectedCells = field.validCount;
|
|
57
|
+
|
|
58
|
+
/** Sort by spill elevation, then by cell index for reproducible flat routing. */
|
|
59
|
+
const before = (a: number, b: number) =>
|
|
60
|
+
heights[a] < heights[b] || (heights[a] === heights[b] && a < b);
|
|
61
|
+
|
|
62
|
+
/** Insert a newly reached cell. Its finalized spill height never changes. */
|
|
63
|
+
function push(cell: number): void {
|
|
64
|
+
let slot = size++;
|
|
65
|
+
while (slot > 0) {
|
|
66
|
+
const parent = Math.floor((slot - 1) / 2);
|
|
67
|
+
if (!before(cell, heap[parent])) break;
|
|
68
|
+
heap[slot] = heap[parent];
|
|
69
|
+
slot = parent;
|
|
70
|
+
}
|
|
71
|
+
heap[slot] = cell;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Remove the cell with the lowest known spill elevation. */
|
|
75
|
+
function pop(): number {
|
|
76
|
+
const first = heap[0];
|
|
77
|
+
const tail = heap[--size];
|
|
78
|
+
let slot = 0;
|
|
79
|
+
let child = 1;
|
|
80
|
+
while (child < size) {
|
|
81
|
+
if (child + 1 < size && before(heap[child + 1], heap[child])) child++;
|
|
82
|
+
if (!before(heap[child], tail)) break;
|
|
83
|
+
heap[slot] = heap[child];
|
|
84
|
+
slot = child;
|
|
85
|
+
child = slot * 2 + 1;
|
|
86
|
+
}
|
|
87
|
+
if (size) heap[slot] = tail;
|
|
88
|
+
return first;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** First discovery from the minimum frontier finalizes the minimax path cost. */
|
|
92
|
+
function visit(cell: number, parent: number): void {
|
|
93
|
+
if (!validity[cell] || receiver[cell] !== -2) return;
|
|
94
|
+
receiver[cell] = parent;
|
|
95
|
+
disconnectedCells--;
|
|
96
|
+
if (parent >= 0) heights[cell] = Math.max(heights[cell], heights[parent]);
|
|
97
|
+
push(cell);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (const outlet of outlets) visit(outlet, -1);
|
|
101
|
+
while (size) {
|
|
102
|
+
const cell = pop();
|
|
103
|
+
const column = cell % width;
|
|
104
|
+
if (column > 0) visit(cell - 1, cell);
|
|
105
|
+
if (column + 1 < width) visit(cell + 1, cell);
|
|
106
|
+
if (cell >= width) visit(cell - width, cell);
|
|
107
|
+
if (cell < count - width) visit(cell + width, cell);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
field: new HeightField({
|
|
111
|
+
width,
|
|
112
|
+
height,
|
|
113
|
+
heights,
|
|
114
|
+
validity,
|
|
115
|
+
origin: field.origin,
|
|
116
|
+
columnStep: field.columnStep,
|
|
117
|
+
rowStep: field.rowStep,
|
|
118
|
+
registration: field.registration,
|
|
119
|
+
diagonal: field.diagonal,
|
|
120
|
+
heightReference: field.heightReference
|
|
121
|
+
}),
|
|
122
|
+
receiver,
|
|
123
|
+
disconnectedCells
|
|
124
|
+
};
|
|
125
|
+
}
|