@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
|
@@ -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,
|
package/src/tasks/index.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
import type {TaskWorker} from '@math.gl/tasks';
|
|
5
|
+
import {TerrainResidencyTask as residencyTask} from './terrain-residency';
|
|
6
|
+
import {CertifyTerrainCoverageTask as coverageTask} from './terrain-coverage';
|
|
5
7
|
import {ProjectCoordinatesTask as projectionTask, PrepareMapTask as mapTask} from './definitions';
|
|
6
8
|
export type {ProjectCoordinatesTypes, PrepareMapTypes} from './definitions';
|
|
7
9
|
declare const __filename: string;
|
|
@@ -37,3 +39,35 @@ export const PrepareMapTask: typeof mapTask & {worker: TaskWorker} = {
|
|
|
37
39
|
capabilities: {atomic: true, streaming: false}
|
|
38
40
|
}
|
|
39
41
|
};
|
|
42
|
+
|
|
43
|
+
export type {CertifyTerrainCoverageTypes} from './terrain-coverage';
|
|
44
|
+
|
|
45
|
+
/** Certify horizontal terrain coverage in an atomic task. */
|
|
46
|
+
export const CertifyTerrainCoverageTask: typeof coverageTask & {worker: TaskWorker} = {
|
|
47
|
+
...coverageTask,
|
|
48
|
+
worker: {
|
|
49
|
+
...(!isBrowser
|
|
50
|
+
? {url: /* @__PURE__ */ (() => new URL('./terrain-coverage-worker.js', moduleUrl).href)()}
|
|
51
|
+
: {
|
|
52
|
+
create: () =>
|
|
53
|
+
new Worker(new URL('./terrain-coverage-worker.js', import.meta.url), {type: 'module'})
|
|
54
|
+
}),
|
|
55
|
+
capabilities: {atomic: true, streaming: false}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type {TerrainResidencyEdit, TerrainResidencyTypes} from './terrain-residency';
|
|
60
|
+
|
|
61
|
+
/** Apply revisioned edit batches to one resident mixed halo snapshot per initialized worker. */
|
|
62
|
+
export const TerrainResidencyTask: typeof residencyTask & {worker: TaskWorker} = {
|
|
63
|
+
...residencyTask,
|
|
64
|
+
worker: {
|
|
65
|
+
...(!isBrowser
|
|
66
|
+
? {url: /* @__PURE__ */ (() => new URL('./terrain-residency-worker.js', moduleUrl).href)()}
|
|
67
|
+
: {
|
|
68
|
+
create: () =>
|
|
69
|
+
new Worker(new URL('./terrain-residency-worker.js', import.meta.url), {type: 'module'})
|
|
70
|
+
}),
|
|
71
|
+
capabilities: {atomic: true, streaming: false}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {initializeTaskWorker} from '@math.gl/tasks';
|
|
5
|
+
import {CertifyTerrainCoverageTask} from './terrain-coverage';
|
|
6
|
+
void initializeTaskWorker(CertifyTerrainCoverageTask);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Task} from '@math.gl/tasks';
|
|
6
|
+
import type {HeightFieldProps} from '../terrain/types';
|
|
7
|
+
import type {TerrainCoverageMesh, TerrainMeshCoverage} from '../terrain/mesh-coverage';
|
|
8
|
+
|
|
9
|
+
export type CertifyTerrainCoverageTypes = {
|
|
10
|
+
input: {field: HeightFieldProps; mesh: TerrainCoverageMesh};
|
|
11
|
+
output: TerrainMeshCoverage;
|
|
12
|
+
options: {reference?: 'triangle' | 'bilinear' | TerrainCoverageMesh; maxTriangles?: number};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Certify coverage from serializable field and triangle buffers. */
|
|
16
|
+
export const CertifyTerrainCoverageTask = {
|
|
17
|
+
id: 'certify-terrain-coverage',
|
|
18
|
+
async process({field, mesh}, options) {
|
|
19
|
+
const [{HeightField}, {certifyTerrainMeshCoverage}] = await Promise.all([
|
|
20
|
+
import('../terrain/height-field'),
|
|
21
|
+
import('../terrain/mesh-coverage')
|
|
22
|
+
]);
|
|
23
|
+
return certifyTerrainMeshCoverage(new HeightField(field), mesh, options);
|
|
24
|
+
}
|
|
25
|
+
} satisfies Task<CertifyTerrainCoverageTypes>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {initializeTaskWorker} from '@math.gl/tasks';
|
|
5
|
+
import {TerrainResidencyTask} from './terrain-residency';
|
|
6
|
+
void initializeTaskWorker(TerrainResidencyTask);
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Task} from '@math.gl/tasks';
|
|
6
|
+
import type {TerrainMixedHaloSnapshot} from '../terrain/mixed-halo-update';
|
|
7
|
+
import type {TerrainMixedVertexTile} from '../terrain/mixed-vertex-halos';
|
|
8
|
+
import type {HeightFieldProps, TerrainArray} from '../terrain/types';
|
|
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
|
+
};
|
|
17
|
+
type ResidentHalo = TerrainMixedHaloSnapshot['tiles'][number];
|
|
18
|
+
export type TerrainResidencyEdit =
|
|
19
|
+
| {type: 'upsert'; tile: TerrainMixedVertexTile}
|
|
20
|
+
| {type: 'remove'; address: TileAddress}
|
|
21
|
+
| {
|
|
22
|
+
type: 'samples';
|
|
23
|
+
address: TileAddress;
|
|
24
|
+
/** Row-major sample indices. Null marks nodata. */
|
|
25
|
+
samples: readonly {index: number; height: number | null}[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type TerrainResidencyTypes = {
|
|
29
|
+
initialization: {maxSamples?: number; maxTileTests?: number; maxDependencyTests?: number};
|
|
30
|
+
state: {
|
|
31
|
+
limits: TerrainResidencyTypes['initialization'];
|
|
32
|
+
snapshot: TerrainMixedHaloSnapshot | null;
|
|
33
|
+
revision: number;
|
|
34
|
+
};
|
|
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
|
+
};
|
|
45
|
+
};
|
|
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
|
+
|
|
50
|
+
const addressKey = ({spacing, column, row}: TileAddress) => `${spacing}/${column}/${row}`;
|
|
51
|
+
|
|
52
|
+
function sameArray(a: ArrayLike<number>, b: ArrayLike<number>): boolean {
|
|
53
|
+
if (a.length !== b.length) return false;
|
|
54
|
+
for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function sameHalo(a: ResidentHalo, b: ResidentHalo): boolean {
|
|
59
|
+
if (a === b) return true;
|
|
60
|
+
const af = a.field;
|
|
61
|
+
const bf = b.field;
|
|
62
|
+
const keys = Object.keys(af) as (keyof typeof af)[];
|
|
63
|
+
return (
|
|
64
|
+
keys.length === Object.keys(bf).length &&
|
|
65
|
+
keys.every(key => {
|
|
66
|
+
const left = af[key];
|
|
67
|
+
const right = bf[key];
|
|
68
|
+
if (typeof left === 'object' && typeof right === 'object') return sameArray(left, right);
|
|
69
|
+
return Object.prototype.hasOwnProperty.call(bf, key) && Object.is(left, right);
|
|
70
|
+
}) &&
|
|
71
|
+
sameArray(a.statuses, b.statuses)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
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
|
+
|
|
119
|
+
/** Keep mixed halo sources and outputs resident across serialized edit batches. */
|
|
120
|
+
export const TerrainResidencyTask = {
|
|
121
|
+
id: 'terrain-residency',
|
|
122
|
+
initialize(limits): TerrainResidencyTypes['state'] {
|
|
123
|
+
return {limits: {...limits}, snapshot: null, revision: 0};
|
|
124
|
+
},
|
|
125
|
+
async process(input, _options, context): Promise<TerrainResidencyTypes['output']> {
|
|
126
|
+
const state = context.state;
|
|
127
|
+
if ('type' in input) {
|
|
128
|
+
if (input.type !== 'snapshot') throw new Error('Unknown terrain residency request');
|
|
129
|
+
return {
|
|
130
|
+
revision: state.revision,
|
|
131
|
+
tiles: structuredClone(state.snapshot?.tiles ?? []),
|
|
132
|
+
removed: []
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const start = input.measureStages ? performance.now() : 0;
|
|
136
|
+
try {
|
|
137
|
+
if (input.revision !== state.revision) throw new Error('Stale terrain residency revision');
|
|
138
|
+
|
|
139
|
+
const {updateTerrainMixedVertexTileHalos} = await import('../terrain/mixed-halo-update');
|
|
140
|
+
context.throwIfAborted();
|
|
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
|
+
};
|
|
165
|
+
// Several edits to a tile in one batch share one private copy.
|
|
166
|
+
const writable = new Map<string, ReturnType<typeof copyResidentSamples>>();
|
|
167
|
+
for (const edit of input.edits) {
|
|
168
|
+
if (edit.type === 'upsert') {
|
|
169
|
+
const key = addressKey(edit.tile);
|
|
170
|
+
editLayout().set(key, structuredClone(edit.tile));
|
|
171
|
+
writable.delete(key);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const key = addressKey(edit.address);
|
|
175
|
+
if (edit.type === 'remove') {
|
|
176
|
+
editLayout().delete(key);
|
|
177
|
+
writable.delete(key);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (edit.type !== 'samples') throw new Error('Unknown terrain residency edit');
|
|
181
|
+
const source = getSource(key);
|
|
182
|
+
if (!source) throw new Error('Terrain sample edit requires a resident tile');
|
|
183
|
+
if (!edit.samples.length) continue;
|
|
184
|
+
let data = writable.get(key);
|
|
185
|
+
if (!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);
|
|
190
|
+
writable.set(key, data);
|
|
191
|
+
setSource(key, {
|
|
192
|
+
...source,
|
|
193
|
+
field: {...source.field, ...data, offset: 0, stride: source.field.width}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
for (const {index, height} of edit.samples) {
|
|
197
|
+
if (
|
|
198
|
+
!Number.isSafeInteger(index) ||
|
|
199
|
+
index < 0 ||
|
|
200
|
+
index >= data.heights.length ||
|
|
201
|
+
(height !== null && !Number.isFinite(height))
|
|
202
|
+
) {
|
|
203
|
+
throw new Error('Invalid terrain sample edit');
|
|
204
|
+
}
|
|
205
|
+
data.heights[index] = height ?? 0;
|
|
206
|
+
if (!Number.isFinite(data.heights[index]))
|
|
207
|
+
throw new Error('Terrain sample edit overflow');
|
|
208
|
+
data.validity[index] = height === null ? 0 : 1;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const applied = input.measureStages ? performance.now() : 0;
|
|
212
|
+
const next = updateTerrainMixedVertexTileHalos(
|
|
213
|
+
state.snapshot,
|
|
214
|
+
structural ? [...structural.values()] : resident,
|
|
215
|
+
state.limits
|
|
216
|
+
);
|
|
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));
|
|
220
|
+
context.throwIfAborted();
|
|
221
|
+
if (!structural) sourceIndexes.set(next, sourceIndex);
|
|
222
|
+
state.snapshot = next;
|
|
223
|
+
state.revision++;
|
|
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;
|
|
239
|
+
} catch (error) {
|
|
240
|
+
context.throwIfAborted();
|
|
241
|
+
// A rejected transaction preserves the initialized handle on both task transports.
|
|
242
|
+
return {
|
|
243
|
+
revision: state.revision,
|
|
244
|
+
tiles: [],
|
|
245
|
+
removed: [],
|
|
246
|
+
error: error instanceof Error ? error.message : String(error)
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
} satisfies Task<TerrainResidencyTypes>;
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
import {
|
|
7
|
+
meshValidDomain,
|
|
8
|
+
type Edge,
|
|
9
|
+
type ValidDomainMeshOptions,
|
|
10
|
+
type ValidDomainTerrainMesh
|
|
11
|
+
} from './valid-domain-mesh';
|
|
12
|
+
|
|
13
|
+
/** X and Y are fractional sample indices. Z is in the field's vertical reference. */
|
|
14
|
+
export type TerrainBreaklinePoint = readonly [number, number, number];
|
|
15
|
+
export type TerrainBreakline = readonly [TerrainBreaklinePoint, TerrainBreaklinePoint];
|
|
16
|
+
|
|
17
|
+
export type BreaklineMeshOptions = ValidDomainMeshOptions & {
|
|
18
|
+
breaklines: readonly TerrainBreakline[];
|
|
19
|
+
/** Let a line override source samples that lie exactly on it. Defaults to false. */
|
|
20
|
+
breaklinesOverrideSamples?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type BreaklineTerrainMesh = ValidDomainTerrainMesh & {
|
|
24
|
+
/** Packed vertex pairs, one pair per input segment in input order. */
|
|
25
|
+
breaklineEdges: Uint32Array;
|
|
26
|
+
overriddenSamples: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type XY = readonly [number, number];
|
|
30
|
+
const cross = (a: XY, b: XY, c: XY) =>
|
|
31
|
+
(b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
32
|
+
const onSegment = (a: XY, b: XY, p: XY) =>
|
|
33
|
+
Math.abs(cross(a, b, p)) <=
|
|
34
|
+
8 *
|
|
35
|
+
Number.EPSILON *
|
|
36
|
+
(Math.abs((b[0] - a[0]) * (p[1] - a[1])) + Math.abs((b[1] - a[1]) * (p[0] - a[0]))) &&
|
|
37
|
+
p[0] >= Math.min(a[0], b[0]) &&
|
|
38
|
+
p[0] <= Math.max(a[0], b[0]) &&
|
|
39
|
+
p[1] >= Math.min(a[1], b[1]) &&
|
|
40
|
+
p[1] <= Math.max(a[1], b[1]);
|
|
41
|
+
|
|
42
|
+
/** Mesh a valid raster domain with noncrossing, piecewise-linear XYZ constraints. */
|
|
43
|
+
export function createBreaklineTerrainMesh(
|
|
44
|
+
field: HeightField,
|
|
45
|
+
options: BreaklineMeshOptions
|
|
46
|
+
): BreaklineTerrainMesh {
|
|
47
|
+
const breaklineEdges: Edge[] = [];
|
|
48
|
+
let overriddenSamples = 0;
|
|
49
|
+
const mesh = meshValidDomain(field, options, (points, heights, boundary, selected, originZ) => {
|
|
50
|
+
const ids = new Map(points.map(([x, y], i) => [`${x},${y}`, i]));
|
|
51
|
+
const fixed = new Map<number, number>();
|
|
52
|
+
const excluded = new Set<number>();
|
|
53
|
+
const fixedSamples = new Set<number>();
|
|
54
|
+
|
|
55
|
+
const add = ([x, y, z]: TerrainBreaklinePoint): number => {
|
|
56
|
+
if (
|
|
57
|
+
![x, y, z, z - originZ].every(Number.isFinite) ||
|
|
58
|
+
x < 0 ||
|
|
59
|
+
y < 0 ||
|
|
60
|
+
x > field.width - 1 ||
|
|
61
|
+
y > field.height - 1
|
|
62
|
+
) {
|
|
63
|
+
throw new Error('Breakline endpoint is outside the sample rectangle or nonfinite');
|
|
64
|
+
}
|
|
65
|
+
const key = `${x},${y}`;
|
|
66
|
+
const id = ids.get(key) ?? points.length;
|
|
67
|
+
if (fixed.has(id) && fixed.get(id) !== z) throw new Error('Conflicting breakline heights');
|
|
68
|
+
if (!ids.has(key)) {
|
|
69
|
+
points.push([x, y]);
|
|
70
|
+
ids.set(key, id);
|
|
71
|
+
}
|
|
72
|
+
fixed.set(id, z);
|
|
73
|
+
heights[id] = z - originZ;
|
|
74
|
+
if (Number.isInteger(x) && Number.isInteger(y)) selected[y * field.width + x] = id;
|
|
75
|
+
return id;
|
|
76
|
+
};
|
|
77
|
+
if (options.breaklines.length > 2048) throw new Error('Breakline limit exceeded');
|
|
78
|
+
for (const [a, b] of options.breaklines) {
|
|
79
|
+
const p = add(a),
|
|
80
|
+
q = add(b);
|
|
81
|
+
if (p === q) throw new Error('Zero-length breakline');
|
|
82
|
+
breaklineEdges.push([p, q]);
|
|
83
|
+
}
|
|
84
|
+
const edges: Edge[] = [];
|
|
85
|
+
for (const [a, b] of boundary) {
|
|
86
|
+
const split = [
|
|
87
|
+
a,
|
|
88
|
+
...Array.from(fixed.keys()).filter(
|
|
89
|
+
id => id !== a && id !== b && onSegment(points[a], points[b], points[id])
|
|
90
|
+
),
|
|
91
|
+
b
|
|
92
|
+
];
|
|
93
|
+
const [x, y] = points[a];
|
|
94
|
+
split.sort(
|
|
95
|
+
(i, j) =>
|
|
96
|
+
Math.hypot(points[i][0] - x, points[i][1] - y) -
|
|
97
|
+
Math.hypot(points[j][0] - x, points[j][1] - y)
|
|
98
|
+
);
|
|
99
|
+
for (let i = 1; i < split.length; i++) edges.push([split[i - 1], split[i]]);
|
|
100
|
+
}
|
|
101
|
+
const seen = new Set<string>();
|
|
102
|
+
for (const [a, b] of breaklineEdges) {
|
|
103
|
+
const key = `${Math.min(a, b)},${Math.max(a, b)}`;
|
|
104
|
+
if (seen.has(key)) throw new Error('Duplicate breakline');
|
|
105
|
+
seen.add(key);
|
|
106
|
+
const p = points[a],
|
|
107
|
+
q = points[b];
|
|
108
|
+
let coincident = false;
|
|
109
|
+
for (const [c, d] of edges) {
|
|
110
|
+
if ((a === c && b === d) || (a === d && b === c)) {
|
|
111
|
+
coincident = true;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const r = points[c],
|
|
115
|
+
s = points[d];
|
|
116
|
+
const intersects =
|
|
117
|
+
Math.sign(cross(p, q, r)) * Math.sign(cross(p, q, s)) < 0 &&
|
|
118
|
+
Math.sign(cross(r, s, p)) * Math.sign(cross(r, s, q)) < 0;
|
|
119
|
+
if (
|
|
120
|
+
intersects ||
|
|
121
|
+
(c !== a && c !== b && onSegment(p, q, r)) ||
|
|
122
|
+
(d !== a && d !== b && onSegment(p, q, s)) ||
|
|
123
|
+
(a !== c && a !== d && onSegment(r, s, p)) ||
|
|
124
|
+
(b !== c && b !== d && onSegment(r, s, q))
|
|
125
|
+
) {
|
|
126
|
+
throw new Error('Breaklines and domain edges must meet only at shared endpoints');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (!coincident) edges.push([a, b]);
|
|
130
|
+
for (let y = Math.ceil(Math.min(p[1], q[1])); y <= Math.floor(Math.max(p[1], q[1])); y++) {
|
|
131
|
+
for (let x = Math.ceil(Math.min(p[0], q[0])); x <= Math.floor(Math.max(p[0], q[0])); x++) {
|
|
132
|
+
const source = field.getHeight(x, y);
|
|
133
|
+
if (source === undefined || !onSegment(p, q, [x, y])) continue;
|
|
134
|
+
fixedSamples.add(y * field.width + x);
|
|
135
|
+
|
|
136
|
+
const dx = q[0] - p[0],
|
|
137
|
+
dy = q[1] - p[1];
|
|
138
|
+
const f = Math.abs(dx) >= Math.abs(dy) ? (x - p[0]) / dx : (y - p[1]) / dy;
|
|
139
|
+
const z = (1 - f) * heights[a] + f * heights[b] + originZ;
|
|
140
|
+
if (Math.abs(source - z) <= options.maxError) continue;
|
|
141
|
+
if (!options.breaklinesOverrideSamples)
|
|
142
|
+
throw new Error('Breakline conflicts with source tolerance');
|
|
143
|
+
excluded.add(y * field.width + x);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Samples on constraints are already represented by the linear constraint.
|
|
148
|
+
// Prevent refinement from introducing T-junctions through roundoff.
|
|
149
|
+
overriddenSamples = excluded.size;
|
|
150
|
+
return {edges, excluded, fixedSamples};
|
|
151
|
+
});
|
|
152
|
+
const edges = new Set<string>();
|
|
153
|
+
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
154
|
+
for (let j = 0; j < 3; j++) {
|
|
155
|
+
const a = mesh.indices[i + j],
|
|
156
|
+
b = mesh.indices[i + ((j + 1) % 3)];
|
|
157
|
+
edges.add(`${Math.min(a, b)},${Math.max(a, b)}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (breaklineEdges.some(([a, b]) => !edges.has(`${Math.min(a, b)},${Math.max(a, b)}`))) {
|
|
161
|
+
throw new Error('Breakline was not preserved inside the valid terrain domain');
|
|
162
|
+
}
|
|
163
|
+
return {...mesh, breaklineEdges: Uint32Array.from(breaklineEdges.flat()), overriddenSamples};
|
|
164
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import type {TerrainBreakline, TerrainBreaklinePoint} from './breakline-mesh';
|
|
5
|
+
|
|
6
|
+
/** Split a set of XYZ constraints at crossings and T-junctions. */
|
|
7
|
+
export function splitTerrainBreaklines(
|
|
8
|
+
input: readonly TerrainBreakline[],
|
|
9
|
+
options: {heightTolerance?: number; maxPairTests?: number; maxSegments?: number} = {}
|
|
10
|
+
): {segments: TerrainBreakline[]; sourceSegments: Uint32Array} {
|
|
11
|
+
const {heightTolerance = 1e-8, maxPairTests = 2_100_000, maxSegments = 2048} = options;
|
|
12
|
+
if (
|
|
13
|
+
!Number.isFinite(heightTolerance) ||
|
|
14
|
+
heightTolerance < 0 ||
|
|
15
|
+
![maxPairTests, maxSegments].every(n => Number.isSafeInteger(n) && n >= 0 && n <= 0xffffffff)
|
|
16
|
+
)
|
|
17
|
+
throw new Error('Invalid breakline split limits');
|
|
18
|
+
if (input.length > maxSegments || (input.length * (input.length - 1)) / 2 > maxPairTests)
|
|
19
|
+
throw new Error('Breakline preprocessing work limit exceeded');
|
|
20
|
+
type Knot = {t: number; point: TerrainBreaklinePoint};
|
|
21
|
+
const vertices = new Map<string, TerrainBreaklinePoint>();
|
|
22
|
+
const canonical = (p: TerrainBreaklinePoint): TerrainBreaklinePoint => {
|
|
23
|
+
if (!p.every(Number.isFinite)) throw new Error('Invalid breakline vertex');
|
|
24
|
+
const key = `${p[0]},${p[1]}`;
|
|
25
|
+
const prior = vertices.get(key);
|
|
26
|
+
if (prior) {
|
|
27
|
+
if (Math.abs(prior[2] - p[2]) > heightTolerance)
|
|
28
|
+
throw new Error('Conflicting breakline heights');
|
|
29
|
+
return prior;
|
|
30
|
+
}
|
|
31
|
+
const point: TerrainBreaklinePoint = [...p];
|
|
32
|
+
vertices.set(key, point);
|
|
33
|
+
return point;
|
|
34
|
+
};
|
|
35
|
+
const lines = input.map(([a, b]) => {
|
|
36
|
+
const p = canonical(a),
|
|
37
|
+
q = canonical(b);
|
|
38
|
+
if (p === q) throw new Error('Zero-length breakline');
|
|
39
|
+
const knots: Knot[] = [
|
|
40
|
+
{t: 0, point: p},
|
|
41
|
+
{t: 1, point: q}
|
|
42
|
+
];
|
|
43
|
+
return {p, q, dx: q[0] - p[0], dy: q[1] - p[1], knots};
|
|
44
|
+
});
|
|
45
|
+
let count = input.length;
|
|
46
|
+
const add = (knots: Knot[], t: number, point: TerrainBreaklinePoint) => {
|
|
47
|
+
if (knots.some(k => k.point === point)) return;
|
|
48
|
+
if (knots.some(k => k.t === t))
|
|
49
|
+
throw new Error('Unresolved coincident breakline intersections');
|
|
50
|
+
if (++count > maxSegments) throw new Error('Breakline output limit exceeded');
|
|
51
|
+
knots.push({t, point});
|
|
52
|
+
};
|
|
53
|
+
const cross = (ax: number, ay: number, bx: number, by: number) => ax * by - ay * bx;
|
|
54
|
+
for (let i = 0; i < lines.length; i++) {
|
|
55
|
+
const a = lines[i];
|
|
56
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
57
|
+
const b = lines[j];
|
|
58
|
+
const x = b.p[0] - a.p[0],
|
|
59
|
+
y = b.p[1] - a.p[1];
|
|
60
|
+
const det = cross(a.dx, a.dy, b.dx, b.dy);
|
|
61
|
+
const u = cross(x, y, a.dx, a.dy),
|
|
62
|
+
t = cross(x, y, b.dx, b.dy);
|
|
63
|
+
if (![det, u, t].every(Number.isFinite)) throw new Error('Breakline intersection overflow');
|
|
64
|
+
if (det === 0) {
|
|
65
|
+
if (u !== 0 || t !== 0) continue;
|
|
66
|
+
const axis = Math.abs(a.dx) >= Math.abs(a.dy) ? 0 : 1;
|
|
67
|
+
if (
|
|
68
|
+
Math.max(Math.min(a.p[axis], a.q[axis]), Math.min(b.p[axis], b.q[axis])) <
|
|
69
|
+
Math.min(Math.max(a.p[axis], a.q[axis]), Math.max(b.p[axis], b.q[axis]))
|
|
70
|
+
)
|
|
71
|
+
throw new Error('Overlapping collinear breaklines');
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const fa = t / det,
|
|
75
|
+
fb = u / det;
|
|
76
|
+
if (fa < 0 || fa > 1 || fb < 0 || fb > 1) continue;
|
|
77
|
+
const za = (1 - fa) * a.p[2] + fa * a.q[2],
|
|
78
|
+
zb = (1 - fb) * b.p[2] + fb * b.q[2];
|
|
79
|
+
if (!Number.isFinite(za) || !Number.isFinite(zb) || Math.abs(za - zb) > heightTolerance)
|
|
80
|
+
throw new Error('Conflicting breakline heights at intersection');
|
|
81
|
+
const point = canonical(
|
|
82
|
+
fa === 0
|
|
83
|
+
? a.p
|
|
84
|
+
: fa === 1
|
|
85
|
+
? a.q
|
|
86
|
+
: fb === 0
|
|
87
|
+
? b.p
|
|
88
|
+
: fb === 1
|
|
89
|
+
? b.q
|
|
90
|
+
: [a.p[0] + fa * a.dx, a.p[1] + fa * a.dy, za]
|
|
91
|
+
);
|
|
92
|
+
add(a.knots, fa, point);
|
|
93
|
+
add(b.knots, fb, point);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const segments: TerrainBreakline[] = [];
|
|
97
|
+
const sourceSegments = new Uint32Array(count);
|
|
98
|
+
for (let i = 0; i < lines.length; i++) {
|
|
99
|
+
const knots = lines[i].knots.sort((a, b) => a.t - b.t);
|
|
100
|
+
for (let j = 1; j < knots.length; j++) {
|
|
101
|
+
sourceSegments[segments.length] = i;
|
|
102
|
+
segments.push([knots[j - 1].point, knots[j].point]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {segments, sourceSegments};
|
|
106
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
declare module 'cdt2d' {
|
|
5
|
+
export default function triangulate(
|
|
6
|
+
points: [number, number][],
|
|
7
|
+
edges: [number, number][],
|
|
8
|
+
options?: {exterior?: boolean; delaunay?: boolean}
|
|
9
|
+
): [number, number, number][];
|
|
10
|
+
}
|