@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
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,7 @@ __export(index_exports, {
|
|
|
73
73
|
TerrainContourBoundaryAxis: () => TerrainContourBoundaryAxis,
|
|
74
74
|
TerrainMorphStatus: () => TerrainMorphStatus,
|
|
75
75
|
TerrainProfileViewStatus: () => TerrainProfileViewStatus,
|
|
76
|
+
TerrainRegionalViewStatus: () => TerrainRegionalViewStatus,
|
|
76
77
|
TerrainSampleStatus: () => TerrainSampleStatus,
|
|
77
78
|
TerrainSurface: () => TerrainSurface,
|
|
78
79
|
TerrainVertexHaloStatus: () => TerrainVertexHaloStatus,
|
|
@@ -81,8 +82,10 @@ __export(index_exports, {
|
|
|
81
82
|
WKTCRSSyntaxError: () => WKTCRSSyntaxError,
|
|
82
83
|
WKTCRSValidationError: () => WKTCRSValidationError,
|
|
83
84
|
WebMercatorViewport: () => web_mercator_exports.WebMercatorViewport,
|
|
85
|
+
accumulateTerrainWatersheds: () => accumulateTerrainWatersheds,
|
|
84
86
|
addMetersToLngLat: () => web_mercator_exports.addMetersToLngLat,
|
|
85
87
|
altitudeToFovy: () => web_mercator_exports.altitudeToFovy,
|
|
88
|
+
boundTerrainLodScreenError: () => boundTerrainLodScreenError,
|
|
86
89
|
boundTerrainMeshError: () => boundTerrainMeshError,
|
|
87
90
|
certifyTerrainMeshCoverage: () => certifyTerrainMeshCoverage,
|
|
88
91
|
clipGeographicPolygon: () => clipGeographicPolygon,
|
|
@@ -95,12 +98,15 @@ __export(index_exports, {
|
|
|
95
98
|
createCRSProjectionDomain: () => createCRSProjectionDomain,
|
|
96
99
|
createCRSResolver: () => createCRSResolver,
|
|
97
100
|
createDelatinTerrainMesh: () => createDelatinTerrainMesh,
|
|
101
|
+
createGeographicTerrainCutoutFrame: () => createGeographicTerrainCutoutFrame,
|
|
98
102
|
createMartiniTerrainMesh: () => createMartiniTerrainMesh,
|
|
99
103
|
createOctahedralCutAtlas: () => createOctahedralCutAtlas,
|
|
100
104
|
createOctahedralCutGraph: () => createOctahedralCutGraph,
|
|
101
105
|
createOrthographicCutAtlas: () => createOrthographicCutAtlas,
|
|
102
106
|
createSpatialReference: () => createSpatialReference,
|
|
103
107
|
createTerrainContours: () => createTerrainContours,
|
|
108
|
+
createTerrainCutoutSkirts: () => createTerrainCutoutSkirts,
|
|
109
|
+
createTerrainDrainage: () => createTerrainDrainage,
|
|
104
110
|
createTerrainFilteredPyramid: () => createTerrainFilteredPyramid,
|
|
105
111
|
createTerrainGradientGrid: () => createTerrainGradientGrid,
|
|
106
112
|
createTerrainGradientPyramid: () => createTerrainGradientPyramid,
|
|
@@ -109,16 +115,20 @@ __export(index_exports, {
|
|
|
109
115
|
createTerrainMesh: () => createTerrainMesh,
|
|
110
116
|
createTerrainMixedIsobands: () => createTerrainMixedIsobands,
|
|
111
117
|
createTerrainMixedVertexTileHalos: () => createTerrainMixedVertexTileHalos,
|
|
118
|
+
createTerrainRegionalViewshed: () => createTerrainRegionalViewshed,
|
|
112
119
|
createTerrainSkirt: () => createTerrainSkirt,
|
|
113
120
|
createTerrainSlopeAspectGrid: () => createTerrainSlopeAspectGrid,
|
|
114
121
|
createTerrainSurface: () => createTerrainSurface,
|
|
115
122
|
createTerrainVertexTileHalos: () => createTerrainVertexTileHalos,
|
|
116
123
|
createValidDomainTerrainMesh: () => createValidDomainTerrainMesh,
|
|
117
124
|
diagnoseTerrainContourBoundaries: () => diagnoseTerrainContourBoundaries,
|
|
125
|
+
discoverGeographicTerrainLodSeams: () => discoverGeographicTerrainLodSeams,
|
|
126
|
+
discoverGeographicTerrainPoles: () => discoverGeographicTerrainPoles,
|
|
118
127
|
eastNorthUpToFixedFrame: () => eastNorthUpToFixedFrame,
|
|
119
128
|
encodePROJString: () => encodePROJString,
|
|
120
129
|
encodeWKTCRS: () => encodeWKTCRS,
|
|
121
130
|
evaluateTerrainLodMorph: () => evaluateTerrainLodMorph,
|
|
131
|
+
fillTerrainDepressions: () => fillTerrainDepressions,
|
|
122
132
|
fitBounds: () => web_mercator_exports.fitBounds,
|
|
123
133
|
flyToViewport: () => web_mercator_exports.flyToViewport,
|
|
124
134
|
formatAngle: () => formatAngle,
|
|
@@ -131,6 +141,7 @@ __export(index_exports, {
|
|
|
131
141
|
getCRSSignature: () => getCRSSignature,
|
|
132
142
|
getDistanceScales: () => web_mercator_exports.getDistanceScales,
|
|
133
143
|
getFlyToDuration: () => web_mercator_exports.getFlyToDuration,
|
|
144
|
+
getGeographicTerrainNeighbor: () => getGeographicTerrainNeighbor,
|
|
134
145
|
getGeographicTile: () => getGeographicTile,
|
|
135
146
|
getGeographicTileBounds: () => getGeographicTileBounds,
|
|
136
147
|
getGeographicTileRanges: () => getGeographicTileRanges,
|
|
@@ -138,6 +149,7 @@ __export(index_exports, {
|
|
|
138
149
|
getMeterZoom: () => web_mercator_exports.getMeterZoom,
|
|
139
150
|
getProjectionMatrix: () => web_mercator_exports.getProjectionMatrix,
|
|
140
151
|
getProjectionParameters: () => web_mercator_exports.getProjectionParameters,
|
|
152
|
+
getTerrainCellMetrics: () => getTerrainCellMetrics,
|
|
141
153
|
getTerrainHierarchyNode: () => getTerrainHierarchyNode,
|
|
142
154
|
getTerrainMeshEdge: () => getTerrainMeshEdge,
|
|
143
155
|
getTerrainProfileHorizon: () => getTerrainProfileHorizon,
|
|
@@ -171,6 +183,8 @@ __export(index_exports, {
|
|
|
171
183
|
parsePROJString: () => parsePROJString,
|
|
172
184
|
parseWKTCRS: () => parseWKTCRS,
|
|
173
185
|
pixelsToWorld: () => web_mercator_exports.pixelsToWorld,
|
|
186
|
+
prepareTerrainCutoutPolygons: () => prepareTerrainCutoutPolygons,
|
|
187
|
+
projectGeographicTerrainCutout: () => projectGeographicTerrainCutout,
|
|
174
188
|
projectGrid: () => projectGrid,
|
|
175
189
|
reconcileTerrainVertexTiles: () => reconcileTerrainVertexTiles,
|
|
176
190
|
resolveTileIndex: () => resolveTileIndex,
|
|
@@ -184,6 +198,8 @@ __export(index_exports, {
|
|
|
184
198
|
splitGeographicPolyline: () => splitGeographicPolyline,
|
|
185
199
|
splitGlobeBounds: () => splitGlobeBounds,
|
|
186
200
|
splitTerrainBreaklines: () => splitTerrainBreaklines,
|
|
201
|
+
splitTerrainMesh: () => splitTerrainMesh,
|
|
202
|
+
splitTerrainMeshTiles: () => splitTerrainMeshTiles,
|
|
187
203
|
standardGridZone: () => standardGridZone,
|
|
188
204
|
stitchTerrainContourTiles: () => stitchTerrainContourTiles,
|
|
189
205
|
stitchTerrainContours: () => stitchTerrainContours,
|
|
@@ -193,9 +209,22 @@ __export(index_exports, {
|
|
|
193
209
|
subdivideGeographicCutRing: () => subdivideGeographicCutRing,
|
|
194
210
|
subdivideGlobeMesh: () => subdivideGlobeMesh,
|
|
195
211
|
subdivideRhumbPolyline: () => subdivideRhumbPolyline,
|
|
212
|
+
sweepTerrainBox: () => sweepTerrainBox,
|
|
213
|
+
sweepTerrainCapsule: () => sweepTerrainCapsule,
|
|
214
|
+
sweepTerrainCylinder: () => sweepTerrainCylinder,
|
|
215
|
+
sweepTerrainPlane: () => sweepTerrainPlane,
|
|
216
|
+
sweepTerrainPolytope: () => sweepTerrainPolytope,
|
|
217
|
+
sweepTerrainRotatingBox: () => sweepTerrainRotatingBox,
|
|
218
|
+
sweepTerrainRotatingCapsule: () => sweepTerrainRotatingCapsule,
|
|
219
|
+
sweepTerrainRotatingPolytope: () => sweepTerrainRotatingPolytope,
|
|
220
|
+
sweepTerrainRotatingSphere: () => sweepTerrainRotatingSphere,
|
|
221
|
+
sweepTerrainSphere: () => sweepTerrainSphere,
|
|
222
|
+
sweepTerrainTaperedCapsule: () => sweepTerrainTaperedCapsule,
|
|
223
|
+
sweepTerrainTriangleMesh: () => sweepTerrainTriangleMesh,
|
|
196
224
|
transferGrid: () => transferGrid,
|
|
197
225
|
unitsPerMeter: () => web_mercator_exports.unitsPerMeter,
|
|
198
226
|
unpackTerrainHeightField: () => unpackTerrainHeightField,
|
|
227
|
+
unprojectGeographicTerrainCutout: () => unprojectGeographicTerrainCutout,
|
|
199
228
|
unprojectGrid: () => unprojectGrid,
|
|
200
229
|
updateTerrainBounds: () => updateTerrainBounds,
|
|
201
230
|
updateTerrainBoundsRegions: () => updateTerrainBoundsRegions,
|
|
@@ -209,6 +238,7 @@ __export(index_exports, {
|
|
|
209
238
|
updateTerrainMixedVertexTileHalos: () => updateTerrainMixedVertexTileHalos,
|
|
210
239
|
updateTerrainPersistentBounds: () => updateTerrainPersistentBounds,
|
|
211
240
|
updateTerrainPersistentGradients: () => updateTerrainPersistentGradients,
|
|
241
|
+
updateTerrainTileCutouts: () => updateTerrainTileCutouts,
|
|
212
242
|
updateTerrainValidDomainMeshRegions: () => updateTerrainValidDomainMeshRegions,
|
|
213
243
|
updateTerrainVertexTileHalos: () => updateTerrainVertexTileHalos,
|
|
214
244
|
validateTileMatrix: () => validateTileMatrix,
|
|
@@ -225,8 +255,8 @@ __export(index_exports, {
|
|
|
225
255
|
module.exports = __toCommonJS(index_exports);
|
|
226
256
|
|
|
227
257
|
// dist/ellipsoid.js
|
|
228
|
-
var
|
|
229
|
-
var
|
|
258
|
+
var import_matrix3 = require("@math.gl/core/matrix");
|
|
259
|
+
var import_matrix4 = require("@math.gl/core/matrix");
|
|
230
260
|
|
|
231
261
|
// dist/constants.js
|
|
232
262
|
var WGS84_RADIUS_X = 6378137;
|
|
@@ -251,11 +281,11 @@ var WGS84_CONSTANTS = {
|
|
|
251
281
|
};
|
|
252
282
|
|
|
253
283
|
// dist/type-utils.js
|
|
254
|
-
var
|
|
284
|
+
var import_matrix = require("@math.gl/core/matrix");
|
|
255
285
|
function identity(x) {
|
|
256
286
|
return x;
|
|
257
287
|
}
|
|
258
|
-
var scratchVector = new
|
|
288
|
+
var scratchVector = new import_matrix.Vector3();
|
|
259
289
|
function fromCartographic(cartographic, result = [], map = identity) {
|
|
260
290
|
if ("longitude" in cartographic) {
|
|
261
291
|
result[0] = map(cartographic.longitude);
|
|
@@ -273,11 +303,11 @@ function fromCartographic(cartographic, result = [], map = identity) {
|
|
|
273
303
|
return result;
|
|
274
304
|
}
|
|
275
305
|
function fromCartographicToRadians(cartographic, vector2 = []) {
|
|
276
|
-
return fromCartographic(cartographic, vector2,
|
|
306
|
+
return fromCartographic(cartographic, vector2, import_matrix.config._cartographicRadians ? identity : import_matrix.toRadians);
|
|
277
307
|
}
|
|
278
|
-
function toCartographicFromRadiansComponents(longitude,
|
|
279
|
-
const map =
|
|
280
|
-
const mappedLongitude = map(longitude), mappedLatitude = map(
|
|
308
|
+
function toCartographicFromRadiansComponents(longitude, latitude2, height, cartographic) {
|
|
309
|
+
const map = import_matrix.config._cartographicRadians ? identity : import_matrix.toDegrees;
|
|
310
|
+
const mappedLongitude = map(longitude), mappedLatitude = map(latitude2);
|
|
281
311
|
if ("longitude" in cartographic) {
|
|
282
312
|
cartographic.longitude = mappedLongitude;
|
|
283
313
|
cartographic.latitude = mappedLatitude;
|
|
@@ -306,17 +336,17 @@ function isWGS84(vector2) {
|
|
|
306
336
|
}
|
|
307
337
|
|
|
308
338
|
// dist/ellipsoid-helpers/scale-to-geodetic-surface.js
|
|
309
|
-
var
|
|
339
|
+
var import_matrix2 = require("@math.gl/core/matrix");
|
|
310
340
|
|
|
311
341
|
// dist/ellipsoid-helpers/exact-nearest-surface.js
|
|
312
342
|
function exactNearestSurface(x, y, z, a, b, c, result) {
|
|
313
343
|
const values = [a, b, c, Math.abs(x), Math.abs(y), Math.abs(z)];
|
|
314
344
|
const parts = values.map((value3) => {
|
|
315
345
|
const bits2 = value3.toString(2);
|
|
316
|
-
const
|
|
346
|
+
const dot5 = bits2.indexOf(".");
|
|
317
347
|
return {
|
|
318
348
|
integer: BigInt("0b" + bits2.replace(".", "")),
|
|
319
|
-
exponent:
|
|
349
|
+
exponent: dot5 < 0 ? 0 : dot5 + 1 - bits2.length
|
|
320
350
|
};
|
|
321
351
|
});
|
|
322
352
|
const exponent = Math.min(...parts.filter((p) => p.integer !== 0n).map((p) => p.exponent));
|
|
@@ -518,7 +548,7 @@ function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
|
|
|
518
548
|
return writeResult(result, surface.x, surface.y, surface.z);
|
|
519
549
|
}
|
|
520
550
|
function writeResult(result, x, y, z) {
|
|
521
|
-
if ((0,
|
|
551
|
+
if ((0, import_matrix2.isArray)(result)) {
|
|
522
552
|
result[0] = x;
|
|
523
553
|
result[1] = y;
|
|
524
554
|
result[2] = z;
|
|
@@ -533,10 +563,10 @@ function writeResult(result, x, y, z) {
|
|
|
533
563
|
|
|
534
564
|
// dist/ellipsoid.js
|
|
535
565
|
var spheroidScratch = { x: 0, y: 0, z: 0 };
|
|
536
|
-
var scratchVector2 = new
|
|
537
|
-
var scratchNormal = new
|
|
538
|
-
var scratchPosition = new
|
|
539
|
-
var scratchCartesian = new
|
|
566
|
+
var scratchVector2 = new import_matrix3.Vector3();
|
|
567
|
+
var scratchNormal = new import_matrix3.Vector3();
|
|
568
|
+
var scratchPosition = new import_matrix3.Vector3();
|
|
569
|
+
var scratchCartesian = new import_matrix3.Vector3();
|
|
540
570
|
var Ellipsoid = class _Ellipsoid {
|
|
541
571
|
/** Construct from two-axis geometry, including normalized projection ellipsoids.
|
|
542
572
|
* The equatorial X/Y radii are equal; no CRS or datum information is inferred.
|
|
@@ -547,15 +577,15 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
547
577
|
return new _Ellipsoid(semiMajorAxis, semiMajorAxis, semiMinorAxis);
|
|
548
578
|
}
|
|
549
579
|
constructor(x = 0, y = 0, z = 0) {
|
|
550
|
-
this.centerToleranceSquared =
|
|
551
|
-
(0,
|
|
552
|
-
(0,
|
|
553
|
-
(0,
|
|
554
|
-
this.radii = new
|
|
555
|
-
this.radiiSquared = new
|
|
556
|
-
this.radiiToTheFourth = new
|
|
557
|
-
this.oneOverRadii = new
|
|
558
|
-
this.oneOverRadiiSquared = new
|
|
580
|
+
this.centerToleranceSquared = import_matrix3._MathUtils.EPSILON1;
|
|
581
|
+
(0, import_matrix3.assert)(Number.isFinite(x) && x >= 0);
|
|
582
|
+
(0, import_matrix3.assert)(Number.isFinite(y) && y >= 0);
|
|
583
|
+
(0, import_matrix3.assert)(Number.isFinite(z) && z >= 0);
|
|
584
|
+
this.radii = new import_matrix3.Vector3(x, y, z);
|
|
585
|
+
this.radiiSquared = new import_matrix3.Vector3(x * x, y * y, z * z);
|
|
586
|
+
this.radiiToTheFourth = new import_matrix3.Vector3(x * x * x * x, y * y * y * y, z * z * z * z);
|
|
587
|
+
this.oneOverRadii = new import_matrix3.Vector3(x === 0 ? 0 : 1 / x, y === 0 ? 0 : 1 / y, z === 0 ? 0 : 1 / z);
|
|
588
|
+
this.oneOverRadiiSquared = new import_matrix3.Vector3(x === 0 ? 0 : 1 / (x * x), y === 0 ? 0 : 1 / (y * y), z === 0 ? 0 : 1 / (z * z));
|
|
559
589
|
this.minimumRadius = Math.min(x, y, z);
|
|
560
590
|
this.maximumRadius = Math.max(x, y, z);
|
|
561
591
|
if (z !== 0) {
|
|
@@ -595,14 +625,14 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
595
625
|
}
|
|
596
626
|
cartographicToCartesian(cartographic, result = [0, 0, 0]) {
|
|
597
627
|
const llh = fromCartographicToRadians(cartographic, scratchCartesian);
|
|
598
|
-
const longitude = llh[0],
|
|
599
|
-
if (!Number.isFinite(longitude) || !Number.isFinite(
|
|
628
|
+
const longitude = llh[0], latitude2 = llh[1], height = llh[2];
|
|
629
|
+
if (!Number.isFinite(longitude) || !Number.isFinite(latitude2) || !Number.isFinite(height) || !(this.minimumRadius > 0) || !Number.isFinite(this.maximumRadius * this.maximumRadius))
|
|
600
630
|
return void 0;
|
|
601
|
-
if (this.spheroidGeometry && (
|
|
631
|
+
if (this.spheroidGeometry && (import_matrix3.config._cartographicRadians || Math.abs(latitude2) <= Math.PI / 4)) {
|
|
602
632
|
spheroidScratch.x = longitude;
|
|
603
|
-
spheroidScratch.y =
|
|
633
|
+
spheroidScratch.y = latitude2;
|
|
604
634
|
spheroidScratch.z = height;
|
|
605
|
-
if (!(0,
|
|
635
|
+
if (!(0, import_matrix4.spheroidToCartesian)(spheroidScratch, this.spheroidGeometry))
|
|
606
636
|
return void 0;
|
|
607
637
|
return writeResult(result, spheroidScratch.x, spheroidScratch.y, spheroidScratch.z);
|
|
608
638
|
}
|
|
@@ -631,7 +661,7 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
631
661
|
spheroidScratch.z = z;
|
|
632
662
|
const shape = this.spheroidGeometry;
|
|
633
663
|
const nearBoundary = z === 0 && shape.semiMinorAxis < shape.semiMajorAxis && Math.abs(Math.hypot(x, y) - shape.semiMajorAxis * shape.eccentricitySquared) <= 64 * Number.EPSILON * shape.semiMajorAxis;
|
|
634
|
-
if (!nearBoundary && (0,
|
|
664
|
+
if (!nearBoundary && (0, import_matrix4.cartesianToSpheroid)(spheroidScratch, shape)) {
|
|
635
665
|
const longitude2 = x === 0 && y === 0 ? Math.atan2(y, x) : spheroidScratch.x;
|
|
636
666
|
return toCartographicFromRadiansComponents(longitude2, spheroidScratch.y, spheroidScratch.z, result);
|
|
637
667
|
}
|
|
@@ -651,9 +681,9 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
651
681
|
return void 0;
|
|
652
682
|
const nx = gx / length, ny = gy / length, nz = gz / length;
|
|
653
683
|
const longitude = Math.atan2(ny, nx);
|
|
654
|
-
const
|
|
684
|
+
const latitude2 = Math.atan2(nz, Math.hypot(nx, ny));
|
|
655
685
|
const height = (x - point2[0]) * nx + (y - point2[1]) * ny + (z - point2[2]) * nz;
|
|
656
|
-
return toCartographicFromRadiansComponents(longitude,
|
|
686
|
+
return toCartographicFromRadiansComponents(longitude, latitude2, height, result);
|
|
657
687
|
}
|
|
658
688
|
geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
659
689
|
fromCartographic(cartesian, scratchVector2);
|
|
@@ -662,12 +692,12 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
662
692
|
}
|
|
663
693
|
geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {
|
|
664
694
|
const point2 = fromCartographic(cartographic, scratchCartesian);
|
|
665
|
-
const longitude =
|
|
666
|
-
const
|
|
667
|
-
const polarDegrees = !
|
|
695
|
+
const longitude = import_matrix3.config._cartographicRadians ? point2[0] : point2[0] * Math.PI / 180;
|
|
696
|
+
const latitude2 = import_matrix3.config._cartographicRadians ? point2[1] : point2[1] * Math.PI / 180;
|
|
697
|
+
const polarDegrees = !import_matrix3.config._cartographicRadians && Math.abs(point2[1]) > 45;
|
|
668
698
|
const complement = (90 - Math.abs(point2[1])) * Math.PI / 180;
|
|
669
|
-
const cosLatitude = polarDegrees ? Math.sin(complement) : Math.abs(
|
|
670
|
-
const sinLatitude = polarDegrees ? Math.sign(point2[1]) * Math.cos(complement) : Math.sin(
|
|
699
|
+
const cosLatitude = polarDegrees ? Math.sin(complement) : Math.abs(latitude2) === Math.PI / 2 ? 0 : Math.cos(latitude2);
|
|
700
|
+
const sinLatitude = polarDegrees ? Math.sign(point2[1]) * Math.cos(complement) : Math.sin(latitude2);
|
|
671
701
|
return normalResult(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), sinLatitude, result);
|
|
672
702
|
}
|
|
673
703
|
geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
@@ -733,7 +763,7 @@ var Ellipsoid = class _Ellipsoid {
|
|
|
733
763
|
}
|
|
734
764
|
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
735
765
|
getSurfaceNormalIntersectionWithZAxis(position2, buffer = 0, result = [0, 0, 0]) {
|
|
736
|
-
(0,
|
|
766
|
+
(0, import_matrix3.assert)(this.radii.x === this.radii.y && this.minimumRadius > 0);
|
|
737
767
|
fromCartographic(position2, scratchPosition);
|
|
738
768
|
if (!Number.isFinite(scratchPosition.x) || !Number.isFinite(scratchPosition.y) || !Number.isFinite(scratchPosition.z) || !Number.isFinite(buffer))
|
|
739
769
|
return void 0;
|
|
@@ -761,7 +791,7 @@ function normalResult(x, y, z, result) {
|
|
|
761
791
|
}
|
|
762
792
|
|
|
763
793
|
// dist/ellipsoid-tangent-plane.js
|
|
764
|
-
var
|
|
794
|
+
var import_matrix5 = require("@math.gl/core/matrix");
|
|
765
795
|
var import_culling = require("@math.gl/geometry/culling");
|
|
766
796
|
|
|
767
797
|
// dist/ellipsoid-helpers/tangent-plane-numerics.js
|
|
@@ -817,8 +847,8 @@ function exactNormalIntersection(radii, origin, east, north, normal2, point2, sp
|
|
|
817
847
|
const factors = [v[1] * v[2], v[0] * v[2], v[0] * v[1]];
|
|
818
848
|
const p = [0, 1, 2].map((i) => (v[3 + i] * unit3 + v[6 + i] * v[15] + v[9 + i] * v[16]) * factors[i]);
|
|
819
849
|
const n = v.slice(12, 15).map((x, i) => x * factors[i]);
|
|
820
|
-
const
|
|
821
|
-
const a =
|
|
850
|
+
const dot5 = (x, y) => x.reduce((s, v2, i) => s + v2 * y[i], 0n);
|
|
851
|
+
const a = dot5(n, n), b = dot5(n, p), c = dot5(p, p) - (v[0] * v[1] * v[2] * unit3) ** 2n;
|
|
822
852
|
const discriminant = b * b - a * c;
|
|
823
853
|
if (a === 0n || discriminant < 0n)
|
|
824
854
|
return void 0;
|
|
@@ -855,18 +885,18 @@ var EllipsoidTangentPlane = class {
|
|
|
855
885
|
if (!this.radii.every((radius) => radius > 0 && Number.isFinite(radius))) {
|
|
856
886
|
throw new RangeError("Tangent plane requires positive finite ellipsoid radii");
|
|
857
887
|
}
|
|
858
|
-
const originOnSurface = ellipsoid.scaleToGeodeticSurface(Array.from(origin), new
|
|
888
|
+
const originOnSurface = ellipsoid.scaleToGeodeticSurface(Array.from(origin), new import_matrix5.Vector3());
|
|
859
889
|
if (!originOnSurface)
|
|
860
890
|
throw new RangeError("Origin has no unique ellipsoid surface point");
|
|
861
|
-
this.anchor = new
|
|
862
|
-
const normal2 = new
|
|
891
|
+
this.anchor = new import_matrix5.Vector3(originOnSurface);
|
|
892
|
+
const normal2 = new import_matrix5.Vector3(ellipsoid.geodeticSurfaceNormal(originOnSurface));
|
|
863
893
|
if (!normal2.every(Number.isFinite) || !(normal2.len() > 0)) {
|
|
864
894
|
throw new RangeError("Cannot resolve tangent-plane normal");
|
|
865
895
|
}
|
|
866
896
|
normal2.normalize();
|
|
867
897
|
const horizontal = Math.hypot(normal2[0], normal2[1]);
|
|
868
|
-
this.east = horizontal > 0 ? new
|
|
869
|
-
this.north = new
|
|
898
|
+
this.east = horizontal > 0 ? new import_matrix5.Vector3(-normal2[1] / horizontal, normal2[0] / horizontal, 0) : new import_matrix5.Vector3(0, 1, 0);
|
|
899
|
+
this.north = new import_matrix5.Vector3(normal2).cross(this.east).normalize();
|
|
870
900
|
this._plane = new import_culling.Plane().fromPointNormal(this.anchor, normal2);
|
|
871
901
|
}
|
|
872
902
|
/**
|
|
@@ -876,7 +906,7 @@ var EllipsoidTangentPlane = class {
|
|
|
876
906
|
* @param result The optional object in which to store the local east-north coordinates.
|
|
877
907
|
* @returns The supplied result or a new Vector2.
|
|
878
908
|
*/
|
|
879
|
-
projectPointToNearestOnPlane(cartesian, result = new
|
|
909
|
+
projectPointToNearestOnPlane(cartesian, result = new import_matrix5.Vector2()) {
|
|
880
910
|
finiteInput(cartesian, 3);
|
|
881
911
|
const x = cartesian[0] - this.anchor[0];
|
|
882
912
|
const y = cartesian[1] - this.anchor[1];
|
|
@@ -889,7 +919,7 @@ var EllipsoidTangentPlane = class {
|
|
|
889
919
|
/** Project along the outward ray from the ellipsoid center.
|
|
890
920
|
* Back-facing, horizon and nonfinite intersections return undefined without writing result.
|
|
891
921
|
*/
|
|
892
|
-
projectPointRadiallyOntoPlane(cartesian, result = new
|
|
922
|
+
projectPointRadiallyOntoPlane(cartesian, result = new import_matrix5.Vector2()) {
|
|
893
923
|
finiteInput(cartesian, 3);
|
|
894
924
|
const scale3 = Math.max(Math.abs(cartesian[0]), Math.abs(cartesian[1]), Math.abs(cartesian[2]));
|
|
895
925
|
if (scale3 === 0)
|
|
@@ -910,7 +940,7 @@ var EllipsoidTangentPlane = class {
|
|
|
910
940
|
* projection. Normal selects the nearest-facing line intersection and can miss.
|
|
911
941
|
* Neither operation restores a source point's height. Failure leaves result untouched.
|
|
912
942
|
*/
|
|
913
|
-
projectPointOntoEllipsoid(point2, mode = "radial", result = new
|
|
943
|
+
projectPointOntoEllipsoid(point2, mode = "radial", result = new import_matrix5.Vector3()) {
|
|
914
944
|
finiteInput(point2, 2);
|
|
915
945
|
checkMode(mode);
|
|
916
946
|
const [rx, ry, rz] = this.radii;
|
|
@@ -972,8 +1002,8 @@ var EllipsoidTangentPlane = class {
|
|
|
972
1002
|
throw new RangeError("Expected finite coordinates");
|
|
973
1003
|
}
|
|
974
1004
|
const valid = new Uint8Array(count);
|
|
975
|
-
const point2 = new
|
|
976
|
-
const projected = new
|
|
1005
|
+
const point2 = new import_matrix5.Vector3();
|
|
1006
|
+
const projected = new import_matrix5.Vector2();
|
|
977
1007
|
for (let i = 0; i < count; i++) {
|
|
978
1008
|
point2.set(input[i * 3], input[i * 3 + 1], input[i * 3 + 2]);
|
|
979
1009
|
const value3 = mode === "normal" ? this.projectPointToNearestOnPlane(point2, projected) : this.projectPointRadiallyOntoPlane(point2, projected);
|
|
@@ -1071,10 +1101,10 @@ geodesic.Accumulator = {};
|
|
|
1071
1101
|
return Math.abs(x) * (y < 0 || y === 0 && 1 / y < 0 ? -1 : 1);
|
|
1072
1102
|
};
|
|
1073
1103
|
m.sum = function(u, v) {
|
|
1074
|
-
var s = u + v,
|
|
1075
|
-
|
|
1104
|
+
var s = u + v, up2 = s - v, vpp = s - up2, t;
|
|
1105
|
+
up2 -= u;
|
|
1076
1106
|
vpp -= v;
|
|
1077
|
-
t = s ? 0 - (
|
|
1107
|
+
t = s ? 0 - (up2 + vpp) : s;
|
|
1078
1108
|
return { s, t };
|
|
1079
1109
|
};
|
|
1080
1110
|
m.polyval = function(N, p, s, x) {
|
|
@@ -2421,17 +2451,17 @@ var EllipsoidGeodesic = class {
|
|
|
2421
2451
|
validatePoint(lat2, lon2);
|
|
2422
2452
|
return this.engine.Inverse(lat1, lon1, lat2, lon2, outputMask(options));
|
|
2423
2453
|
}
|
|
2424
|
-
direct(
|
|
2425
|
-
return this.line(
|
|
2454
|
+
direct(latitude2, longitude, azimuth, distance, options = {}) {
|
|
2455
|
+
return this.line(latitude2, longitude, azimuth, options).position(distance);
|
|
2426
2456
|
}
|
|
2427
|
-
arcDirect(
|
|
2428
|
-
return this.line(
|
|
2457
|
+
arcDirect(latitude2, longitude, azimuth, arc, options = {}) {
|
|
2458
|
+
return this.line(latitude2, longitude, azimuth, options).arcPosition(arc);
|
|
2429
2459
|
}
|
|
2430
|
-
line(
|
|
2431
|
-
validatePoint(
|
|
2460
|
+
line(latitude2, longitude, azimuth, options = {}) {
|
|
2461
|
+
validatePoint(latitude2, longitude);
|
|
2432
2462
|
validateFinite(azimuth);
|
|
2433
2463
|
const selectedMask = outputMask(options);
|
|
2434
|
-
const line = this.engine.Line(
|
|
2464
|
+
const line = this.engine.Line(latitude2, longitude, azimuth, selectedMask | library.DISTANCE_IN);
|
|
2435
2465
|
return {
|
|
2436
2466
|
// Fourth argument is an internal result request; ordinary Array.map arguments remain ignored.
|
|
2437
2467
|
position(distance, _index, _array, output2) {
|
|
@@ -2445,8 +2475,8 @@ var EllipsoidGeodesic = class {
|
|
|
2445
2475
|
};
|
|
2446
2476
|
}
|
|
2447
2477
|
};
|
|
2448
|
-
function validatePoint(
|
|
2449
|
-
if (!(Number.isFinite(
|
|
2478
|
+
function validatePoint(latitude2, longitude) {
|
|
2479
|
+
if (!(Number.isFinite(latitude2) && Math.abs(latitude2) <= 90 && Number.isFinite(longitude))) {
|
|
2450
2480
|
throw new Error("Invalid geodesic coordinates");
|
|
2451
2481
|
}
|
|
2452
2482
|
}
|
|
@@ -2465,8 +2495,8 @@ function createGeodesicEngine({ semiMajorAxis: a, semiMinorAxis: b }) {
|
|
|
2465
2495
|
}
|
|
2466
2496
|
|
|
2467
2497
|
// dist/local-reference-frame.js
|
|
2468
|
-
var
|
|
2469
|
-
var
|
|
2498
|
+
var import_matrix6 = require("@math.gl/core/matrix");
|
|
2499
|
+
var import_matrix7 = require("@math.gl/core/matrix");
|
|
2470
2500
|
var LocalReferenceFrame = class {
|
|
2471
2501
|
constructor(origin, options = {}) {
|
|
2472
2502
|
finiteCoordinate(origin);
|
|
@@ -2478,13 +2508,13 @@ var LocalReferenceFrame = class {
|
|
|
2478
2508
|
const llh = ellipsoid.cartesianToCartographic(origin);
|
|
2479
2509
|
if (!llh)
|
|
2480
2510
|
throw new RangeError("Origin has no unique geodetic frame");
|
|
2481
|
-
const basis2 = (0,
|
|
2482
|
-
const radians2 =
|
|
2483
|
-
if (!(0,
|
|
2511
|
+
const basis2 = (0, import_matrix7.createLocalFrameBasis)();
|
|
2512
|
+
const radians2 = import_matrix6.config._cartographicRadians ? 1 : Math.PI / 180;
|
|
2513
|
+
if (!(0, import_matrix7.eastNorthUpBasis)(llh[0] * radians2, llh[1] * radians2, basis2))
|
|
2484
2514
|
throw new RangeError("Cannot resolve local geodetic basis");
|
|
2485
2515
|
const axes = options.axes || ["east", "north", "up"];
|
|
2486
2516
|
const matrix = [];
|
|
2487
|
-
if (!(0,
|
|
2517
|
+
if (!(0, import_matrix7.localFrameToMatrix)(basis2, { x: origin[0], y: origin[1], z: origin[2] }, ...axes, matrix)) {
|
|
2488
2518
|
throw new RangeError("Expected three right-handed geographic axes");
|
|
2489
2519
|
}
|
|
2490
2520
|
this.matrix = Object.freeze(matrix);
|
|
@@ -2492,21 +2522,21 @@ var LocalReferenceFrame = class {
|
|
|
2492
2522
|
}
|
|
2493
2523
|
/** Independent copies: callers cannot mutate the cached frame. */
|
|
2494
2524
|
get localToFixedMatrix() {
|
|
2495
|
-
return new
|
|
2525
|
+
return new import_matrix6.Matrix4(this.matrix);
|
|
2496
2526
|
}
|
|
2497
2527
|
get fixedToLocalMatrix() {
|
|
2498
|
-
return new
|
|
2528
|
+
return new import_matrix6.Matrix4(this.matrix).invert();
|
|
2499
2529
|
}
|
|
2500
|
-
localToFixedPoint(point2, result = new
|
|
2530
|
+
localToFixedPoint(point2, result = new import_matrix6.Vector3()) {
|
|
2501
2531
|
return this.transform(point2, result, false, true);
|
|
2502
2532
|
}
|
|
2503
|
-
fixedToLocalPoint(point2, result = new
|
|
2533
|
+
fixedToLocalPoint(point2, result = new import_matrix6.Vector3()) {
|
|
2504
2534
|
return this.transform(point2, result, true, true);
|
|
2505
2535
|
}
|
|
2506
|
-
localToFixedVector(vector2, result = new
|
|
2536
|
+
localToFixedVector(vector2, result = new import_matrix6.Vector3()) {
|
|
2507
2537
|
return this.transform(vector2, result, false, false);
|
|
2508
2538
|
}
|
|
2509
|
-
fixedToLocalVector(vector2, result = new
|
|
2539
|
+
fixedToLocalVector(vector2, result = new import_matrix6.Vector3()) {
|
|
2510
2540
|
return this.transform(vector2, result, true, false);
|
|
2511
2541
|
}
|
|
2512
2542
|
/** Packed XYZ points. Exact in-place operation is supported; other overlap is rejected.
|
|
@@ -2525,13 +2555,13 @@ var LocalReferenceFrame = class {
|
|
|
2525
2555
|
return this.transformFlat(input, result, true, false);
|
|
2526
2556
|
}
|
|
2527
2557
|
/** Model-to-fixed affine pose, with unit scale. Angles are radians. */
|
|
2528
|
-
headingPitchRollToFixedFrame(attitude, result = new
|
|
2558
|
+
headingPitchRollToFixedFrame(attitude, result = new import_matrix6.Matrix4()) {
|
|
2529
2559
|
const { heading, pitch, roll } = attitude;
|
|
2530
2560
|
if (![heading, pitch, roll].every(Number.isFinite))
|
|
2531
2561
|
throw new RangeError("Nonfinite attitude");
|
|
2532
2562
|
return result.copy(this.matrix).rotateZ(-heading).rotateY(-pitch).rotateX(roll);
|
|
2533
2563
|
}
|
|
2534
|
-
headingPitchRollQuaternion(attitude, result = new
|
|
2564
|
+
headingPitchRollQuaternion(attitude, result = new import_matrix6.Quaternion()) {
|
|
2535
2565
|
const m = this.headingPitchRollToFixedFrame(attitude);
|
|
2536
2566
|
return result.fromMatrix3([m[0], m[1], m[2], m[4], m[5], m[6], m[8], m[9], m[10]]).normalize();
|
|
2537
2567
|
}
|
|
@@ -2540,7 +2570,7 @@ var LocalReferenceFrame = class {
|
|
|
2540
2570
|
*/
|
|
2541
2571
|
fixedFrameToHeadingPitchRoll(pose) {
|
|
2542
2572
|
validateRigidPose(pose);
|
|
2543
|
-
const local = new
|
|
2573
|
+
const local = new import_matrix6.Matrix4();
|
|
2544
2574
|
const m = this.matrix;
|
|
2545
2575
|
for (let column = 0; column < 3; column++) {
|
|
2546
2576
|
for (let row = 0; row < 3; row++) {
|
|
@@ -2557,18 +2587,18 @@ var LocalReferenceFrame = class {
|
|
|
2557
2587
|
* Returns undefined without writing result for zero or nearly vertical velocity.
|
|
2558
2588
|
* Stateless: callers own temporal continuity across these singularities.
|
|
2559
2589
|
*/
|
|
2560
|
-
velocityQuaternion(velocity, result = new
|
|
2590
|
+
velocityQuaternion(velocity, result = new import_matrix6.Quaternion()) {
|
|
2561
2591
|
finiteCoordinate(velocity);
|
|
2562
2592
|
const scale3 = Math.max(Math.abs(velocity[0]), Math.abs(velocity[1]), Math.abs(velocity[2]));
|
|
2563
2593
|
if (scale3 === 0)
|
|
2564
2594
|
return void 0;
|
|
2565
|
-
const x = new
|
|
2595
|
+
const x = new import_matrix6.Vector3(velocity[0] / scale3, velocity[1] / scale3, velocity[2] / scale3);
|
|
2566
2596
|
x.scale(1 / Math.hypot(x[0], x[1], x[2]));
|
|
2567
|
-
const y = new
|
|
2597
|
+
const y = new import_matrix6.Vector3(this.up).cross(x);
|
|
2568
2598
|
if (y.len() < 1e-12)
|
|
2569
2599
|
return void 0;
|
|
2570
2600
|
y.normalize();
|
|
2571
|
-
const z = new
|
|
2601
|
+
const z = new import_matrix6.Vector3(x).cross(y).normalize();
|
|
2572
2602
|
return result.fromMatrix3([...x, ...y, ...z]).normalize();
|
|
2573
2603
|
}
|
|
2574
2604
|
transformFlat(input, result, inverse4, position2) {
|
|
@@ -2582,7 +2612,7 @@ var LocalReferenceFrame = class {
|
|
|
2582
2612
|
throw new RangeError("Expected finite packed coordinates");
|
|
2583
2613
|
bounded && (bounded = Math.abs(input[i]) <= Number.MAX_VALUE / 8);
|
|
2584
2614
|
}
|
|
2585
|
-
const scratch = bounded ? void 0 : new
|
|
2615
|
+
const scratch = bounded ? void 0 : new import_matrix6.Vector3();
|
|
2586
2616
|
if (scratch)
|
|
2587
2617
|
for (let i = 0; i < input.length; i += 3)
|
|
2588
2618
|
this.transform(scratch.set(input[i], input[i + 1], input[i + 2]), scratch, inverse4, position2);
|
|
@@ -2632,9 +2662,9 @@ function validateRigidPose(pose) {
|
|
|
2632
2662
|
if (pose.length !== 16 || !Array.from(pose).every(Number.isFinite) || pose[3] !== 0 || pose[7] !== 0 || pose[11] !== 0 || pose[15] !== 1) {
|
|
2633
2663
|
throw new RangeError("Expected a finite affine pose");
|
|
2634
2664
|
}
|
|
2635
|
-
const x = new
|
|
2636
|
-
const y = new
|
|
2637
|
-
const z = new
|
|
2665
|
+
const x = new import_matrix6.Vector3(pose[0], pose[1], pose[2]);
|
|
2666
|
+
const y = new import_matrix6.Vector3(pose[4], pose[5], pose[6]);
|
|
2667
|
+
const z = new import_matrix6.Vector3(pose[8], pose[9], pose[10]);
|
|
2638
2668
|
for (const axis of [x, y, z]) {
|
|
2639
2669
|
if (Math.abs(Math.hypot(axis[0], axis[1], axis[2]) - 1) > 1e-6) {
|
|
2640
2670
|
throw new RangeError("Pose rotation must be orthonormal and right-handed");
|
|
@@ -2647,7 +2677,7 @@ function validateRigidPose(pose) {
|
|
|
2647
2677
|
Math.abs(x.dot(y)),
|
|
2648
2678
|
Math.abs(x.dot(z)),
|
|
2649
2679
|
Math.abs(y.dot(z)),
|
|
2650
|
-
Math.abs(new
|
|
2680
|
+
Math.abs(new import_matrix6.Vector3(x).cross(y).dot(z) - 1)
|
|
2651
2681
|
];
|
|
2652
2682
|
if (!errors.every(Number.isFinite) || Math.max(...errors) > 1e-6) {
|
|
2653
2683
|
throw new RangeError("Pose rotation must be orthonormal and right-handed");
|
|
@@ -2704,36 +2734,36 @@ var EllipsoidMetrics = class {
|
|
|
2704
2734
|
}
|
|
2705
2735
|
Object.freeze(this);
|
|
2706
2736
|
}
|
|
2707
|
-
meridianDistance(
|
|
2708
|
-
validateLatitude(
|
|
2709
|
-
return Math.sign(
|
|
2737
|
+
meridianDistance(latitude2) {
|
|
2738
|
+
validateLatitude(latitude2);
|
|
2739
|
+
return Math.sign(latitude2) * this.semiMajorAxis * this.meridian(Math.abs(latitude2));
|
|
2710
2740
|
}
|
|
2711
|
-
meridionalCurvatureRadius(
|
|
2712
|
-
validateLatitude(
|
|
2713
|
-
return this.semiMajorAxis * this.meridianIntegrand(
|
|
2741
|
+
meridionalCurvatureRadius(latitude2) {
|
|
2742
|
+
validateLatitude(latitude2);
|
|
2743
|
+
return this.semiMajorAxis * this.meridianIntegrand(latitude2 * DEG);
|
|
2714
2744
|
}
|
|
2715
|
-
transverseCurvatureRadius(
|
|
2716
|
-
validateLatitude(
|
|
2717
|
-
const [s, c] = sincos(
|
|
2745
|
+
transverseCurvatureRadius(latitude2) {
|
|
2746
|
+
validateLatitude(latitude2);
|
|
2747
|
+
const [s, c] = sincos(latitude2);
|
|
2718
2748
|
return this.semiMajorAxis / Math.hypot(c, this.ratio * s);
|
|
2719
2749
|
}
|
|
2720
|
-
normalCurvatureRadius(
|
|
2750
|
+
normalCurvatureRadius(latitude2, azimuth) {
|
|
2721
2751
|
if (!Number.isFinite(azimuth))
|
|
2722
2752
|
throw new Error("Azimuth must be finite");
|
|
2723
2753
|
const [s, c] = sincos(azimuth % 180);
|
|
2724
|
-
return 1 / (c * c / this.meridionalCurvatureRadius(
|
|
2754
|
+
return 1 / (c * c / this.meridionalCurvatureRadius(latitude2) + s * s / this.transverseCurvatureRadius(latitude2));
|
|
2725
2755
|
}
|
|
2726
|
-
latitudeToAuxiliary(
|
|
2756
|
+
latitudeToAuxiliary(latitude2, kind) {
|
|
2727
2757
|
validateKind(kind);
|
|
2728
|
-
validateLatitude(
|
|
2729
|
-
if (
|
|
2730
|
-
return
|
|
2731
|
-
if (Math.abs(
|
|
2732
|
-
return kind === "isometric" ? Math.sign(
|
|
2758
|
+
validateLatitude(latitude2);
|
|
2759
|
+
if (latitude2 === 0)
|
|
2760
|
+
return latitude2;
|
|
2761
|
+
if (Math.abs(latitude2) === 90)
|
|
2762
|
+
return kind === "isometric" ? Math.sign(latitude2) * Infinity : latitude2;
|
|
2733
2763
|
if (this.ratio === 1 && kind !== "isometric")
|
|
2734
|
-
return
|
|
2735
|
-
const sign2 = Math.sign(
|
|
2736
|
-
const phi = Math.abs(
|
|
2764
|
+
return latitude2;
|
|
2765
|
+
const sign2 = Math.sign(latitude2);
|
|
2766
|
+
const phi = Math.abs(latitude2);
|
|
2737
2767
|
const [s, c] = sincos(phi);
|
|
2738
2768
|
switch (kind) {
|
|
2739
2769
|
case "geocentric":
|
|
@@ -2760,21 +2790,21 @@ var EllipsoidMetrics = class {
|
|
|
2760
2790
|
}
|
|
2761
2791
|
}
|
|
2762
2792
|
}
|
|
2763
|
-
latitudeFromAuxiliary(
|
|
2793
|
+
latitudeFromAuxiliary(latitude2, kind) {
|
|
2764
2794
|
validateKind(kind);
|
|
2765
|
-
if (kind === "isometric" && Math.abs(
|
|
2766
|
-
return Math.sign(
|
|
2795
|
+
if (kind === "isometric" && Math.abs(latitude2) === Infinity)
|
|
2796
|
+
return Math.sign(latitude2) * 90;
|
|
2767
2797
|
if (kind !== "isometric")
|
|
2768
|
-
validateLatitude(
|
|
2769
|
-
else if (!Number.isFinite(
|
|
2798
|
+
validateLatitude(latitude2);
|
|
2799
|
+
else if (!Number.isFinite(latitude2))
|
|
2770
2800
|
throw new Error("Isometric latitude must be finite or a pole infinity");
|
|
2771
|
-
if (
|
|
2772
|
-
return
|
|
2773
|
-
if (kind !== "isometric" && Math.abs(
|
|
2774
|
-
return
|
|
2801
|
+
if (latitude2 === 0)
|
|
2802
|
+
return latitude2;
|
|
2803
|
+
if (kind !== "isometric" && Math.abs(latitude2) === 90)
|
|
2804
|
+
return latitude2;
|
|
2775
2805
|
if (this.ratio === 1 && kind !== "isometric")
|
|
2776
|
-
return
|
|
2777
|
-
const sign2 = Math.sign(
|
|
2806
|
+
return latitude2;
|
|
2807
|
+
const sign2 = Math.sign(latitude2), target = Math.abs(latitude2);
|
|
2778
2808
|
if (kind === "geocentric" || kind === "parametric") {
|
|
2779
2809
|
const [s, c] = sincos(target);
|
|
2780
2810
|
return sign2 * angle(s, c * (kind === "geocentric" ? this.ratio ** 2 : this.ratio));
|
|
@@ -2861,12 +2891,12 @@ var SurfacePolygon = class {
|
|
|
2861
2891
|
this.area = new Accumulator();
|
|
2862
2892
|
return this;
|
|
2863
2893
|
}
|
|
2864
|
-
addPoint(
|
|
2865
|
-
if (!(Number.isFinite(
|
|
2894
|
+
addPoint(latitude2, longitude, options = {}) {
|
|
2895
|
+
if (!(Number.isFinite(latitude2) && Math.abs(latitude2) <= 90 && Number.isFinite(longitude))) {
|
|
2866
2896
|
throw new Error("Polygon point requires finite longitude and latitude in [-90, 90]");
|
|
2867
2897
|
}
|
|
2868
2898
|
if (this.count) {
|
|
2869
|
-
const edge2 = this.geodesic.inverse(this.lastLat, this.lastLon,
|
|
2899
|
+
const edge2 = this.geodesic.inverse(this.lastLat, this.lastLon, latitude2, longitude, {
|
|
2870
2900
|
area: !this.polyline,
|
|
2871
2901
|
longitudeTurns: options.longitudeTurns,
|
|
2872
2902
|
unrollLongitude: Boolean(options.longitudeTurns)
|
|
@@ -2876,10 +2906,10 @@ var SurfacePolygon = class {
|
|
|
2876
2906
|
this.crossings = (this.crossings + (options.longitudeTurns ? transitDirect(this.lastLon, edge2.lon2) : transit(this.lastLon, longitude))) % 2;
|
|
2877
2907
|
}
|
|
2878
2908
|
} else {
|
|
2879
|
-
this.firstLat =
|
|
2909
|
+
this.firstLat = latitude2;
|
|
2880
2910
|
this.firstLon = longitude;
|
|
2881
2911
|
}
|
|
2882
|
-
this.lastLat =
|
|
2912
|
+
this.lastLat = latitude2;
|
|
2883
2913
|
this.lastLon = longitude;
|
|
2884
2914
|
++this.count;
|
|
2885
2915
|
return this;
|
|
@@ -2933,8 +2963,8 @@ var SurfacePolygon = class {
|
|
|
2933
2963
|
return { number: this.count, perimeter: this.perimeter.Sum(edge2.s12), area: 0 + total.Sum() };
|
|
2934
2964
|
}
|
|
2935
2965
|
/** Nonmutating preview, with the same compensated arithmetic as insertion. */
|
|
2936
|
-
testPoint(
|
|
2937
|
-
return this.copy().addPoint(
|
|
2966
|
+
testPoint(latitude2, longitude, options = {}) {
|
|
2967
|
+
return this.copy().addPoint(latitude2, longitude, options).compute(options);
|
|
2938
2968
|
}
|
|
2939
2969
|
testEdge(azimuth, distance, options = {}) {
|
|
2940
2970
|
return this.copy().addEdge(azimuth, distance).compute(options);
|
|
@@ -2972,8 +3002,8 @@ var GeodesicPolygon = class extends SurfacePolygon {
|
|
|
2972
3002
|
constructor(parameters, options = {}) {
|
|
2973
3003
|
super(new EllipsoidGeodesic(parameters), options);
|
|
2974
3004
|
}
|
|
2975
|
-
addPoint(
|
|
2976
|
-
return super.addPoint(
|
|
3005
|
+
addPoint(latitude2, longitude) {
|
|
3006
|
+
return super.addPoint(latitude2, longitude);
|
|
2977
3007
|
}
|
|
2978
3008
|
};
|
|
2979
3009
|
|
|
@@ -3004,13 +3034,13 @@ function sc(x) {
|
|
|
3004
3034
|
}
|
|
3005
3035
|
return [s, c];
|
|
3006
3036
|
}
|
|
3007
|
-
function remainingPoleDistance(a, b,
|
|
3037
|
+
function remainingPoleDistance(a, b, latitude2, azimuth, distance, sign2) {
|
|
3008
3038
|
const unit3 = 2 ** Math.floor(Math.log2(a));
|
|
3009
3039
|
a /= unit3;
|
|
3010
3040
|
b /= unit3;
|
|
3011
3041
|
distance /= unit3;
|
|
3012
3042
|
const ratio2 = div(exact(b), exact(a));
|
|
3013
|
-
const theta = mul(90n * Q - BigInt(sign2) * exact(
|
|
3043
|
+
const theta = mul(90n * Q - BigInt(sign2) * exact(latitude2), PI) / 180n;
|
|
3014
3044
|
const [s, c] = sc(theta), prolate = ratio2 > Q;
|
|
3015
3045
|
const square = mul(ratio2, ratio2);
|
|
3016
3046
|
const k = prolate ? Q - div(Q, square) : Q - square;
|
|
@@ -3082,11 +3112,11 @@ var EllipsoidRhumb = class {
|
|
|
3082
3112
|
throw new RangeError("Unrepresentable rhumb distance");
|
|
3083
3113
|
return result;
|
|
3084
3114
|
}
|
|
3085
|
-
direct(
|
|
3086
|
-
return this.line(
|
|
3115
|
+
direct(latitude2, longitude, azimuth, distance, options = {}) {
|
|
3116
|
+
return this.line(latitude2, longitude, azimuth, options).position(distance);
|
|
3087
3117
|
}
|
|
3088
|
-
line(
|
|
3089
|
-
validateRhumbPoint(
|
|
3118
|
+
line(latitude2, longitude, azimuth, options = {}) {
|
|
3119
|
+
validateRhumbPoint(latitude2, longitude);
|
|
3090
3120
|
if (!Number.isFinite(azimuth))
|
|
3091
3121
|
throw new RangeError("Rhumb azimuth must be finite");
|
|
3092
3122
|
const [sa, ca] = sincosDegrees(azimuth);
|
|
@@ -3101,26 +3131,26 @@ var EllipsoidRhumb = class {
|
|
|
3101
3131
|
const north = delta * ca;
|
|
3102
3132
|
let poleDistance;
|
|
3103
3133
|
if (north !== 0) {
|
|
3104
|
-
const gap = north > 0 ? this.meridianDelta(
|
|
3134
|
+
const gap = north > 0 ? this.meridianDelta(latitude2, 90) : this.meridianDelta(-90, latitude2);
|
|
3105
3135
|
poleDistance = gap - Math.abs(north);
|
|
3106
3136
|
if (Math.abs(poleDistance) < 1e-4 * gap)
|
|
3107
|
-
poleDistance = remainingPoleDistance(this.a, this.b,
|
|
3137
|
+
poleDistance = remainingPoleDistance(this.a, this.b, latitude2, azimuth, distance, Math.sign(north));
|
|
3108
3138
|
if (poleDistance < 0)
|
|
3109
3139
|
throw new RhumbDomainError("pole-crossing");
|
|
3110
3140
|
if (poleDistance === 0)
|
|
3111
3141
|
throw new RhumbDomainError("pole");
|
|
3112
3142
|
}
|
|
3113
|
-
const polar = north === 0 ? void 0 : this.polarEndpoint(
|
|
3114
|
-
const lat2 = north === 0 ?
|
|
3143
|
+
const polar = north === 0 ? void 0 : this.polarEndpoint(latitude2, north, poleDistance);
|
|
3144
|
+
const lat2 = north === 0 ? latitude2 : (polar == null ? void 0 : polar.latitude) ?? this.inverseMeridian(latitude2, north);
|
|
3115
3145
|
if (Math.abs(lat2) === 90)
|
|
3116
3146
|
throw new RhumbDomainError("pole");
|
|
3117
|
-
const [meanM, meanP] = (polar == null ? void 0 : polar.means) ?? this.means(
|
|
3147
|
+
const [meanM, meanP] = (polar == null ? void 0 : polar.means) ?? this.means(latitude2, lat2);
|
|
3118
3148
|
const dlon = delta * sa * meanP / meanM / DEG2;
|
|
3119
3149
|
const lon2 = unroll ? longitude + dlon : normalize(normalize(longitude) + dlon);
|
|
3120
3150
|
if (!Number.isFinite(lon2))
|
|
3121
3151
|
throw new RangeError("Unrepresentable rhumb longitude");
|
|
3122
3152
|
const result = output2 ?? {};
|
|
3123
|
-
result.lat1 =
|
|
3153
|
+
result.lat1 = latitude2;
|
|
3124
3154
|
result.lon1 = longitude;
|
|
3125
3155
|
result.lat2 = lat2;
|
|
3126
3156
|
result.lon2 = lon2;
|
|
@@ -3129,7 +3159,7 @@ var EllipsoidRhumb = class {
|
|
|
3129
3159
|
if (!area)
|
|
3130
3160
|
delete result.S12;
|
|
3131
3161
|
if (area)
|
|
3132
|
-
result.S12 = this.area(
|
|
3162
|
+
result.S12 = this.area(latitude2, lat2, dlon * DEG2, polar == null ? void 0 : polar.psi);
|
|
3133
3163
|
return result;
|
|
3134
3164
|
};
|
|
3135
3165
|
return { position: evaluate2 };
|
|
@@ -3145,14 +3175,14 @@ var EllipsoidRhumb = class {
|
|
|
3145
3175
|
}, -1, 1) / 2 : (this.psi(lat2) - this.psi(lat1)) / d;
|
|
3146
3176
|
return [meanM, meanP];
|
|
3147
3177
|
}
|
|
3148
|
-
psi(
|
|
3149
|
-
return this.metrics.latitudeToAuxiliary(
|
|
3178
|
+
psi(latitude2) {
|
|
3179
|
+
return this.metrics.latitudeToAuxiliary(latitude2, "isometric") * DEG2;
|
|
3150
3180
|
}
|
|
3151
|
-
polarEndpoint(
|
|
3152
|
-
const sign2 = Math.abs(
|
|
3181
|
+
polarEndpoint(latitude2, north, poleDistance) {
|
|
3182
|
+
const sign2 = Math.abs(latitude2) > 80 && Math.abs(north) < Math.abs(this.meridianDelta(0, latitude2)) ? Math.sign(latitude2) : Math.sign(north), theta1 = (90 - sign2 * latitude2) * DEG2, limit = 10 * DEG2;
|
|
3153
3183
|
const density = (theta2) => this.r ** 2 / Math.hypot(Math.sin(theta2), this.r * Math.cos(theta2)) ** 3;
|
|
3154
3184
|
const gap = (theta2) => integrate(density, 0, theta2);
|
|
3155
|
-
const target = sign2 === Math.sign(north) ? poleDistance : this.meridianDelta(sign2 > 0 ?
|
|
3185
|
+
const target = sign2 === Math.sign(north) ? poleDistance : this.meridianDelta(sign2 > 0 ? latitude2 : -90, sign2 > 0 ? 90 : latitude2) - sign2 * north;
|
|
3156
3186
|
if (!(target > 0 && target < gap(limit)))
|
|
3157
3187
|
return void 0;
|
|
3158
3188
|
let lo = 0, hi = limit, theta = target * this.r;
|
|
@@ -3248,8 +3278,8 @@ var EllipsoidRhumb = class {
|
|
|
3248
3278
|
}
|
|
3249
3279
|
throw new Error("Rhumb isometric inversion did not converge");
|
|
3250
3280
|
}
|
|
3251
|
-
potential(
|
|
3252
|
-
const [s, c] = latitudeSinCos(
|
|
3281
|
+
potential(latitude2) {
|
|
3282
|
+
const [s, c] = latitudeSinCos(latitude2), e2 = (1 - this.r) * (1 + this.r), e = Math.sqrt(Math.abs(e2));
|
|
3253
3283
|
const I = e === 0 ? s : (e2 > 0 ? Math.atanh(e * s) : Math.atan(e * s)) / e;
|
|
3254
3284
|
return this.r ** 2 * (s / (c * c + (this.r * s) ** 2) + I) / 2;
|
|
3255
3285
|
}
|
|
@@ -3273,10 +3303,10 @@ var EllipsoidRhumb = class {
|
|
|
3273
3303
|
return value3;
|
|
3274
3304
|
}
|
|
3275
3305
|
};
|
|
3276
|
-
function validateRhumbPoint(
|
|
3277
|
-
if (!(Number.isFinite(
|
|
3306
|
+
function validateRhumbPoint(latitude2, longitude) {
|
|
3307
|
+
if (!(Number.isFinite(latitude2) && Math.abs(latitude2) <= 90 && Number.isFinite(longitude)))
|
|
3278
3308
|
throw new RangeError("Rhumb coordinates require finite longitude and latitude in [-90,90]");
|
|
3279
|
-
if (Math.abs(
|
|
3309
|
+
if (Math.abs(latitude2) === 90)
|
|
3280
3310
|
throw new RhumbDomainError("pole");
|
|
3281
3311
|
}
|
|
3282
3312
|
function latitudeSinCos(phi) {
|
|
@@ -3322,11 +3352,11 @@ var RhumbPolygon = class extends SurfacePolygon {
|
|
|
3322
3352
|
constructor(parameters, options = {}) {
|
|
3323
3353
|
super(new EllipsoidRhumb(parameters), options);
|
|
3324
3354
|
}
|
|
3325
|
-
addPoint(
|
|
3326
|
-
validateRhumbPoint(
|
|
3355
|
+
addPoint(latitude2, longitude, options = {}) {
|
|
3356
|
+
validateRhumbPoint(latitude2, longitude);
|
|
3327
3357
|
if (!Number.isSafeInteger(options.longitudeTurns ?? 0))
|
|
3328
3358
|
throw new RangeError("Rhumb longitudeTurns must be a safe integer");
|
|
3329
|
-
return super.addPoint(
|
|
3359
|
+
return super.addPoint(latitude2, longitude, options);
|
|
3330
3360
|
}
|
|
3331
3361
|
};
|
|
3332
3362
|
|
|
@@ -3359,8 +3389,8 @@ var IntersectionBounds = class {
|
|
|
3359
3389
|
}
|
|
3360
3390
|
throw new Error("Conjugate distance did not converge");
|
|
3361
3391
|
}
|
|
3362
|
-
polarDistance(
|
|
3363
|
-
return this.conjugate(this.solver.line(
|
|
3392
|
+
polarDistance(latitude2, ratio2) {
|
|
3393
|
+
return this.conjugate(this.solver.line(latitude2, 0, 0), (1 + (1 - ratio2) / 2) * Math.PI / 2, true);
|
|
3364
3394
|
}
|
|
3365
3395
|
polarMinimum(ratio2) {
|
|
3366
3396
|
let lat0 = 63, lat1 = 65, lat2 = 64;
|
|
@@ -3427,7 +3457,7 @@ var GeodesicIntersections = class {
|
|
|
3427
3457
|
seeds.push([x + spacing * (i + j) / 2, y + spacing * (i - j) / 2, spacing, 0]);
|
|
3428
3458
|
let failed = 0, unresolved = 0;
|
|
3429
3459
|
const isolated = [], lines = [];
|
|
3430
|
-
const
|
|
3460
|
+
const equal2 = (p, q) => Math.abs(p.x - q.x) + Math.abs(p.y - q.y) <= this.bounds.margin;
|
|
3431
3461
|
const canonical = (p, c) => {
|
|
3432
3462
|
const shift2 = (x + c * y - (p.x + c * p.y)) / 2;
|
|
3433
3463
|
return { ...p, x: p.x + shift2, y: p.y + c * shift2, c };
|
|
@@ -3459,14 +3489,14 @@ var GeodesicIntersections = class {
|
|
|
3459
3489
|
retry(seed);
|
|
3460
3490
|
continue;
|
|
3461
3491
|
}
|
|
3462
|
-
if (!lines.some((p) => p.c === q.c &&
|
|
3492
|
+
if (!lines.some((p) => p.c === q.c && equal2(p, q)))
|
|
3463
3493
|
lines.push(q);
|
|
3464
|
-
} else if (!isolated.some((p) =>
|
|
3494
|
+
} else if (!isolated.some((p) => equal2(p, root2)))
|
|
3465
3495
|
isolated.push(root2);
|
|
3466
3496
|
}
|
|
3467
3497
|
const roots2 = [], coincidences = [];
|
|
3468
3498
|
for (const p of isolated) {
|
|
3469
|
-
if (lines.some((q) =>
|
|
3499
|
+
if (lines.some((q) => equal2(canonical(p, q.c), q)))
|
|
3470
3500
|
continue;
|
|
3471
3501
|
if (Math.abs(p.x - x) + Math.abs(p.y - y) > d + this.tolerance)
|
|
3472
3502
|
continue;
|
|
@@ -3522,13 +3552,13 @@ var GeodesicIntersections = class {
|
|
|
3522
3552
|
/** Global next crossing, excluding the shared parameter origin. For a
|
|
3523
3553
|
* coincident continuum use GeographicLib's nearest-conjugate convention.
|
|
3524
3554
|
*/
|
|
3525
|
-
next(
|
|
3526
|
-
const a = { latitude, longitude, azimuth: azimuthA }, b = { latitude, longitude, azimuth: azimuthB };
|
|
3555
|
+
next(latitude2, longitude, azimuthA, azimuthB, maxDistance) {
|
|
3556
|
+
const a = { latitude: latitude2, longitude, azimuth: azimuthA }, b = { latitude: latitude2, longitude, azimuth: azimuthB };
|
|
3527
3557
|
const bound = maxDistance === void 0 ? 4 * this.bounds.halfCircumference : maxDistance / this.a;
|
|
3528
3558
|
const search = this.search(a, b, { maxDistance: maxDistance ?? bound }, maxDistance === void 0);
|
|
3529
3559
|
search.intersections = search.intersections.filter((p) => Math.abs(p.s / this.a) + Math.abs(p.t / this.a) > this.bounds.margin);
|
|
3530
3560
|
const candidates = [...search.intersections];
|
|
3531
|
-
const A3 = this.solver.line(
|
|
3561
|
+
const A3 = this.solver.line(latitude2, longitude, azimuthA);
|
|
3532
3562
|
for (const c of search.coincidences) {
|
|
3533
3563
|
if (Math.abs(c.s / this.a) + Math.abs(c.t / this.a) > this.bounds.margin) {
|
|
3534
3564
|
const point2 = this.coincidencePoint(a, b, c);
|
|
@@ -3824,24 +3854,24 @@ var GeodesicPath = class {
|
|
|
3824
3854
|
if (result.length !== this.size)
|
|
3825
3855
|
throw new RangeError("Invalid geodesic sample output length");
|
|
3826
3856
|
let longitude;
|
|
3827
|
-
let
|
|
3857
|
+
let latitude2;
|
|
3828
3858
|
if (fraction === 0 || this.length === 0) {
|
|
3829
3859
|
longitude = this.first[0];
|
|
3830
|
-
|
|
3860
|
+
latitude2 = this.first[1];
|
|
3831
3861
|
} else if (fraction === 1) {
|
|
3832
3862
|
longitude = this.last[0];
|
|
3833
|
-
|
|
3863
|
+
latitude2 = this.last[1];
|
|
3834
3864
|
} else {
|
|
3835
3865
|
const value3 = this.line.position(this.length * fraction);
|
|
3836
3866
|
longitude = value3.lon2;
|
|
3837
|
-
|
|
3867
|
+
latitude2 = value3.lat2;
|
|
3838
3868
|
}
|
|
3839
3869
|
const height = this.size === 3 ? this.first[2] * (1 - fraction) + this.last[2] * fraction : 0;
|
|
3840
|
-
if (![longitude,
|
|
3870
|
+
if (![longitude, latitude2, height].every(Number.isFinite) || result instanceof Float32Array && ![longitude, latitude2, height].every((value3) => Number.isFinite(Math.fround(value3)))) {
|
|
3841
3871
|
throw new RangeError("Unrepresentable geodesic sample");
|
|
3842
3872
|
}
|
|
3843
3873
|
result[0] = longitude;
|
|
3844
|
-
result[1] =
|
|
3874
|
+
result[1] = latitude2;
|
|
3845
3875
|
if (this.size === 3)
|
|
3846
3876
|
result[2] = height;
|
|
3847
3877
|
return result;
|
|
@@ -3919,21 +3949,21 @@ var RhumbPath = class {
|
|
|
3919
3949
|
throw new RangeError("Rhumb fraction must be in [0, 1]");
|
|
3920
3950
|
if (result.length !== this.size || ArrayBuffer.isView(result) && !(result instanceof Float32Array) && !(result instanceof Float64Array))
|
|
3921
3951
|
throw new RangeError("Expected a floating rhumb output with matching dimensions");
|
|
3922
|
-
let longitude = this.first[0],
|
|
3952
|
+
let longitude = this.first[0], latitude2 = this.first[1];
|
|
3923
3953
|
if (fraction === 1) {
|
|
3924
3954
|
longitude = this.last[0];
|
|
3925
|
-
|
|
3955
|
+
latitude2 = this.last[1];
|
|
3926
3956
|
} else if (fraction !== 0 && this.length !== 0) {
|
|
3927
3957
|
const p = this.line.position(this.length * fraction);
|
|
3928
3958
|
longitude = p.lon2;
|
|
3929
|
-
|
|
3959
|
+
latitude2 = p.lat2;
|
|
3930
3960
|
}
|
|
3931
3961
|
const height = this.size === 3 ? this.first[2] * (1 - fraction) + this.last[2] * fraction : 0;
|
|
3932
|
-
const values = [longitude,
|
|
3962
|
+
const values = [longitude, latitude2, height];
|
|
3933
3963
|
if (!values.every(Number.isFinite) || result instanceof Float32Array && !values.every((x) => Number.isFinite(Math.fround(x))))
|
|
3934
3964
|
throw new RangeError("Unrepresentable rhumb sample");
|
|
3935
3965
|
result[0] = longitude;
|
|
3936
|
-
result[1] =
|
|
3966
|
+
result[1] = latitude2;
|
|
3937
3967
|
if (this.size === 3)
|
|
3938
3968
|
result[2] = height;
|
|
3939
3969
|
return result;
|
|
@@ -3946,14 +3976,14 @@ var RhumbPath = class {
|
|
|
3946
3976
|
};
|
|
3947
3977
|
|
|
3948
3978
|
// dist/ellipsoid-transforms.js
|
|
3949
|
-
var
|
|
3979
|
+
var import_matrix10 = require("@math.gl/core/matrix");
|
|
3950
3980
|
|
|
3951
3981
|
// dist/ellipsoid-helpers/ellipsoid-transform.js
|
|
3952
|
-
var
|
|
3953
|
-
var
|
|
3982
|
+
var import_matrix8 = require("@math.gl/core/matrix");
|
|
3983
|
+
var import_matrix9 = require("@math.gl/core/matrix");
|
|
3954
3984
|
var EPSILON14 = 1e-14;
|
|
3955
|
-
var scratchOrigin = new
|
|
3956
|
-
var scratchBasis = (0,
|
|
3985
|
+
var scratchOrigin = new import_matrix8.Vector3();
|
|
3986
|
+
var scratchBasis = (0, import_matrix9.createLocalFrameBasis)();
|
|
3957
3987
|
var VECTOR_PRODUCT_LOCAL_FRAME = {
|
|
3958
3988
|
up: {
|
|
3959
3989
|
south: "east",
|
|
@@ -4001,19 +4031,19 @@ var degeneratePositionLocalFrame = {
|
|
|
4001
4031
|
down: [0, 0, -1]
|
|
4002
4032
|
};
|
|
4003
4033
|
var scratchAxisVectors = {
|
|
4004
|
-
east: new
|
|
4005
|
-
north: new
|
|
4006
|
-
up: new
|
|
4007
|
-
west: new
|
|
4008
|
-
south: new
|
|
4009
|
-
down: new
|
|
4034
|
+
east: new import_matrix8.Vector3(),
|
|
4035
|
+
north: new import_matrix8.Vector3(),
|
|
4036
|
+
up: new import_matrix8.Vector3(),
|
|
4037
|
+
west: new import_matrix8.Vector3(),
|
|
4038
|
+
south: new import_matrix8.Vector3(),
|
|
4039
|
+
down: new import_matrix8.Vector3()
|
|
4010
4040
|
};
|
|
4011
|
-
var scratchVector1 = new
|
|
4012
|
-
var scratchVector22 = new
|
|
4013
|
-
var scratchVector3 = new
|
|
4041
|
+
var scratchVector1 = new import_matrix8.Vector3();
|
|
4042
|
+
var scratchVector22 = new import_matrix8.Vector3();
|
|
4043
|
+
var scratchVector3 = new import_matrix8.Vector3();
|
|
4014
4044
|
function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
|
|
4015
4045
|
const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
|
|
4016
|
-
(0,
|
|
4046
|
+
(0, import_matrix8.assert)(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
|
|
4017
4047
|
let firstAxisVector;
|
|
4018
4048
|
let secondAxisVector;
|
|
4019
4049
|
let thirdAxisVector;
|
|
@@ -4024,16 +4054,16 @@ function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, car
|
|
|
4024
4054
|
const atPole = Math.abs(origin.x) <= poleTolerance && Math.abs(origin.y) <= poleTolerance;
|
|
4025
4055
|
const radii = ellipsoid.radii;
|
|
4026
4056
|
if (radii.x === radii.y && radii.x > 0 && radii.z > 0 && radii.z <= radii.x && (!atPole || origin.z !== 0)) {
|
|
4027
|
-
const { east, up } = scratchAxisVectors;
|
|
4057
|
+
const { east, up: up2 } = scratchAxisVectors;
|
|
4028
4058
|
if (atPole) {
|
|
4029
4059
|
east.set(0, 1, 0);
|
|
4030
|
-
|
|
4060
|
+
up2.set(0, 0, Math.sign(origin.z));
|
|
4031
4061
|
} else {
|
|
4032
4062
|
const scale3 = Math.max(Math.abs(origin.x), Math.abs(origin.y));
|
|
4033
4063
|
east.set(-origin.y / scale3, origin.x / scale3, 0).normalize();
|
|
4034
|
-
ellipsoid.geodeticSurfaceNormal(origin,
|
|
4064
|
+
ellipsoid.geodeticSurfaceNormal(origin, up2);
|
|
4035
4065
|
}
|
|
4036
|
-
if (!(0,
|
|
4066
|
+
if (!(0, import_matrix9.eastNorthUpBasisFromDirections)(east, up2, scratchBasis) || !(0, import_matrix9.localFrameToMatrix)(scratchBasis, origin, firstAxis, secondAxis, thirdAxis, result))
|
|
4037
4067
|
throw new Error("Unsupported local frame");
|
|
4038
4068
|
return result;
|
|
4039
4069
|
}
|
|
@@ -4052,13 +4082,13 @@ function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, car
|
|
|
4052
4082
|
thirdAxisVector.scale(sign2);
|
|
4053
4083
|
}
|
|
4054
4084
|
} else {
|
|
4055
|
-
const { up, east, north } = scratchAxisVectors;
|
|
4085
|
+
const { up: up2, east, north } = scratchAxisVectors;
|
|
4056
4086
|
const scale3 = Math.max(Math.abs(origin.x), Math.abs(origin.y));
|
|
4057
4087
|
east.set(-origin.y / scale3, origin.x / scale3, 0).normalize();
|
|
4058
|
-
ellipsoid.geodeticSurfaceNormal(origin,
|
|
4059
|
-
north.copy(
|
|
4060
|
-
const { down, west, south } = scratchAxisVectors;
|
|
4061
|
-
|
|
4088
|
+
ellipsoid.geodeticSurfaceNormal(origin, up2);
|
|
4089
|
+
north.copy(up2).cross(east);
|
|
4090
|
+
const { down: down2, west, south } = scratchAxisVectors;
|
|
4091
|
+
down2.copy(up2).scale(-1);
|
|
4062
4092
|
west.copy(east).scale(-1);
|
|
4063
4093
|
south.copy(north).scale(-1);
|
|
4064
4094
|
firstAxisVector = scratchAxisVectors[firstAxis];
|
|
@@ -4089,15 +4119,15 @@ function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, car
|
|
|
4089
4119
|
}
|
|
4090
4120
|
|
|
4091
4121
|
// dist/ellipsoid-transforms.js
|
|
4092
|
-
function eastNorthUpToFixedFrame(ellipsoid, origin, result = new
|
|
4122
|
+
function eastNorthUpToFixedFrame(ellipsoid, origin, result = new import_matrix10.Matrix4()) {
|
|
4093
4123
|
return localFrameToFixedFrame(ellipsoid, "east", "north", "up", origin, result);
|
|
4094
4124
|
}
|
|
4095
|
-
function localFrameToFixedFrame2(ellipsoid, firstAxis, secondAxis, thirdAxis, origin, result = new
|
|
4125
|
+
function localFrameToFixedFrame2(ellipsoid, firstAxis, secondAxis, thirdAxis, origin, result = new import_matrix10.Matrix4()) {
|
|
4096
4126
|
return localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
4097
4127
|
}
|
|
4098
4128
|
|
|
4099
4129
|
// dist/lng-lat-rectangle.js
|
|
4100
|
-
var
|
|
4130
|
+
var import_matrix11 = require("@math.gl/core/matrix");
|
|
4101
4131
|
var LngLatRectangle = class {
|
|
4102
4132
|
/**
|
|
4103
4133
|
* Creates a new two dimensional region specified as longitude and latitude coordinates.
|
|
@@ -4122,16 +4152,16 @@ var LngLatRectangle = class {
|
|
|
4122
4152
|
*/
|
|
4123
4153
|
static center(rectangle, result) {
|
|
4124
4154
|
if (!result)
|
|
4125
|
-
result = new
|
|
4155
|
+
result = new import_matrix11.Vector3();
|
|
4126
4156
|
let east = rectangle.east;
|
|
4127
4157
|
const west = rectangle.west;
|
|
4128
4158
|
if (east < west) {
|
|
4129
|
-
east +=
|
|
4159
|
+
east += import_matrix11._MathUtils.TWO_PI;
|
|
4130
4160
|
}
|
|
4131
|
-
const longitude = (0,
|
|
4132
|
-
const
|
|
4161
|
+
const longitude = (0, import_matrix11.normalizeAngle)((west + east) * 0.5, "negative-pi-to-pi");
|
|
4162
|
+
const latitude2 = (rectangle.south + rectangle.north) * 0.5;
|
|
4133
4163
|
result.x = longitude;
|
|
4134
|
-
result.y =
|
|
4164
|
+
result.y = latitude2;
|
|
4135
4165
|
result.z = 0;
|
|
4136
4166
|
return result;
|
|
4137
4167
|
}
|
|
@@ -4139,47 +4169,47 @@ var LngLatRectangle = class {
|
|
|
4139
4169
|
let east = this.east;
|
|
4140
4170
|
const west = this.west;
|
|
4141
4171
|
if (east < west) {
|
|
4142
|
-
east +=
|
|
4172
|
+
east += import_matrix11._MathUtils.TWO_PI;
|
|
4143
4173
|
}
|
|
4144
4174
|
return east - west;
|
|
4145
4175
|
}
|
|
4146
4176
|
};
|
|
4147
4177
|
|
|
4148
4178
|
// dist/make-obb-from-region.js
|
|
4149
|
-
var
|
|
4179
|
+
var import_matrix12 = require("@math.gl/core/matrix");
|
|
4150
4180
|
var import_culling2 = require("@math.gl/geometry/culling");
|
|
4151
|
-
var scratchOffset = new
|
|
4152
|
-
var scratchTangentPoint = new
|
|
4153
|
-
var scratchPerimeterCartographicNC = new
|
|
4154
|
-
var scratchPerimeterCartographicNW = new
|
|
4155
|
-
var scratchPerimeterCartographicCW = new
|
|
4156
|
-
var scratchPerimeterCartographicSW = new
|
|
4157
|
-
var scratchPerimeterCartographicSC = new
|
|
4158
|
-
var scratchPerimeterCartesianNC = new
|
|
4159
|
-
var scratchPerimeterCartesianNW = new
|
|
4160
|
-
var scratchPerimeterCartesianCW = new
|
|
4161
|
-
var scratchPerimeterCartesianSW = new
|
|
4162
|
-
var scratchPerimeterCartesianSC = new
|
|
4163
|
-
var scratchPerimeterProjectedNC = new
|
|
4164
|
-
var scratchPerimeterProjectedNW = new
|
|
4165
|
-
var scratchPerimeterProjectedCW = new
|
|
4166
|
-
var scratchPerimeterProjectedSW = new
|
|
4167
|
-
var scratchPerimeterProjectedSC = new
|
|
4181
|
+
var scratchOffset = new import_matrix12.Vector3();
|
|
4182
|
+
var scratchTangentPoint = new import_matrix12.Vector3();
|
|
4183
|
+
var scratchPerimeterCartographicNC = new import_matrix12.Vector3();
|
|
4184
|
+
var scratchPerimeterCartographicNW = new import_matrix12.Vector3();
|
|
4185
|
+
var scratchPerimeterCartographicCW = new import_matrix12.Vector3();
|
|
4186
|
+
var scratchPerimeterCartographicSW = new import_matrix12.Vector3();
|
|
4187
|
+
var scratchPerimeterCartographicSC = new import_matrix12.Vector3();
|
|
4188
|
+
var scratchPerimeterCartesianNC = new import_matrix12.Vector3();
|
|
4189
|
+
var scratchPerimeterCartesianNW = new import_matrix12.Vector3();
|
|
4190
|
+
var scratchPerimeterCartesianCW = new import_matrix12.Vector3();
|
|
4191
|
+
var scratchPerimeterCartesianSW = new import_matrix12.Vector3();
|
|
4192
|
+
var scratchPerimeterCartesianSC = new import_matrix12.Vector3();
|
|
4193
|
+
var scratchPerimeterProjectedNC = new import_matrix12.Vector2();
|
|
4194
|
+
var scratchPerimeterProjectedNW = new import_matrix12.Vector2();
|
|
4195
|
+
var scratchPerimeterProjectedCW = new import_matrix12.Vector2();
|
|
4196
|
+
var scratchPerimeterProjectedSW = new import_matrix12.Vector2();
|
|
4197
|
+
var scratchPerimeterProjectedSC = new import_matrix12.Vector2();
|
|
4168
4198
|
var scratchPlane = new import_culling2.Plane();
|
|
4169
|
-
var scratchPlaneOrigin = new
|
|
4170
|
-
var scratchPlaneNormal = new
|
|
4171
|
-
var scratchPlaneXAxis = new
|
|
4172
|
-
var scratchHorizonCartesian = new
|
|
4173
|
-
var scratchHorizonProjected = new
|
|
4174
|
-
var scratchMaxY = new
|
|
4175
|
-
var scratchZ = new
|
|
4176
|
-
var VECTOR3_UNIT_X = new
|
|
4177
|
-
var VECTOR3_UNIT_Z = new
|
|
4199
|
+
var scratchPlaneOrigin = new import_matrix12.Vector3();
|
|
4200
|
+
var scratchPlaneNormal = new import_matrix12.Vector3();
|
|
4201
|
+
var scratchPlaneXAxis = new import_matrix12.Vector3();
|
|
4202
|
+
var scratchHorizonCartesian = new import_matrix12.Vector3();
|
|
4203
|
+
var scratchHorizonProjected = new import_matrix12.Vector2();
|
|
4204
|
+
var scratchMaxY = new import_matrix12.Vector3();
|
|
4205
|
+
var scratchZ = new import_matrix12.Vector3();
|
|
4206
|
+
var VECTOR3_UNIT_X = new import_matrix12.Vector3(1, 0, 0);
|
|
4207
|
+
var VECTOR3_UNIT_Z = new import_matrix12.Vector3(0, 0, 1);
|
|
4178
4208
|
function makeOBBFromRegion(region, ellipsoid = Ellipsoid.WGS84, options = {}) {
|
|
4179
4209
|
if (!region || region.length !== 6 || region.some((value3) => !Number.isFinite(value3))) {
|
|
4180
4210
|
throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");
|
|
4181
4211
|
}
|
|
4182
|
-
const unitScale = options.units === "degrees" ? (0,
|
|
4212
|
+
const unitScale = options.units === "degrees" ? (0, import_matrix12.radians)(1) : 1;
|
|
4183
4213
|
const [rawWest, rawSouth, rawEast, rawNorth, minimumHeight, maximumHeight] = region;
|
|
4184
4214
|
if (minimumHeight > maximumHeight) {
|
|
4185
4215
|
throw new Error("makeOBBFromRegion: minimumHeight must not exceed maximumHeight");
|
|
@@ -4189,26 +4219,26 @@ function makeOBBFromRegion(region, ellipsoid = Ellipsoid.WGS84, options = {}) {
|
|
|
4189
4219
|
const west = normalizeLongitude(rawWest * unitScale);
|
|
4190
4220
|
let east = normalizeLongitude(rawEast * unitScale);
|
|
4191
4221
|
const directedSpan = rawEast * unitScale - rawWest * unitScale;
|
|
4192
|
-
if (directedSpan >=
|
|
4193
|
-
east = west +
|
|
4222
|
+
if (directedSpan >= import_matrix12._MathUtils.TWO_PI - 1e-12) {
|
|
4223
|
+
east = west + import_matrix12._MathUtils.TWO_PI;
|
|
4194
4224
|
}
|
|
4195
4225
|
const latitudeTolerance = 1e-12;
|
|
4196
|
-
if (south > north || south < -
|
|
4226
|
+
if (south > north || south < -import_matrix12._MathUtils.PI_OVER_TWO - latitudeTolerance || north > import_matrix12._MathUtils.PI_OVER_TWO + latitudeTolerance) {
|
|
4197
4227
|
throw new Error("makeOBBFromRegion: latitude must be within [-\u03C0/2, \u03C0/2] and south \u2264 north");
|
|
4198
4228
|
}
|
|
4199
|
-
const clampedSouth = Math.max(-
|
|
4200
|
-
const clampedNorth = Math.max(-
|
|
4229
|
+
const clampedSouth = Math.max(-import_matrix12._MathUtils.PI_OVER_TWO, Math.min(import_matrix12._MathUtils.PI_OVER_TWO, south));
|
|
4230
|
+
const clampedNorth = Math.max(-import_matrix12._MathUtils.PI_OVER_TWO, Math.min(import_matrix12._MathUtils.PI_OVER_TWO, north));
|
|
4201
4231
|
return makeOBBFromNormalizedRegion([west, clampedSouth, east, clampedNorth, minimumHeight, maximumHeight], ellipsoid, options.transform);
|
|
4202
4232
|
}
|
|
4203
4233
|
function normalizeLongitude(value3) {
|
|
4204
|
-
const normalized = ((value3 + Math.PI) %
|
|
4234
|
+
const normalized = ((value3 + Math.PI) % import_matrix12._MathUtils.TWO_PI + import_matrix12._MathUtils.TWO_PI) % import_matrix12._MathUtils.TWO_PI - Math.PI;
|
|
4205
4235
|
return normalized === -Math.PI && value3 > 0 ? Math.PI : normalized;
|
|
4206
4236
|
}
|
|
4207
4237
|
function makeOBBFromNormalizedRegion(region, ellipsoid, transform) {
|
|
4208
4238
|
const obb = new import_culling2.OrientedBoundingBox();
|
|
4209
4239
|
const [west, south, east, north, minimumHeight, maximumHeight] = region;
|
|
4210
|
-
const northDeg = (0,
|
|
4211
|
-
const southDeg = (0,
|
|
4240
|
+
const northDeg = (0, import_matrix12.degrees)(north);
|
|
4241
|
+
const southDeg = (0, import_matrix12.degrees)(south);
|
|
4212
4242
|
let maxX;
|
|
4213
4243
|
let maxY;
|
|
4214
4244
|
let maxZ;
|
|
@@ -4218,15 +4248,15 @@ function makeOBBFromNormalizedRegion(region, ellipsoid, transform) {
|
|
|
4218
4248
|
let plane;
|
|
4219
4249
|
const rectangle = new LngLatRectangle(west, south, east, north);
|
|
4220
4250
|
const tangentPoint = LngLatRectangle.center(rectangle, scratchTangentPoint);
|
|
4221
|
-
const tangentPointCartographic = new
|
|
4222
|
-
(0,
|
|
4223
|
-
(0,
|
|
4251
|
+
const tangentPointCartographic = new import_matrix12.Vector3([
|
|
4252
|
+
(0, import_matrix12.degrees)(tangentPoint.x),
|
|
4253
|
+
(0, import_matrix12.degrees)(tangentPoint.y),
|
|
4224
4254
|
0
|
|
4225
4255
|
]);
|
|
4226
4256
|
const lonCenter = tangentPoint.x;
|
|
4227
4257
|
const lonCenterDeg = tangentPointCartographic.x;
|
|
4228
|
-
if (rectangle.width <=
|
|
4229
|
-
const westDeg = (0,
|
|
4258
|
+
if (rectangle.width <= import_matrix12._MathUtils.PI) {
|
|
4259
|
+
const westDeg = (0, import_matrix12.degrees)(west);
|
|
4230
4260
|
const tangentPoint2 = ellipsoid.cartographicToCartesian(tangentPointCartographic);
|
|
4231
4261
|
const ellipsoidTangentPlane = new EllipsoidTangentPlane(tangentPoint2, ellipsoid);
|
|
4232
4262
|
const latCenter = southDeg < 0 && northDeg > 0 ? 0 : tangentPointCartographic.y;
|
|
@@ -4277,18 +4307,18 @@ function makeOBBFromNormalizedRegion(region, ellipsoid, transform) {
|
|
|
4277
4307
|
maxZ = maximumHeight;
|
|
4278
4308
|
return applyTransform(fromPlaneExtents(ellipsoidTangentPlane.origin, ellipsoidTangentPlane.xAxis, ellipsoidTangentPlane.yAxis, ellipsoidTangentPlane.zAxis, minX, maxX, minY, maxY, minZ, maxZ, obb), transform);
|
|
4279
4309
|
}
|
|
4280
|
-
const eastDeg = (0,
|
|
4310
|
+
const eastDeg = (0, import_matrix12.degrees)(east);
|
|
4281
4311
|
const fullyAboveEquator = south > 0;
|
|
4282
4312
|
const fullyBelowEquator = north < 0;
|
|
4283
4313
|
const latitudeNearestToEquator = fullyAboveEquator ? southDeg : fullyBelowEquator ? northDeg : 0;
|
|
4284
4314
|
const planeOrigin = ellipsoid.cartographicToCartesian([lonCenterDeg, latitudeNearestToEquator, maximumHeight], scratchPlaneOrigin);
|
|
4285
4315
|
planeOrigin.z = 0;
|
|
4286
|
-
const isPole = Math.abs(planeOrigin.x) <
|
|
4316
|
+
const isPole = Math.abs(planeOrigin.x) < import_matrix12._MathUtils.EPSILON10 && Math.abs(planeOrigin.y) < import_matrix12._MathUtils.EPSILON10;
|
|
4287
4317
|
const planeNormal = !isPole ? scratchPlaneNormal.copy(planeOrigin).normalize() : VECTOR3_UNIT_X;
|
|
4288
4318
|
const planeYAxis = VECTOR3_UNIT_Z;
|
|
4289
4319
|
const planeXAxis = scratchPlaneXAxis.copy(planeNormal).cross(planeYAxis);
|
|
4290
4320
|
plane = scratchPlane.fromPointNormal(planeOrigin, planeNormal);
|
|
4291
|
-
const horizonCartesian = ellipsoid.cartographicToCartesian([(0,
|
|
4321
|
+
const horizonCartesian = ellipsoid.cartographicToCartesian([(0, import_matrix12.degrees)(lonCenter + import_matrix12._MathUtils.PI_OVER_TWO), latitudeNearestToEquator, maximumHeight], scratchHorizonCartesian);
|
|
4292
4322
|
const projectedPoint = plane.projectPointOntoPlane(horizonCartesian, scratchHorizonProjected);
|
|
4293
4323
|
maxX = projectedPoint.dot(planeXAxis);
|
|
4294
4324
|
minX = -maxX;
|
|
@@ -4304,15 +4334,15 @@ function makeOBBFromNormalizedRegion(region, ellipsoid, transform) {
|
|
|
4304
4334
|
function applyTransform(obb, transform) {
|
|
4305
4335
|
if (!transform)
|
|
4306
4336
|
return obb;
|
|
4307
|
-
const axes = [0, 1, 2].map((column) => obb.halfAxes.getColumn(column, new
|
|
4337
|
+
const axes = [0, 1, 2].map((column) => obb.halfAxes.getColumn(column, new import_matrix12.Vector3()));
|
|
4308
4338
|
const center = transform.transformAsPoint(obb.center);
|
|
4309
4339
|
const minimum = [Infinity, Infinity, Infinity];
|
|
4310
4340
|
const maximum = [-Infinity, -Infinity, -Infinity];
|
|
4311
4341
|
for (let mask = 0; mask < 8; mask++) {
|
|
4312
|
-
const corner = new
|
|
4342
|
+
const corner = new import_matrix12.Vector3(center);
|
|
4313
4343
|
for (let axis = 0; axis < 3; axis++) {
|
|
4314
4344
|
const transformedAxis = transform.transformAsVector(axes[axis]);
|
|
4315
|
-
corner.add(new
|
|
4345
|
+
corner.add(new import_matrix12.Vector3(transformedAxis).scale((mask & 1 << axis) === 0 ? -1 : 1));
|
|
4316
4346
|
}
|
|
4317
4347
|
for (let component = 0; component < 3; component++) {
|
|
4318
4348
|
minimum[component] = Math.min(minimum[component], corner[component]);
|
|
@@ -4320,14 +4350,14 @@ function applyTransform(obb, transform) {
|
|
|
4320
4350
|
}
|
|
4321
4351
|
}
|
|
4322
4352
|
obb.center.copy(minimum).add(maximum).scale(0.5);
|
|
4323
|
-
const halfSize = new
|
|
4324
|
-
obb.halfAxes = new
|
|
4353
|
+
const halfSize = new import_matrix12.Vector3(maximum).subtract(minimum).scale(0.5);
|
|
4354
|
+
obb.halfAxes = new import_matrix12.Matrix3().set(halfSize.x, 0, 0, 0, halfSize.y, 0, 0, 0, halfSize.z);
|
|
4325
4355
|
return obb;
|
|
4326
4356
|
}
|
|
4327
|
-
function latitudeZExtent(ellipsoid,
|
|
4357
|
+
function latitudeZExtent(ellipsoid, latitude2, height, maximum) {
|
|
4328
4358
|
let extent = maximum ? -Infinity : Infinity;
|
|
4329
4359
|
for (const longitude of [0, 90, 180, 270]) {
|
|
4330
|
-
const z = ellipsoid.cartographicToCartesian([longitude,
|
|
4360
|
+
const z = ellipsoid.cartographicToCartesian([longitude, latitude2, height], scratchMaxY).z;
|
|
4331
4361
|
extent = maximum ? Math.max(extent, z) : Math.min(extent, z);
|
|
4332
4362
|
}
|
|
4333
4363
|
return extent;
|
|
@@ -4468,16 +4498,16 @@ function getGlobeHorizonBounds(camera, radius) {
|
|
|
4468
4498
|
throw new RangeError("Camera magnitude must be finite");
|
|
4469
4499
|
if (distance <= radius)
|
|
4470
4500
|
return void 0;
|
|
4471
|
-
const
|
|
4501
|
+
const latitude2 = Math.atan2(camera[2], Math.hypot(camera[0], camera[1]));
|
|
4472
4502
|
const longitude = Math.atan2(camera[1], camera[0]);
|
|
4473
4503
|
const angle3 = Math.acos(radius / distance);
|
|
4474
4504
|
const degrees2 = 180 / Math.PI;
|
|
4475
4505
|
const padding = 1e-10;
|
|
4476
|
-
const south = Math.max(-90, (
|
|
4477
|
-
const north = Math.min(90, (
|
|
4478
|
-
if (Math.abs(
|
|
4506
|
+
const south = Math.max(-90, (latitude2 - angle3) * degrees2 - padding);
|
|
4507
|
+
const north = Math.min(90, (latitude2 + angle3) * degrees2 + padding);
|
|
4508
|
+
if (Math.abs(latitude2) + angle3 >= Math.PI / 2 - 1e-12)
|
|
4479
4509
|
return [-180, south, 180, north];
|
|
4480
|
-
const extent = Math.asin(Math.min(1, Math.sin(angle3) / Math.cos(
|
|
4510
|
+
const extent = Math.asin(Math.min(1, Math.sin(angle3) / Math.cos(latitude2))) * degrees2 + padding;
|
|
4481
4511
|
return [wrap(longitude * degrees2 - extent), south, wrap(longitude * degrees2 + extent), north];
|
|
4482
4512
|
}
|
|
4483
4513
|
function splitGlobeBounds(bounds2) {
|
|
@@ -4494,7 +4524,7 @@ function wrap(longitude) {
|
|
|
4494
4524
|
}
|
|
4495
4525
|
|
|
4496
4526
|
// dist/subdivide-globe-mesh.js
|
|
4497
|
-
var
|
|
4527
|
+
var import_matrix13 = require("@math.gl/core/matrix");
|
|
4498
4528
|
var import_geometry = require("@math.gl/geometry");
|
|
4499
4529
|
function subdivideGlobeMesh(mesh, options) {
|
|
4500
4530
|
const { semiMajorAxis = 6371e3, semiMinorAxis = semiMajorAxis, size = 2, ...limits } = options;
|
|
@@ -4525,7 +4555,7 @@ function subdivideGlobeMesh(mesh, options) {
|
|
|
4525
4555
|
y: position2[1] * Math.PI / 180,
|
|
4526
4556
|
z: size === 3 ? position2[2] : 0
|
|
4527
4557
|
};
|
|
4528
|
-
if (!(0,
|
|
4558
|
+
if (!(0, import_matrix13.spheroidToCartesian)(point2, geometry))
|
|
4529
4559
|
return null;
|
|
4530
4560
|
return [point2.x, point2.y, point2.z];
|
|
4531
4561
|
}
|
|
@@ -4834,11 +4864,11 @@ function createEdges(start, end, originalStart, edgeIndex, ringIndex, turns, con
|
|
|
4834
4864
|
}
|
|
4835
4865
|
const c1 = Math.cos(inverse4.azi1 * Math.PI / 180), c2 = Math.cos(inverse4.azi2 * Math.PI / 180);
|
|
4836
4866
|
if (path.length > 0 && oppositeMeridians(originalStart[0], end[0]) && (inverse4.azi1 === 0 || Math.abs(inverse4.azi1) === 180) && Math.abs(first[1]) !== 90 && Math.abs(last[1]) !== 90) {
|
|
4837
|
-
const
|
|
4867
|
+
const latitude2 = c1 > 0 ? 90 : -90;
|
|
4838
4868
|
context.tick(2);
|
|
4839
|
-
const fraction = solver.inverse(start[1], start[0],
|
|
4840
|
-
if (fraction > 0 && fraction < 1 && Math.abs(path.sample(fraction)[1] -
|
|
4841
|
-
pole = { fraction, latitude };
|
|
4869
|
+
const fraction = solver.inverse(start[1], start[0], latitude2, start[0]).s12 / path.length;
|
|
4870
|
+
if (fraction > 0 && fraction < 1 && Math.abs(path.sample(fraction)[1] - latitude2) < ANGULAR_TOLERANCE)
|
|
4871
|
+
pole = { fraction, latitude: latitude2 };
|
|
4842
4872
|
} else if (splitLatitude && c1 * c2 < 0 && path.length > 0) {
|
|
4843
4873
|
context.tick();
|
|
4844
4874
|
const line = solver.line(originalStart[1], originalStart[0], inverse4.azi1, {
|
|
@@ -4948,13 +4978,13 @@ function readLatitudeRange(value3) {
|
|
|
4948
4978
|
}
|
|
4949
4979
|
function clipLatitudeEdge(edge2, range, context) {
|
|
4950
4980
|
const fractions = [0, 1], events = /* @__PURE__ */ new Map();
|
|
4951
|
-
for (const
|
|
4952
|
-
if (
|
|
4953
|
-
const t = root(edge2, 1,
|
|
4954
|
-
if (events.has(t) && events.get(t) !==
|
|
4981
|
+
for (const latitude2 of range)
|
|
4982
|
+
if (latitude2 > Math.min(edge2.a[1], edge2.b[1]) && latitude2 < Math.max(edge2.a[1], edge2.b[1])) {
|
|
4983
|
+
const t = root(edge2, 1, latitude2, context);
|
|
4984
|
+
if (events.has(t) && events.get(t) !== latitude2)
|
|
4955
4985
|
throw new GeographicSeamError("precision", "Unresolvable latitude events");
|
|
4956
4986
|
fractions.push(t);
|
|
4957
|
-
events.set(t,
|
|
4987
|
+
events.set(t, latitude2);
|
|
4958
4988
|
}
|
|
4959
4989
|
fractions.sort((a, b) => a - b);
|
|
4960
4990
|
const result = [];
|
|
@@ -4977,9 +5007,9 @@ function clipLatitudeEdge(edge2, range, context) {
|
|
|
4977
5007
|
}
|
|
4978
5008
|
|
|
4979
5009
|
// dist/geographic-seams/polygon.js
|
|
4980
|
-
function winding(
|
|
5010
|
+
function winding(edges2, point2, context, side, generatedBoundary = true, longitudeShift = 0, verticalSide) {
|
|
4981
5011
|
let value3 = 0, boundary = false;
|
|
4982
|
-
for (const edge2 of
|
|
5012
|
+
for (const edge2 of edges2) {
|
|
4983
5013
|
context.tick();
|
|
4984
5014
|
const a = edge2.a, b = edge2.b;
|
|
4985
5015
|
if (a[1] === b[1]) {
|
|
@@ -5021,59 +5051,59 @@ function prepare(input, index, context) {
|
|
|
5021
5051
|
const turns = input.longitudeTurns ? Array.from(input.longitudeTurns) : new Array(positions.length).fill(0);
|
|
5022
5052
|
if (turns.length !== positions.length)
|
|
5023
5053
|
throw new GeographicSeamError("input", "Expected a turn count per ring edge");
|
|
5024
|
-
const
|
|
5054
|
+
const edges2 = [];
|
|
5025
5055
|
let cursor = positions[0];
|
|
5026
5056
|
for (let i = 0; i < positions.length; i++) {
|
|
5027
5057
|
const end = positions[(i + 1) % positions.length];
|
|
5028
5058
|
const pieces = createEdges(cursor, end, positions[i], i, index, turns[i], context);
|
|
5029
|
-
if (
|
|
5059
|
+
if (edges2.length && !same(cursor, pieces[0].a)) {
|
|
5030
5060
|
if (Math.abs(cursor[1]) !== 90 || cursor[1] !== pieces[0].a[1])
|
|
5031
5061
|
throw new GeographicSeamError("precision", "Discontinuous ring edge");
|
|
5032
|
-
|
|
5062
|
+
edges2.push(straight(cursor, pieces[0].a));
|
|
5033
5063
|
}
|
|
5034
5064
|
for (const edge2 of pieces) {
|
|
5035
5065
|
if (edge2.a[0] === edge2.b[0] && edge2.a[1] === edge2.b[1]) {
|
|
5036
5066
|
if (!same(edge2.a, edge2.b))
|
|
5037
5067
|
throw new GeographicSeamError("topology", "Zero-length polygon edge changes attributes");
|
|
5038
5068
|
} else
|
|
5039
|
-
|
|
5069
|
+
edges2.push(edge2);
|
|
5040
5070
|
}
|
|
5041
5071
|
cursor = pieces[pieces.length - 1].b;
|
|
5042
5072
|
}
|
|
5043
|
-
if (!
|
|
5073
|
+
if (!edges2.length)
|
|
5044
5074
|
throw new GeographicSeamError("topology", "Empty polygon boundary");
|
|
5045
|
-
const first =
|
|
5075
|
+
const first = edges2[0].a;
|
|
5046
5076
|
if (Math.abs(first[1]) === 90) {
|
|
5047
5077
|
const closing = first.slice();
|
|
5048
5078
|
closing[0] += 360 * Math.round((cursor[0] - first[0]) / 360);
|
|
5049
5079
|
if (!same(cursor, closing))
|
|
5050
|
-
|
|
5080
|
+
edges2.push(straight(cursor, closing));
|
|
5051
5081
|
cursor = closing;
|
|
5052
5082
|
}
|
|
5053
5083
|
const turnsAround = Math.round((cursor[0] - first[0]) / 360);
|
|
5054
5084
|
if (Math.abs(cursor[0] - first[0] - 360 * turnsAround) > ANGULAR_TOLERANCE || cursor[1] !== first[1] || Math.abs(turnsAround) > 1)
|
|
5055
5085
|
throw new GeographicSeamError("topology", "Unsupported ring winding");
|
|
5056
5086
|
let min = Infinity, max = -Infinity;
|
|
5057
|
-
for (const e of
|
|
5087
|
+
for (const e of edges2) {
|
|
5058
5088
|
min = Math.min(min, e.a[0], e.b[0]);
|
|
5059
5089
|
max = Math.max(max, e.a[0], e.b[0]);
|
|
5060
5090
|
}
|
|
5061
5091
|
if (max - min > 360 + ANGULAR_TOLERANCE)
|
|
5062
5092
|
throw new GeographicSeamError("topology", "Ring exceeds a single longitude chart");
|
|
5063
|
-
const membership =
|
|
5093
|
+
const membership = edges2.slice();
|
|
5064
5094
|
const poleAttributes = input.poleAttributes ? Array.from(input.poleAttributes) : [];
|
|
5065
5095
|
if (turnsAround !== 0) {
|
|
5066
|
-
if (!["north", "south"].includes(input.pole) ||
|
|
5096
|
+
if (!["north", "south"].includes(input.pole) || edges2.some((e) => Math.abs(e.a[1]) === 90 || (e.b[0] - e.a[0]) * turnsAround < 0))
|
|
5067
5097
|
throw new GeographicSeamError("topology", "Polar rings require an explicit pole and monotone longitude winding");
|
|
5068
5098
|
if (poleAttributes.length !== context.size - 2 || !poleAttributes.every(Number.isFinite))
|
|
5069
5099
|
throw new GeographicSeamError("input", "Explicit poleAttributes are required for polar attributes");
|
|
5070
|
-
const
|
|
5071
|
-
const a = [cursor[0],
|
|
5100
|
+
const latitude2 = input.pole === "north" ? 90 : -90;
|
|
5101
|
+
const a = [cursor[0], latitude2, ...poleAttributes], b = [first[0], latitude2, ...poleAttributes];
|
|
5072
5102
|
membership.push(straight(cursor, a), straight(a, b), straight(b, first));
|
|
5073
5103
|
} else if (input.pole !== void 0 || poleAttributes.length) {
|
|
5074
5104
|
throw new GeographicSeamError("input", "Pole selection applies only to once-winding polar rings");
|
|
5075
5105
|
}
|
|
5076
|
-
return { edges, membership, min, max, pole: input.pole, poleAttributes };
|
|
5106
|
+
return { edges: edges2, membership, min, max, pole: input.pole, poleAttributes };
|
|
5077
5107
|
}
|
|
5078
5108
|
function reverse(edge2) {
|
|
5079
5109
|
return {
|
|
@@ -5094,8 +5124,8 @@ function canonicalAlias(edge2, context) {
|
|
|
5094
5124
|
};
|
|
5095
5125
|
return { ...edge2, a: move(edge2.a), b: move(edge2.b), sample: (t) => move(edge2.sample(t)) };
|
|
5096
5126
|
}
|
|
5097
|
-
function interior(
|
|
5098
|
-
const ys = Array.from(new Set(
|
|
5127
|
+
function interior(edges2, context) {
|
|
5128
|
+
const ys = Array.from(new Set(edges2.flatMap((e) => [e.a[1], e.b[1]]))).sort((a, b) => a - b);
|
|
5099
5129
|
let index = 1;
|
|
5100
5130
|
for (let i = 2; i < ys.length; i++)
|
|
5101
5131
|
if (ys[i] - ys[i - 1] > ys[index] - ys[index - 1])
|
|
@@ -5103,7 +5133,7 @@ function interior(edges, context) {
|
|
|
5103
5133
|
if (ys.length < 2 || ys[index] - ys[index - 1] < 8 * ANGULAR_TOLERANCE)
|
|
5104
5134
|
throw new GeographicSeamError("precision", "Polygon height below the topology budget");
|
|
5105
5135
|
const y = (ys[index] + ys[index - 1]) / 2, xs = [];
|
|
5106
|
-
for (const edge2 of
|
|
5136
|
+
for (const edge2 of edges2) {
|
|
5107
5137
|
context.tick();
|
|
5108
5138
|
if (edge2.a[1] > y !== edge2.b[1] > y)
|
|
5109
5139
|
xs.push(edge2.sample(root(edge2, 1, y, context))[0]);
|
|
@@ -5113,7 +5143,7 @@ function interior(edges, context) {
|
|
|
5113
5143
|
context.tick();
|
|
5114
5144
|
if (xs[i] - xs[i - 1] < 8 * ANGULAR_TOLERANCE)
|
|
5115
5145
|
continue;
|
|
5116
|
-
const point2 = [(xs[i] + xs[i - 1]) / 2, y], w = winding(
|
|
5146
|
+
const point2 = [(xs[i] + xs[i - 1]) / 2, y], w = winding(edges2, point2, context);
|
|
5117
5147
|
if (w.value && !w.boundary) {
|
|
5118
5148
|
if (Math.abs(w.value) !== 1)
|
|
5119
5149
|
throw new GeographicSeamError("topology", "Non-simple polygon winding");
|
|
@@ -5122,13 +5152,13 @@ function interior(edges, context) {
|
|
|
5122
5152
|
}
|
|
5123
5153
|
throw new GeographicSeamError("topology", "No resolvable polygon interior");
|
|
5124
5154
|
}
|
|
5125
|
-
function output(
|
|
5126
|
-
if (interior(
|
|
5127
|
-
|
|
5128
|
-
context.addVertices(
|
|
5155
|
+
function output(edges2, sign2, context) {
|
|
5156
|
+
if (interior(edges2, context).sign !== sign2)
|
|
5157
|
+
edges2 = edges2.slice().reverse().map(reverse);
|
|
5158
|
+
context.addVertices(edges2.length + 1);
|
|
5129
5159
|
return {
|
|
5130
|
-
positions: new Float64Array([...
|
|
5131
|
-
edges:
|
|
5160
|
+
positions: new Float64Array([...edges2.flatMap((e) => e.a), ...edges2[0].a]),
|
|
5161
|
+
edges: edges2.map((e) => e.source && { ...e.source })
|
|
5132
5162
|
};
|
|
5133
5163
|
}
|
|
5134
5164
|
function splitGeographicPolygon(inputs, options) {
|
|
@@ -5216,13 +5246,13 @@ function processPolygon(inputs, options, latitudeRange) {
|
|
|
5216
5246
|
piece.b[1] = latitudes.get(fractions[i]);
|
|
5217
5247
|
if (fractions.length > 2)
|
|
5218
5248
|
context.addVertices(2);
|
|
5219
|
-
const x = piece.a[0],
|
|
5249
|
+
const x = piece.a[0], latitude2 = (piece.a[1] + piece.b[1]) / 2;
|
|
5220
5250
|
const seam = x === context.left;
|
|
5221
5251
|
const ring = piece.source && rings[piece.source.ringIndex];
|
|
5222
|
-
if (ring && ring.max - ring.min >= 360 - ANGULAR_TOLERANCE && contains(ring, [x,
|
|
5252
|
+
if (ring && ring.max - ring.min >= 360 - ANGULAR_TOLERANCE && contains(ring, [x, latitude2], context, seam ? "right" : "left") && contains(ring, [seam ? context.right : x, latitude2], context, seam ? "left" : "right"))
|
|
5223
5253
|
continue;
|
|
5224
|
-
const left = filled(rings, [x,
|
|
5225
|
-
const right = filled(rings, [seam ? context.right : x,
|
|
5254
|
+
const left = filled(rings, [x, latitude2], context, seam ? "right" : "left");
|
|
5255
|
+
const right = filled(rings, [seam ? context.right : x, latitude2], context, seam ? "left" : "right");
|
|
5226
5256
|
if (left && right)
|
|
5227
5257
|
continue;
|
|
5228
5258
|
if (!left && !right)
|
|
@@ -5242,20 +5272,20 @@ function processPolygon(inputs, options, latitudeRange) {
|
|
|
5242
5272
|
}
|
|
5243
5273
|
const pole = rings[0].pole;
|
|
5244
5274
|
if (pole && !rings.slice(1).some((r) => r.pole === pole)) {
|
|
5245
|
-
const
|
|
5246
|
-
add4(straight([context.left,
|
|
5275
|
+
const latitude2 = pole === "north" ? 90 : -90;
|
|
5276
|
+
add4(straight([context.left, latitude2, ...rings[0].poleAttributes], [context.right, latitude2, ...rings[0].poleAttributes]));
|
|
5247
5277
|
}
|
|
5248
5278
|
for (const boundary of [context.left, context.right]) {
|
|
5249
5279
|
const boundaryNodes = Array.from(nodes.values()).filter((n) => n.p[0] === boundary).sort((a, b) => a.p[1] - b.p[1]);
|
|
5250
5280
|
const aligned = graph.filter((e) => e.a[0] === boundary && e.b[0] === boundary);
|
|
5251
5281
|
for (let i = 1; i < boundaryNodes.length; i++) {
|
|
5252
5282
|
context.tick();
|
|
5253
|
-
const a = boundaryNodes[i - 1].p, b = boundaryNodes[i].p,
|
|
5254
|
-
if (
|
|
5283
|
+
const a = boundaryNodes[i - 1].p, b = boundaryNodes[i].p, latitude2 = (a[1] + b[1]) / 2;
|
|
5284
|
+
if (latitude2 === a[1] || latitude2 === b[1])
|
|
5255
5285
|
throw new GeographicSeamError("precision", "Unresolvable seam event separation");
|
|
5256
|
-
if (filled(rings, [boundary,
|
|
5286
|
+
if (filled(rings, [boundary, latitude2], context, boundary === context.left ? "right" : "left") && !aligned.some((e) => {
|
|
5257
5287
|
context.tick();
|
|
5258
|
-
return
|
|
5288
|
+
return latitude2 > Math.min(e.a[1], e.b[1]) && latitude2 < Math.max(e.a[1], e.b[1]);
|
|
5259
5289
|
}))
|
|
5260
5290
|
add4(straight(a, b));
|
|
5261
5291
|
}
|
|
@@ -5361,8 +5391,8 @@ function splitGeographicPolyline(input, options) {
|
|
|
5361
5391
|
const parts = [];
|
|
5362
5392
|
let cursor = points[0];
|
|
5363
5393
|
for (let i = 1; i < points.length; i++) {
|
|
5364
|
-
const
|
|
5365
|
-
for (const original of
|
|
5394
|
+
const edges2 = createEdges(cursor, points[i], points[i - 1], i - 1, 0, turns[i - 1], context, false);
|
|
5395
|
+
for (const original of edges2) {
|
|
5366
5396
|
if (!original.source)
|
|
5367
5397
|
continue;
|
|
5368
5398
|
for (const { edge: edge2, world } of cut(original, context)) {
|
|
@@ -5374,7 +5404,7 @@ function splitGeographicPolyline(input, options) {
|
|
|
5374
5404
|
parts.push({ points: [edge2.a, edge2.b], edges: [edge2.source], world });
|
|
5375
5405
|
}
|
|
5376
5406
|
}
|
|
5377
|
-
cursor =
|
|
5407
|
+
cursor = edges2[edges2.length - 1].b;
|
|
5378
5408
|
}
|
|
5379
5409
|
return parts.map((part) => ({
|
|
5380
5410
|
positions: new Float64Array(part.points.flat()),
|
|
@@ -5395,13 +5425,13 @@ function getGeographicTileBounds(tile) {
|
|
|
5395
5425
|
90 - 180 * tile.y / size
|
|
5396
5426
|
];
|
|
5397
5427
|
}
|
|
5398
|
-
function getGeographicTile(longitude,
|
|
5428
|
+
function getGeographicTile(longitude, latitude2, level) {
|
|
5399
5429
|
const size = gridSize(level);
|
|
5400
|
-
if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180 || !Number.isFinite(
|
|
5430
|
+
if (!Number.isFinite(longitude) || longitude < -180 || longitude > 180 || !Number.isFinite(latitude2) || latitude2 < -90 || latitude2 > 90)
|
|
5401
5431
|
throw new RangeError("Expected longitude in [-180, 180] and latitude in [-90, 90]");
|
|
5402
5432
|
return {
|
|
5403
5433
|
x: Math.min(size - 1, Math.floor((longitude + 180) / 360 * size)),
|
|
5404
|
-
y: Math.min(size - 1, Math.floor((90 -
|
|
5434
|
+
y: Math.min(size - 1, Math.floor((90 - latitude2) / 180 * size)),
|
|
5405
5435
|
level
|
|
5406
5436
|
};
|
|
5407
5437
|
}
|
|
@@ -6945,10 +6975,10 @@ function requireValue(condition, field) {
|
|
|
6945
6975
|
|
|
6946
6976
|
// dist/web-mercator.js
|
|
6947
6977
|
var web_mercator_exports = {};
|
|
6948
|
-
__reExport(web_mercator_exports, require("@math.gl/web-mercator"));
|
|
6978
|
+
__reExport(web_mercator_exports, require("@math.gl/geospatial/web-mercator"));
|
|
6949
6979
|
|
|
6950
6980
|
// dist/expressions.js
|
|
6951
|
-
var
|
|
6981
|
+
var import_matrix14 = require("@math.gl/core/matrix");
|
|
6952
6982
|
var GEOSPATIAL_FUNCTION_LIBRARY = {
|
|
6953
6983
|
cartesianToCartographic: (cartesian, result) => Ellipsoid.WGS84.cartesianToCartographic(cartesian, result),
|
|
6954
6984
|
cartographicToCartesian: (cartographic, result) => Ellipsoid.WGS84.cartographicToCartesian(cartographic, result),
|
|
@@ -6958,8 +6988,8 @@ var GEOSPATIAL_FUNCTION_LIBRARY = {
|
|
|
6958
6988
|
isWGS84,
|
|
6959
6989
|
scaleToGeocentricSurface: (cartesian, result) => Ellipsoid.WGS84.scaleToGeocentricSurface(cartesian, result),
|
|
6960
6990
|
scaleToGeodeticSurface: (cartesian, result) => Ellipsoid.WGS84.scaleToGeodeticSurface(cartesian, result),
|
|
6961
|
-
toDegrees:
|
|
6962
|
-
toRadians:
|
|
6991
|
+
toDegrees: import_matrix14.toDegrees,
|
|
6992
|
+
toRadians: import_matrix14.toRadians,
|
|
6963
6993
|
transformPositionFromScaledSpace: (position2, result) => Ellipsoid.WGS84.transformPositionFromScaledSpace(position2, result),
|
|
6964
6994
|
transformPositionToScaledSpace: (position2, result) => Ellipsoid.WGS84.transformPositionToScaledSpace(position2, result)
|
|
6965
6995
|
};
|
|
@@ -7343,9 +7373,9 @@ function reverseArc(e) {
|
|
|
7343
7373
|
} : { ...d, startAngle: d.endAngle, endAngle: d.startAngle }
|
|
7344
7374
|
};
|
|
7345
7375
|
}
|
|
7346
|
-
function crossings(
|
|
7376
|
+
function crossings(edges2, y, frame2, context) {
|
|
7347
7377
|
const direction = frame2.v.map((x, i) => x - y * frame2.center[i]), m = Math.hypot(...direction), query = circle("ray", unit(direction), y / m), result = [];
|
|
7348
|
-
for (const edge2 of
|
|
7378
|
+
for (const edge2 of edges2) {
|
|
7349
7379
|
const hits = roots(edge2.curve, query, context);
|
|
7350
7380
|
if (hits.coincident)
|
|
7351
7381
|
throw new GeographicSeamError("precision", "Interior ray coincides with a boundary");
|
|
@@ -7358,25 +7388,25 @@ function crossings(edges, y, frame2, context) {
|
|
|
7358
7388
|
}
|
|
7359
7389
|
return result.sort((a, b) => a.x - b.x);
|
|
7360
7390
|
}
|
|
7361
|
-
function winding2(
|
|
7391
|
+
function winding2(edges2, n, frame2, context) {
|
|
7362
7392
|
const [x, y] = chartPoint2(frame2, n);
|
|
7363
|
-
return crossings(
|
|
7393
|
+
return crossings(edges2, y, frame2, context).reduce((s, p) => s + (p.x > x ? p.sign : 0), 0);
|
|
7364
7394
|
}
|
|
7365
|
-
function orientation(
|
|
7366
|
-
const ys = Array.from(new Set(
|
|
7395
|
+
function orientation(edges2, frame2, context) {
|
|
7396
|
+
const ys = Array.from(new Set(edges2.map((e) => chartPoint2(frame2, e.a.n)[1]))).sort((a, b) => a - b);
|
|
7367
7397
|
const bands = ys.slice(1).map((y, i) => [ys[i], y]).sort((a, b) => b[1] - b[0] - (a[1] - a[0]));
|
|
7368
7398
|
for (const [lo, hi] of bands) {
|
|
7369
7399
|
if (hi - lo < 1e-11)
|
|
7370
7400
|
continue;
|
|
7371
|
-
const hits = crossings(
|
|
7401
|
+
const hits = crossings(edges2, (lo + hi) / 2, frame2, context);
|
|
7372
7402
|
for (let i = 1; i < hits.length; i++)
|
|
7373
7403
|
if (hits[i].x - hits[i - 1].x > 1e-11) {
|
|
7374
|
-
const n = chartNormal(frame2, (hits[i].x + hits[i - 1].x) / 2, (lo + hi) / 2), w = winding2(
|
|
7404
|
+
const n = chartNormal(frame2, (hits[i].x + hits[i - 1].x) / 2, (lo + hi) / 2), w = winding2(edges2, n, frame2, context);
|
|
7375
7405
|
if (w)
|
|
7376
7406
|
return Math.sign(w);
|
|
7377
7407
|
}
|
|
7378
7408
|
}
|
|
7379
|
-
for (const edge2 of
|
|
7409
|
+
for (const edge2 of edges2)
|
|
7380
7410
|
for (const t of [0.371, 0.613, 0.5]) {
|
|
7381
7411
|
context.tick();
|
|
7382
7412
|
const n = normal(edge2.curve.sample(t)), left = cross3(n, edge2.curve.derivative(t));
|
|
@@ -7388,7 +7418,7 @@ function orientation(edges, frame2, context) {
|
|
|
7388
7418
|
context.tick();
|
|
7389
7419
|
const probe = unit(add(n, scale(direction, side * epsilon)));
|
|
7390
7420
|
try {
|
|
7391
|
-
const w = winding2(
|
|
7421
|
+
const w = winding2(edges2, probe, frame2, context);
|
|
7392
7422
|
if (w)
|
|
7393
7423
|
return Math.sign(w);
|
|
7394
7424
|
} catch (error) {
|
|
@@ -7526,12 +7556,12 @@ function subdivideAtlasRing(sources, boundaries, ring, options, context, axes, c
|
|
|
7526
7556
|
};
|
|
7527
7557
|
}
|
|
7528
7558
|
});
|
|
7529
|
-
const
|
|
7559
|
+
const edges2 = [];
|
|
7530
7560
|
for (let i = 1; i < result.segmentIndices.length; i++) {
|
|
7531
7561
|
const index = result.segmentIndices[i], edge2 = descriptors[index], lo = result.segmentIndices[i - 1] === index ? result.segmentFractions[i - 1] : 0, hi = result.segmentFractions[i];
|
|
7532
7562
|
if (edge2.kind === "source") {
|
|
7533
7563
|
const s = edge2.source, d = s.endFraction - s.startFraction;
|
|
7534
|
-
|
|
7564
|
+
edges2.push({
|
|
7535
7565
|
kind: "source",
|
|
7536
7566
|
source: {
|
|
7537
7567
|
...s,
|
|
@@ -7541,14 +7571,14 @@ function subdivideAtlasRing(sources, boundaries, ring, options, context, axes, c
|
|
|
7541
7571
|
});
|
|
7542
7572
|
} else {
|
|
7543
7573
|
const d = edge2.endAngle - edge2.startAngle;
|
|
7544
|
-
|
|
7574
|
+
edges2.push({
|
|
7545
7575
|
...edge2,
|
|
7546
7576
|
startAngle: edge2.startAngle + d * lo,
|
|
7547
7577
|
endAngle: edge2.startAngle + d * hi
|
|
7548
7578
|
});
|
|
7549
7579
|
}
|
|
7550
7580
|
}
|
|
7551
|
-
return { ...result, edges };
|
|
7581
|
+
return { ...result, edges: edges2 };
|
|
7552
7582
|
}
|
|
7553
7583
|
|
|
7554
7584
|
// dist/geographic-atlas/atlas.js
|
|
@@ -7556,9 +7586,9 @@ var key = (n) => n.map((x) => x === 0 ? 0 : x).join(",");
|
|
|
7556
7586
|
function fail(message) {
|
|
7557
7587
|
throw new GeographicSeamError("input", message);
|
|
7558
7588
|
}
|
|
7559
|
-
function mergeEdges(
|
|
7589
|
+
function mergeEdges(edges2) {
|
|
7560
7590
|
const groups = /* @__PURE__ */ new Map();
|
|
7561
|
-
for (const e of
|
|
7591
|
+
for (const e of edges2)
|
|
7562
7592
|
if (e.source) {
|
|
7563
7593
|
const k = e.source.ringIndex + ":" + e.source.edgeIndex;
|
|
7564
7594
|
const list = groups.get(k) ?? [];
|
|
@@ -7736,11 +7766,11 @@ var GeographicCutAtlas = class {
|
|
|
7736
7766
|
}
|
|
7737
7767
|
return this.clip(sources, context);
|
|
7738
7768
|
}
|
|
7739
|
-
clip(sources, context,
|
|
7769
|
+
clip(sources, context, contains3, sign2 = 1) {
|
|
7740
7770
|
const registry = /* @__PURE__ */ new Map(), events = new Map(this.boundaries.map((c) => [c.id, /* @__PURE__ */ new Set()]));
|
|
7741
7771
|
let serial = 0;
|
|
7742
7772
|
const node = (n, attributes, source = false) => {
|
|
7743
|
-
const k = key(n) + (!
|
|
7773
|
+
const k = key(n) + (!contains3 && source ? "|" + attributes.join(",") : ""), previous = registry.get(k);
|
|
7744
7774
|
if (previous) {
|
|
7745
7775
|
if (source && previous.source && attributes.some((x, i) => x !== previous.p[i + 2]))
|
|
7746
7776
|
throw new GeographicSeamError("topology", "Shared source vertex attributes disagree");
|
|
@@ -7817,7 +7847,7 @@ var GeographicCutAtlas = class {
|
|
|
7817
7847
|
if (value(b, v.n) === 0)
|
|
7818
7848
|
on2(v, b);
|
|
7819
7849
|
}
|
|
7820
|
-
if (!
|
|
7850
|
+
if (!contains3 && Math.hypot(...endpoints[0].n.map((x, i) => x - endpoints[1].n[i])) === 0 && curve.speed > ANGULAR) {
|
|
7821
7851
|
const steps = Math.max(4, Math.ceil(curve.speed / (Math.PI / 2)));
|
|
7822
7852
|
if (steps > context.maxVertices)
|
|
7823
7853
|
throw new GeographicSeamError("limit", "Too many closed-line samples");
|
|
@@ -7882,12 +7912,12 @@ var GeographicCutAtlas = class {
|
|
|
7882
7912
|
const n = normal(arc.curve.sample(0.5));
|
|
7883
7913
|
if (!accepts(cell, n, arc.coincident))
|
|
7884
7914
|
continue;
|
|
7885
|
-
if (
|
|
7915
|
+
if (contains3 && cell.cuts.some((r) => {
|
|
7886
7916
|
var _a;
|
|
7887
7917
|
return ((_a = arc.coincident) == null ? void 0 : _a.has(r.circle.id)) && r.side * dot2(r.circle.normal, cross3(n, arc.curve.derivative(0.5))) < 0;
|
|
7888
7918
|
}))
|
|
7889
7919
|
continue;
|
|
7890
|
-
if (!
|
|
7920
|
+
if (!contains3) {
|
|
7891
7921
|
const coincident = cell.cuts.filter((r) => {
|
|
7892
7922
|
var _a;
|
|
7893
7923
|
return (_a = arc.coincident) == null ? void 0 : _a.has(r.circle.id);
|
|
@@ -7900,7 +7930,7 @@ var GeographicCutAtlas = class {
|
|
|
7900
7930
|
}
|
|
7901
7931
|
arcs.push(arc);
|
|
7902
7932
|
}
|
|
7903
|
-
if (!
|
|
7933
|
+
if (!contains3) {
|
|
7904
7934
|
const parts = [];
|
|
7905
7935
|
for (const e of arcs) {
|
|
7906
7936
|
context.tick();
|
|
@@ -7933,7 +7963,7 @@ var GeographicCutAtlas = class {
|
|
|
7933
7963
|
continue;
|
|
7934
7964
|
}
|
|
7935
7965
|
const midpoint = onCircle(b, (a.angle + hi) / 2), known = /* @__PURE__ */ new Set([b.id]);
|
|
7936
|
-
if (!accepts(cell, midpoint, known) || !
|
|
7966
|
+
if (!accepts(cell, midpoint, known) || !contains3(midpoint))
|
|
7937
7967
|
continue;
|
|
7938
7968
|
if (sourceArcs.some((e) => {
|
|
7939
7969
|
var _a;
|
|
@@ -8028,8 +8058,8 @@ function createOctahedralCutGraph() {
|
|
|
8028
8058
|
}
|
|
8029
8059
|
function createOctahedralCutAtlas(options) {
|
|
8030
8060
|
const graph = createOctahedralCutGraph(), atlas = new GeographicCutAtlas(graph, options), frames = new Map(graph.charts.map((c) => {
|
|
8031
|
-
const center = unit(c.center), [right,
|
|
8032
|
-
return [c.id, { center, right, up }];
|
|
8061
|
+
const center = unit(c.center), [right, up2] = basis(center);
|
|
8062
|
+
return [c.id, { center, right, up: up2 }];
|
|
8033
8063
|
}));
|
|
8034
8064
|
const project2 = (chart, p) => {
|
|
8035
8065
|
const frame2 = frames.get(chart);
|
|
@@ -8217,12 +8247,12 @@ var GeodesicPolygonExact = class extends SurfacePolygon {
|
|
|
8217
8247
|
direct: (a, b, c, d, opts) => solver.direct(a, b % 720, c, d, opts)
|
|
8218
8248
|
}, options);
|
|
8219
8249
|
}
|
|
8220
|
-
addPoint(
|
|
8250
|
+
addPoint(latitude2, longitude, options = {}) {
|
|
8221
8251
|
if (Math.abs(longitude) > 1e6)
|
|
8222
8252
|
throw new RangeError("Exact polygon longitude exceeds input profile");
|
|
8223
8253
|
if (options.longitudeTurns !== void 0 && options.longitudeTurns !== 0)
|
|
8224
8254
|
throw new RangeError("Exact geodesic point insertion does not select winding routes; use addEdge");
|
|
8225
|
-
return super.addPoint(
|
|
8255
|
+
return super.addPoint(latitude2, longitude);
|
|
8226
8256
|
}
|
|
8227
8257
|
};
|
|
8228
8258
|
|
|
@@ -8440,9 +8470,9 @@ function integrateGeodesic(initial, q, distance) {
|
|
|
8440
8470
|
for (let i = 0; i < 3; i++)
|
|
8441
8471
|
state[i] /= surface2;
|
|
8442
8472
|
const normal2 = state.slice(0, 3).map((x, i) => q[i] * x), nn = normal2.reduce((s, x) => s + x * x, 0);
|
|
8443
|
-
const
|
|
8473
|
+
const dot5 = normal2.reduce((s, x, i) => s + x * state[i + 3], 0) / nn;
|
|
8444
8474
|
for (let i = 0; i < 3; i++)
|
|
8445
|
-
state[i + 3] -= normal2[i] *
|
|
8475
|
+
state[i + 3] -= normal2[i] * dot5;
|
|
8446
8476
|
const speed = Math.hypot(state[3], state[4], state[5]);
|
|
8447
8477
|
for (let i = 3; i < 6; i++)
|
|
8448
8478
|
state[i] /= speed;
|
|
@@ -8508,11 +8538,11 @@ var TriaxialEllipsoid = class {
|
|
|
8508
8538
|
}
|
|
8509
8539
|
throw new RangeError("Surface sampling work limit exceeded");
|
|
8510
8540
|
}
|
|
8511
|
-
toCartesian(
|
|
8541
|
+
toCartesian(latitude2, longitude, coordinates = "geodetic") {
|
|
8512
8542
|
system(coordinates);
|
|
8513
|
-
if (!Number.isFinite(
|
|
8543
|
+
if (!Number.isFinite(latitude2) || Math.abs(latitude2) > 90 || !Number.isFinite(longitude))
|
|
8514
8544
|
throw new RangeError("Invalid triaxial latitude/longitude");
|
|
8515
|
-
const p = trig(
|
|
8545
|
+
const p = trig(latitude2), l = trig(longitude), n = [p.c * l.c, p.c * l.s, p.s], r = this.axes;
|
|
8516
8546
|
if (coordinates === "parametric")
|
|
8517
8547
|
return n.map((x, i) => x * this.radii[i]);
|
|
8518
8548
|
const denominator = coordinates === "geodetic" ? Math.hypot(...n.map((x, i) => x * r[i])) : Math.hypot(...n.map((x, i) => x / r[i]));
|
|
@@ -8551,12 +8581,12 @@ var TriaxialEllipsoid = class {
|
|
|
8551
8581
|
basis(position2) {
|
|
8552
8582
|
const p = this.surface(position2), normal2 = unit2(p.map((x, i) => x / this.axes[i] ** 2));
|
|
8553
8583
|
const horizontal = Math.hypot(p[0], p[1]), meridian = horizontal ? [-p[1] / horizontal, p[0] / horizontal, 0] : [0, 1, 0];
|
|
8554
|
-
const
|
|
8584
|
+
const cross7 = (a, b) => [
|
|
8555
8585
|
a[1] * b[2] - a[2] * b[1],
|
|
8556
8586
|
a[2] * b[0] - a[0] * b[2],
|
|
8557
8587
|
a[0] * b[1] - a[1] * b[0]
|
|
8558
8588
|
];
|
|
8559
|
-
const north = unit2(
|
|
8589
|
+
const north = unit2(cross7(normal2, meridian)), east = unit2(cross7(north, normal2));
|
|
8560
8590
|
return { north, east, normal: normal2 };
|
|
8561
8591
|
}
|
|
8562
8592
|
/** Cartesian initial-value geodesic. No global triaxial inverse is implied. */
|
|
@@ -8662,8 +8692,8 @@ function parseGeographicCoordinates(text, options = {}) {
|
|
|
8662
8692
|
longitude: parseAngle(lon, "longitude")
|
|
8663
8693
|
};
|
|
8664
8694
|
}
|
|
8665
|
-
function formatGeographicCoordinates(
|
|
8666
|
-
const lat = formatAngle(
|
|
8695
|
+
function formatGeographicCoordinates(latitude2, longitude, options = {}) {
|
|
8696
|
+
const lat = formatAngle(latitude2, { ...options, axis: "latitude" }), lon = formatAngle(longitude, { ...options, axis: "longitude" });
|
|
8667
8697
|
return (options.longitudeFirst ? [lon, lat] : [lat, lon]).join(", ");
|
|
8668
8698
|
}
|
|
8669
8699
|
|
|
@@ -8806,13 +8836,13 @@ function intersectGeographicBounds(a, b) {
|
|
|
8806
8836
|
}
|
|
8807
8837
|
function clampGeographicPoint(bounds2, point2) {
|
|
8808
8838
|
let longitude = normalizeLongitude2(point2[0]);
|
|
8809
|
-
const
|
|
8810
|
-
if (!containsGeographicPoint(bounds2, [longitude,
|
|
8839
|
+
const latitude2 = Math.max(bounds2[1], Math.min(bounds2[3], point2[1]));
|
|
8840
|
+
if (!containsGeographicPoint(bounds2, [longitude, latitude2])) {
|
|
8811
8841
|
const westDistance = Math.abs(normalizeLongitude2(longitude - bounds2[0]));
|
|
8812
8842
|
const eastDistance = Math.abs(normalizeLongitude2(longitude - bounds2[2]));
|
|
8813
8843
|
longitude = westDistance <= eastDistance ? bounds2[0] : bounds2[2];
|
|
8814
8844
|
}
|
|
8815
|
-
return [longitude,
|
|
8845
|
+
return [longitude, latitude2];
|
|
8816
8846
|
}
|
|
8817
8847
|
function getAngularRanges(bounds2, primeMeridian = 0, origin = 0) {
|
|
8818
8848
|
const width = getLongitudeSpan(bounds2);
|
|
@@ -9072,10 +9102,10 @@ function bindKernel(name, state, forward4, inverse4, adapt = createProjection) {
|
|
|
9072
9102
|
function guardAzimuthalDomain(base, implementation) {
|
|
9073
9103
|
const forward4 = projectionOperation(implementation, false);
|
|
9074
9104
|
return createProjection((point2) => {
|
|
9075
|
-
const longitude = point2.x,
|
|
9105
|
+
const longitude = point2.x, latitude2 = point2.y;
|
|
9076
9106
|
const delta = Math.atan2(Math.sin(longitude - base.long0), Math.cos(longitude - base.long0));
|
|
9077
9107
|
const polar = Math.abs(Math.abs(base.lat0) - Math.PI / 2) < 1e-10;
|
|
9078
|
-
if (Math.abs(
|
|
9108
|
+
if (Math.abs(latitude2 + base.lat0) < 1e-10 && (polar || Math.abs(Math.abs(delta) - Math.PI) < 1e-10))
|
|
9079
9109
|
throw new Error("Azimuthal projection is undefined at the antipode");
|
|
9080
9110
|
forward4(point2);
|
|
9081
9111
|
}, projectionOperation(implementation, true));
|
|
@@ -9604,11 +9634,11 @@ var universalTransverseMercator = {
|
|
|
9604
9634
|
};
|
|
9605
9635
|
|
|
9606
9636
|
// dist/projection/experimental/rendering-profile/spherical-rendering-domain.js
|
|
9607
|
-
function geographicVector(longitude,
|
|
9637
|
+
function geographicVector(longitude, latitude2) {
|
|
9608
9638
|
return [
|
|
9609
|
-
Math.cos(
|
|
9610
|
-
Math.cos(
|
|
9611
|
-
Math.sin(
|
|
9639
|
+
Math.cos(latitude2) * Math.cos(longitude),
|
|
9640
|
+
Math.cos(latitude2) * Math.sin(longitude),
|
|
9641
|
+
Math.sin(latitude2)
|
|
9612
9642
|
];
|
|
9613
9643
|
}
|
|
9614
9644
|
var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
@@ -9633,38 +9663,38 @@ function sphericalExtremum(vector2, parameters, domain, maximize = true) {
|
|
|
9633
9663
|
const limit = domain ? Math.cos(domain.distance) : -1;
|
|
9634
9664
|
let best = maximize ? -Infinity : Infinity;
|
|
9635
9665
|
let point2 = [NaN, NaN];
|
|
9636
|
-
const consider = (longitude,
|
|
9666
|
+
const consider = (longitude, latitude2) => {
|
|
9637
9667
|
longitude = center + wrapLongitude(longitude - center);
|
|
9638
|
-
if (longitude < west - 1e-12 || longitude > east + 1e-12 ||
|
|
9668
|
+
if (longitude < west - 1e-12 || longitude > east + 1e-12 || latitude2 < south - 1e-12 || latitude2 > north + 1e-12)
|
|
9639
9669
|
return;
|
|
9640
|
-
const position2 = geographicVector(longitude,
|
|
9670
|
+
const position2 = geographicVector(longitude, latitude2);
|
|
9641
9671
|
if (domain && dot3(axis, position2) < limit - 1e-13)
|
|
9642
9672
|
return;
|
|
9643
9673
|
const value3 = dot3(vector2, position2);
|
|
9644
9674
|
if (maximize ? value3 > best : value3 < best) {
|
|
9645
9675
|
best = value3;
|
|
9646
|
-
point2 = [longitude,
|
|
9676
|
+
point2 = [longitude, latitude2];
|
|
9647
9677
|
}
|
|
9648
9678
|
};
|
|
9649
9679
|
const longitudes = [west, east, ...trigonometricRoots(-vector2[1], vector2[0], 0, west, east)];
|
|
9650
9680
|
for (const longitude of longitudes) {
|
|
9651
9681
|
const coefficient = vector2[0] * Math.cos(longitude) + vector2[1] * Math.sin(longitude);
|
|
9652
|
-
for (const
|
|
9682
|
+
for (const latitude2 of [
|
|
9653
9683
|
south,
|
|
9654
9684
|
north,
|
|
9655
9685
|
...trigonometricRoots(vector2[2], -coefficient, 0, south, north)
|
|
9656
9686
|
])
|
|
9657
|
-
consider(longitude,
|
|
9687
|
+
consider(longitude, latitude2);
|
|
9658
9688
|
}
|
|
9659
9689
|
if (domain) {
|
|
9660
9690
|
const [a, , c] = axis;
|
|
9661
|
-
for (const
|
|
9662
|
-
for (const longitude of trigonometricRoots(a * Math.cos(
|
|
9663
|
-
consider(longitude,
|
|
9691
|
+
for (const latitude2 of [south, north]) {
|
|
9692
|
+
for (const longitude of trigonometricRoots(a * Math.cos(latitude2), 0, limit - c * Math.sin(latitude2), west, east))
|
|
9693
|
+
consider(longitude, latitude2);
|
|
9664
9694
|
}
|
|
9665
9695
|
for (const longitude of [west, east]) {
|
|
9666
|
-
for (const
|
|
9667
|
-
consider(longitude,
|
|
9696
|
+
for (const latitude2 of trigonometricRoots(a * Math.cos(longitude), c, limit, south, north))
|
|
9697
|
+
consider(longitude, latitude2);
|
|
9668
9698
|
}
|
|
9669
9699
|
const parallel = dot3(vector2, axis);
|
|
9670
9700
|
let tangent = vector2.map((value3, index) => value3 - parallel * axis[index]);
|
|
@@ -9732,10 +9762,10 @@ function createAngularRenderingProfile(base, maximumDistance, resolveBounds2, ho
|
|
|
9732
9762
|
const angle3 = base.lat0 + domain.distance;
|
|
9733
9763
|
const center = (local[0][0] + local[1][0]) / 2;
|
|
9734
9764
|
const longitude = center + wrapLongitude((Math.cos(angle3) < 0 ? Math.PI : 0) - center);
|
|
9735
|
-
const
|
|
9736
|
-
if (longitude >= local[0][0] && longitude <= local[1][0] &&
|
|
9765
|
+
const latitude2 = Math.atan2(Math.sin(angle3), Math.abs(Math.cos(angle3)));
|
|
9766
|
+
if (longitude >= local[0][0] && longitude <= local[1][0] && latitude2 >= local[0][1] && latitude2 <= local[1][1]) {
|
|
9737
9767
|
point2.x = longitude + base.long0;
|
|
9738
|
-
point2.y =
|
|
9768
|
+
point2.y = latitude2;
|
|
9739
9769
|
return;
|
|
9740
9770
|
}
|
|
9741
9771
|
}
|
|
@@ -9995,7 +10025,7 @@ var stereographic = {
|
|
|
9995
10025
|
const base = kernelParameters(context);
|
|
9996
10026
|
const state = createState3(base);
|
|
9997
10027
|
const projection2 = guardAzimuthalDomain(base, bindKernel("stere", state, forward3, inverse3));
|
|
9998
|
-
return withAngularRenderingProfile(projection2, base, 150 * Math.PI / 180, (region, domain) => state.sphere ? sphericalAzimuthalBounds(state, region, domain, "stere") : ellipsoidalStereographicBounds(state, (
|
|
10028
|
+
return withAngularRenderingProfile(projection2, base, 150 * Math.PI / 180, (region, domain) => state.sphere ? sphericalAzimuthalBounds(state, region, domain, "stere") : ellipsoidalStereographicBounds(state, (latitude2) => 2 * Math.atan(Math.tan(Math.PI / 4 + latitude2 / 2) * Math.pow((1 - state.e * Math.sin(latitude2)) / (1 + state.e * Math.sin(latitude2)), state.e / 2)) - Math.PI / 2, state.X0, 2 * state.a * state.k0 * (Math.abs(state.coslat0) < 1e-10 ? 1 / state.cons : state.ms1 / state.cosX0), region, domain));
|
|
9999
10029
|
}
|
|
10000
10030
|
};
|
|
10001
10031
|
|
|
@@ -10003,16 +10033,16 @@ var stereographic = {
|
|
|
10003
10033
|
var DEG5 = Math.PI / 180;
|
|
10004
10034
|
var A2 = 6378137;
|
|
10005
10035
|
var F = 1 / 298.257223563;
|
|
10006
|
-
function standardGridZone(
|
|
10007
|
-
if (!Number.isFinite(
|
|
10036
|
+
function standardGridZone(latitude2, longitude) {
|
|
10037
|
+
if (!Number.isFinite(latitude2) || Math.abs(latitude2) > 90 || !Number.isFinite(longitude) || Math.abs(longitude) > 180)
|
|
10008
10038
|
throw new RangeError("Expected latitude/longitude degrees in [-90,90]/[-180,180]");
|
|
10009
|
-
if (
|
|
10039
|
+
if (latitude2 < -80 || latitude2 >= 84)
|
|
10010
10040
|
return 0;
|
|
10011
10041
|
const lon = longitude === 180 ? -180 : longitude;
|
|
10012
10042
|
let zone = Math.floor((Math.floor(lon) + 186) / 6);
|
|
10013
|
-
if (
|
|
10043
|
+
if (latitude2 >= 56 && latitude2 < 64 && lon >= 3 && lon < 12)
|
|
10014
10044
|
zone = 32;
|
|
10015
|
-
if (
|
|
10045
|
+
if (latitude2 >= 72 && lon >= 0 && lon < 42)
|
|
10016
10046
|
zone = 2 * Math.floor((Math.floor(lon) + 183) / 12) + 1;
|
|
10017
10047
|
return zone;
|
|
10018
10048
|
}
|
|
@@ -10037,16 +10067,16 @@ function projection(zone, north) {
|
|
|
10037
10067
|
prepared.set(key3, result);
|
|
10038
10068
|
return result;
|
|
10039
10069
|
}
|
|
10040
|
-
function projectGrid(
|
|
10041
|
-
const standard = standardGridZone(
|
|
10070
|
+
function projectGrid(latitude2, longitude, options = {}) {
|
|
10071
|
+
const standard = standardGridZone(latitude2, longitude), zone = options.zone ?? standard, naturalNorth = !(latitude2 < 0 || Object.is(latitude2, -0)), north = options.north ?? naturalNorth;
|
|
10042
10072
|
validateZone(zone, north);
|
|
10043
|
-
if (zone === 0 && (Math.abs(
|
|
10073
|
+
if (zone === 0 && (Math.abs(latitude2) < 70 || north !== naturalNorth))
|
|
10044
10074
|
throw new RangeError("UPS requires its matching polar hemisphere");
|
|
10045
10075
|
if (zone && Math.abs((longitude - (6 * zone - 183) + 540) % 360 - 180) > 60)
|
|
10046
10076
|
throw new RangeError("Longitude too far from UTM central meridian");
|
|
10047
|
-
if (zone === 0 && Math.abs(
|
|
10077
|
+
if (zone === 0 && Math.abs(latitude2) === 90)
|
|
10048
10078
|
return { zone, north, easting: 2e6, northing: 2e6 };
|
|
10049
|
-
const p = projection(zone, north).forward(longitude * DEG5,
|
|
10079
|
+
const p = projection(zone, north).forward(longitude * DEG5, latitude2 * DEG5);
|
|
10050
10080
|
if (zone === 0) {
|
|
10051
10081
|
if (longitude % 180 === 0)
|
|
10052
10082
|
p[0] = 2e6;
|
|
@@ -10111,17 +10141,17 @@ function utmRow(band, column, row) {
|
|
|
10111
10141
|
}
|
|
10112
10142
|
return row;
|
|
10113
10143
|
}
|
|
10114
|
-
function formatMGRS(
|
|
10144
|
+
function formatMGRS(latitude2, longitude, precision = 5, options = {}) {
|
|
10115
10145
|
if (!Number.isInteger(precision) || precision < 0 || precision > 11)
|
|
10116
10146
|
throw new RangeError("MGRS precision must be in [0,11]");
|
|
10117
|
-
const grid = projectGrid(
|
|
10147
|
+
const grid = projectGrid(latitude2, longitude, options), { zone, north, easting: x } = grid;
|
|
10118
10148
|
let y = grid.northing;
|
|
10119
10149
|
if (zone && !north && y === 1e7)
|
|
10120
10150
|
y -= 2 ** -28;
|
|
10121
10151
|
const column = Math.floor(x / TILE), row = Math.floor(y / TILE);
|
|
10122
10152
|
let prefix;
|
|
10123
10153
|
if (zone) {
|
|
10124
|
-
const band = Math.abs(
|
|
10154
|
+
const band = Math.abs(latitude2) < 2 ** -46 ? north ? 0 : -1 : Math.max(-10, Math.min(9, Math.floor((Math.floor(latitude2) + 80) / 8) - 10));
|
|
10125
10155
|
if (column < 1 || column > 8 || utmRow(band, column - 1, row % 20) !== row - (north ? 0 : 100))
|
|
10126
10156
|
throw new RangeError("Grid outside MGRS domain");
|
|
10127
10157
|
prefix = String(zone).padStart(2, "0") + BANDS[band + 10] + COLUMNS[(zone - 1) % 3][column - 1] + ROWS[(row + ((zone - 1) % 2 ? 5 : 0)) % 20];
|
|
@@ -10193,8 +10223,8 @@ function parseMGRSZone(text) {
|
|
|
10193
10223
|
band
|
|
10194
10224
|
};
|
|
10195
10225
|
}
|
|
10196
|
-
function formatMGRSZone(
|
|
10197
|
-
const cell = formatMGRS(
|
|
10226
|
+
function formatMGRSZone(latitude2, longitude, options = {}) {
|
|
10227
|
+
const cell = formatMGRS(latitude2, longitude, 0, options);
|
|
10198
10228
|
return cell.slice(0, cell.length - 2);
|
|
10199
10229
|
}
|
|
10200
10230
|
|
|
@@ -10375,10 +10405,10 @@ function subdivideGeographicCutRing(inputs, ring, options) {
|
|
|
10375
10405
|
};
|
|
10376
10406
|
}
|
|
10377
10407
|
});
|
|
10378
|
-
const
|
|
10408
|
+
const edges2 = [];
|
|
10379
10409
|
for (let i = 1; i < result.segmentIndices.length; i++) {
|
|
10380
10410
|
const index = result.segmentIndices[i], edge2 = descriptors[index], lo = result.segmentIndices[i - 1] === index ? result.segmentFractions[i - 1] : 0, hi = result.segmentFractions[i];
|
|
10381
|
-
|
|
10411
|
+
edges2.push(edge2.kind === "source" ? {
|
|
10382
10412
|
kind: "source",
|
|
10383
10413
|
source: {
|
|
10384
10414
|
...edge2.source,
|
|
@@ -10387,7 +10417,7 @@ function subdivideGeographicCutRing(inputs, ring, options) {
|
|
|
10387
10417
|
}
|
|
10388
10418
|
} : { ...edge2 });
|
|
10389
10419
|
}
|
|
10390
|
-
return { ...result, edges };
|
|
10420
|
+
return { ...result, edges: edges2 };
|
|
10391
10421
|
}
|
|
10392
10422
|
|
|
10393
10423
|
// dist/geographic-cuts.js
|
|
@@ -10763,13 +10793,13 @@ function validateBatch(positions, output2) {
|
|
|
10763
10793
|
|
|
10764
10794
|
// dist/terrain/mesh-skirts.js
|
|
10765
10795
|
function createTerrainSkirt(mesh, options) {
|
|
10766
|
-
const { positions, indices } = mesh, { height, edges } = options;
|
|
10796
|
+
const { positions, indices } = mesh, { height, baseZ, edges: edges2 } = options;
|
|
10767
10797
|
const maxVertices = options.maxVertices ?? 2e6, maxTriangles = options.maxTriangles ?? 4e6;
|
|
10768
|
-
if (!Number.isFinite(height)
|
|
10798
|
+
if ((baseZ === void 0 ? !(Number.isFinite(height) && height > 0) : height !== void 0 || !Number.isFinite(baseZ)) || !Number.isSafeInteger(maxVertices) || maxVertices < 0 || maxVertices > 4294967295 || !Number.isSafeInteger(maxTriangles) || maxTriangles < 0 || maxTriangles > 4294967295)
|
|
10769
10799
|
throw new Error("Invalid terrain skirt height or capacity");
|
|
10770
10800
|
if (!(positions instanceof Float32Array || positions instanceof Float64Array) || positions.length < 3 || positions.length % 3 || !positions.every(Number.isFinite) || !(indices instanceof Uint16Array || indices instanceof Uint32Array) || indices.length % 3 || positions.length / 3 > maxVertices || indices.length / 3 > maxTriangles)
|
|
10771
10801
|
throw new Error("Invalid terrain skirt mesh or capacity");
|
|
10772
|
-
if (
|
|
10802
|
+
if (edges2 !== void 0 && (!(edges2 instanceof Uint16Array || edges2 instanceof Uint32Array) || edges2.length % 2))
|
|
10773
10803
|
throw new Error("Invalid terrain skirt edge pairs");
|
|
10774
10804
|
const vertexCount = positions.length / 3, triangleCount = indices.length / 3;
|
|
10775
10805
|
const boundary = /* @__PURE__ */ new Map();
|
|
@@ -10793,11 +10823,11 @@ function createTerrainSkirt(mesh, options) {
|
|
|
10793
10823
|
}
|
|
10794
10824
|
}
|
|
10795
10825
|
let selected;
|
|
10796
|
-
if (
|
|
10826
|
+
if (edges2) {
|
|
10797
10827
|
selected = [];
|
|
10798
10828
|
const used = /* @__PURE__ */ new Set();
|
|
10799
|
-
for (let i = 0; i <
|
|
10800
|
-
const key3 = edgeKey(
|
|
10829
|
+
for (let i = 0; i < edges2.length; i += 2) {
|
|
10830
|
+
const key3 = edgeKey(edges2[i], edges2[i + 1]), edge2 = boundary.get(key3);
|
|
10801
10831
|
if (!edge2 || edge2.count !== 1 || used.has(key3))
|
|
10802
10832
|
throw new Error("Terrain skirt selection must contain unique boundary edges");
|
|
10803
10833
|
used.add(key3);
|
|
@@ -10821,7 +10851,7 @@ function createTerrainSkirt(mesh, options) {
|
|
|
10821
10851
|
[b, lowerB]
|
|
10822
10852
|
]) {
|
|
10823
10853
|
resultPositions.set(positions.subarray(3 * source, 3 * source + 3), 3 * target);
|
|
10824
|
-
resultPositions[3 * target + 2] = positions[3 * source + 2] - height;
|
|
10854
|
+
resultPositions[3 * target + 2] = baseZ ?? positions[3 * source + 2] - height;
|
|
10825
10855
|
if (!Number.isFinite(resultPositions[3 * target + 2]) || resultPositions[3 * target + 2] >= positions[3 * source + 2])
|
|
10826
10856
|
throw new Error("Terrain skirt height cannot be represented in position precision");
|
|
10827
10857
|
sourceVertexIndices[target - vertexCount] = source;
|
|
@@ -10982,17 +11012,17 @@ var GeographicHeightField = class {
|
|
|
10982
11012
|
});
|
|
10983
11013
|
}
|
|
10984
11014
|
/** Longitude must use the bounds' unwrapped interval; no implicit wrapping or clamping. */
|
|
10985
|
-
sample(longitude,
|
|
10986
|
-
const valid = Number.isFinite(longitude) && Number.isFinite(
|
|
10987
|
-
const inside = valid && longitude >= this.bounds[0] && longitude <= this.bounds[2] &&
|
|
10988
|
-
const sample = this.field.sample(inside ? this.projectX(longitude) : NaN, inside ? this.projectY(
|
|
11015
|
+
sample(longitude, latitude2, options, result) {
|
|
11016
|
+
const valid = Number.isFinite(longitude) && Number.isFinite(latitude2);
|
|
11017
|
+
const inside = valid && longitude >= this.bounds[0] && longitude <= this.bounds[2] && latitude2 >= this.bounds[1] && latitude2 <= this.bounds[3];
|
|
11018
|
+
const sample = this.field.sample(inside ? this.projectX(longitude) : NaN, inside ? this.projectY(latitude2) : NaN, options, result);
|
|
10989
11019
|
if (!inside) {
|
|
10990
11020
|
sample.status = sample.gradientStatus = valid ? TerrainSampleStatus.OUTSIDE_DOMAIN : TerrainSampleStatus.INVALID_INPUT;
|
|
10991
11021
|
return sample;
|
|
10992
11022
|
}
|
|
10993
11023
|
if (sample.gradientStatus !== TerrainSampleStatus.VALID)
|
|
10994
11024
|
return sample;
|
|
10995
|
-
const phi =
|
|
11025
|
+
const phi = latitude2 * RADIANS2;
|
|
10996
11026
|
const denominator = 1 - ECCENTRICITY_SQUARED * Math.sin(phi) ** 2;
|
|
10997
11027
|
const n = RADIUS / Math.sqrt(denominator);
|
|
10998
11028
|
const m = RADIUS * (1 - ECCENTRICITY_SQUARED) / denominator ** 1.5;
|
|
@@ -11016,8 +11046,8 @@ var GeographicHeightField = class {
|
|
|
11016
11046
|
projectX(longitude) {
|
|
11017
11047
|
return this.projection === "web-mercator" ? RADIUS * longitude * RADIANS2 : longitude;
|
|
11018
11048
|
}
|
|
11019
|
-
projectY(
|
|
11020
|
-
return this.projection === "web-mercator" ? RADIUS * Math.asinh(Math.tan(
|
|
11049
|
+
projectY(latitude2) {
|
|
11050
|
+
return this.projection === "web-mercator" ? RADIUS * Math.asinh(Math.tan(latitude2 * RADIANS2)) : latitude2;
|
|
11021
11051
|
}
|
|
11022
11052
|
};
|
|
11023
11053
|
|
|
@@ -11458,7 +11488,7 @@ function createTransform(steps) {
|
|
|
11458
11488
|
}
|
|
11459
11489
|
|
|
11460
11490
|
// dist/terrain/surface.js
|
|
11461
|
-
var
|
|
11491
|
+
var import_spatial_index = require("@math.gl/geometry/spatial-index");
|
|
11462
11492
|
|
|
11463
11493
|
// dist/terrain/mesh-data.js
|
|
11464
11494
|
function assembleTerrainMesh(field, gridCoordinates, indices, options) {
|
|
@@ -11600,8 +11630,8 @@ var TerrainSurface = class {
|
|
|
11600
11630
|
}
|
|
11601
11631
|
this.activeTriangleCount = active;
|
|
11602
11632
|
this.topology = buildTopology(this.indices, this.validity);
|
|
11603
|
-
this.xyIndex = new
|
|
11604
|
-
this.bvh = new
|
|
11633
|
+
this.xyIndex = new import_spatial_index.BoxIndex({ bounds: bounds2, dimension: 2 });
|
|
11634
|
+
this.bvh = new import_spatial_index.TriangleBVH({ positions: this.positions, indices: this.indices });
|
|
11605
11635
|
}
|
|
11606
11636
|
/** Detached source data; changing these buffers never changes this surface. */
|
|
11607
11637
|
copyData() {
|
|
@@ -11845,16 +11875,16 @@ var TerrainSurface = class {
|
|
|
11845
11875
|
};
|
|
11846
11876
|
function buildTopology(indices, validity) {
|
|
11847
11877
|
const halfedges = new Int32Array(indices.length).fill(-1);
|
|
11848
|
-
const
|
|
11878
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
11849
11879
|
for (let i = 0; i < indices.length; i++) {
|
|
11850
11880
|
const triangle = Math.floor(i / 3);
|
|
11851
11881
|
if (!validity[triangle])
|
|
11852
11882
|
continue;
|
|
11853
11883
|
const a = indices[i], b = indices[triangle * 3 + (i % 3 + 1) % 3];
|
|
11854
11884
|
const key3 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
11855
|
-
const opposite =
|
|
11885
|
+
const opposite = edges2.get(key3);
|
|
11856
11886
|
if (opposite === void 0)
|
|
11857
|
-
|
|
11887
|
+
edges2.set(key3, i);
|
|
11858
11888
|
else {
|
|
11859
11889
|
if (halfedges[opposite] !== -1)
|
|
11860
11890
|
throw new Error("Nonmanifold terrain edge");
|
|
@@ -12130,19 +12160,19 @@ function createMartiniTerrainMesh(field, options) {
|
|
|
12130
12160
|
throw new Error("Adaptive terrain sample capacity exceeded");
|
|
12131
12161
|
if (field.validCount !== size * size)
|
|
12132
12162
|
throw new Error("Adaptive terrain requires complete source data; use a regular mesh for holes");
|
|
12133
|
-
const
|
|
12134
|
-
for (const edge2 of
|
|
12163
|
+
const edges2 = options.fullEdges ?? [];
|
|
12164
|
+
for (const edge2 of edges2)
|
|
12135
12165
|
if (!["minColumn", "maxColumn", "minRow", "maxRow"].includes(edge2))
|
|
12136
12166
|
throw new Error("Unknown adaptive terrain edge");
|
|
12137
12167
|
const { heights } = field.copyData();
|
|
12138
12168
|
const tile = new import_martini.default(size).createTile(heights);
|
|
12139
|
-
for (const edge2 of
|
|
12169
|
+
for (const edge2 of edges2)
|
|
12140
12170
|
for (let i = 0; i < size; i++) {
|
|
12141
12171
|
const column = edge2 === "minColumn" ? 0 : edge2 === "maxColumn" ? cells : i;
|
|
12142
12172
|
const row = edge2 === "minRow" ? 0 : edge2 === "maxRow" ? cells : i;
|
|
12143
12173
|
tile.errors[row * size + column] = Infinity;
|
|
12144
12174
|
}
|
|
12145
|
-
if (
|
|
12175
|
+
if (edges2.length)
|
|
12146
12176
|
tile.update();
|
|
12147
12177
|
let threshold = options.maxError;
|
|
12148
12178
|
for (let pass = 0; pass <= 8; pass++) {
|
|
@@ -12763,7 +12793,7 @@ function createTerrainContours(field, levels, options = {}) {
|
|
|
12763
12793
|
const outputLevels = Float64Array.from(levels), positions = [], coordinates = [], segments = [], levelIndices = [];
|
|
12764
12794
|
const shift2 = field.registration === "cell" ? 0.5 : 0;
|
|
12765
12795
|
for (let levelIndex = 0; levelIndex < outputLevels.length; levelIndex++) {
|
|
12766
|
-
const level = outputLevels[levelIndex], vertices = /* @__PURE__ */ new Map(),
|
|
12796
|
+
const level = outputLevels[levelIndex], vertices = /* @__PURE__ */ new Map(), edges2 = /* @__PURE__ */ new Set();
|
|
12767
12797
|
const height = (i) => field.getHeight(i % field.width, Math.floor(i / field.width));
|
|
12768
12798
|
const intersection = (a, b) => {
|
|
12769
12799
|
if (a > b)
|
|
@@ -12817,13 +12847,13 @@ function createTerrainContours(field, levels, options = {}) {
|
|
|
12817
12847
|
return;
|
|
12818
12848
|
const va = vertex(hits[0]), vb = vertex(hits[1]);
|
|
12819
12849
|
const key3 = va < vb ? `${va}/${vb}` : `${vb}/${va}`;
|
|
12820
|
-
if (
|
|
12850
|
+
if (edges2.has(key3))
|
|
12821
12851
|
return;
|
|
12822
12852
|
if (segments.length / 2 >= maxSegments)
|
|
12823
12853
|
throw new Error("Terrain contour segment capacity exceeded");
|
|
12824
12854
|
if (positions[3 * va] === positions[3 * vb] && positions[3 * va + 1] === positions[3 * vb + 1])
|
|
12825
12855
|
throw new Error("Terrain contour segment collapses; use a local origin");
|
|
12826
|
-
|
|
12856
|
+
edges2.add(key3);
|
|
12827
12857
|
segments.push(va, vb);
|
|
12828
12858
|
levelIndices.push(levelIndex);
|
|
12829
12859
|
};
|
|
@@ -12982,7 +13012,7 @@ function weldTerrainContourTiles(tiles, options) {
|
|
|
12982
13012
|
const levels = first.levels.slice();
|
|
12983
13013
|
const positions = [], grid = [], segments = [], levelIndices = [];
|
|
12984
13014
|
const vertices = /* @__PURE__ */ new Map();
|
|
12985
|
-
const
|
|
13015
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
12986
13016
|
const addresses = /* @__PURE__ */ new Set();
|
|
12987
13017
|
let inputVertices = 0;
|
|
12988
13018
|
let inputSegments = 0;
|
|
@@ -13059,7 +13089,7 @@ function weldTerrainContourTiles(tiles, options) {
|
|
|
13059
13089
|
if (a === b || positions[3 * a] === positions[3 * b] && positions[3 * a + 1] === positions[3 * b + 1])
|
|
13060
13090
|
throw new Error("Degenerate terrain contour segment after rebasing");
|
|
13061
13091
|
const edge2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
13062
|
-
const previous =
|
|
13092
|
+
const previous = edges2.get(edge2);
|
|
13063
13093
|
if (previous !== void 0) {
|
|
13064
13094
|
if (previous === tileIndex)
|
|
13065
13095
|
throw new Error("Duplicate terrain contour segment");
|
|
@@ -13067,7 +13097,7 @@ function weldTerrainContourTiles(tiles, options) {
|
|
|
13067
13097
|
}
|
|
13068
13098
|
if (levelIndices.length >= limits.maxSegments)
|
|
13069
13099
|
throw new Error("Terrain contour segment capacity exceeded");
|
|
13070
|
-
|
|
13100
|
+
edges2.set(edge2, tileIndex);
|
|
13071
13101
|
segments.push(a, b);
|
|
13072
13102
|
levelIndices.push(level);
|
|
13073
13103
|
}
|
|
@@ -14140,7 +14170,7 @@ function weldTerrainMixedContourTiles(tiles, options = {}) {
|
|
|
14140
14170
|
const positions = [], grid = [], vertexLevels = [];
|
|
14141
14171
|
const roundedBoundary = /* @__PURE__ */ new Map();
|
|
14142
14172
|
const boundary = /* @__PURE__ */ new Set(), shared2 = /* @__PURE__ */ new Map();
|
|
14143
|
-
const
|
|
14173
|
+
const edges2 = [];
|
|
14144
14174
|
let inputVertices = 0, inputSegments = 0;
|
|
14145
14175
|
for (let ti = 0; ti < sorted.length; ti++) {
|
|
14146
14176
|
const tile = sorted[ti], data = tile.contours;
|
|
@@ -14217,11 +14247,11 @@ function weldTerrainMixedContourTiles(tiles, options = {}) {
|
|
|
14217
14247
|
localEdges.add(key3);
|
|
14218
14248
|
const box = bounds2[ti];
|
|
14219
14249
|
const seam = grid[2 * a] === grid[2 * b] && (grid[2 * a] === box[0] || grid[2 * a] === box[2]) || grid[2 * a + 1] === grid[2 * b + 1] && (grid[2 * a + 1] === box[1] || grid[2 * a + 1] === box[3]);
|
|
14220
|
-
|
|
14250
|
+
edges2.push({ a, b, level, tile: ti, seam });
|
|
14221
14251
|
}
|
|
14222
14252
|
}
|
|
14223
14253
|
const segments = [], levels = [], emitted = /* @__PURE__ */ new Map();
|
|
14224
|
-
for (const edge2 of
|
|
14254
|
+
for (const edge2 of edges2) {
|
|
14225
14255
|
const { a, b, level } = edge2;
|
|
14226
14256
|
const axis = grid[2 * a] === grid[2 * b] ? 1 : 0;
|
|
14227
14257
|
const start = grid[2 * a + axis], end = grid[2 * b + axis];
|
|
@@ -14358,56 +14388,48 @@ function buildMixedVertexTileHalos(tiles, options = {}, targets, preparation) {
|
|
|
14358
14388
|
if (![maxSamples, maxTests].every((v) => Number.isSafeInteger(v) && v >= 0))
|
|
14359
14389
|
throw new Error("Invalid mixed halo capacity");
|
|
14360
14390
|
let count = 0;
|
|
14361
|
-
|
|
14391
|
+
let previousKey;
|
|
14362
14392
|
let frame2;
|
|
14363
14393
|
const sources = [...tiles].sort((a, b) => a.spacing - b.spacing || a.column - b.column || a.row - b.row).map((tile) => {
|
|
14364
|
-
if (![tile.column, tile.row, tile.spacing].every(Number.isSafeInteger) || tile.spacing < 1 || 2 ** Math.round(Math.log2(tile.spacing)) !== tile.spacing)
|
|
14365
|
-
throw new Error("Invalid mixed halo lattice");
|
|
14366
|
-
const key3 = `${tile.spacing}/${tile.column}/${tile.row}`;
|
|
14367
|
-
if (addresses.has(key3))
|
|
14368
|
-
throw new Error("Duplicate mixed halo tile");
|
|
14369
|
-
addresses.add(key3);
|
|
14370
14394
|
count += (tile.field.width + 2) * (tile.field.height + 2);
|
|
14371
14395
|
if (!Number.isSafeInteger(count) || count > maxSamples)
|
|
14372
14396
|
throw new Error("Mixed halo sample capacity exceeded");
|
|
14373
|
-
let
|
|
14374
|
-
if (!
|
|
14375
|
-
|
|
14376
|
-
preparation == null ? void 0 : preparation.
|
|
14397
|
+
let prepared2 = preparation == null ? void 0 : preparation.tiles.get(tile);
|
|
14398
|
+
if (!prepared2) {
|
|
14399
|
+
prepared2 = prepareMixedHaloTile(tile);
|
|
14400
|
+
preparation == null ? void 0 : preparation.tiles.set(tile, prepared2);
|
|
14401
|
+
}
|
|
14402
|
+
const { key: key3, source: field, columnStep: column, rowStep: row, frameOrigin: origin, scale: scale3 } = prepared2;
|
|
14403
|
+
if (previousKey === key3)
|
|
14404
|
+
throw new Error("Duplicate mixed halo tile");
|
|
14405
|
+
previousKey = key3;
|
|
14406
|
+
if (frame2) {
|
|
14407
|
+
if (frame2.reference !== field.heightReference)
|
|
14408
|
+
throw new Error("Mixed halo frames or height references differ");
|
|
14409
|
+
for (let i = 0; i < 2; i++) {
|
|
14410
|
+
if (column[i] !== frame2.column[i] || row[i] !== frame2.row[i] || origin[i] !== frame2.origin[i] && Math.abs(origin[i] - frame2.origin[i]) > Math.min(16 * Number.EPSILON * Math.max(scale3[i], frame2.scale[i]), 1e-9 * Math.max(Math.abs(column[i]), Math.abs(row[i]))))
|
|
14411
|
+
throw new Error("Mixed halo frames or height references differ");
|
|
14412
|
+
}
|
|
14377
14413
|
}
|
|
14378
|
-
if (field.registration !== "vertex")
|
|
14379
|
-
throw new Error("Mixed halos require vertex registration");
|
|
14380
|
-
const column = field.columnStep.map((v) => v / tile.spacing);
|
|
14381
|
-
const row = field.rowStep.map((v) => v / tile.spacing);
|
|
14382
|
-
const origin = field.origin.map((v, axis) => v - tile.column * column[axis] - tile.row * row[axis]);
|
|
14383
|
-
const scale3 = field.origin.map((v, i) => Math.max(1, Math.abs(v), Math.abs(tile.column * column[i]), Math.abs(tile.row * row[i])));
|
|
14384
|
-
if (!origin.every(Number.isFinite))
|
|
14385
|
-
throw new Error("Mixed halo coordinate overflow");
|
|
14386
|
-
if (frame2 && (frame2.reference !== field.heightReference || column.some((v, i) => v !== frame2.column[i]) || row.some((v, i) => v !== frame2.row[i]) || origin.some((v, i) => Math.abs(v - frame2.origin[i]) > Math.min(16 * Number.EPSILON * Math.max(scale3[i], frame2.scale[i]), 1e-9 * Math.max(Math.abs(column[i]), Math.abs(row[i]))))))
|
|
14387
|
-
throw new Error("Mixed halo frames or height references differ");
|
|
14388
14414
|
frame2 ?? (frame2 = { origin, column, row, reference: field.heightReference, scale: scale3 });
|
|
14389
|
-
return
|
|
14415
|
+
return prepared2;
|
|
14390
14416
|
});
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
if (sources.length && !Number.isSafeInteger(max - min))
|
|
14402
|
-
throw new Error("Mixed halo lattice span overflow");
|
|
14403
|
-
}
|
|
14417
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
14418
|
+
for (let i = 0; i < sources.length; i++) {
|
|
14419
|
+
const { haloBounds } = sources[i];
|
|
14420
|
+
minX = Math.min(minX, haloBounds.minX);
|
|
14421
|
+
minY = Math.min(minY, haloBounds.minY);
|
|
14422
|
+
maxX = Math.max(maxX, haloBounds.maxX);
|
|
14423
|
+
maxY = Math.max(maxY, haloBounds.maxY);
|
|
14424
|
+
}
|
|
14425
|
+
if (sources.length && (!Number.isSafeInteger(maxX - minX) || !Number.isSafeInteger(maxY - minY)))
|
|
14426
|
+
throw new Error("Mixed halo lattice span overflow");
|
|
14404
14427
|
if (targets && targets.size === 0)
|
|
14405
14428
|
return { tiles: [] };
|
|
14406
14429
|
let index;
|
|
14407
14430
|
if (sources.length > 8) {
|
|
14408
|
-
const keys = preparation && sources.map((tile) => `${tile.spacing}/${tile.column}/${tile.row}/${tile.source.width}/${tile.source.height}`);
|
|
14409
14431
|
const cached = preparation == null ? void 0 : preparation.layout;
|
|
14410
|
-
if (
|
|
14432
|
+
if (cached && sources.length === cached.keys.length && sources.every((tile, i) => tile.layoutKey === cached.keys[i])) {
|
|
14411
14433
|
index = cached.query;
|
|
14412
14434
|
} else {
|
|
14413
14435
|
index = createTerrainBoxIndex(sources.map((tile) => ({
|
|
@@ -14416,8 +14438,8 @@ function buildMixedVertexTileHalos(tiles, options = {}, targets, preparation) {
|
|
|
14416
14438
|
maxX: tile.column + (tile.source.width - 1) * tile.spacing,
|
|
14417
14439
|
maxY: tile.row + (tile.source.height - 1) * tile.spacing
|
|
14418
14440
|
})));
|
|
14419
|
-
if (preparation
|
|
14420
|
-
preparation.layout = { keys, query: index };
|
|
14441
|
+
if (preparation)
|
|
14442
|
+
preparation.layout = { keys: sources.map((tile) => tile.layoutKey), query: index };
|
|
14421
14443
|
}
|
|
14422
14444
|
}
|
|
14423
14445
|
let tests = 0;
|
|
@@ -14426,21 +14448,17 @@ function buildMixedVertexTileHalos(tiles, options = {}, targets, preparation) {
|
|
|
14426
14448
|
throw new Error("Mixed halo tile-test budget exceeded");
|
|
14427
14449
|
};
|
|
14428
14450
|
return {
|
|
14429
|
-
tiles: sources.filter((tile) => !targets || targets.has(
|
|
14451
|
+
tiles: sources.filter((tile) => !targets || targets.has(tile.key)).map((tile) => {
|
|
14430
14452
|
const source = tile.source, width = source.width + 2, height = source.height + 2;
|
|
14431
14453
|
const heights = new Float64Array(width * height), validity = new Uint8Array(heights.length), statuses = new Uint8Array(heights.length);
|
|
14432
|
-
const candidates = (index == null ? void 0 : index(
|
|
14433
|
-
minX: tile.column - tile.spacing,
|
|
14434
|
-
minY: tile.row - tile.spacing,
|
|
14435
|
-
maxX: tile.column + source.width * tile.spacing,
|
|
14436
|
-
maxY: tile.row + source.height * tile.spacing
|
|
14437
|
-
}, charge).map((id) => sources[id])) ?? sources;
|
|
14454
|
+
const candidates = (index == null ? void 0 : index(tile.haloBounds, charge).map((id) => sources[id])) ?? sources;
|
|
14438
14455
|
for (let y = 0; y < height; y++)
|
|
14439
14456
|
for (let x = 0; x < width; x++) {
|
|
14440
14457
|
const gx = tile.column + (x - 1) * tile.spacing, gy = tile.row + (y - 1) * tile.spacing;
|
|
14441
|
-
if (!
|
|
14458
|
+
if (!Number.isSafeInteger(gx) || !Number.isSafeInteger(gy))
|
|
14442
14459
|
throw new Error("Mixed halo lattice overflow");
|
|
14443
|
-
for (
|
|
14460
|
+
for (let candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
|
|
14461
|
+
const candidate = candidates[candidateIndex];
|
|
14444
14462
|
charge();
|
|
14445
14463
|
const cx = (gx - candidate.column) / candidate.spacing, cy = (gy - candidate.row) / candidate.spacing;
|
|
14446
14464
|
const f = candidate.source;
|
|
@@ -14483,6 +14501,36 @@ function buildMixedVertexTileHalos(tiles, options = {}, targets, preparation) {
|
|
|
14483
14501
|
})
|
|
14484
14502
|
};
|
|
14485
14503
|
}
|
|
14504
|
+
function prepareMixedHaloTile(tile) {
|
|
14505
|
+
const { column, row, spacing } = tile;
|
|
14506
|
+
if (![column, row, spacing].every(Number.isSafeInteger) || spacing < 1 || 2 ** Math.round(Math.log2(spacing)) !== spacing)
|
|
14507
|
+
throw new Error("Invalid mixed halo lattice");
|
|
14508
|
+
const source = new HeightField(tile.field);
|
|
14509
|
+
if (source.registration !== "vertex")
|
|
14510
|
+
throw new Error("Mixed halos require vertex registration");
|
|
14511
|
+
const columnStep = source.columnStep.map((v) => v / spacing);
|
|
14512
|
+
const rowStep = source.rowStep.map((v) => v / spacing);
|
|
14513
|
+
const frameOrigin = source.origin.map((v, i) => v - column * columnStep[i] - row * rowStep[i]);
|
|
14514
|
+
const scale3 = source.origin.map((v, i) => Math.max(1, Math.abs(v), Math.abs(column * columnStep[i]), Math.abs(row * rowStep[i])));
|
|
14515
|
+
if (!frameOrigin.every(Number.isFinite))
|
|
14516
|
+
throw new Error("Mixed halo coordinate overflow");
|
|
14517
|
+
const minX = column - spacing, minY = row - spacing;
|
|
14518
|
+
const maxX = column + source.width * spacing, maxY = row + source.height * spacing;
|
|
14519
|
+
if (![minX, minY, maxX, maxY].every(Number.isSafeInteger))
|
|
14520
|
+
throw new Error("Mixed halo lattice overflow");
|
|
14521
|
+
const key3 = `${spacing}/${column}/${row}`;
|
|
14522
|
+
return {
|
|
14523
|
+
...tile,
|
|
14524
|
+
source,
|
|
14525
|
+
columnStep,
|
|
14526
|
+
rowStep,
|
|
14527
|
+
frameOrigin,
|
|
14528
|
+
scale: scale3,
|
|
14529
|
+
key: key3,
|
|
14530
|
+
layoutKey: `${key3}/${source.width}/${source.height}`,
|
|
14531
|
+
haloBounds: { minX, minY, maxX, maxY }
|
|
14532
|
+
};
|
|
14533
|
+
}
|
|
14486
14534
|
|
|
14487
14535
|
// dist/terrain/mixed-halo-update.js
|
|
14488
14536
|
var key2 = (t) => `${t.spacing}/${t.column}/${t.row}`;
|
|
@@ -14528,14 +14576,21 @@ function updateTerrainMixedVertexTileHalos(previous, resident, options = {}) {
|
|
|
14528
14576
|
const budget = options.maxDependencyTests ?? 1e7;
|
|
14529
14577
|
if (!Number.isSafeInteger(budget) || budget < 0)
|
|
14530
14578
|
throw new Error("Invalid mixed halo dependency budget");
|
|
14531
|
-
const old = new Map(previous == null ? void 0 : previous.sources.map((t) => [key2(t), t]));
|
|
14532
|
-
const current = new Map(resident.map((t) => [key2(t), t]));
|
|
14533
|
-
const cached = new Map(previous == null ? void 0 : previous.tiles.map((t) => [key2(t), t]));
|
|
14534
|
-
const targets = /* @__PURE__ */ new Set();
|
|
14535
14579
|
const unchangedLayout = (previous == null ? void 0 : previous.sources.length) === resident.length && resident.every((tile, i) => {
|
|
14536
14580
|
const prior = previous.sources[i];
|
|
14537
|
-
return
|
|
14581
|
+
return prior === tile || prior.column === tile.column && prior.row === tile.row && prior.spacing === tile.spacing && prior.field.width === tile.field.width && prior.field.height === tile.field.height;
|
|
14538
14582
|
});
|
|
14583
|
+
const old = unchangedLayout ? void 0 : new Map(previous == null ? void 0 : previous.sources.map((t) => [key2(t), t]));
|
|
14584
|
+
const targets = /* @__PURE__ */ new Set();
|
|
14585
|
+
const initialized = previous !== null && preparations.has(previous);
|
|
14586
|
+
if (!initialized) {
|
|
14587
|
+
const cached = new Set(previous == null ? void 0 : previous.tiles.map(key2));
|
|
14588
|
+
for (const tile of resident) {
|
|
14589
|
+
const address = key2(tile);
|
|
14590
|
+
if (!cached.has(address))
|
|
14591
|
+
targets.add(address);
|
|
14592
|
+
}
|
|
14593
|
+
}
|
|
14539
14594
|
let index = unchangedLayout && previous ? targetIndexes.get(previous) : void 0;
|
|
14540
14595
|
let tests = 0;
|
|
14541
14596
|
const charge = () => {
|
|
@@ -14547,12 +14602,13 @@ function updateTerrainMixedVertexTileHalos(previous, resident, options = {}) {
|
|
|
14547
14602
|
for (const id of index(box, charge))
|
|
14548
14603
|
targets.add(key2(resident[id]));
|
|
14549
14604
|
}
|
|
14550
|
-
for (
|
|
14551
|
-
const
|
|
14552
|
-
const prior = old.get(
|
|
14553
|
-
if (
|
|
14554
|
-
|
|
14555
|
-
|
|
14605
|
+
for (let i = 0; i < resident.length; i++) {
|
|
14606
|
+
const tile = resident[i];
|
|
14607
|
+
const prior = unchangedLayout ? previous.sources[i] : old == null ? void 0 : old.get(key2(tile));
|
|
14608
|
+
if (prior === tile)
|
|
14609
|
+
continue;
|
|
14610
|
+
targets.add(key2(tile));
|
|
14611
|
+
if (!previous)
|
|
14556
14612
|
continue;
|
|
14557
14613
|
if (!prior) {
|
|
14558
14614
|
invalidate(bounds(tile));
|
|
@@ -14565,24 +14621,44 @@ function updateTerrainMixedVertexTileHalos(previous, resident, options = {}) {
|
|
|
14565
14621
|
invalidate(dirty);
|
|
14566
14622
|
}
|
|
14567
14623
|
}
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14624
|
+
const removed = [];
|
|
14625
|
+
if (old == null ? void 0 : old.size) {
|
|
14626
|
+
const current = new Set(resident.map(key2));
|
|
14627
|
+
for (const [address, tile] of old) {
|
|
14628
|
+
if (current.has(address))
|
|
14629
|
+
continue;
|
|
14630
|
+
removed.push(address);
|
|
14631
|
+
if (resident.length)
|
|
14632
|
+
invalidate(bounds(tile));
|
|
14633
|
+
}
|
|
14571
14634
|
}
|
|
14572
14635
|
const priorPreparation = previous && preparations.get(previous);
|
|
14573
14636
|
const preparation = {
|
|
14574
|
-
|
|
14637
|
+
tiles: (priorPreparation == null ? void 0 : priorPreparation.tiles) ?? /* @__PURE__ */ new WeakMap(),
|
|
14575
14638
|
layout: priorPreparation == null ? void 0 : priorPreparation.layout
|
|
14576
14639
|
};
|
|
14577
14640
|
const built = buildMixedVertexTileHalos(resident, options, targets, preparation).tiles;
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14641
|
+
let tiles;
|
|
14642
|
+
if (unchangedLayout && initialized) {
|
|
14643
|
+
let cursor = 0;
|
|
14644
|
+
tiles = previous.tiles.map((tile) => {
|
|
14645
|
+
const replacement = built[cursor];
|
|
14646
|
+
if ((replacement == null ? void 0 : replacement.spacing) !== tile.spacing || replacement.column !== tile.column || replacement.row !== tile.row)
|
|
14647
|
+
return tile;
|
|
14648
|
+
cursor++;
|
|
14649
|
+
return replacement;
|
|
14650
|
+
});
|
|
14651
|
+
} else {
|
|
14652
|
+
const cached = new Map(previous == null ? void 0 : previous.tiles.map((tile) => [key2(tile), tile]));
|
|
14653
|
+
for (const tile of built)
|
|
14654
|
+
cached.set(key2(tile), tile);
|
|
14655
|
+
tiles = resident.map((tile) => cached.get(key2(tile))).sort((a, b) => a.spacing - b.spacing || a.column - b.column || a.row - b.row);
|
|
14656
|
+
}
|
|
14581
14657
|
const snapshot2 = {
|
|
14582
14658
|
sources: resident.slice(),
|
|
14583
14659
|
tiles,
|
|
14584
14660
|
rebuilt: built.map(key2),
|
|
14585
|
-
removed:
|
|
14661
|
+
removed: removed.sort()
|
|
14586
14662
|
};
|
|
14587
14663
|
preparations.set(snapshot2, preparation);
|
|
14588
14664
|
if (index)
|
|
@@ -14641,24 +14717,24 @@ function simplifyTerrainContourPathsTopology(paths, options) {
|
|
|
14641
14717
|
const points = new Array(paths.positions.length / 3);
|
|
14642
14718
|
for (const i of new Set(paths.indices))
|
|
14643
14719
|
points[i] = { x: integer(paths.positions[3 * i]), y: integer(paths.positions[3 * i + 1]) };
|
|
14644
|
-
const
|
|
14720
|
+
const edges2 = [];
|
|
14645
14721
|
for (let p = 0; p < paths.closed.length; p++)
|
|
14646
14722
|
for (let i = paths.offsets[p]; i + 1 < paths.offsets[p + 1]; i++)
|
|
14647
|
-
|
|
14723
|
+
edges2.push({ a: paths.indices[i], b: paths.indices[i + 1], p, i });
|
|
14648
14724
|
const box = (a, b) => ({
|
|
14649
14725
|
minX: Math.min(paths.positions[3 * a], paths.positions[3 * b]),
|
|
14650
14726
|
maxX: Math.max(paths.positions[3 * a], paths.positions[3 * b]),
|
|
14651
14727
|
minY: Math.min(paths.positions[3 * a + 1], paths.positions[3 * b + 1]),
|
|
14652
14728
|
maxY: Math.max(paths.positions[3 * a + 1], paths.positions[3 * b + 1])
|
|
14653
14729
|
});
|
|
14654
|
-
const edgeBoxes =
|
|
14730
|
+
const edgeBoxes = edges2.map((e) => box(e.a, e.b)), edgeIndex = createTerrainBoxIndex(edgeBoxes);
|
|
14655
14731
|
const vertexIds = [...new Set(paths.indices)], vertexIndex = createTerrainBoxIndex(vertexIds.map((v) => box(v, v)));
|
|
14656
|
-
for (let i = 0; i <
|
|
14732
|
+
for (let i = 0; i < edges2.length; i++)
|
|
14657
14733
|
for (const j of edgeIndex(edgeBoxes[i], charge)) {
|
|
14658
14734
|
if (j <= i)
|
|
14659
14735
|
continue;
|
|
14660
14736
|
charge();
|
|
14661
|
-
const a =
|
|
14737
|
+
const a = edges2[i], b = edges2[j];
|
|
14662
14738
|
const common = [a.a, a.b].filter((v) => v === b.a || v === b.b);
|
|
14663
14739
|
if (common.length === 1) {
|
|
14664
14740
|
const v = common[0], x = a.a === v ? a.b : a.a, y = b.a === v ? b.b : b.a;
|
|
@@ -14691,7 +14767,7 @@ function simplifyTerrainContourPathsTopology(paths, options) {
|
|
|
14691
14767
|
const interior2 = new Set(Array.from(paths.indices.subarray(start + 1, end)));
|
|
14692
14768
|
let unsafe = false;
|
|
14693
14769
|
for (const edgeId of edgeIndex(box(a, b), charge)) {
|
|
14694
|
-
const edge2 =
|
|
14770
|
+
const edge2 = edges2[edgeId];
|
|
14695
14771
|
if (edge2.p === p && edge2.i >= start && edge2.i < end) {
|
|
14696
14772
|
if (straight2)
|
|
14697
14773
|
continue;
|
|
@@ -14931,7 +15007,7 @@ function createTerrainIsobands(fields, levels, options = {}) {
|
|
|
14931
15007
|
return out.filter((v, i) => v.key !== out[(i + 1) % out.length].key);
|
|
14932
15008
|
};
|
|
14933
15009
|
for (let band = 0; band + 1 < levels.length; band++) {
|
|
14934
|
-
const
|
|
15010
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
14935
15011
|
for (const fieldId of rangeIndex({ minX: levels[band], maxX: levels[band + 1], minY: 0, maxY: 0 }, charge))
|
|
14936
15012
|
for (let y = 0; y < fields[fieldId].height - 1; y++)
|
|
14937
15013
|
for (let x = 0; x < fields[fieldId].width - 1; x++) {
|
|
@@ -14987,33 +15063,33 @@ function createTerrainIsobands(fields, levels, options = {}) {
|
|
|
14987
15063
|
if (++edgeCount > maxEdges)
|
|
14988
15064
|
throw new Error("Isoband edge capacity exceeded");
|
|
14989
15065
|
const key3 = `${a.key}>${b.key}`, reverse2 = `${b.key}>${a.key}`;
|
|
14990
|
-
if (
|
|
14991
|
-
|
|
15066
|
+
if (edges2.has(reverse2))
|
|
15067
|
+
edges2.delete(reverse2);
|
|
14992
15068
|
else {
|
|
14993
|
-
if (
|
|
15069
|
+
if (edges2.has(key3))
|
|
14994
15070
|
throw new Error("Overlapping isoband tiles");
|
|
14995
|
-
|
|
15071
|
+
edges2.set(key3, { a, b });
|
|
14996
15072
|
}
|
|
14997
15073
|
}
|
|
14998
15074
|
}
|
|
14999
15075
|
}
|
|
15000
15076
|
const outgoing = /* @__PURE__ */ new Map();
|
|
15001
|
-
for (const [key3, e] of
|
|
15077
|
+
for (const [key3, e] of edges2) {
|
|
15002
15078
|
if (!outgoing.has(e.a.key))
|
|
15003
15079
|
outgoing.set(e.a.key, /* @__PURE__ */ new Set());
|
|
15004
15080
|
outgoing.get(e.a.key).add(key3);
|
|
15005
15081
|
}
|
|
15006
|
-
while (
|
|
15007
|
-
const first =
|
|
15082
|
+
while (edges2.size) {
|
|
15083
|
+
const first = edges2.values().next().value, ring = [];
|
|
15008
15084
|
let edge2 = first;
|
|
15009
15085
|
for (; ; ) {
|
|
15010
15086
|
charge();
|
|
15011
15087
|
ring.push(edge2.a);
|
|
15012
|
-
|
|
15088
|
+
edges2.delete(`${edge2.a.key}>${edge2.b.key}`);
|
|
15013
15089
|
outgoing.get(edge2.a.key).delete(`${edge2.a.key}>${edge2.b.key}`);
|
|
15014
15090
|
if (edge2.b.key === first.a.key)
|
|
15015
15091
|
break;
|
|
15016
|
-
const choices = [...outgoing.get(edge2.b.key) ?? []].map((k) =>
|
|
15092
|
+
const choices = [...outgoing.get(edge2.b.key) ?? []].map((k) => edges2.get(k));
|
|
15017
15093
|
if (!choices.length)
|
|
15018
15094
|
throw new Error("Open isoband boundary");
|
|
15019
15095
|
const angle3 = (e) => Math.atan2((edge2.b.x - edge2.a.x) * (e.b.y - e.a.y) - (edge2.b.y - edge2.a.y) * (e.b.x - e.a.x), (edge2.b.x - edge2.a.x) * (e.b.x - e.a.x) + (edge2.b.y - edge2.a.y) * (e.b.y - e.a.y));
|
|
@@ -15894,12 +15970,12 @@ function meshValidDomain(field, options, constraints) {
|
|
|
15894
15970
|
const { width, height, origin, heightReference } = regular;
|
|
15895
15971
|
const active = new Uint8Array(count);
|
|
15896
15972
|
const boundary = /* @__PURE__ */ new Map();
|
|
15897
|
-
const
|
|
15973
|
+
const edgeKey3 = (a, b) => Math.min(a, b) * count + Math.max(a, b);
|
|
15898
15974
|
for (let i = 0; i < regular.indices.length; i += 3) {
|
|
15899
15975
|
for (let j = 0; j < 3; j++) {
|
|
15900
15976
|
const a = regular.indices[i + j], b = regular.indices[i + (j + 1) % 3];
|
|
15901
15977
|
active[a] = 1;
|
|
15902
|
-
const key3 =
|
|
15978
|
+
const key3 = edgeKey3(a, b);
|
|
15903
15979
|
if (!boundary.delete(key3))
|
|
15904
15980
|
boundary.set(key3, [a, b]);
|
|
15905
15981
|
}
|
|
@@ -15915,8 +15991,8 @@ function meshValidDomain(field, options, constraints) {
|
|
|
15915
15991
|
}
|
|
15916
15992
|
return selected[i];
|
|
15917
15993
|
};
|
|
15918
|
-
const
|
|
15919
|
-
const extra = constraints == null ? void 0 : constraints(points, heights,
|
|
15994
|
+
const edges2 = Array.from(boundary.values(), ([a, b]) => [add4(a), add4(b)]);
|
|
15995
|
+
const extra = constraints == null ? void 0 : constraints(points, heights, edges2, selected, origin[2]);
|
|
15920
15996
|
const inDomain = ([a, b, c]) => {
|
|
15921
15997
|
const x = (points[a][0] + points[b][0] + points[c][0]) / 3;
|
|
15922
15998
|
const y = (points[a][1] + points[b][1] + points[c][1]) / 3;
|
|
@@ -15934,7 +16010,7 @@ function meshValidDomain(field, options, constraints) {
|
|
|
15934
16010
|
let certifiedSamples = 0;
|
|
15935
16011
|
let tests = 0;
|
|
15936
16012
|
for (let pass = 0; points.length; pass++) {
|
|
15937
|
-
triangles = (0, import_cdt2d.default)(points, (extra == null ? void 0 : extra.edges) ??
|
|
16013
|
+
triangles = (0, import_cdt2d.default)(points, (extra == null ? void 0 : extra.edges) ?? edges2, {
|
|
15938
16014
|
exterior: Boolean(extra),
|
|
15939
16015
|
delaunay: false
|
|
15940
16016
|
});
|
|
@@ -16078,7 +16154,7 @@ function createBreaklineTerrainMesh(field, options) {
|
|
|
16078
16154
|
throw new Error("Zero-length breakline");
|
|
16079
16155
|
breaklineEdges.push([p, q]);
|
|
16080
16156
|
}
|
|
16081
|
-
const
|
|
16157
|
+
const edges3 = [];
|
|
16082
16158
|
for (const [a, b] of boundary) {
|
|
16083
16159
|
const split = [
|
|
16084
16160
|
a,
|
|
@@ -16088,7 +16164,7 @@ function createBreaklineTerrainMesh(field, options) {
|
|
|
16088
16164
|
const [x, y] = points[a];
|
|
16089
16165
|
split.sort((i, j) => Math.hypot(points[i][0] - x, points[i][1] - y) - Math.hypot(points[j][0] - x, points[j][1] - y));
|
|
16090
16166
|
for (let i = 1; i < split.length; i++)
|
|
16091
|
-
|
|
16167
|
+
edges3.push([split[i - 1], split[i]]);
|
|
16092
16168
|
}
|
|
16093
16169
|
const seen = /* @__PURE__ */ new Set();
|
|
16094
16170
|
for (const [a, b] of breaklineEdges) {
|
|
@@ -16098,19 +16174,19 @@ function createBreaklineTerrainMesh(field, options) {
|
|
|
16098
16174
|
seen.add(key3);
|
|
16099
16175
|
const p = points[a], q = points[b];
|
|
16100
16176
|
let coincident = false;
|
|
16101
|
-
for (const [c, d] of
|
|
16177
|
+
for (const [c, d] of edges3) {
|
|
16102
16178
|
if (a === c && b === d || a === d && b === c) {
|
|
16103
16179
|
coincident = true;
|
|
16104
16180
|
continue;
|
|
16105
16181
|
}
|
|
16106
16182
|
const r = points[c], s = points[d];
|
|
16107
|
-
const
|
|
16108
|
-
if (
|
|
16183
|
+
const intersects3 = Math.sign(cross4(p, q, r)) * Math.sign(cross4(p, q, s)) < 0 && Math.sign(cross4(r, s, p)) * Math.sign(cross4(r, s, q)) < 0;
|
|
16184
|
+
if (intersects3 || c !== a && c !== b && onSegment(p, q, r) || d !== a && d !== b && onSegment(p, q, s) || a !== c && a !== d && onSegment(r, s, p) || b !== c && b !== d && onSegment(r, s, q)) {
|
|
16109
16185
|
throw new Error("Breaklines and domain edges must meet only at shared endpoints");
|
|
16110
16186
|
}
|
|
16111
16187
|
}
|
|
16112
16188
|
if (!coincident)
|
|
16113
|
-
|
|
16189
|
+
edges3.push([a, b]);
|
|
16114
16190
|
for (let y = Math.ceil(Math.min(p[1], q[1])); y <= Math.floor(Math.max(p[1], q[1])); y++) {
|
|
16115
16191
|
for (let x = Math.ceil(Math.min(p[0], q[0])); x <= Math.floor(Math.max(p[0], q[0])); x++) {
|
|
16116
16192
|
const source = field.getHeight(x, y);
|
|
@@ -16129,16 +16205,16 @@ function createBreaklineTerrainMesh(field, options) {
|
|
|
16129
16205
|
}
|
|
16130
16206
|
}
|
|
16131
16207
|
overriddenSamples = excluded.size;
|
|
16132
|
-
return { edges:
|
|
16208
|
+
return { edges: edges3, excluded, fixedSamples };
|
|
16133
16209
|
});
|
|
16134
|
-
const
|
|
16210
|
+
const edges2 = /* @__PURE__ */ new Set();
|
|
16135
16211
|
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
16136
16212
|
for (let j = 0; j < 3; j++) {
|
|
16137
16213
|
const a = mesh.indices[i + j], b = mesh.indices[i + (j + 1) % 3];
|
|
16138
|
-
|
|
16214
|
+
edges2.add(`${Math.min(a, b)},${Math.max(a, b)}`);
|
|
16139
16215
|
}
|
|
16140
16216
|
}
|
|
16141
|
-
if (breaklineEdges.some(([a, b]) => !
|
|
16217
|
+
if (breaklineEdges.some(([a, b]) => !edges2.has(`${Math.min(a, b)},${Math.max(a, b)}`))) {
|
|
16142
16218
|
throw new Error("Breakline was not preserved inside the valid terrain domain");
|
|
16143
16219
|
}
|
|
16144
16220
|
return { ...mesh, breaklineEdges: Uint32Array.from(breaklineEdges.flat()), overriddenSamples };
|
|
@@ -16338,21 +16414,21 @@ function wrapTerrainLongitude(longitude, west, east) {
|
|
|
16338
16414
|
function measureGeographicTerrainSeam(a, b, probes, options = {}) {
|
|
16339
16415
|
if (a && b && a.heightReference !== b.heightReference)
|
|
16340
16416
|
throw new Error("Terrain seam height references differ");
|
|
16341
|
-
const sample = (field, longitude,
|
|
16417
|
+
const sample = (field, longitude, latitude2) => {
|
|
16342
16418
|
if (!field || !Number.isFinite(longitude))
|
|
16343
|
-
return field == null ? void 0 : field.sample(longitude,
|
|
16419
|
+
return field == null ? void 0 : field.sample(longitude, latitude2, options);
|
|
16344
16420
|
const mapped = wrapTerrainLongitude(longitude, field.bounds[0], field.bounds[2]);
|
|
16345
|
-
return field.sample(mapped ?? longitude,
|
|
16421
|
+
return field.sample(mapped ?? longitude, latitude2, options);
|
|
16346
16422
|
};
|
|
16347
|
-
return probes.map(([longitude,
|
|
16348
|
-
const left = sample(a, longitude,
|
|
16349
|
-
const right = sample(b, longitude,
|
|
16423
|
+
return probes.map(([longitude, latitude2]) => {
|
|
16424
|
+
const left = sample(a, longitude, latitude2);
|
|
16425
|
+
const right = sample(b, longitude, latitude2);
|
|
16350
16426
|
const valid = (left == null ? void 0 : left.status) === TerrainSampleStatus.VALID && (right == null ? void 0 : right.status) === TerrainSampleStatus.VALID;
|
|
16351
16427
|
const derivatives = (left == null ? void 0 : left.gradientStatus) === TerrainSampleStatus.VALID && (right == null ? void 0 : right.gradientStatus) === TerrainSampleStatus.VALID;
|
|
16352
16428
|
const normalAngle = derivatives ? Math.atan2(Math.hypot(left.normalY * right.normalZ - left.normalZ * right.normalY, left.normalZ * right.normalX - left.normalX * right.normalZ, left.normalX * right.normalY - left.normalY * right.normalX), left.normalX * right.normalX + left.normalY * right.normalY + left.normalZ * right.normalZ) : null;
|
|
16353
16429
|
return {
|
|
16354
16430
|
longitude,
|
|
16355
|
-
latitude,
|
|
16431
|
+
latitude: latitude2,
|
|
16356
16432
|
statusA: (left == null ? void 0 : left.status) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
16357
16433
|
statusB: (right == null ? void 0 : right.status) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
16358
16434
|
gradientStatusA: (left == null ? void 0 : left.gradientStatus) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
@@ -16363,15 +16439,75 @@ function measureGeographicTerrainSeam(a, b, probes, options = {}) {
|
|
|
16363
16439
|
});
|
|
16364
16440
|
}
|
|
16365
16441
|
|
|
16442
|
+
// dist/terrain/lod-screen-error.js
|
|
16443
|
+
function slack(value3) {
|
|
16444
|
+
return Math.abs(value3) * (2 * Number.EPSILON) + Number.MIN_VALUE;
|
|
16445
|
+
}
|
|
16446
|
+
function down(value3) {
|
|
16447
|
+
return value3 - slack(value3);
|
|
16448
|
+
}
|
|
16449
|
+
function up(value3) {
|
|
16450
|
+
return value3 + slack(value3);
|
|
16451
|
+
}
|
|
16452
|
+
function boundTerrainLodScreenError(bounds2, projection2) {
|
|
16453
|
+
if (bounds2.min.length !== 3 || bounds2.max.length !== 3 || !bounds2.min.every((value3, i) => Number.isFinite(value3) && value3 <= bounds2.max[i]) || !bounds2.max.every(Number.isFinite) || !Number.isFinite(bounds2.geometricError) || bounds2.geometricError < 0)
|
|
16454
|
+
throw new RangeError("Invalid terrain LOD screen-error bounds");
|
|
16455
|
+
return prepareTerrainLodScreenError(projection2)(bounds2);
|
|
16456
|
+
}
|
|
16457
|
+
function prepareTerrainLodScreenError(projection2) {
|
|
16458
|
+
const { width, height, depthRange = "negative-one-to-one", reversedDepth = false } = projection2;
|
|
16459
|
+
if (projection2.matrix.length !== 16)
|
|
16460
|
+
throw new RangeError("Invalid terrain LOD clip matrix");
|
|
16461
|
+
const matrix = Array.from(projection2.matrix);
|
|
16462
|
+
if (!matrix.every(Number.isFinite) || !Number.isFinite(width) || width <= 0 || !Number.isFinite(height) || height <= 0 || depthRange !== "negative-one-to-one" && depthRange !== "zero-to-one")
|
|
16463
|
+
throw new RangeError("Invalid terrain LOD projection");
|
|
16464
|
+
return ({ min, max, geometricError: error }) => {
|
|
16465
|
+
if (error === 0)
|
|
16466
|
+
return 0;
|
|
16467
|
+
function row(index) {
|
|
16468
|
+
let lower = matrix[12 + index];
|
|
16469
|
+
let upper = lower;
|
|
16470
|
+
let change = 0;
|
|
16471
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
16472
|
+
const coefficient = matrix[4 * axis + index];
|
|
16473
|
+
const a = coefficient * min[axis];
|
|
16474
|
+
const b = coefficient * max[axis];
|
|
16475
|
+
lower = down(lower + down(Math.min(a, b)));
|
|
16476
|
+
upper = up(upper + up(Math.max(a, b)));
|
|
16477
|
+
change = up(change + up(Math.abs(coefficient) * error));
|
|
16478
|
+
}
|
|
16479
|
+
return { lower, upper, change };
|
|
16480
|
+
}
|
|
16481
|
+
const w = row(3);
|
|
16482
|
+
const z = row(2);
|
|
16483
|
+
const nearLow = reversedDepth ? down(w.lower - z.upper) : depthRange === "zero-to-one" ? z.lower : down(z.lower + w.lower);
|
|
16484
|
+
const nearHigh = reversedDepth ? up(w.upper - z.lower) : depthRange === "zero-to-one" ? z.upper : up(z.upper + w.upper);
|
|
16485
|
+
const nearChange = !reversedDepth && depthRange === "zero-to-one" ? z.change : up(z.change + w.change);
|
|
16486
|
+
if (up(nearHigh + nearChange) < 0)
|
|
16487
|
+
return 0;
|
|
16488
|
+
const denominator = down(w.lower - w.change);
|
|
16489
|
+
if (!(down(nearLow - nearChange) > 0 && denominator > 0))
|
|
16490
|
+
return Infinity;
|
|
16491
|
+
function pixelAxis(index, extent) {
|
|
16492
|
+
const coordinate = row(index);
|
|
16493
|
+
const magnitude2 = Math.max(Math.abs(coordinate.lower), Math.abs(coordinate.upper));
|
|
16494
|
+
const ndc = up(magnitude2 / denominator);
|
|
16495
|
+
const coupling = up(ndc * w.change);
|
|
16496
|
+
const numerator = up(coordinate.change + coupling);
|
|
16497
|
+
return up(up(numerator / denominator) * up(extent / 2));
|
|
16498
|
+
}
|
|
16499
|
+
const pixels = pixelAxis(0, width) + pixelAxis(1, height);
|
|
16500
|
+
return Number.isFinite(pixels) ? up(pixels) : Infinity;
|
|
16501
|
+
};
|
|
16502
|
+
}
|
|
16503
|
+
|
|
16366
16504
|
// dist/terrain/lod-select.js
|
|
16367
16505
|
function selectTerrainLod(roots2, view) {
|
|
16368
16506
|
var _a;
|
|
16369
|
-
const {
|
|
16370
|
-
if (!
|
|
16507
|
+
const { targetPixels, hysteresis = 0.2, previouslyRefined, maxVisited = 1e5 } = view;
|
|
16508
|
+
if (!Number.isFinite(targetPixels) || targetPixels <= 0 || !(hysteresis >= 0 && hysteresis < 1) || !Number.isSafeInteger(maxVisited) || maxVisited < 1)
|
|
16371
16509
|
throw new Error("Invalid terrain LOD view");
|
|
16372
|
-
const
|
|
16373
|
-
if (!Number.isFinite(scale3))
|
|
16374
|
-
throw new Error("Terrain LOD projection scale overflow");
|
|
16510
|
+
const pixelError = "projection" in view ? prepareTerrainLodScreenError(view.projection) : createDistanceEstimator(view.position, view.verticalFov, view.viewportHeight);
|
|
16375
16511
|
const selected = [];
|
|
16376
16512
|
const refined = /* @__PURE__ */ new Set();
|
|
16377
16513
|
const unavailable = [];
|
|
@@ -16384,14 +16520,13 @@ function selectTerrainLod(roots2, view) {
|
|
|
16384
16520
|
if (seen.has(tile.id))
|
|
16385
16521
|
throw new Error("Duplicate terrain LOD tile or cycle");
|
|
16386
16522
|
seen.add(tile.id);
|
|
16387
|
-
if (![...tile.min, ...tile.max, tile.geometricError].every(Number.isFinite) || tile.geometricError < 0 || tile.min.some((n, i) => n > tile.max[i]))
|
|
16523
|
+
if (tile.min.length !== 3 || tile.max.length !== 3 || ![...tile.min, ...tile.max, tile.geometricError].every(Number.isFinite) || tile.geometricError < 0 || tile.min.some((n, i) => n > tile.max[i]))
|
|
16388
16524
|
throw new Error("Invalid terrain LOD tile bounds or error");
|
|
16389
16525
|
if (!tile.resident) {
|
|
16390
16526
|
unavailable.push(tile.id);
|
|
16391
16527
|
continue;
|
|
16392
16528
|
}
|
|
16393
|
-
const
|
|
16394
|
-
const pixels = tile.geometricError === 0 ? 0 : tile.geometricError / distance * scale3;
|
|
16529
|
+
const pixels = pixelError(tile);
|
|
16395
16530
|
const threshold = targetPixels * ((previouslyRefined == null ? void 0 : previouslyRefined.has(tile.id)) ? 1 - hysteresis : 1);
|
|
16396
16531
|
if (pixels > threshold && ((_a = tile.children) == null ? void 0 : _a.length) && tile.children.every((child) => child.resident)) {
|
|
16397
16532
|
if (pending.length + seen.size + tile.children.length > maxVisited)
|
|
@@ -16405,20 +16540,41 @@ function selectTerrainLod(roots2, view) {
|
|
|
16405
16540
|
}
|
|
16406
16541
|
return { selected, refined, unavailable };
|
|
16407
16542
|
}
|
|
16543
|
+
function createDistanceEstimator(position2, verticalFov, viewportHeight) {
|
|
16544
|
+
if (!position2.every(Number.isFinite) || !Number.isFinite(verticalFov) || verticalFov <= 0 || verticalFov >= Math.PI || !Number.isFinite(viewportHeight) || viewportHeight <= 0)
|
|
16545
|
+
throw new Error("Invalid terrain LOD view");
|
|
16546
|
+
const scale3 = viewportHeight / (2 * Math.tan(verticalFov / 2));
|
|
16547
|
+
if (!Number.isFinite(scale3))
|
|
16548
|
+
throw new Error("Terrain LOD projection scale overflow");
|
|
16549
|
+
return (tile) => {
|
|
16550
|
+
const distance = Math.hypot(...position2.map((n, i) => Math.max(tile.min[i] - n, n - tile.max[i], 0)));
|
|
16551
|
+
return tile.geometricError === 0 ? 0 : tile.geometricError / distance * scale3;
|
|
16552
|
+
};
|
|
16553
|
+
}
|
|
16408
16554
|
|
|
16409
16555
|
// dist/terrain/lod-stitch.js
|
|
16410
16556
|
function stitchTerrainLodCut(input, seams) {
|
|
16411
16557
|
const meshes = input.slice();
|
|
16412
16558
|
const paired = [];
|
|
16413
|
-
for (const { a, edgeA, b, edgeB, options } of seams) {
|
|
16559
|
+
for (const { a, edgeA, b, edgeB, options, offsetBX = 0 } of seams) {
|
|
16414
16560
|
if (a === b || !Number.isInteger(a) || !Number.isInteger(b) || !meshes[a] || !meshes[b])
|
|
16415
16561
|
throw new Error("Invalid terrain LOD seam tile index");
|
|
16416
|
-
|
|
16562
|
+
if (!Number.isFinite(offsetBX))
|
|
16563
|
+
throw new Error("Invalid terrain LOD seam offset");
|
|
16564
|
+
const meshB = meshes[b];
|
|
16565
|
+
const shiftedB = offsetBX === 0 ? meshB : {
|
|
16566
|
+
...meshB,
|
|
16567
|
+
origin: [meshB.origin[0] + offsetBX, meshB.origin[1], meshB.origin[2]]
|
|
16568
|
+
};
|
|
16569
|
+
const result = stitchTerrainMeshEdges(meshes[a], edgeA, shiftedB, edgeB, options);
|
|
16417
16570
|
meshes[a] = result.a;
|
|
16418
|
-
meshes[b] = result.b
|
|
16419
|
-
|
|
16571
|
+
meshes[b] = offsetBX === 0 ? result.b : {
|
|
16572
|
+
...result.b,
|
|
16573
|
+
origin: [result.b.origin[0] - offsetBX, result.b.origin[1], result.b.origin[2]]
|
|
16574
|
+
};
|
|
16575
|
+
paired.push({ a, b, idsA: result.seamA, idsB: result.seamB, offsetBX });
|
|
16420
16576
|
}
|
|
16421
|
-
for (const { a, b, idsA, idsB } of paired) {
|
|
16577
|
+
for (const { a, b, idsA, idsB, offsetBX } of paired) {
|
|
16422
16578
|
const ma = meshes[a], mb = meshes[b];
|
|
16423
16579
|
const path = (mesh, ids) => {
|
|
16424
16580
|
const links = /* @__PURE__ */ new Set();
|
|
@@ -16437,7 +16593,7 @@ function stitchTerrainLodCut(input, seams) {
|
|
|
16437
16593
|
throw new Error("Overlapping terrain LOD seam ranges require a common subdivision");
|
|
16438
16594
|
for (let i = 0; i < idsA.length; i++) {
|
|
16439
16595
|
for (let axis = 0; axis < 3; axis++) {
|
|
16440
|
-
const offset2 = mb.origin[axis] - ma.origin[axis];
|
|
16596
|
+
const offset2 = mb.origin[axis] + (axis === 0 ? offsetBX : 0) - ma.origin[axis];
|
|
16441
16597
|
const av = ma.positions[3 * idsA[i] + axis], bv = mb.positions[3 * idsB[i] + axis];
|
|
16442
16598
|
const residual = av - bv - offset2;
|
|
16443
16599
|
const roundoff = 8 * Number.EPSILON * (Math.abs(av) + Math.abs(bv) + Math.abs(offset2));
|
|
@@ -16491,14 +16647,14 @@ function splitTerrainBreaklines(input, options = {}) {
|
|
|
16491
16647
|
throw new Error("Breakline output limit exceeded");
|
|
16492
16648
|
knots.push({ t, point: point2 });
|
|
16493
16649
|
};
|
|
16494
|
-
const
|
|
16650
|
+
const cross7 = (ax, ay, bx, by) => ax * by - ay * bx;
|
|
16495
16651
|
for (let i = 0; i < lines.length; i++) {
|
|
16496
16652
|
const a = lines[i];
|
|
16497
16653
|
for (let j = i + 1; j < lines.length; j++) {
|
|
16498
16654
|
const b = lines[j];
|
|
16499
16655
|
const x = b.p[0] - a.p[0], y = b.p[1] - a.p[1];
|
|
16500
|
-
const det =
|
|
16501
|
-
const u =
|
|
16656
|
+
const det = cross7(a.dx, a.dy, b.dx, b.dy);
|
|
16657
|
+
const u = cross7(x, y, a.dx, a.dy), t = cross7(x, y, b.dx, b.dy);
|
|
16502
16658
|
if (![det, u, t].every(Number.isFinite))
|
|
16503
16659
|
throw new Error("Breakline intersection overflow");
|
|
16504
16660
|
if (det === 0) {
|
|
@@ -16587,7 +16743,7 @@ function certifyTerrainMeshCoverage(field, mesh, options = {}) {
|
|
|
16587
16743
|
}
|
|
16588
16744
|
const vertices = [];
|
|
16589
16745
|
const vertexIds = /* @__PURE__ */ new Map();
|
|
16590
|
-
const
|
|
16746
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
16591
16747
|
function vertex(x, y) {
|
|
16592
16748
|
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
16593
16749
|
throw new Error("Nonfinite coverage coordinate");
|
|
@@ -16607,11 +16763,11 @@ function certifyTerrainMeshCoverage(field, mesh, options = {}) {
|
|
|
16607
16763
|
weight = -weight;
|
|
16608
16764
|
}
|
|
16609
16765
|
const key3 = b < 2 ** 26 ? a * 2 ** 26 + b : `${a},${b}`;
|
|
16610
|
-
const sum = (((_a2 =
|
|
16766
|
+
const sum = (((_a2 = edges2.get(key3)) == null ? void 0 : _a2.weight) ?? 0) + weight;
|
|
16611
16767
|
if (sum === 0)
|
|
16612
|
-
|
|
16768
|
+
edges2.delete(key3);
|
|
16613
16769
|
else
|
|
16614
|
-
|
|
16770
|
+
edges2.set(key3, { a, b, weight: sum });
|
|
16615
16771
|
}
|
|
16616
16772
|
function triangle(a, b, c, weight) {
|
|
16617
16773
|
edge2(a, b, weight);
|
|
@@ -16676,7 +16832,7 @@ function certifyTerrainMeshCoverage(field, mesh, options = {}) {
|
|
|
16676
16832
|
}
|
|
16677
16833
|
}
|
|
16678
16834
|
const lines = /* @__PURE__ */ new Map();
|
|
16679
|
-
for (const { a, b, weight } of
|
|
16835
|
+
for (const { a, b, weight } of edges2.values()) {
|
|
16680
16836
|
const p = vertices[a], q = vertices[b];
|
|
16681
16837
|
const [x, y] = p.map(exact3), [u, v] = q.map(exact3);
|
|
16682
16838
|
const divisor = gcd(u - x, v - y);
|
|
@@ -16712,7 +16868,1807 @@ function certifyTerrainMeshCoverage(field, mesh, options = {}) {
|
|
|
16712
16868
|
unmatchedSegments,
|
|
16713
16869
|
witness,
|
|
16714
16870
|
trianglesVisited,
|
|
16715
|
-
residualEdges:
|
|
16871
|
+
residualEdges: edges2.size
|
|
16716
16872
|
};
|
|
16717
16873
|
}
|
|
16874
|
+
|
|
16875
|
+
// dist/terrain/geographic-neighbor.js
|
|
16876
|
+
function getGeographicTerrainNeighbor(tile, edge2) {
|
|
16877
|
+
getGeographicTileBounds(tile);
|
|
16878
|
+
const { x, y, level } = tile;
|
|
16879
|
+
const size = 2 ** level;
|
|
16880
|
+
switch (edge2) {
|
|
16881
|
+
case "west":
|
|
16882
|
+
case "east": {
|
|
16883
|
+
const ownerX = edge2 === "west" ? x : (x + 1) % size;
|
|
16884
|
+
return {
|
|
16885
|
+
owner: { x: ownerX, y, level },
|
|
16886
|
+
ownerEdge: "west",
|
|
16887
|
+
other: { x: (ownerX + size - 1) % size, y, level },
|
|
16888
|
+
otherEdge: "east",
|
|
16889
|
+
crossesAntimeridian: ownerX === 0
|
|
16890
|
+
};
|
|
16891
|
+
}
|
|
16892
|
+
case "north":
|
|
16893
|
+
case "south": {
|
|
16894
|
+
const ownerY = edge2 === "north" ? y : y + 1;
|
|
16895
|
+
if (ownerY === 0 || ownerY === size)
|
|
16896
|
+
return null;
|
|
16897
|
+
return {
|
|
16898
|
+
owner: { x, y: ownerY, level },
|
|
16899
|
+
ownerEdge: "north",
|
|
16900
|
+
other: { x, y: ownerY - 1, level },
|
|
16901
|
+
otherEdge: "south",
|
|
16902
|
+
crossesAntimeridian: false
|
|
16903
|
+
};
|
|
16904
|
+
}
|
|
16905
|
+
default:
|
|
16906
|
+
throw new RangeError("Invalid geographic terrain edge");
|
|
16907
|
+
}
|
|
16908
|
+
}
|
|
16909
|
+
|
|
16910
|
+
// dist/terrain/sweep-sphere.js
|
|
16911
|
+
function sweepTerrainSphere(surface2, start, end, radius, { fractionTolerance = 1e-6, maxWork = 1e5 } = {}) {
|
|
16912
|
+
if (!(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1) || !Number.isSafeInteger(maxWork) || maxWork < 0)
|
|
16913
|
+
throw new RangeError("Invalid terrain sphere sweep limits");
|
|
16914
|
+
const delta = end.map((value3, axis) => value3 - start[axis]);
|
|
16915
|
+
if (start.length !== 3 || end.length !== 3 || !start.every(Number.isFinite) || !end.every(Number.isFinite) || !delta.every(Number.isFinite) || !Number.isFinite(radius) || radius < 0)
|
|
16916
|
+
throw new RangeError("Invalid terrain sphere sweep motion or radius");
|
|
16917
|
+
let work = 0;
|
|
16918
|
+
let lower = 0;
|
|
16919
|
+
let upper = 1;
|
|
16920
|
+
const prefix = (fraction) => {
|
|
16921
|
+
const endPoint = fraction === 0 ? start : fraction === 1 ? end : [
|
|
16922
|
+
start[0] + delta[0] * fraction,
|
|
16923
|
+
start[1] + delta[1] * fraction,
|
|
16924
|
+
start[2] + delta[2] * fraction
|
|
16925
|
+
];
|
|
16926
|
+
const query = surface2.intersectCapsule(start, endPoint, radius, {
|
|
16927
|
+
maxWork: maxWork - work,
|
|
16928
|
+
maxContacts: 1
|
|
16929
|
+
});
|
|
16930
|
+
work += query.work;
|
|
16931
|
+
return query;
|
|
16932
|
+
};
|
|
16933
|
+
const initial = prefix(0);
|
|
16934
|
+
if (initial.result[0])
|
|
16935
|
+
return { status: "hit", fraction: 0, lowerFraction: 0, contact: initial.result[0], work };
|
|
16936
|
+
if (!initial.complete)
|
|
16937
|
+
return { status: "incomplete", work };
|
|
16938
|
+
const full = prefix(1);
|
|
16939
|
+
let contact = full.result[0];
|
|
16940
|
+
if (!contact)
|
|
16941
|
+
return { status: full.complete ? "miss" : "incomplete", work };
|
|
16942
|
+
while (upper - lower > fractionTolerance) {
|
|
16943
|
+
const middle = (lower + upper) / 2;
|
|
16944
|
+
const query = prefix(middle);
|
|
16945
|
+
if (query.result[0]) {
|
|
16946
|
+
upper = middle;
|
|
16947
|
+
contact = query.result[0];
|
|
16948
|
+
} else if (query.complete) {
|
|
16949
|
+
lower = middle;
|
|
16950
|
+
} else {
|
|
16951
|
+
return { status: "incomplete", work };
|
|
16952
|
+
}
|
|
16953
|
+
}
|
|
16954
|
+
return { status: "hit", fraction: upper, lowerFraction: lower, contact, work };
|
|
16955
|
+
}
|
|
16956
|
+
|
|
16957
|
+
// dist/terrain/sweep-capsule.js
|
|
16958
|
+
function sweepTerrainCapsule(surface2, start, end, translation, radius, { fractionTolerance = 1e-6, maxWork = 1e5 } = {}) {
|
|
16959
|
+
var _a;
|
|
16960
|
+
const speed = Math.hypot(...translation);
|
|
16961
|
+
if (![start, end, translation].every((point2) => point2.length === 3 && point2.every(Number.isFinite)) || !Number.isFinite(speed) || !Number.isFinite(radius) || radius < 0 || !(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1) || !Number.isSafeInteger(maxWork) || maxWork < 0)
|
|
16962
|
+
throw new RangeError("Invalid terrain capsule sweep");
|
|
16963
|
+
let work = 0;
|
|
16964
|
+
const probe = (fraction) => {
|
|
16965
|
+
if (work >= maxWork)
|
|
16966
|
+
return null;
|
|
16967
|
+
work++;
|
|
16968
|
+
const move = (point2) => [
|
|
16969
|
+
point2[0] + translation[0] * fraction,
|
|
16970
|
+
point2[1] + translation[1] * fraction,
|
|
16971
|
+
point2[2] + translation[2] * fraction
|
|
16972
|
+
];
|
|
16973
|
+
const query = surface2.nearestSegmentQuery(move(start), move(end), { maxWork: maxWork - work });
|
|
16974
|
+
work += query.work;
|
|
16975
|
+
return query;
|
|
16976
|
+
};
|
|
16977
|
+
const initial = probe(0);
|
|
16978
|
+
if ((initial == null ? void 0 : initial.result) && initial.result.distance <= radius)
|
|
16979
|
+
return { status: "hit", work, fraction: 0, lowerFraction: 0, contact: initial.result };
|
|
16980
|
+
if (!(initial == null ? void 0 : initial.complete))
|
|
16981
|
+
return { status: "incomplete", work };
|
|
16982
|
+
if (!initial.result || speed === 0)
|
|
16983
|
+
return { status: "miss", work };
|
|
16984
|
+
let clearUntil = 0;
|
|
16985
|
+
let witness;
|
|
16986
|
+
const pending = [[0, 1]];
|
|
16987
|
+
while (pending.length) {
|
|
16988
|
+
const [lower, upper] = pending.pop();
|
|
16989
|
+
if (witness && witness.fraction - clearUntil <= fractionTolerance)
|
|
16990
|
+
return { status: "hit", work, lowerFraction: clearUntil, ...witness };
|
|
16991
|
+
const middle = lower + (upper - lower) / 2;
|
|
16992
|
+
const query = probe(middle);
|
|
16993
|
+
if (!query)
|
|
16994
|
+
return { status: "incomplete", work };
|
|
16995
|
+
const hit = query.result;
|
|
16996
|
+
if (hit && hit.distance <= radius) {
|
|
16997
|
+
witness = { fraction: middle, contact: hit };
|
|
16998
|
+
if (middle - clearUntil <= fractionTolerance)
|
|
16999
|
+
return { status: "hit", work, lowerFraction: clearUntil, ...witness };
|
|
17000
|
+
pending.push([lower, middle]);
|
|
17001
|
+
continue;
|
|
17002
|
+
}
|
|
17003
|
+
if (!query.complete)
|
|
17004
|
+
return { status: "incomplete", work };
|
|
17005
|
+
const travel = speed * Math.max(middle - lower, upper - middle);
|
|
17006
|
+
const allowance = 8 * Number.EPSILON * Math.max((hit == null ? void 0 : hit.distance) ?? 0, radius, travel);
|
|
17007
|
+
if (!hit || hit.distance - radius > travel + allowance) {
|
|
17008
|
+
clearUntil = upper;
|
|
17009
|
+
continue;
|
|
17010
|
+
}
|
|
17011
|
+
if (upper - lower <= fractionTolerance) {
|
|
17012
|
+
const final = (_a = probe(upper)) == null ? void 0 : _a.result;
|
|
17013
|
+
if (final && final.distance <= radius && upper - clearUntil <= fractionTolerance)
|
|
17014
|
+
return { status: "hit", work, fraction: upper, lowerFraction: clearUntil, contact: final };
|
|
17015
|
+
return { status: "incomplete", work };
|
|
17016
|
+
}
|
|
17017
|
+
pending.push([middle, upper], [lower, middle]);
|
|
17018
|
+
}
|
|
17019
|
+
return witness ? { status: "hit", work, lowerFraction: clearUntil, ...witness } : { status: "miss", work };
|
|
17020
|
+
}
|
|
17021
|
+
function sweepTerrainTaperedCapsule(surface2, start, end, translation, radiusStart, radiusEnd, { maxWork = 1e5, fractionTolerance } = {}) {
|
|
17022
|
+
if (![radiusStart, radiusEnd].every((radius) => Number.isFinite(radius) && radius >= 0))
|
|
17023
|
+
throw new RangeError("Invalid terrain tapered capsule radii");
|
|
17024
|
+
const outer = sweepTerrainCapsule(surface2, start, end, translation, Math.max(radiusStart, radiusEnd), {
|
|
17025
|
+
maxWork,
|
|
17026
|
+
fractionTolerance
|
|
17027
|
+
});
|
|
17028
|
+
if (outer.status !== "hit" || radiusStart === radiusEnd)
|
|
17029
|
+
return outer;
|
|
17030
|
+
const inner = sweepTerrainCapsule(surface2, start, end, translation, Math.min(radiusStart, radiusEnd), {
|
|
17031
|
+
maxWork: maxWork - outer.work,
|
|
17032
|
+
fractionTolerance
|
|
17033
|
+
});
|
|
17034
|
+
const work = outer.work + inner.work;
|
|
17035
|
+
return inner.status === "hit" && outer.lowerFraction <= inner.fraction ? { ...inner, lowerFraction: outer.lowerFraction, work } : { status: "incomplete", work };
|
|
17036
|
+
}
|
|
17037
|
+
|
|
17038
|
+
// dist/terrain/sweep-polytope.js
|
|
17039
|
+
var sub2 = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
17040
|
+
var cross5 = (a, b) => [
|
|
17041
|
+
a[1] * b[2] - a[2] * b[1],
|
|
17042
|
+
a[2] * b[0] - a[0] * b[2],
|
|
17043
|
+
a[0] * b[1] - a[1] * b[0]
|
|
17044
|
+
];
|
|
17045
|
+
var dot4 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
17046
|
+
var edges = ([a, b, c]) => [sub2(b, a), sub2(c, b), sub2(a, c)];
|
|
17047
|
+
function sweepTerrainPolytope(surface2, collider, translation, { maxWork = 1e5 } = {}) {
|
|
17048
|
+
return queryTerrainPolytope(surface2.copyData(), surface2.origin, collider, translation, maxWork);
|
|
17049
|
+
}
|
|
17050
|
+
function queryTerrainPolytope(data, origin, collider, translation, maxWork, padding = 0) {
|
|
17051
|
+
if (!Number.isSafeInteger(maxWork) || maxWork < 0 || translation.length !== 3 || !translation.every(Number.isFinite) || collider.vertices.length < 4 || collider.faces.length < 4 || collider.vertices.some((point2) => point2.length !== 3 || !point2.every(Number.isFinite)))
|
|
17052
|
+
throw new RangeError("Invalid terrain polytope sweep");
|
|
17053
|
+
const vertices = collider.vertices.map((point2) => sub2(point2, origin));
|
|
17054
|
+
const normals = [];
|
|
17055
|
+
const directions = [];
|
|
17056
|
+
for (const face of collider.faces) {
|
|
17057
|
+
if (face.length !== 3 || face.some((i) => !Number.isSafeInteger(i) || !vertices[i]))
|
|
17058
|
+
throw new RangeError("Invalid terrain polytope face");
|
|
17059
|
+
const side = edges([vertices[face[0]], vertices[face[1]], vertices[face[2]]]);
|
|
17060
|
+
const normal2 = cross5(side[0], side[1]);
|
|
17061
|
+
if (!normal2.every(Number.isFinite) || !normal2.some(Boolean))
|
|
17062
|
+
throw new RangeError("Degenerate terrain polytope face");
|
|
17063
|
+
normals.push(normal2);
|
|
17064
|
+
directions.push(...side);
|
|
17065
|
+
}
|
|
17066
|
+
return sweepTriangles(data, vertices, normals, directions, translation, maxWork, void 0, padding);
|
|
17067
|
+
}
|
|
17068
|
+
function sweepTerrainTriangleMesh(surface2, collider, translation, { maxWork = 1e5 } = {}) {
|
|
17069
|
+
if (!Number.isSafeInteger(maxWork) || maxWork < 0 || translation.length !== 3 || !translation.every(Number.isFinite))
|
|
17070
|
+
throw new RangeError("Invalid terrain triangle mesh sweep");
|
|
17071
|
+
const data = surface2.copyData();
|
|
17072
|
+
let work = 0;
|
|
17073
|
+
let best;
|
|
17074
|
+
for (const face of collider.faces) {
|
|
17075
|
+
if (face.length !== 3)
|
|
17076
|
+
throw new RangeError("Invalid terrain sweep mesh face");
|
|
17077
|
+
const vertices = face.map((index) => {
|
|
17078
|
+
const point2 = collider.vertices[index];
|
|
17079
|
+
if (!Number.isSafeInteger(index) || !point2 || point2.length !== 3 || !point2.every(Number.isFinite))
|
|
17080
|
+
throw new RangeError("Invalid terrain sweep mesh vertex");
|
|
17081
|
+
return sub2(point2, surface2.origin);
|
|
17082
|
+
});
|
|
17083
|
+
const directions = edges(vertices);
|
|
17084
|
+
const normal2 = cross5(directions[0], directions[1]);
|
|
17085
|
+
if (!normal2.every(Number.isFinite) || !normal2.some(Boolean))
|
|
17086
|
+
throw new RangeError("Degenerate terrain sweep mesh face");
|
|
17087
|
+
const result = sweepTriangles(data, vertices, [normal2], directions, translation, maxWork - work, normal2);
|
|
17088
|
+
work += result.work;
|
|
17089
|
+
if (result.status === "incomplete")
|
|
17090
|
+
return { status: "incomplete", work };
|
|
17091
|
+
if (result.status === "hit" && (!best || result.fraction < best.fraction))
|
|
17092
|
+
best = result;
|
|
17093
|
+
}
|
|
17094
|
+
return best ? { ...best, work } : { status: "miss", work };
|
|
17095
|
+
}
|
|
17096
|
+
function sweepTriangles(data, vertices, normals, directions, translation, maxWork, movingTriangleNormal, padding = 0) {
|
|
17097
|
+
let work = 0;
|
|
17098
|
+
let best;
|
|
17099
|
+
const vertex = (index) => {
|
|
17100
|
+
const i = 3 * data.indices[index];
|
|
17101
|
+
return [data.positions[i], data.positions[i + 1], data.positions[i + 2]];
|
|
17102
|
+
};
|
|
17103
|
+
for (let i = 0; i < data.triangleValidity.length; i++) {
|
|
17104
|
+
if (!data.triangleValidity[i])
|
|
17105
|
+
continue;
|
|
17106
|
+
const triangle = [vertex(3 * i), vertex(3 * i + 1), vertex(3 * i + 2)];
|
|
17107
|
+
const sides = edges(triangle);
|
|
17108
|
+
let enter = 0;
|
|
17109
|
+
let exit = (best == null ? void 0 : best.fraction) ?? 1;
|
|
17110
|
+
let normal2 = null;
|
|
17111
|
+
function* axes() {
|
|
17112
|
+
const terrainNormal = cross5(sides[0], sides[1]);
|
|
17113
|
+
yield terrainNormal;
|
|
17114
|
+
if (movingTriangleNormal) {
|
|
17115
|
+
for (const side of sides)
|
|
17116
|
+
yield cross5(terrainNormal, side);
|
|
17117
|
+
for (const direction of directions)
|
|
17118
|
+
yield cross5(movingTriangleNormal, direction);
|
|
17119
|
+
}
|
|
17120
|
+
yield* normals;
|
|
17121
|
+
for (const side of sides)
|
|
17122
|
+
for (const direction of directions)
|
|
17123
|
+
yield cross5(side, direction);
|
|
17124
|
+
}
|
|
17125
|
+
for (const axis of axes()) {
|
|
17126
|
+
if (work >= maxWork)
|
|
17127
|
+
return { status: "incomplete", work };
|
|
17128
|
+
work++;
|
|
17129
|
+
const length = Math.hypot(...axis);
|
|
17130
|
+
if (length === 0)
|
|
17131
|
+
continue;
|
|
17132
|
+
const unit3 = [axis[0] / length, axis[1] / length, axis[2] / length];
|
|
17133
|
+
const low = Math.min(...triangle.map((point2) => dot4(point2, unit3)));
|
|
17134
|
+
const high = Math.max(...triangle.map((point2) => dot4(point2, unit3)));
|
|
17135
|
+
let min = Infinity;
|
|
17136
|
+
let max = -Infinity;
|
|
17137
|
+
for (const point2 of vertices) {
|
|
17138
|
+
const projection2 = dot4(point2, unit3);
|
|
17139
|
+
min = Math.min(min, projection2);
|
|
17140
|
+
max = Math.max(max, projection2);
|
|
17141
|
+
}
|
|
17142
|
+
min -= padding;
|
|
17143
|
+
max += padding;
|
|
17144
|
+
const speed = dot4(translation, unit3);
|
|
17145
|
+
if (![low, high, min, max, speed, length].every(Number.isFinite))
|
|
17146
|
+
throw new RangeError("Terrain polytope projection overflow");
|
|
17147
|
+
if (speed === 0) {
|
|
17148
|
+
if (min > high || max < low)
|
|
17149
|
+
exit = -1;
|
|
17150
|
+
} else {
|
|
17151
|
+
const first = (low - max) / speed;
|
|
17152
|
+
const last = (high - min) / speed;
|
|
17153
|
+
const entry = Math.min(first, last);
|
|
17154
|
+
if (entry > enter) {
|
|
17155
|
+
enter = entry;
|
|
17156
|
+
normal2 = speed < 0 ? unit3 : [-unit3[0], -unit3[1], -unit3[2]];
|
|
17157
|
+
}
|
|
17158
|
+
exit = Math.min(exit, Math.max(first, last));
|
|
17159
|
+
}
|
|
17160
|
+
if (enter > exit)
|
|
17161
|
+
break;
|
|
17162
|
+
}
|
|
17163
|
+
if (enter <= exit && (!best || enter < best.fraction)) {
|
|
17164
|
+
best = { status: "hit", fraction: enter, triangleIndex: i, normal: normal2, work };
|
|
17165
|
+
if (enter === 0)
|
|
17166
|
+
break;
|
|
17167
|
+
}
|
|
17168
|
+
}
|
|
17169
|
+
return best ? { ...best, work } : { status: "miss", work };
|
|
17170
|
+
}
|
|
17171
|
+
function sweepTerrainBox(surface2, center, halfExtents, translation, options) {
|
|
17172
|
+
return sweepTerrainPolytope(surface2, createSweepBox(center, halfExtents), translation, options);
|
|
17173
|
+
}
|
|
17174
|
+
function createSweepBox(center, halfExtents) {
|
|
17175
|
+
if (halfExtents.length !== 3 || halfExtents.some((value3) => !(value3 > 0)))
|
|
17176
|
+
throw new RangeError("Terrain box half extents must be positive");
|
|
17177
|
+
const vertices = Array.from({ length: 8 }, (_, i) => [
|
|
17178
|
+
center[0] + (i & 1 ? 1 : -1) * halfExtents[0],
|
|
17179
|
+
center[1] + (i & 2 ? 1 : -1) * halfExtents[1],
|
|
17180
|
+
center[2] + (i & 4 ? 1 : -1) * halfExtents[2]
|
|
17181
|
+
]);
|
|
17182
|
+
return {
|
|
17183
|
+
vertices,
|
|
17184
|
+
faces: [
|
|
17185
|
+
[0, 1, 3],
|
|
17186
|
+
[0, 3, 2],
|
|
17187
|
+
[4, 6, 7],
|
|
17188
|
+
[4, 7, 5],
|
|
17189
|
+
[0, 4, 5],
|
|
17190
|
+
[0, 5, 1],
|
|
17191
|
+
[2, 3, 7],
|
|
17192
|
+
[2, 7, 6],
|
|
17193
|
+
[0, 2, 6],
|
|
17194
|
+
[0, 6, 4],
|
|
17195
|
+
[1, 5, 7],
|
|
17196
|
+
[1, 7, 3]
|
|
17197
|
+
]
|
|
17198
|
+
};
|
|
17199
|
+
}
|
|
17200
|
+
|
|
17201
|
+
// dist/terrain/sweep-rotating-capsule.js
|
|
17202
|
+
function sweepTerrainRotatingCapsule(surface2, start, end, radius, { pivot, translation, rotation }, { maxWork = 1e5, fractionTolerance = 1e-5 } = {}) {
|
|
17203
|
+
var _a;
|
|
17204
|
+
const norm = Math.hypot(...rotation);
|
|
17205
|
+
if (![start, end, pivot, translation].every((p) => p.length === 3 && p.every(Number.isFinite)) || rotation.length !== 4 || !(norm > 0 && Number.isFinite(norm)) || !Number.isFinite(radius) || radius < 0 || !Number.isSafeInteger(maxWork) || maxWork < 0 || !(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1))
|
|
17206
|
+
throw new RangeError("Invalid terrain capsule rigid motion");
|
|
17207
|
+
const sign2 = rotation[3] < 0 ? -1 : 1;
|
|
17208
|
+
const axisLength = Math.hypot(rotation[0], rotation[1], rotation[2]);
|
|
17209
|
+
const angle3 = 2 * Math.atan2(axisLength, Math.abs(rotation[3]));
|
|
17210
|
+
if (angle3 === 0) {
|
|
17211
|
+
return sweepTerrainCapsule(surface2, start, end, translation, radius, {
|
|
17212
|
+
maxWork,
|
|
17213
|
+
fractionTolerance
|
|
17214
|
+
});
|
|
17215
|
+
}
|
|
17216
|
+
const x = rotation[0] / axisLength * sign2;
|
|
17217
|
+
const y = rotation[1] / axisLength * sign2;
|
|
17218
|
+
const z = rotation[2] / axisLength * sign2;
|
|
17219
|
+
const offsets = [start, end].map((p) => p.map((v, i) => v - pivot[i]));
|
|
17220
|
+
const reach = Math.max(...offsets.map((p) => Math.hypot(...p)));
|
|
17221
|
+
const speed = Math.hypot(...translation) + angle3 * reach;
|
|
17222
|
+
const scale3 = Math.max(Math.hypot(...pivot), reach, speed, radius);
|
|
17223
|
+
if (!Number.isFinite(scale3))
|
|
17224
|
+
throw new RangeError("Terrain capsule rigid motion overflow");
|
|
17225
|
+
let work = 0;
|
|
17226
|
+
function probe(t) {
|
|
17227
|
+
if (work >= maxWork)
|
|
17228
|
+
return null;
|
|
17229
|
+
work++;
|
|
17230
|
+
const sin = Math.sin(angle3 * t);
|
|
17231
|
+
const cos = Math.cos(angle3 * t);
|
|
17232
|
+
const [a, b] = t === 0 ? [start, end] : offsets.map(([u, v, w]) => {
|
|
17233
|
+
const d = (x * u + y * v + z * w) * (1 - cos);
|
|
17234
|
+
const pos = [
|
|
17235
|
+
pivot[0] + (translation[0] * t + u * cos + (y * w - z * v) * sin + x * d),
|
|
17236
|
+
pivot[1] + (translation[1] * t + v * cos + (z * u - x * w) * sin + y * d),
|
|
17237
|
+
pivot[2] + (translation[2] * t + w * cos + (x * v - y * u) * sin + z * d)
|
|
17238
|
+
];
|
|
17239
|
+
if (!pos.every(Number.isFinite))
|
|
17240
|
+
throw new RangeError("Terrain capsule pose overflow");
|
|
17241
|
+
return pos;
|
|
17242
|
+
});
|
|
17243
|
+
const query = surface2.nearestSegmentQuery(a, b, { maxWork: maxWork - work });
|
|
17244
|
+
work += query.work;
|
|
17245
|
+
return query;
|
|
17246
|
+
}
|
|
17247
|
+
const initial = probe(0);
|
|
17248
|
+
if ((initial == null ? void 0 : initial.result) && initial.result.distance <= radius)
|
|
17249
|
+
return { status: "hit", fraction: 0, lowerFraction: 0, work, contact: initial.result };
|
|
17250
|
+
if (!(initial == null ? void 0 : initial.complete))
|
|
17251
|
+
return { status: "incomplete", work };
|
|
17252
|
+
if (!initial.result || speed === 0)
|
|
17253
|
+
return { status: "miss", work };
|
|
17254
|
+
let clearUntil = 0;
|
|
17255
|
+
let witness;
|
|
17256
|
+
const pending = [[0, 1]];
|
|
17257
|
+
while (pending.length) {
|
|
17258
|
+
if (witness && witness.fraction - clearUntil <= fractionTolerance)
|
|
17259
|
+
return { status: "hit", lowerFraction: clearUntil, work, ...witness };
|
|
17260
|
+
const [lo, hi] = pending.pop();
|
|
17261
|
+
const mid = lo + (hi - lo) / 2;
|
|
17262
|
+
const query = probe(mid);
|
|
17263
|
+
const contact = query == null ? void 0 : query.result;
|
|
17264
|
+
if (contact && contact.distance <= radius) {
|
|
17265
|
+
witness = { fraction: mid, contact };
|
|
17266
|
+
if (mid - clearUntil <= fractionTolerance)
|
|
17267
|
+
return { status: "hit", lowerFraction: clearUntil, work, ...witness };
|
|
17268
|
+
if (mid === lo || mid === hi)
|
|
17269
|
+
return { status: "incomplete", work };
|
|
17270
|
+
pending.push([lo, mid]);
|
|
17271
|
+
continue;
|
|
17272
|
+
}
|
|
17273
|
+
if (!(query == null ? void 0 : query.complete))
|
|
17274
|
+
return { status: "incomplete", work };
|
|
17275
|
+
const travel = speed * Math.max(mid - lo, hi - mid);
|
|
17276
|
+
const allowance = 16 * Number.EPSILON * Math.max(scale3, (contact == null ? void 0 : contact.distance) ?? 0);
|
|
17277
|
+
if (!contact || contact.distance - radius > travel + allowance) {
|
|
17278
|
+
clearUntil = hi;
|
|
17279
|
+
continue;
|
|
17280
|
+
}
|
|
17281
|
+
if (hi - clearUntil <= fractionTolerance) {
|
|
17282
|
+
const final = (witness == null ? void 0 : witness.fraction) === hi ? witness.contact : (_a = probe(hi)) == null ? void 0 : _a.result;
|
|
17283
|
+
if (final && final.distance <= radius)
|
|
17284
|
+
return { status: "hit", fraction: hi, lowerFraction: clearUntil, work, contact: final };
|
|
17285
|
+
}
|
|
17286
|
+
if (mid === lo || mid === hi || hi - lo <= fractionTolerance / 4)
|
|
17287
|
+
return { status: "incomplete", work };
|
|
17288
|
+
pending.push([mid, hi], [lo, mid]);
|
|
17289
|
+
}
|
|
17290
|
+
return witness ? { status: "hit", lowerFraction: clearUntil, work, ...witness } : { status: "miss", work };
|
|
17291
|
+
}
|
|
17292
|
+
function sweepTerrainRotatingSphere(surface2, center, radius, motion, options) {
|
|
17293
|
+
return sweepTerrainRotatingCapsule(surface2, center, center, radius, motion, options);
|
|
17294
|
+
}
|
|
17295
|
+
|
|
17296
|
+
// dist/terrain/sweep-cylinder.js
|
|
17297
|
+
function sweepTerrainCylinder(surface2, center, height, radiusBottom, radiusTop, translation, { sides = 16, maxWork = 1e5 } = {}) {
|
|
17298
|
+
if (center.length !== 3 || !center.every(Number.isFinite) || ![height, radiusBottom, radiusTop].every((value3) => Number.isFinite(value3) && value3 > 0) || !Number.isInteger(sides) || sides < 3 || sides > 128)
|
|
17299
|
+
throw new RangeError("Invalid terrain cylinder sweep");
|
|
17300
|
+
const faces = [];
|
|
17301
|
+
for (let i = 0; i < sides; i++) {
|
|
17302
|
+
const next = (i + 1) % sides;
|
|
17303
|
+
faces.push([i, next, next + sides], [i, next + sides, i + sides]);
|
|
17304
|
+
if (i > 0 && i < sides - 1)
|
|
17305
|
+
faces.push([0, i + 1, i], [sides, sides + i, sides + i + 1]);
|
|
17306
|
+
}
|
|
17307
|
+
const hull = (scale3) => ({
|
|
17308
|
+
faces,
|
|
17309
|
+
vertices: Array.from({ length: 2 * sides }, (_, i) => {
|
|
17310
|
+
const top = i >= sides;
|
|
17311
|
+
const angle3 = 2 * Math.PI * (i % sides) / sides;
|
|
17312
|
+
const radius = (top ? radiusTop : radiusBottom) * scale3;
|
|
17313
|
+
return [
|
|
17314
|
+
center[0] + radius * Math.cos(angle3),
|
|
17315
|
+
center[1] + radius * Math.sin(angle3),
|
|
17316
|
+
center[2] + (top ? height : -height) / 2
|
|
17317
|
+
];
|
|
17318
|
+
})
|
|
17319
|
+
});
|
|
17320
|
+
const outer = sweepTerrainPolytope(surface2, hull(1 / Math.cos(Math.PI / sides)), translation, {
|
|
17321
|
+
maxWork
|
|
17322
|
+
});
|
|
17323
|
+
if (outer.status !== "hit")
|
|
17324
|
+
return outer;
|
|
17325
|
+
const inner = sweepTerrainPolytope(surface2, hull(1), translation, {
|
|
17326
|
+
maxWork: maxWork - outer.work
|
|
17327
|
+
});
|
|
17328
|
+
const work = outer.work + inner.work;
|
|
17329
|
+
if (inner.status !== "hit" || inner.fraction < outer.fraction)
|
|
17330
|
+
return { status: "incomplete", work };
|
|
17331
|
+
return { ...inner, normal: null, lowerFraction: outer.fraction, work };
|
|
17332
|
+
}
|
|
17333
|
+
|
|
17334
|
+
// dist/terrain/sweep-plane.js
|
|
17335
|
+
function sweepTerrainPlane(surface2, point2, normal2, translation, { maxWork = 1e5 } = {}) {
|
|
17336
|
+
const length = Math.hypot(...normal2);
|
|
17337
|
+
if (![point2, normal2, translation].every((v) => v.length === 3 && v.every(Number.isFinite)) || !(length > 0 && Number.isFinite(length)) || !Number.isSafeInteger(maxWork) || maxWork < 0)
|
|
17338
|
+
throw new RangeError("Invalid terrain plane sweep");
|
|
17339
|
+
const unit3 = [normal2[0] / length, normal2[1] / length, normal2[2] / length];
|
|
17340
|
+
const velocity = translation[0] * unit3[0] + translation[1] * unit3[1] + translation[2] * unit3[2];
|
|
17341
|
+
if (!Number.isFinite(velocity))
|
|
17342
|
+
throw new RangeError("Terrain plane velocity overflow");
|
|
17343
|
+
const { positions, indices, triangleValidity } = surface2.copyData();
|
|
17344
|
+
const local = point2.map((value3, axis) => value3 - surface2.origin[axis]);
|
|
17345
|
+
let work = 0;
|
|
17346
|
+
let fraction = Infinity;
|
|
17347
|
+
let triangleIndex = -1;
|
|
17348
|
+
for (let i = 0; i < triangleValidity.length; i++) {
|
|
17349
|
+
if (!triangleValidity[i])
|
|
17350
|
+
continue;
|
|
17351
|
+
if (work >= maxWork)
|
|
17352
|
+
return { status: "incomplete", work };
|
|
17353
|
+
work++;
|
|
17354
|
+
let min = Infinity;
|
|
17355
|
+
let max = -Infinity;
|
|
17356
|
+
for (let j = 0; j < 3; j++) {
|
|
17357
|
+
const k = indices[3 * i + j] * 3;
|
|
17358
|
+
const distance = (positions[k] - local[0]) * unit3[0] + (positions[k + 1] - local[1]) * unit3[1] + (positions[k + 2] - local[2]) * unit3[2];
|
|
17359
|
+
if (!Number.isFinite(distance))
|
|
17360
|
+
throw new RangeError("Terrain plane projection overflow");
|
|
17361
|
+
min = Math.min(min, distance);
|
|
17362
|
+
max = Math.max(max, distance);
|
|
17363
|
+
}
|
|
17364
|
+
if (min <= 0 && max >= 0)
|
|
17365
|
+
return { status: "hit", fraction: 0, triangleIndex: i, normal: null, work };
|
|
17366
|
+
const entry = velocity > 0 ? min / velocity : max / velocity;
|
|
17367
|
+
if (velocity !== 0 && entry > 0 && entry <= 1 && entry < fraction) {
|
|
17368
|
+
triangleIndex = i;
|
|
17369
|
+
fraction = entry;
|
|
17370
|
+
}
|
|
17371
|
+
}
|
|
17372
|
+
if (triangleIndex < 0)
|
|
17373
|
+
return { status: "miss", work };
|
|
17374
|
+
const entryNormal = velocity < 0 ? unit3 : [-unit3[0], -unit3[1], -unit3[2]];
|
|
17375
|
+
return { status: "hit", fraction, triangleIndex, normal: entryNormal, work };
|
|
17376
|
+
}
|
|
17377
|
+
|
|
17378
|
+
// dist/terrain/geographic-lod-seams.js
|
|
17379
|
+
function discoverGeographicTerrainLodSeams(cut2) {
|
|
17380
|
+
const vertical = /* @__PURE__ */ new Map();
|
|
17381
|
+
const horizontal = /* @__PURE__ */ new Map();
|
|
17382
|
+
const world = 2 ** 30;
|
|
17383
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
17384
|
+
const key3 = (level, x, y) => `${level}/${x}/${y}`;
|
|
17385
|
+
for (const tile of cut2) {
|
|
17386
|
+
getGeographicTileBounds(tile);
|
|
17387
|
+
const address = key3(tile.level, tile.x, tile.y);
|
|
17388
|
+
if (addresses.has(address))
|
|
17389
|
+
throw new Error("Duplicate geographic terrain tile");
|
|
17390
|
+
addresses.add(address);
|
|
17391
|
+
}
|
|
17392
|
+
function add4(lines, line, side, span) {
|
|
17393
|
+
let group = lines.get(line);
|
|
17394
|
+
if (!group) {
|
|
17395
|
+
group = { before: [], after: [] };
|
|
17396
|
+
lines.set(line, group);
|
|
17397
|
+
}
|
|
17398
|
+
group[side].push(span);
|
|
17399
|
+
}
|
|
17400
|
+
cut2.forEach(({ level, x, y }, tile) => {
|
|
17401
|
+
for (let parent = level - 1; parent >= 0; parent--) {
|
|
17402
|
+
const scale3 = 2 ** (level - parent);
|
|
17403
|
+
if (addresses.has(key3(parent, Math.floor(x / scale3), Math.floor(y / scale3))))
|
|
17404
|
+
throw new Error("Overlapping geographic terrain tiles");
|
|
17405
|
+
}
|
|
17406
|
+
const size = 2 ** (30 - level);
|
|
17407
|
+
const west = x * size;
|
|
17408
|
+
const north = y * size;
|
|
17409
|
+
const east = west + size;
|
|
17410
|
+
const south = north + size;
|
|
17411
|
+
add4(vertical, west, "after", { tile, start: north, end: south });
|
|
17412
|
+
add4(vertical, east % world, "before", { tile, start: north, end: south });
|
|
17413
|
+
if (north !== 0)
|
|
17414
|
+
add4(horizontal, north, "after", { tile, start: west, end: east });
|
|
17415
|
+
if (south !== world)
|
|
17416
|
+
add4(horizontal, south, "before", { tile, start: west, end: east });
|
|
17417
|
+
});
|
|
17418
|
+
const seams = [];
|
|
17419
|
+
function match(lines, column) {
|
|
17420
|
+
const beforeEdge = column ? "maxColumn" : "maxRow";
|
|
17421
|
+
const afterEdge = column ? "minColumn" : "minRow";
|
|
17422
|
+
const byStart = (a, b) => a.start - b.start;
|
|
17423
|
+
for (const [line, { before, after }] of lines) {
|
|
17424
|
+
before.sort(byStart);
|
|
17425
|
+
after.sort(byStart);
|
|
17426
|
+
let i = 0;
|
|
17427
|
+
let j = 0;
|
|
17428
|
+
while (i < before.length && j < after.length) {
|
|
17429
|
+
const left = before[i];
|
|
17430
|
+
const right = after[j];
|
|
17431
|
+
const start = Math.max(left.start, right.start);
|
|
17432
|
+
const end = Math.min(left.end, right.end);
|
|
17433
|
+
const leftLevel = cut2[left.tile].level;
|
|
17434
|
+
const rightLevel = cut2[right.tile].level;
|
|
17435
|
+
if (end > start && leftLevel !== rightLevel) {
|
|
17436
|
+
const leftOwns = leftLevel < rightLevel;
|
|
17437
|
+
const coarse = leftOwns ? left : right;
|
|
17438
|
+
seams.push({
|
|
17439
|
+
a: coarse.tile,
|
|
17440
|
+
edgeA: leftOwns ? beforeEdge : afterEdge,
|
|
17441
|
+
b: leftOwns ? right.tile : left.tile,
|
|
17442
|
+
edgeB: leftOwns ? afterEdge : beforeEdge,
|
|
17443
|
+
...column && line === 0 ? { offsetBX: leftOwns ? 360 : -360 } : {},
|
|
17444
|
+
options: {
|
|
17445
|
+
rangeA: [
|
|
17446
|
+
(start - coarse.start) / (coarse.end - coarse.start),
|
|
17447
|
+
(end - coarse.start) / (coarse.end - coarse.start)
|
|
17448
|
+
]
|
|
17449
|
+
}
|
|
17450
|
+
});
|
|
17451
|
+
}
|
|
17452
|
+
if (left.end <= right.end)
|
|
17453
|
+
i++;
|
|
17454
|
+
if (right.end <= left.end)
|
|
17455
|
+
j++;
|
|
17456
|
+
}
|
|
17457
|
+
}
|
|
17458
|
+
}
|
|
17459
|
+
match(vertical, true);
|
|
17460
|
+
match(horizontal, false);
|
|
17461
|
+
const edges2 = ["minColumn", "maxColumn", "minRow", "maxRow"];
|
|
17462
|
+
return seams.sort((a, b) => cut2[a.a].level - cut2[b.a].level || cut2[a.a].y - cut2[b.a].y || cut2[a.a].x - cut2[b.a].x || edges2.indexOf(a.edgeA) - edges2.indexOf(b.edgeA) || a.options.rangeA[0] - b.options.rangeA[0]);
|
|
17463
|
+
}
|
|
17464
|
+
|
|
17465
|
+
// dist/terrain/geographic-poles.js
|
|
17466
|
+
function discoverGeographicTerrainPoles(cut2) {
|
|
17467
|
+
function collect(latitude2, edge2) {
|
|
17468
|
+
const incident = [];
|
|
17469
|
+
for (let tile = 0; tile < cut2.length; tile++) {
|
|
17470
|
+
const [west, south, east, north] = getGeographicTileBounds(cut2[tile]);
|
|
17471
|
+
if ((edge2 === "north" ? north : south) === latitude2)
|
|
17472
|
+
incident.push({ tile, edge: edge2, longitude: [west, east] });
|
|
17473
|
+
}
|
|
17474
|
+
incident.sort((a, b) => a.longitude[0] - b.longitude[0]);
|
|
17475
|
+
const gaps = [];
|
|
17476
|
+
let cursor = -180;
|
|
17477
|
+
for (const { longitude: [west, east] } of incident) {
|
|
17478
|
+
if (west < cursor)
|
|
17479
|
+
throw new Error("Overlapping geographic terrain pole sectors");
|
|
17480
|
+
if (west > cursor)
|
|
17481
|
+
gaps.push([cursor, west]);
|
|
17482
|
+
cursor = east;
|
|
17483
|
+
}
|
|
17484
|
+
if (cursor < 180)
|
|
17485
|
+
gaps.push([cursor, 180]);
|
|
17486
|
+
return { latitude: latitude2, incident, gaps };
|
|
17487
|
+
}
|
|
17488
|
+
return { north: collect(90, "north"), south: collect(-90, "south") };
|
|
17489
|
+
}
|
|
17490
|
+
|
|
17491
|
+
// dist/terrain/sweep-rotation.js
|
|
17492
|
+
function sweepTerrainRotatingPolytope(surface2, collider, { pivot, translation, rotation }, { maxWork = 1e5, fractionTolerance = 1e-5 } = {}) {
|
|
17493
|
+
const norm = Math.hypot(...rotation);
|
|
17494
|
+
if (pivot.length !== 3 || translation.length !== 3 || rotation.length !== 4 || !pivot.every(Number.isFinite) || !translation.every(Number.isFinite) || !(norm > 0 && Number.isFinite(norm)) || !Number.isSafeInteger(maxWork) || maxWork < 0 || !(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1))
|
|
17495
|
+
throw new RangeError("Invalid terrain rigid motion");
|
|
17496
|
+
const localPivot = pivot.map((v, i) => v - surface2.origin[i]);
|
|
17497
|
+
const offsets = collider.vertices.map((v) => v.map((x2, i) => x2 - pivot[i]));
|
|
17498
|
+
const radius = offsets.reduce((r, v) => Math.max(r, Math.hypot(...v)), 0);
|
|
17499
|
+
const sign2 = rotation[3] < 0 ? -1 : 1;
|
|
17500
|
+
const vectorNorm = Math.hypot(rotation[0], rotation[1], rotation[2]);
|
|
17501
|
+
const angle3 = 2 * Math.atan2(vectorNorm, Math.abs(rotation[3]));
|
|
17502
|
+
const speed = Math.hypot(...translation) + angle3 * radius;
|
|
17503
|
+
if (!Number.isFinite(speed))
|
|
17504
|
+
throw new RangeError("Terrain rigid motion overflow");
|
|
17505
|
+
const data = surface2.copyData();
|
|
17506
|
+
if (angle3 === 0) {
|
|
17507
|
+
const result = queryTerrainPolytope(data, surface2.origin, collider, translation, maxWork);
|
|
17508
|
+
return result.status === "hit" ? { ...result, lowerFraction: result.fraction } : result;
|
|
17509
|
+
}
|
|
17510
|
+
const [x, y, z] = rotation.slice(0, 3).map((v) => v / vectorNorm * sign2);
|
|
17511
|
+
const zero = [0, 0, 0];
|
|
17512
|
+
let work = 0;
|
|
17513
|
+
const pose = (t) => {
|
|
17514
|
+
const sin = Math.sin(angle3 * t);
|
|
17515
|
+
const cos = Math.cos(angle3 * t);
|
|
17516
|
+
return {
|
|
17517
|
+
faces: collider.faces,
|
|
17518
|
+
vertices: offsets.map(([a, b, c]) => {
|
|
17519
|
+
const projection2 = (x * a + y * b + z * c) * (1 - cos);
|
|
17520
|
+
return [
|
|
17521
|
+
localPivot[0] + translation[0] * t + a * cos + (y * c - z * b) * sin + x * projection2,
|
|
17522
|
+
localPivot[1] + translation[1] * t + b * cos + (z * a - x * c) * sin + y * projection2,
|
|
17523
|
+
localPivot[2] + translation[2] * t + c * cos + (x * b - y * a) * sin + z * projection2
|
|
17524
|
+
];
|
|
17525
|
+
})
|
|
17526
|
+
};
|
|
17527
|
+
};
|
|
17528
|
+
const probe = (shape, padding = 0) => {
|
|
17529
|
+
if (work >= maxWork)
|
|
17530
|
+
return { status: "incomplete", work: 0 };
|
|
17531
|
+
work++;
|
|
17532
|
+
const result = queryTerrainPolytope(data, zero, shape, zero, maxWork - work, padding);
|
|
17533
|
+
work += result.work;
|
|
17534
|
+
return result;
|
|
17535
|
+
};
|
|
17536
|
+
const initial = probe(pose(0));
|
|
17537
|
+
if (initial.status === "hit")
|
|
17538
|
+
return { ...initial, lowerFraction: 0, work };
|
|
17539
|
+
if (initial.status === "incomplete")
|
|
17540
|
+
return { status: "incomplete", work };
|
|
17541
|
+
let clearUntil = 0;
|
|
17542
|
+
let witness;
|
|
17543
|
+
const pending = [[0, 1]];
|
|
17544
|
+
while (pending.length) {
|
|
17545
|
+
if (witness && witness.fraction - clearUntil <= fractionTolerance)
|
|
17546
|
+
return { ...witness, lowerFraction: clearUntil, work };
|
|
17547
|
+
const [lo, hi] = pending.pop();
|
|
17548
|
+
const mid = lo + (hi - lo) / 2;
|
|
17549
|
+
const shape = pose(mid);
|
|
17550
|
+
const padding = speed * Math.max(mid - lo, hi - mid);
|
|
17551
|
+
const expanded = probe(shape, padding + 8 * Number.EPSILON * (radius + padding));
|
|
17552
|
+
if (expanded.status === "miss") {
|
|
17553
|
+
clearUntil = hi;
|
|
17554
|
+
continue;
|
|
17555
|
+
}
|
|
17556
|
+
if (expanded.status === "incomplete")
|
|
17557
|
+
return { status: "incomplete", work };
|
|
17558
|
+
const hit = probe(shape);
|
|
17559
|
+
if (hit.status === "incomplete")
|
|
17560
|
+
return { status: "incomplete", work };
|
|
17561
|
+
if (hit.status === "hit") {
|
|
17562
|
+
witness = { ...hit, fraction: mid };
|
|
17563
|
+
if (mid - clearUntil <= fractionTolerance)
|
|
17564
|
+
return { ...witness, lowerFraction: clearUntil, work };
|
|
17565
|
+
pending.push([lo, mid]);
|
|
17566
|
+
} else if (hi - clearUntil <= fractionTolerance) {
|
|
17567
|
+
const end = (witness == null ? void 0 : witness.fraction) === hi ? witness : probe(pose(hi));
|
|
17568
|
+
if ((end == null ? void 0 : end.status) === "hit")
|
|
17569
|
+
return { ...end, fraction: hi, lowerFraction: clearUntil, work };
|
|
17570
|
+
if (hi - lo <= fractionTolerance / 4)
|
|
17571
|
+
return { status: "incomplete", work };
|
|
17572
|
+
pending.push([mid, hi], [lo, mid]);
|
|
17573
|
+
} else {
|
|
17574
|
+
if (mid === lo || mid === hi || hi - lo <= fractionTolerance / 4)
|
|
17575
|
+
return { status: "incomplete", work };
|
|
17576
|
+
pending.push([mid, hi], [lo, mid]);
|
|
17577
|
+
}
|
|
17578
|
+
}
|
|
17579
|
+
return witness ? { ...witness, lowerFraction: clearUntil, work } : { status: "miss", work };
|
|
17580
|
+
}
|
|
17581
|
+
function sweepTerrainRotatingBox(surface2, center, halfExtents, motion, options) {
|
|
17582
|
+
return sweepTerrainRotatingPolytope(surface2, createSweepBox(center, halfExtents), motion, options);
|
|
17583
|
+
}
|
|
17584
|
+
|
|
17585
|
+
// dist/terrain/regional-viewshed.js
|
|
17586
|
+
var TerrainRegionalViewStatus = {
|
|
17587
|
+
VISIBLE: 0,
|
|
17588
|
+
BLOCKED: 1,
|
|
17589
|
+
UNKNOWN: 2,
|
|
17590
|
+
MISSING_TARGET: 3,
|
|
17591
|
+
OBSERVER: 4
|
|
17592
|
+
};
|
|
17593
|
+
function createTerrainRegionalViewshed(grid, sample, options) {
|
|
17594
|
+
const { width, height, origin, spacing } = grid;
|
|
17595
|
+
const { observer, sampleStep, radius, targetOffset = 0, maxTargets = 1e5, maxSamples = 4e6 } = options;
|
|
17596
|
+
const count = width * height;
|
|
17597
|
+
if (![width, height, count, maxTargets, maxSamples].every(Number.isSafeInteger) || width < 1 || height < 1 || count > maxTargets || maxSamples < 1 || origin.length !== 2 || spacing.length !== 2 || observer.length !== 3 || ![...origin, ...spacing, ...observer, sampleStep, targetOffset].every(Number.isFinite) || spacing.some((value3) => value3 <= 0) || sampleStep <= 0 || targetOffset < 0 || radius !== void 0 && (!Number.isFinite(radius) || radius <= 0 || observer[2] <= -radius))
|
|
17598
|
+
throw new RangeError("Invalid regional viewshed grid or options");
|
|
17599
|
+
const statuses = new Uint8Array(count);
|
|
17600
|
+
const targetStatuses = new Uint8Array(count);
|
|
17601
|
+
const sampledCoverage = new Uint8Array(count);
|
|
17602
|
+
let samples = 0;
|
|
17603
|
+
function read(x, y) {
|
|
17604
|
+
if (samples >= maxSamples)
|
|
17605
|
+
throw new RangeError("Regional viewshed sample budget exceeded");
|
|
17606
|
+
samples++;
|
|
17607
|
+
const result = sample(x, y);
|
|
17608
|
+
if (!Number.isInteger(result.status) || result.status < 0 || result.status > TerrainSampleStatus.NOT_RESIDENT || result.status === TerrainSampleStatus.VALID && (!Number.isFinite(result.height) || radius !== void 0 && result.height <= -radius))
|
|
17609
|
+
throw new RangeError("Invalid regional viewshed sample");
|
|
17610
|
+
return result;
|
|
17611
|
+
}
|
|
17612
|
+
function sight(distance, elevation) {
|
|
17613
|
+
let rise = elevation - observer[2];
|
|
17614
|
+
let run = distance;
|
|
17615
|
+
if (radius !== void 0) {
|
|
17616
|
+
const theta = distance / radius;
|
|
17617
|
+
const radial = radius + elevation;
|
|
17618
|
+
const halfSine = Math.sin(theta / 2);
|
|
17619
|
+
rise -= radial * (2 * halfSine * halfSine);
|
|
17620
|
+
run = radial * Math.sin(theta);
|
|
17621
|
+
}
|
|
17622
|
+
if (!Number.isFinite(rise) || !Number.isFinite(run) || run <= 0)
|
|
17623
|
+
throw new RangeError("Regional viewshed sight calculation overflow");
|
|
17624
|
+
return [rise, run];
|
|
17625
|
+
}
|
|
17626
|
+
const observerSample = { ...read(observer[0], observer[1]) };
|
|
17627
|
+
const observerValid = observerSample.status === TerrainSampleStatus.VALID;
|
|
17628
|
+
for (let i = 0; i < count; i++) {
|
|
17629
|
+
const x = origin[0] + i % width * spacing[0];
|
|
17630
|
+
const y = origin[1] + Math.floor(i / width) * spacing[1];
|
|
17631
|
+
const dx = x - observer[0];
|
|
17632
|
+
const dy = y - observer[1];
|
|
17633
|
+
const distance = Math.hypot(dx, dy);
|
|
17634
|
+
if (!Number.isFinite(distance) || radius !== void 0 && distance / radius >= Math.PI)
|
|
17635
|
+
throw new RangeError("Regional viewshed distance outside supported range");
|
|
17636
|
+
const target = distance === 0 ? observerSample : read(x, y);
|
|
17637
|
+
targetStatuses[i] = target.status;
|
|
17638
|
+
if (target.status !== TerrainSampleStatus.VALID) {
|
|
17639
|
+
statuses[i] = TerrainRegionalViewStatus.MISSING_TARGET;
|
|
17640
|
+
continue;
|
|
17641
|
+
}
|
|
17642
|
+
if (distance === 0) {
|
|
17643
|
+
statuses[i] = TerrainRegionalViewStatus.OBSERVER;
|
|
17644
|
+
sampledCoverage[i] = 1;
|
|
17645
|
+
continue;
|
|
17646
|
+
}
|
|
17647
|
+
const [targetRise, targetRun] = sight(distance, target.height + targetOffset);
|
|
17648
|
+
const segments = Math.max(1, Math.ceil(distance / sampleStep));
|
|
17649
|
+
if (!Number.isSafeInteger(segments) || segments - 1 > maxSamples - samples)
|
|
17650
|
+
throw new RangeError("Regional viewshed sample budget exceeded");
|
|
17651
|
+
let complete = observerValid;
|
|
17652
|
+
let blocked = observerValid && observerSample.height > observer[2];
|
|
17653
|
+
for (let j = 1; j < segments; j++) {
|
|
17654
|
+
const fraction = j / segments;
|
|
17655
|
+
const station = read(observer[0] + dx * fraction, observer[1] + dy * fraction);
|
|
17656
|
+
if (station.status !== TerrainSampleStatus.VALID) {
|
|
17657
|
+
complete = false;
|
|
17658
|
+
} else if (!blocked) {
|
|
17659
|
+
const [rise, run] = sight(distance * fraction, station.height);
|
|
17660
|
+
blocked = compareTerrainSlopes(rise, run, targetRise, targetRun) >= 0;
|
|
17661
|
+
}
|
|
17662
|
+
}
|
|
17663
|
+
sampledCoverage[i] = complete ? 1 : 0;
|
|
17664
|
+
statuses[i] = blocked ? TerrainRegionalViewStatus.BLOCKED : complete ? TerrainRegionalViewStatus.VISIBLE : TerrainRegionalViewStatus.UNKNOWN;
|
|
17665
|
+
}
|
|
17666
|
+
return { statuses, targetStatuses, sampledCoverage, samples };
|
|
17667
|
+
}
|
|
17668
|
+
|
|
17669
|
+
// dist/terrain/hydrology.js
|
|
17670
|
+
function getTerrainCellMetrics(field) {
|
|
17671
|
+
if (field.registration !== "cell")
|
|
17672
|
+
throw new Error("Terrain cell metrics require cell registration");
|
|
17673
|
+
const [cx, cy] = field.columnStep;
|
|
17674
|
+
const [rx, ry] = field.rowStep;
|
|
17675
|
+
const determinant = cx * ry - cy * rx;
|
|
17676
|
+
const columnLength = Math.hypot(cx, cy);
|
|
17677
|
+
const rowLength = Math.hypot(rx, ry);
|
|
17678
|
+
const area = Math.abs(determinant);
|
|
17679
|
+
if (!(area > 0 && Number.isFinite(area) && Number.isFinite(columnLength + rowLength)))
|
|
17680
|
+
throw new RangeError("Invalid terrain cell geometry");
|
|
17681
|
+
const sign2 = Math.sign(determinant);
|
|
17682
|
+
const east = [sign2 * ry / rowLength, -sign2 * rx / rowLength];
|
|
17683
|
+
const south = [-sign2 * cy / columnLength, sign2 * cx / columnLength];
|
|
17684
|
+
return {
|
|
17685
|
+
area,
|
|
17686
|
+
faceLengths: [rowLength, rowLength, columnLength, columnLength],
|
|
17687
|
+
faceNormals: [[-east[0], -east[1]], east, [-south[0], -south[1]], south]
|
|
17688
|
+
};
|
|
17689
|
+
}
|
|
17690
|
+
function createTerrainDrainage(field, { outlets = [], maxCells = 4194304 } = {}) {
|
|
17691
|
+
const { width, height, columnStep, rowStep } = field;
|
|
17692
|
+
const count = width * height;
|
|
17693
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 2147483647)
|
|
17694
|
+
throw new RangeError("Terrain drainage exceeds its cell budget");
|
|
17695
|
+
const { area: cellArea } = getTerrainCellMetrics(field);
|
|
17696
|
+
for (const i of outlets) {
|
|
17697
|
+
if (!Number.isInteger(i) || i < 0 || i >= count || field.getHeight(i % width, Math.floor(i / width)) === void 0)
|
|
17698
|
+
throw new RangeError("Terrain outlet must identify a valid cell");
|
|
17699
|
+
}
|
|
17700
|
+
const { heights, validity } = field.copyData();
|
|
17701
|
+
const receiver = new Int32Array(count).fill(-1);
|
|
17702
|
+
const terminal = new Int32Array(count).fill(-1);
|
|
17703
|
+
const contributingCells = new Uint32Array(count);
|
|
17704
|
+
const incoming = new Uint8Array(count);
|
|
17705
|
+
const queue = new Int32Array(count);
|
|
17706
|
+
const outletSet = new Set(outlets);
|
|
17707
|
+
const offsets = [];
|
|
17708
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
17709
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
17710
|
+
if (!dx && !dy)
|
|
17711
|
+
continue;
|
|
17712
|
+
const distance = Math.hypot(dx * columnStep[0] + dy * rowStep[0], dx * columnStep[1] + dy * rowStep[1]);
|
|
17713
|
+
if (!(distance > 0 && Number.isFinite(distance)))
|
|
17714
|
+
throw new RangeError("Invalid terrain neighbor distance");
|
|
17715
|
+
offsets.push({ dx, dy, distance });
|
|
17716
|
+
}
|
|
17717
|
+
}
|
|
17718
|
+
for (let i = 0; i < count; i++) {
|
|
17719
|
+
if (!validity[i])
|
|
17720
|
+
continue;
|
|
17721
|
+
contributingCells[i] = 1;
|
|
17722
|
+
if (outletSet.has(i))
|
|
17723
|
+
continue;
|
|
17724
|
+
const col = i % width;
|
|
17725
|
+
const row = Math.floor(i / width);
|
|
17726
|
+
let steepest = 0;
|
|
17727
|
+
for (const { dx, dy, distance } of offsets) {
|
|
17728
|
+
if (col + dx < 0 || col + dx >= width || row + dy < 0 || row + dy >= height)
|
|
17729
|
+
continue;
|
|
17730
|
+
const j = i + dx + dy * width;
|
|
17731
|
+
if (!validity[j] || heights[j] >= heights[i])
|
|
17732
|
+
continue;
|
|
17733
|
+
if (dx && dy && (!validity[i + dx] || !validity[i + dy * width]))
|
|
17734
|
+
continue;
|
|
17735
|
+
const slope2 = (heights[i] - heights[j]) / distance;
|
|
17736
|
+
if (!Number.isFinite(slope2) || slope2 === 0)
|
|
17737
|
+
throw new RangeError("Terrain drainage slope is outside the representable range");
|
|
17738
|
+
if (slope2 > steepest) {
|
|
17739
|
+
steepest = slope2;
|
|
17740
|
+
receiver[i] = j;
|
|
17741
|
+
}
|
|
17742
|
+
}
|
|
17743
|
+
if (receiver[i] >= 0)
|
|
17744
|
+
incoming[receiver[i]]++;
|
|
17745
|
+
}
|
|
17746
|
+
let end = 0;
|
|
17747
|
+
for (let i = 0; i < count; i++)
|
|
17748
|
+
if (validity[i] && !incoming[i])
|
|
17749
|
+
queue[end++] = i;
|
|
17750
|
+
for (let cursor = 0; cursor < end; cursor++) {
|
|
17751
|
+
const i = queue[cursor];
|
|
17752
|
+
const next = receiver[i];
|
|
17753
|
+
if (next < 0)
|
|
17754
|
+
continue;
|
|
17755
|
+
contributingCells[next] += contributingCells[i];
|
|
17756
|
+
if (--incoming[next] === 0)
|
|
17757
|
+
queue[end++] = next;
|
|
17758
|
+
}
|
|
17759
|
+
for (let cursor = end - 1; cursor >= 0; cursor--) {
|
|
17760
|
+
const i = queue[cursor];
|
|
17761
|
+
const next = receiver[i];
|
|
17762
|
+
terminal[i] = next < 0 ? i : terminal[next];
|
|
17763
|
+
}
|
|
17764
|
+
return { receiver, terminal, contributingCells, cellArea };
|
|
17765
|
+
}
|
|
17766
|
+
|
|
17767
|
+
// dist/terrain/depression-fill.js
|
|
17768
|
+
function fillTerrainDepressions(field, { outlets, maxCells = 4194304 }) {
|
|
17769
|
+
if (field.registration !== "cell")
|
|
17770
|
+
throw new Error("Terrain depression fill requires cell registration");
|
|
17771
|
+
const { width, height } = field;
|
|
17772
|
+
const count = width * height;
|
|
17773
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 2147483647)
|
|
17774
|
+
throw new RangeError("Terrain depression fill exceeds its cell budget");
|
|
17775
|
+
if (!outlets.length)
|
|
17776
|
+
throw new RangeError("Terrain depression fill requires an outlet");
|
|
17777
|
+
for (const i of outlets) {
|
|
17778
|
+
if (!Number.isInteger(i) || i < 0 || i >= count || field.getHeight(i % width, Math.floor(i / width)) === void 0)
|
|
17779
|
+
throw new RangeError("Terrain outlet must identify a valid cell");
|
|
17780
|
+
}
|
|
17781
|
+
const { heights, validity } = field.copyData();
|
|
17782
|
+
const receiver = new Int32Array(count).fill(-2);
|
|
17783
|
+
const heap = new Int32Array(count);
|
|
17784
|
+
let size = 0;
|
|
17785
|
+
let disconnectedCells = field.validCount;
|
|
17786
|
+
const before = (a, b) => heights[a] < heights[b] || heights[a] === heights[b] && a < b;
|
|
17787
|
+
function push(cell) {
|
|
17788
|
+
let slot = size++;
|
|
17789
|
+
while (slot > 0) {
|
|
17790
|
+
const parent = Math.floor((slot - 1) / 2);
|
|
17791
|
+
if (!before(cell, heap[parent]))
|
|
17792
|
+
break;
|
|
17793
|
+
heap[slot] = heap[parent];
|
|
17794
|
+
slot = parent;
|
|
17795
|
+
}
|
|
17796
|
+
heap[slot] = cell;
|
|
17797
|
+
}
|
|
17798
|
+
function pop() {
|
|
17799
|
+
const first = heap[0];
|
|
17800
|
+
const tail = heap[--size];
|
|
17801
|
+
let slot = 0;
|
|
17802
|
+
let child = 1;
|
|
17803
|
+
while (child < size) {
|
|
17804
|
+
if (child + 1 < size && before(heap[child + 1], heap[child]))
|
|
17805
|
+
child++;
|
|
17806
|
+
if (!before(heap[child], tail))
|
|
17807
|
+
break;
|
|
17808
|
+
heap[slot] = heap[child];
|
|
17809
|
+
slot = child;
|
|
17810
|
+
child = slot * 2 + 1;
|
|
17811
|
+
}
|
|
17812
|
+
if (size)
|
|
17813
|
+
heap[slot] = tail;
|
|
17814
|
+
return first;
|
|
17815
|
+
}
|
|
17816
|
+
function visit(cell, parent) {
|
|
17817
|
+
if (!validity[cell] || receiver[cell] !== -2)
|
|
17818
|
+
return;
|
|
17819
|
+
receiver[cell] = parent;
|
|
17820
|
+
disconnectedCells--;
|
|
17821
|
+
if (parent >= 0)
|
|
17822
|
+
heights[cell] = Math.max(heights[cell], heights[parent]);
|
|
17823
|
+
push(cell);
|
|
17824
|
+
}
|
|
17825
|
+
for (const outlet of outlets)
|
|
17826
|
+
visit(outlet, -1);
|
|
17827
|
+
while (size) {
|
|
17828
|
+
const cell = pop();
|
|
17829
|
+
const column = cell % width;
|
|
17830
|
+
if (column > 0)
|
|
17831
|
+
visit(cell - 1, cell);
|
|
17832
|
+
if (column + 1 < width)
|
|
17833
|
+
visit(cell + 1, cell);
|
|
17834
|
+
if (cell >= width)
|
|
17835
|
+
visit(cell - width, cell);
|
|
17836
|
+
if (cell < count - width)
|
|
17837
|
+
visit(cell + width, cell);
|
|
17838
|
+
}
|
|
17839
|
+
return {
|
|
17840
|
+
field: new HeightField({
|
|
17841
|
+
width,
|
|
17842
|
+
height,
|
|
17843
|
+
heights,
|
|
17844
|
+
validity,
|
|
17845
|
+
origin: field.origin,
|
|
17846
|
+
columnStep: field.columnStep,
|
|
17847
|
+
rowStep: field.rowStep,
|
|
17848
|
+
registration: field.registration,
|
|
17849
|
+
diagonal: field.diagonal,
|
|
17850
|
+
heightReference: field.heightReference
|
|
17851
|
+
}),
|
|
17852
|
+
receiver,
|
|
17853
|
+
disconnectedCells
|
|
17854
|
+
};
|
|
17855
|
+
}
|
|
17856
|
+
|
|
17857
|
+
// dist/terrain/cutout-region.js
|
|
17858
|
+
var PLAN = /* @__PURE__ */ Symbol.for("@math.gl/geospatial/terrain-cutout-polygons/v1");
|
|
17859
|
+
function createTerrainCutoutPlan(plan) {
|
|
17860
|
+
return Object.freeze({ [PLAN]: Object.freeze(plan) });
|
|
17861
|
+
}
|
|
17862
|
+
function getTerrainCutoutPlan(region) {
|
|
17863
|
+
if (Array.isArray(region))
|
|
17864
|
+
return void 0;
|
|
17865
|
+
const plan = region == null ? void 0 : region[PLAN];
|
|
17866
|
+
if (!plan)
|
|
17867
|
+
throw new RangeError("Invalid prepared terrain cutout polygons");
|
|
17868
|
+
return plan;
|
|
17869
|
+
}
|
|
17870
|
+
function copyTerrainCutoutRegion(region) {
|
|
17871
|
+
return getTerrainCutoutPlan(region) ? region : region.map((p) => [p[0], p[1]]);
|
|
17872
|
+
}
|
|
17873
|
+
function sameTerrainCutoutRegion(a, b) {
|
|
17874
|
+
if (getTerrainCutoutPlan(a) || getTerrainCutoutPlan(b))
|
|
17875
|
+
return a === b;
|
|
17876
|
+
const aa = a, bb = b;
|
|
17877
|
+
return aa.length === bb.length && aa.every((p, i) => bb[i].length === 2 && p[0] === bb[i][0] && p[1] === bb[i][1]);
|
|
17878
|
+
}
|
|
17879
|
+
|
|
17880
|
+
// dist/terrain/mesh-cutout.js
|
|
17881
|
+
function splitTerrainMesh(mesh, polygon2, { maxWork = 4e6, maxVertices = 5e5, maxTriangles = 5e5 } = {}) {
|
|
17882
|
+
if (![maxWork, maxVertices, maxTriangles].every((n) => Number.isSafeInteger(n) && n >= 0) || maxVertices > 4294967295 || maxTriangles > 4294967295 || !(mesh.positions instanceof Float32Array || mesh.positions instanceof Float64Array) || !(mesh.indices instanceof Uint16Array || mesh.indices instanceof Uint32Array) || mesh.positions.length % 3 || mesh.indices.length % 3 || mesh.positions.length / 3 > maxVertices || mesh.indices.length / 3 > maxTriangles || !mesh.positions.every(Number.isFinite))
|
|
17883
|
+
throw new RangeError("Invalid terrain cutout mesh or capacity");
|
|
17884
|
+
let work = 0;
|
|
17885
|
+
function charge(amount) {
|
|
17886
|
+
work += amount;
|
|
17887
|
+
if (work > maxWork)
|
|
17888
|
+
throw new RangeError("Terrain cutout work budget exceeded");
|
|
17889
|
+
}
|
|
17890
|
+
const prepared2 = getTerrainCutoutPlan(polygon2);
|
|
17891
|
+
const ring = prepared2 ? void 0 : validatePolygon(polygon2, charge);
|
|
17892
|
+
const lines = (prepared2 == null ? void 0 : prepared2.lines) ?? ring.map((p, i) => [p, ring[(i + 1) % ring.length]]);
|
|
17893
|
+
const vertices = [];
|
|
17894
|
+
for (let i = 0; i < mesh.positions.length; i += 3)
|
|
17895
|
+
vertices.push([mesh.positions[i], mesh.positions[i + 1], mesh.positions[i + 2]]);
|
|
17896
|
+
const faces = [];
|
|
17897
|
+
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
17898
|
+
const face = [mesh.indices[i], mesh.indices[i + 1], mesh.indices[i + 2]];
|
|
17899
|
+
if (face.some((id) => id >= vertices.length))
|
|
17900
|
+
throw new RangeError("Invalid terrain cutout index");
|
|
17901
|
+
checkTriangle(vertices[face[0]], vertices[face[1]], vertices[face[2]]);
|
|
17902
|
+
faces.push(face);
|
|
17903
|
+
}
|
|
17904
|
+
validateTopology(vertices, faces, charge);
|
|
17905
|
+
const patch = createPiece();
|
|
17906
|
+
const remainder = createPiece();
|
|
17907
|
+
const intersections2 = lines.map(() => /* @__PURE__ */ new Map());
|
|
17908
|
+
let fragmentCount = 0;
|
|
17909
|
+
function addVertex(vertex) {
|
|
17910
|
+
if (vertices.length >= maxVertices || !vertex.every(Number.isFinite))
|
|
17911
|
+
throw new RangeError("Terrain cutout vertex budget or coordinate range exceeded");
|
|
17912
|
+
return vertices.push(vertex) - 1;
|
|
17913
|
+
}
|
|
17914
|
+
function intersection(a, b, da, db, line) {
|
|
17915
|
+
const key3 = edgeKey2(a, b);
|
|
17916
|
+
const cache = intersections2[line];
|
|
17917
|
+
const saved = cache.get(key3);
|
|
17918
|
+
if (saved !== void 0)
|
|
17919
|
+
return saved;
|
|
17920
|
+
const pa = vertices[a], pb = vertices[b];
|
|
17921
|
+
if (pa[0] > pb[0] || pa[0] === pb[0] && (pa[1] > pb[1] || pa[1] === pb[1] && pa[2] > pb[2])) {
|
|
17922
|
+
[a, b] = [b, a];
|
|
17923
|
+
[da, db] = [db, da];
|
|
17924
|
+
}
|
|
17925
|
+
const t = Math.abs(da) / (Math.abs(da) + Math.abs(db));
|
|
17926
|
+
if (!(t > 0 && t < 1))
|
|
17927
|
+
throw new RangeError("Unrepresentable terrain cut intersection");
|
|
17928
|
+
const u = vertices[a];
|
|
17929
|
+
const v = vertices[b];
|
|
17930
|
+
const id = addVertex([
|
|
17931
|
+
u[0] + t * (v[0] - u[0]),
|
|
17932
|
+
u[1] + t * (v[1] - u[1]),
|
|
17933
|
+
u[2] + t * (v[2] - u[2])
|
|
17934
|
+
]);
|
|
17935
|
+
cache.set(key3, id);
|
|
17936
|
+
return id;
|
|
17937
|
+
}
|
|
17938
|
+
for (let source = 0; source < faces.length; source++) {
|
|
17939
|
+
let fragments = [{ ids: faces[source], inside: true }];
|
|
17940
|
+
for (let line = 0; line < lines.length; line++) {
|
|
17941
|
+
const next = [];
|
|
17942
|
+
const [a, b] = lines[line];
|
|
17943
|
+
for (const fragment of fragments) {
|
|
17944
|
+
const { ids } = fragment;
|
|
17945
|
+
charge(ids.length);
|
|
17946
|
+
const distances = ids.map((id) => cross6(a, b, vertices[id]));
|
|
17947
|
+
if (distances.some((d) => !Number.isFinite(d)))
|
|
17948
|
+
throw new RangeError("Invalid terrain cut coordinates");
|
|
17949
|
+
if (!distances.some((d) => d < 0))
|
|
17950
|
+
next.push(fragment);
|
|
17951
|
+
else if (!distances.some((d) => d > 0))
|
|
17952
|
+
next.push({ ...fragment, inside: false });
|
|
17953
|
+
else {
|
|
17954
|
+
const positive2 = [];
|
|
17955
|
+
const negative = [];
|
|
17956
|
+
for (let i = 0; i < ids.length; i++) {
|
|
17957
|
+
const j = (i + 1) % ids.length;
|
|
17958
|
+
const d = distances[i];
|
|
17959
|
+
const e = distances[j];
|
|
17960
|
+
if (d >= 0)
|
|
17961
|
+
positive2.push(ids[i]);
|
|
17962
|
+
if (d <= 0)
|
|
17963
|
+
negative.push(ids[i]);
|
|
17964
|
+
if (d < 0 && e > 0 || d > 0 && e < 0) {
|
|
17965
|
+
const id = intersection(ids[i], ids[j], d, e, line);
|
|
17966
|
+
positive2.push(id);
|
|
17967
|
+
negative.push(id);
|
|
17968
|
+
}
|
|
17969
|
+
}
|
|
17970
|
+
next.push({ ids: positive2, inside: fragment.inside }, { ids: negative, inside: false });
|
|
17971
|
+
}
|
|
17972
|
+
if (fragmentCount + next.length > maxTriangles)
|
|
17973
|
+
throw new RangeError("Terrain cutout fragment budget exceeded");
|
|
17974
|
+
}
|
|
17975
|
+
fragments = next;
|
|
17976
|
+
}
|
|
17977
|
+
fragmentCount += fragments.length;
|
|
17978
|
+
for (const { ids, inside } of fragments) {
|
|
17979
|
+
let center;
|
|
17980
|
+
if (prepared2 || ids.length > 3) {
|
|
17981
|
+
center = [...vertices[ids[0]]];
|
|
17982
|
+
for (const id of ids) {
|
|
17983
|
+
for (let k = 0; k < 3; k++)
|
|
17984
|
+
center[k] += (vertices[id][k] - vertices[ids[0]][k]) / ids.length;
|
|
17985
|
+
}
|
|
17986
|
+
}
|
|
17987
|
+
const polygonIndex = prepared2 ? prepared2.classify([center[0], center[1]], charge) : inside ? 0 : -1;
|
|
17988
|
+
const piece = polygonIndex >= 0 ? patch : remainder;
|
|
17989
|
+
if (ids.length === 3)
|
|
17990
|
+
emit(piece, ids, source, polygonIndex);
|
|
17991
|
+
else {
|
|
17992
|
+
const hub = addVertex(center);
|
|
17993
|
+
for (let i = 0; i < ids.length; i++)
|
|
17994
|
+
emit(piece, [ids[i], ids[(i + 1) % ids.length], hub], source, polygonIndex);
|
|
17995
|
+
}
|
|
17996
|
+
}
|
|
17997
|
+
}
|
|
17998
|
+
function emit(piece, face, source, polygonIndex) {
|
|
17999
|
+
if (patch.sourceFaces.length + remainder.sourceFaces.length >= maxTriangles)
|
|
18000
|
+
throw new RangeError("Terrain cutout triangle budget exceeded");
|
|
18001
|
+
checkTriangle(vertices[face[0]], vertices[face[1]], vertices[face[2]]);
|
|
18002
|
+
const [a, b, c] = faces[source].map((id) => vertices[id]);
|
|
18003
|
+
const area = cross6(a, b, c);
|
|
18004
|
+
for (let i = 0; i < 3; i++) {
|
|
18005
|
+
const id = face[i];
|
|
18006
|
+
if (!piece.ids.has(id)) {
|
|
18007
|
+
if (patch.ids.size + remainder.ids.size >= maxVertices)
|
|
18008
|
+
throw new RangeError("Terrain cutout output vertex budget exceeded");
|
|
18009
|
+
piece.ids.set(id, piece.ids.size);
|
|
18010
|
+
const p = vertices[id];
|
|
18011
|
+
piece.positions.push(...p);
|
|
18012
|
+
piece.sourceTriangles.push(source);
|
|
18013
|
+
piece.sourceWeights.push(cross6(b, c, p) / area, cross6(c, a, p) / area, cross6(a, b, p) / area);
|
|
18014
|
+
}
|
|
18015
|
+
piece.indices.push(piece.ids.get(id));
|
|
18016
|
+
addEdge(piece.boundary, id, face[(i + 1) % 3], polygonIndex);
|
|
18017
|
+
}
|
|
18018
|
+
piece.sourceFaces.push(source);
|
|
18019
|
+
piece.polygonIndices.push(polygonIndex);
|
|
18020
|
+
}
|
|
18021
|
+
for (const [key3, inside] of patch.boundary) {
|
|
18022
|
+
const outside = remainder.boundary.get(key3);
|
|
18023
|
+
if (!outside)
|
|
18024
|
+
continue;
|
|
18025
|
+
const [a, b] = inside.edge;
|
|
18026
|
+
if (inside.count !== 1 || outside.count !== 1 || outside.edge[0] !== b)
|
|
18027
|
+
throw new Error("Nonconforming terrain cut boundary");
|
|
18028
|
+
patch.cutEdges.push(patch.ids.get(a), patch.ids.get(b));
|
|
18029
|
+
remainder.cutEdges.push(remainder.ids.get(b), remainder.ids.get(a));
|
|
18030
|
+
patch.cutPolygonIndices.push(inside.polygon);
|
|
18031
|
+
remainder.cutPolygonIndices.push(inside.polygon);
|
|
18032
|
+
}
|
|
18033
|
+
return { patch: finish(patch), remainder: finish(remainder) };
|
|
18034
|
+
}
|
|
18035
|
+
function validatePolygon(polygon2, charge) {
|
|
18036
|
+
if (polygon2.length < 3 || polygon2.some((p) => p.length !== 2 || !p.every(Number.isFinite)))
|
|
18037
|
+
throw new RangeError("Invalid terrain cut polygon");
|
|
18038
|
+
const ring = [...polygon2];
|
|
18039
|
+
const orientation3 = cross6(ring[0], ring[1], ring[2]);
|
|
18040
|
+
if (orientation3 < 0)
|
|
18041
|
+
ring.reverse();
|
|
18042
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18043
|
+
charge(ring.length);
|
|
18044
|
+
const j = (i + 1) % ring.length;
|
|
18045
|
+
for (let k = 0; k < ring.length; k++) {
|
|
18046
|
+
if (k === i || k === j)
|
|
18047
|
+
continue;
|
|
18048
|
+
const area = cross6(ring[i], ring[j], ring[k]);
|
|
18049
|
+
if (!(area > 0 && Number.isFinite(area)))
|
|
18050
|
+
throw new RangeError("Terrain cut polygon must be strictly convex");
|
|
18051
|
+
}
|
|
18052
|
+
}
|
|
18053
|
+
return ring;
|
|
18054
|
+
}
|
|
18055
|
+
function checkTriangle(a, b, c) {
|
|
18056
|
+
const area = cross6(a, b, c);
|
|
18057
|
+
const scale3 = Math.hypot(b[0] - a[0], b[1] - a[1]) * Math.hypot(c[0] - a[0], c[1] - a[1]);
|
|
18058
|
+
if (!(area > Number.EPSILON * scale3 && Number.isFinite(area)))
|
|
18059
|
+
throw new RangeError("Terrain cut requires upward nondegenerate XY triangles");
|
|
18060
|
+
}
|
|
18061
|
+
function validateTopology(vertices, faces, charge) {
|
|
18062
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
18063
|
+
const boxes = faces.map((face) => {
|
|
18064
|
+
for (let i = 0; i < 3; i++)
|
|
18065
|
+
addEdge(edges2, face[i], face[(i + 1) % 3]);
|
|
18066
|
+
const points = face.map((id) => vertices[id]);
|
|
18067
|
+
return {
|
|
18068
|
+
face,
|
|
18069
|
+
points,
|
|
18070
|
+
low: Math.min(...points.map((p) => p[0])),
|
|
18071
|
+
high: Math.max(...points.map((p) => p[0])),
|
|
18072
|
+
minY: Math.min(...points.map((p) => p[1])),
|
|
18073
|
+
maxY: Math.max(...points.map((p) => p[1]))
|
|
18074
|
+
};
|
|
18075
|
+
}).sort((a, b) => a.low - b.low);
|
|
18076
|
+
for (let i = 0; i < boxes.length; i++) {
|
|
18077
|
+
const a = boxes[i];
|
|
18078
|
+
for (let j = i + 1; j < boxes.length && boxes[j].low <= a.high; j++) {
|
|
18079
|
+
charge(1);
|
|
18080
|
+
const b = boxes[j];
|
|
18081
|
+
if (a.maxY < b.minY || b.maxY < a.minY)
|
|
18082
|
+
continue;
|
|
18083
|
+
if (!separates(a.points, b.points) && !separates(b.points, a.points))
|
|
18084
|
+
throw new RangeError("Terrain cut input has overlapping XY triangles");
|
|
18085
|
+
checkJunctions(a.face, b.face, vertices);
|
|
18086
|
+
checkJunctions(b.face, a.face, vertices);
|
|
18087
|
+
}
|
|
18088
|
+
}
|
|
18089
|
+
}
|
|
18090
|
+
function separates(a, b) {
|
|
18091
|
+
return a.some((p, i) => b.every((q) => cross6(p, a[(i + 1) % 3], q) <= 0));
|
|
18092
|
+
}
|
|
18093
|
+
function checkJunctions(a, b, vertices) {
|
|
18094
|
+
for (let i = 0; i < 3; i++) {
|
|
18095
|
+
const u = vertices[a[i]];
|
|
18096
|
+
const v = vertices[a[(i + 1) % 3]];
|
|
18097
|
+
const overlaps2 = b.filter((id) => {
|
|
18098
|
+
const p = vertices[id];
|
|
18099
|
+
if (cross6(u, v, p) !== 0)
|
|
18100
|
+
return false;
|
|
18101
|
+
const axis = Math.abs(v[0] - u[0]) >= Math.abs(v[1] - u[1]) ? 0 : 1;
|
|
18102
|
+
const low = Math.min(u[axis], v[axis]);
|
|
18103
|
+
const high = Math.max(u[axis], v[axis]);
|
|
18104
|
+
if (p[axis] > low && p[axis] < high)
|
|
18105
|
+
throw new RangeError("Terrain cut input has a T-junction");
|
|
18106
|
+
return p[axis] >= low && p[axis] <= high;
|
|
18107
|
+
});
|
|
18108
|
+
if (overlaps2.length >= 2 && (!overlaps2.includes(a[i]) || !overlaps2.includes(a[(i + 1) % 3])))
|
|
18109
|
+
throw new RangeError("Terrain cut input has an unwelded shared edge");
|
|
18110
|
+
}
|
|
18111
|
+
}
|
|
18112
|
+
function addEdge(edges2, a, b, polygon2 = -1) {
|
|
18113
|
+
const key3 = edgeKey2(a, b);
|
|
18114
|
+
const entry = edges2.get(key3);
|
|
18115
|
+
if (!entry)
|
|
18116
|
+
edges2.set(key3, { edge: [a, b], count: 1, polygon: polygon2 });
|
|
18117
|
+
else {
|
|
18118
|
+
if (entry.count !== 1 || entry.edge[0] !== b)
|
|
18119
|
+
throw new RangeError("Terrain cut mesh has inconsistent or nonmanifold edges");
|
|
18120
|
+
entry.count++;
|
|
18121
|
+
}
|
|
18122
|
+
}
|
|
18123
|
+
function edgeKey2(a, b) {
|
|
18124
|
+
return a < b ? a + "," + b : b + "," + a;
|
|
18125
|
+
}
|
|
18126
|
+
function cross6(a, b, c) {
|
|
18127
|
+
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
18128
|
+
}
|
|
18129
|
+
function createPiece() {
|
|
18130
|
+
return {
|
|
18131
|
+
ids: /* @__PURE__ */ new Map(),
|
|
18132
|
+
positions: [],
|
|
18133
|
+
indices: [],
|
|
18134
|
+
sourceTriangles: [],
|
|
18135
|
+
sourceWeights: [],
|
|
18136
|
+
sourceFaces: [],
|
|
18137
|
+
boundary: /* @__PURE__ */ new Map(),
|
|
18138
|
+
cutEdges: [],
|
|
18139
|
+
polygonIndices: [],
|
|
18140
|
+
cutPolygonIndices: []
|
|
18141
|
+
};
|
|
18142
|
+
}
|
|
18143
|
+
function finish(piece) {
|
|
18144
|
+
return {
|
|
18145
|
+
positions: Float64Array.from(piece.positions),
|
|
18146
|
+
indices: Uint32Array.from(piece.indices),
|
|
18147
|
+
sourceTriangles: Uint32Array.from(piece.sourceTriangles),
|
|
18148
|
+
sourceWeights: Float64Array.from(piece.sourceWeights),
|
|
18149
|
+
sourceFaces: Uint32Array.from(piece.sourceFaces),
|
|
18150
|
+
cutEdges: Uint32Array.from(piece.cutEdges),
|
|
18151
|
+
polygonIndices: Uint32Array.from(piece.polygonIndices),
|
|
18152
|
+
cutPolygonIndices: Uint32Array.from(piece.cutPolygonIndices)
|
|
18153
|
+
};
|
|
18154
|
+
}
|
|
18155
|
+
function validateTerrainCutoutTopology(mesh, maxWork) {
|
|
18156
|
+
const vertices = [];
|
|
18157
|
+
const faces = [];
|
|
18158
|
+
for (let i = 0; i < mesh.positions.length; i += 3)
|
|
18159
|
+
vertices.push([mesh.positions[i], mesh.positions[i + 1], mesh.positions[i + 2]]);
|
|
18160
|
+
for (let i = 0; i < mesh.indices.length; i += 3)
|
|
18161
|
+
faces.push([mesh.indices[i], mesh.indices[i + 1], mesh.indices[i + 2]]);
|
|
18162
|
+
let work = 0;
|
|
18163
|
+
validateTopology(vertices, faces, (amount) => {
|
|
18164
|
+
work += amount;
|
|
18165
|
+
if (work > maxWork)
|
|
18166
|
+
throw new RangeError("Terrain cutout topology work budget exceeded");
|
|
18167
|
+
});
|
|
18168
|
+
}
|
|
18169
|
+
|
|
18170
|
+
// dist/terrain/cutout-skirts.js
|
|
18171
|
+
function createTerrainCutoutSkirts(cutout, { lift = 0, patch, remainder }) {
|
|
18172
|
+
if (!Number.isFinite(lift))
|
|
18173
|
+
throw new RangeError("Invalid terrain cutout lift");
|
|
18174
|
+
const positions = cutout.patch.positions.slice();
|
|
18175
|
+
for (let i = 2; i < positions.length; i += 3) {
|
|
18176
|
+
positions[i] += lift;
|
|
18177
|
+
if (!Number.isFinite(positions[i]))
|
|
18178
|
+
throw new RangeError("Terrain cutout lift overflow");
|
|
18179
|
+
}
|
|
18180
|
+
return {
|
|
18181
|
+
patch: skirtPiece({ ...cutout.patch, positions }, patch),
|
|
18182
|
+
remainder: skirtPiece(cutout.remainder, remainder)
|
|
18183
|
+
};
|
|
18184
|
+
}
|
|
18185
|
+
function skirtPiece(surface2, options) {
|
|
18186
|
+
if (!surface2.cutEdges.length)
|
|
18187
|
+
return { surface: surface2 };
|
|
18188
|
+
return {
|
|
18189
|
+
surface: surface2,
|
|
18190
|
+
skirt: createTerrainSkirt(surface2, { ...options, edges: surface2.cutEdges })
|
|
18191
|
+
};
|
|
18192
|
+
}
|
|
18193
|
+
|
|
18194
|
+
// dist/terrain/watershed-accumulation.js
|
|
18195
|
+
function accumulateTerrainWatersheds(receiver, { maxCells = 4194304 } = {}) {
|
|
18196
|
+
const count = receiver.length;
|
|
18197
|
+
if (!Number.isSafeInteger(maxCells) || maxCells < 0 || count > maxCells || count > 2147483647)
|
|
18198
|
+
throw new RangeError("Terrain watershed accumulation exceeds its cell budget");
|
|
18199
|
+
const incoming = new Uint32Array(count);
|
|
18200
|
+
const contributingCells = new Uint32Array(count);
|
|
18201
|
+
const terminal = new Int32Array(count).fill(-1);
|
|
18202
|
+
const queue = new Int32Array(count);
|
|
18203
|
+
let active = 0;
|
|
18204
|
+
for (let i = 0; i < count; i++) {
|
|
18205
|
+
const next = receiver[i];
|
|
18206
|
+
if (next === -2)
|
|
18207
|
+
continue;
|
|
18208
|
+
if (next < -1 || next >= count || next >= 0 && receiver[next] === -2)
|
|
18209
|
+
throw new RangeError("Invalid terrain watershed receiver");
|
|
18210
|
+
active++;
|
|
18211
|
+
contributingCells[i] = 1;
|
|
18212
|
+
if (next >= 0)
|
|
18213
|
+
incoming[next]++;
|
|
18214
|
+
}
|
|
18215
|
+
let end = 0;
|
|
18216
|
+
for (let i = 0; i < count; i++) {
|
|
18217
|
+
if (contributingCells[i] && !incoming[i])
|
|
18218
|
+
queue[end++] = i;
|
|
18219
|
+
}
|
|
18220
|
+
for (let cursor = 0; cursor < end; cursor++) {
|
|
18221
|
+
const i = queue[cursor];
|
|
18222
|
+
const next = receiver[i];
|
|
18223
|
+
if (next < 0)
|
|
18224
|
+
continue;
|
|
18225
|
+
contributingCells[next] += contributingCells[i];
|
|
18226
|
+
if (--incoming[next] === 0)
|
|
18227
|
+
queue[end++] = next;
|
|
18228
|
+
}
|
|
18229
|
+
if (end !== active)
|
|
18230
|
+
throw new RangeError("Terrain watershed receiver graph contains a cycle");
|
|
18231
|
+
for (let cursor = end - 1; cursor >= 0; cursor--) {
|
|
18232
|
+
const i = queue[cursor];
|
|
18233
|
+
const next = receiver[i];
|
|
18234
|
+
terminal[i] = next < 0 ? i : terminal[next];
|
|
18235
|
+
}
|
|
18236
|
+
return { terminal, contributingCells };
|
|
18237
|
+
}
|
|
18238
|
+
|
|
18239
|
+
// dist/terrain/tile-cutout.js
|
|
18240
|
+
function splitTerrainMeshTiles(tiles, polygon2, options = {}) {
|
|
18241
|
+
const assembled = assembleTerrainCutoutTiles(tiles, options);
|
|
18242
|
+
return {
|
|
18243
|
+
...splitTerrainMesh(assembled.mesh, polygon2, { ...options, maxWork: assembled.remainingWork }),
|
|
18244
|
+
sourceTiles: assembled.sourceTiles,
|
|
18245
|
+
sourceTileFaces: assembled.sourceTileFaces
|
|
18246
|
+
};
|
|
18247
|
+
}
|
|
18248
|
+
function assembleTerrainCutoutTiles(tiles, options = {}) {
|
|
18249
|
+
const maxVertices = options.maxVertices ?? 5e5;
|
|
18250
|
+
const maxTriangles = options.maxTriangles ?? 5e5;
|
|
18251
|
+
const maxWork = options.maxWork ?? 4e6;
|
|
18252
|
+
if (![maxVertices, maxTriangles, maxWork].every((n) => Number.isSafeInteger(n) && n >= 0) || maxVertices > 4294967295 || maxTriangles > 4294967295)
|
|
18253
|
+
throw new RangeError("Invalid terrain tile cutout limits");
|
|
18254
|
+
let vertexCount = 0;
|
|
18255
|
+
let faceCount = 0;
|
|
18256
|
+
let work = 0;
|
|
18257
|
+
for (const tile of tiles) {
|
|
18258
|
+
if (!(tile.positions instanceof Float32Array || tile.positions instanceof Float64Array) || !(tile.indices instanceof Uint16Array || tile.indices instanceof Uint32Array) || tile.positions.length % 3 || tile.indices.length % 3)
|
|
18259
|
+
throw new RangeError("Invalid terrain tile cutout mesh");
|
|
18260
|
+
vertexCount += tile.positions.length / 3;
|
|
18261
|
+
faceCount += tile.indices.length / 3;
|
|
18262
|
+
work += 1 + tile.positions.length / 3 + tile.indices.length;
|
|
18263
|
+
if (vertexCount > maxVertices || faceCount > maxTriangles || work > maxWork)
|
|
18264
|
+
throw new RangeError("Terrain tile cutout input budget exceeded");
|
|
18265
|
+
}
|
|
18266
|
+
const positions = new Float64Array(vertexCount * 3);
|
|
18267
|
+
const indices = new Uint32Array(faceCount * 3);
|
|
18268
|
+
const sourceTiles = new Uint32Array(faceCount);
|
|
18269
|
+
const sourceTileFaces = new Uint32Array(faceCount);
|
|
18270
|
+
const vertices = /* @__PURE__ */ new Map();
|
|
18271
|
+
let vertexOffset = 0;
|
|
18272
|
+
let faceOffset = 0;
|
|
18273
|
+
for (let tileIndex = 0; tileIndex < tiles.length; tileIndex++) {
|
|
18274
|
+
const tile = tiles[tileIndex];
|
|
18275
|
+
const remap = new Uint32Array(tile.positions.length / 3);
|
|
18276
|
+
for (let i = 0; i < remap.length; i++) {
|
|
18277
|
+
const x = tile.positions[i * 3];
|
|
18278
|
+
const y = tile.positions[i * 3 + 1];
|
|
18279
|
+
const z = tile.positions[i * 3 + 2];
|
|
18280
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))
|
|
18281
|
+
throw new RangeError("Invalid terrain tile cutout coordinate");
|
|
18282
|
+
const key3 = `${x},${y},${z}`;
|
|
18283
|
+
let id = vertices.get(key3);
|
|
18284
|
+
if (id === void 0) {
|
|
18285
|
+
id = vertexOffset++;
|
|
18286
|
+
vertices.set(key3, id);
|
|
18287
|
+
positions[id * 3] = x;
|
|
18288
|
+
positions[id * 3 + 1] = y;
|
|
18289
|
+
positions[id * 3 + 2] = z;
|
|
18290
|
+
}
|
|
18291
|
+
remap[i] = id;
|
|
18292
|
+
}
|
|
18293
|
+
for (let i = 0; i < tile.indices.length; i++) {
|
|
18294
|
+
const id = tile.indices[i];
|
|
18295
|
+
if (id >= remap.length)
|
|
18296
|
+
throw new RangeError("Invalid terrain tile cutout index");
|
|
18297
|
+
indices[faceOffset * 3 + i] = remap[id];
|
|
18298
|
+
}
|
|
18299
|
+
for (let i = 0; i < tile.indices.length / 3; i++) {
|
|
18300
|
+
sourceTiles[faceOffset + i] = tileIndex;
|
|
18301
|
+
sourceTileFaces[faceOffset + i] = i;
|
|
18302
|
+
}
|
|
18303
|
+
faceOffset += tile.indices.length / 3;
|
|
18304
|
+
}
|
|
18305
|
+
return {
|
|
18306
|
+
mesh: { positions: positions.subarray(0, vertexOffset * 3), indices },
|
|
18307
|
+
sourceTiles,
|
|
18308
|
+
sourceTileFaces,
|
|
18309
|
+
remainingWork: maxWork - work
|
|
18310
|
+
};
|
|
18311
|
+
}
|
|
18312
|
+
|
|
18313
|
+
// dist/terrain/tile-cutout-update.js
|
|
18314
|
+
var CACHE = /* @__PURE__ */ Symbol("terrain-cutout-cache");
|
|
18315
|
+
function updateTerrainTileCutouts(residents, polygon2, previous, options = {}) {
|
|
18316
|
+
const limits = {
|
|
18317
|
+
maxTiles: options.maxTiles ?? 512,
|
|
18318
|
+
maxPairChecks: options.maxPairChecks ?? 131072,
|
|
18319
|
+
maxBoundaryEdges: options.maxBoundaryEdges ?? 1e6,
|
|
18320
|
+
maxWork: options.maxWork ?? 4e6,
|
|
18321
|
+
maxVertices: options.maxVertices ?? 5e5,
|
|
18322
|
+
maxTriangles: options.maxTriangles ?? 5e5
|
|
18323
|
+
};
|
|
18324
|
+
if (Object.values(limits).some((n) => !Number.isSafeInteger(n) || n < 0) || limits.maxVertices > 4294967295 || limits.maxTriangles > 4294967295 || residents.length > limits.maxTiles)
|
|
18325
|
+
throw new RangeError("Invalid terrain cutout update limits");
|
|
18326
|
+
const prior = previous == null ? void 0 : previous[CACHE];
|
|
18327
|
+
const compatible = prior && sameTerrainCutoutRegion(prior.polygon, polygon2) && Object.keys(limits).every((key3) => prior.options[key3] === limits[key3]);
|
|
18328
|
+
if (!compatible)
|
|
18329
|
+
splitTerrainMesh({ positions: new Float64Array(), indices: new Uint32Array() }, polygon2, limits);
|
|
18330
|
+
const entries = /* @__PURE__ */ new Map();
|
|
18331
|
+
const rebuilt = [];
|
|
18332
|
+
let boundaryCount = 0;
|
|
18333
|
+
for (const resident of residents) {
|
|
18334
|
+
if (!resident.id || typeof resident.id !== "string" || entries.has(resident.id) || !Number.isSafeInteger(resident.revision) || resident.revision < 0)
|
|
18335
|
+
throw new RangeError("Invalid or duplicate terrain cutout resident");
|
|
18336
|
+
const old = compatible ? prior.entries.get(resident.id) : void 0;
|
|
18337
|
+
let entry;
|
|
18338
|
+
if (old && old.resident.mesh === resident.mesh && old.resident.revision === resident.revision)
|
|
18339
|
+
entry = old;
|
|
18340
|
+
else {
|
|
18341
|
+
const split = splitTerrainMesh(resident.mesh, polygon2, limits);
|
|
18342
|
+
const edges2 = [...boundaryEdges(split.patch, 0), ...boundaryEdges(split.remainder, 1)];
|
|
18343
|
+
const bounds2 = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18344
|
+
for (const id of resident.mesh.indices) {
|
|
18345
|
+
const x = resident.mesh.positions[id * 3], y = resident.mesh.positions[id * 3 + 1];
|
|
18346
|
+
bounds2[0] = Math.min(bounds2[0], x);
|
|
18347
|
+
bounds2[1] = Math.min(bounds2[1], y);
|
|
18348
|
+
bounds2[2] = Math.max(bounds2[2], x);
|
|
18349
|
+
bounds2[3] = Math.max(bounds2[3], y);
|
|
18350
|
+
}
|
|
18351
|
+
entry = { resident: { ...resident }, split, displayed: split, bounds: bounds2, edges: edges2 };
|
|
18352
|
+
rebuilt.push(resident.id);
|
|
18353
|
+
}
|
|
18354
|
+
boundaryCount += entry.edges.length;
|
|
18355
|
+
if (boundaryCount > limits.maxBoundaryEdges)
|
|
18356
|
+
throw new RangeError("Terrain cutout boundary budget exceeded");
|
|
18357
|
+
entries.set(resident.id, entry);
|
|
18358
|
+
}
|
|
18359
|
+
const values = [...entries.values()];
|
|
18360
|
+
let pairs = 0;
|
|
18361
|
+
for (let i = 0; i < values.length; i++)
|
|
18362
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
18363
|
+
if (++pairs > limits.maxPairChecks)
|
|
18364
|
+
throw new RangeError("Terrain cutout pair budget exceeded");
|
|
18365
|
+
const a = values[i], b = values[j];
|
|
18366
|
+
if (a.bounds[2] < b.bounds[0] || b.bounds[2] < a.bounds[0] || a.bounds[3] < b.bounds[1] || b.bounds[3] < a.bounds[1])
|
|
18367
|
+
continue;
|
|
18368
|
+
if (compatible && prior.entries.get(a.resident.id) === a && prior.entries.get(b.resident.id) === b)
|
|
18369
|
+
continue;
|
|
18370
|
+
const combined = assembleTerrainCutoutTiles([a.resident.mesh, b.resident.mesh], limits);
|
|
18371
|
+
validateTerrainCutoutTopology(combined.mesh, combined.remainingWork);
|
|
18372
|
+
}
|
|
18373
|
+
const boundaries = /* @__PURE__ */ new Map();
|
|
18374
|
+
const cutKeys = /* @__PURE__ */ new Map();
|
|
18375
|
+
for (let tile = 0; tile < values.length; tile++)
|
|
18376
|
+
for (const edge2 of values[tile].edges) {
|
|
18377
|
+
const other = boundaries.get(edge2.key);
|
|
18378
|
+
if (!other) {
|
|
18379
|
+
boundaries.set(edge2.key, { edge: edge2, paired: false });
|
|
18380
|
+
continue;
|
|
18381
|
+
}
|
|
18382
|
+
if (other.paired || other.edge.start !== edge2.end || other.edge.end !== edge2.start)
|
|
18383
|
+
throw new RangeError("Nonconforming terrain cutout tile boundary");
|
|
18384
|
+
other.paired = true;
|
|
18385
|
+
if (other.edge.side !== edge2.side) {
|
|
18386
|
+
cutKeys.set(edge2.key, edge2.side === 0 ? edge2.polygon : other.edge.polygon);
|
|
18387
|
+
}
|
|
18388
|
+
}
|
|
18389
|
+
const tiles = /* @__PURE__ */ new Map();
|
|
18390
|
+
const changed = [];
|
|
18391
|
+
for (let i = 0; i < values.length; i++) {
|
|
18392
|
+
const entry = values[i];
|
|
18393
|
+
const old = prior == null ? void 0 : prior.entries.get(entry.resident.id);
|
|
18394
|
+
const cuts = [[], []];
|
|
18395
|
+
const polygons2 = [[], []];
|
|
18396
|
+
for (const edge2 of entry.edges) {
|
|
18397
|
+
const polygonIndex = cutKeys.get(edge2.key);
|
|
18398
|
+
if (polygonIndex !== void 0) {
|
|
18399
|
+
cuts[edge2.side].push(edge2.a, edge2.b);
|
|
18400
|
+
polygons2[edge2.side].push(polygonIndex);
|
|
18401
|
+
}
|
|
18402
|
+
}
|
|
18403
|
+
const patch = withEdges(entry.split.patch, cuts[0], polygons2[0], old == null ? void 0 : old.displayed.patch);
|
|
18404
|
+
const remainder = withEdges(entry.split.remainder, cuts[1], polygons2[1], old == null ? void 0 : old.displayed.remainder);
|
|
18405
|
+
const displayed = old && patch === old.displayed.patch && remainder === old.displayed.remainder ? old.displayed : { patch, remainder };
|
|
18406
|
+
if (displayed !== (old == null ? void 0 : old.displayed))
|
|
18407
|
+
changed.push(entry.resident.id);
|
|
18408
|
+
entries.set(entry.resident.id, displayed === entry.displayed ? entry : { ...entry, displayed });
|
|
18409
|
+
tiles.set(entry.resident.id, displayed);
|
|
18410
|
+
}
|
|
18411
|
+
return {
|
|
18412
|
+
cache: { [CACHE]: { polygon: copyTerrainCutoutRegion(polygon2), options: limits, entries } },
|
|
18413
|
+
tiles,
|
|
18414
|
+
changed,
|
|
18415
|
+
rebuilt,
|
|
18416
|
+
removed: prior ? [...prior.entries.keys()].filter((id) => !entries.has(id)) : []
|
|
18417
|
+
};
|
|
18418
|
+
}
|
|
18419
|
+
function withEdges(piece, edges2, polygons2, old) {
|
|
18420
|
+
const same2 = old && old.positions === piece.positions && old.cutEdges.length === edges2.length && old.cutEdges.every((id, i) => id === edges2[i]) && old.cutPolygonIndices.every((id, i) => id === polygons2[i]);
|
|
18421
|
+
return same2 ? old : { ...piece, cutEdges: Uint32Array.from(edges2), cutPolygonIndices: Uint32Array.from(polygons2) };
|
|
18422
|
+
}
|
|
18423
|
+
function boundaryEdges(piece, side) {
|
|
18424
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
18425
|
+
for (let i = 0; i < piece.indices.length; i += 3)
|
|
18426
|
+
for (let j = 0; j < 3; j++) {
|
|
18427
|
+
const a = piece.indices[i + j], b = piece.indices[i + (j + 1) % 3];
|
|
18428
|
+
const key3 = a < b ? `${a},${b}` : `${b},${a}`;
|
|
18429
|
+
const old = edges2.get(key3);
|
|
18430
|
+
if (old)
|
|
18431
|
+
old.count++;
|
|
18432
|
+
else
|
|
18433
|
+
edges2.set(key3, { a, b, count: 1, polygon: piece.polygonIndices[i / 3] });
|
|
18434
|
+
}
|
|
18435
|
+
const result = [];
|
|
18436
|
+
const point2 = (id) => `${piece.positions[id * 3]},${piece.positions[id * 3 + 1]},${piece.positions[id * 3 + 2]}`;
|
|
18437
|
+
for (const { a, b, count, polygon: polygon2 } of edges2.values())
|
|
18438
|
+
if (count === 1) {
|
|
18439
|
+
const start = point2(a), end = point2(b);
|
|
18440
|
+
result.push({
|
|
18441
|
+
polygon: polygon2,
|
|
18442
|
+
a,
|
|
18443
|
+
b,
|
|
18444
|
+
side,
|
|
18445
|
+
start,
|
|
18446
|
+
end,
|
|
18447
|
+
key: start < end ? `${start}/${end}` : `${end}/${start}`
|
|
18448
|
+
});
|
|
18449
|
+
}
|
|
18450
|
+
return result;
|
|
18451
|
+
}
|
|
18452
|
+
|
|
18453
|
+
// dist/terrain/geographic-cutout.js
|
|
18454
|
+
var RAD = Math.PI / 180;
|
|
18455
|
+
function createGeographicTerrainCutoutFrame(options) {
|
|
18456
|
+
if (options.center.length !== 2)
|
|
18457
|
+
throw new RangeError("Invalid geographic terrain cutout center");
|
|
18458
|
+
const frame2 = {
|
|
18459
|
+
center: [wrap2(options.center[0]), options.center[1]],
|
|
18460
|
+
radius: options.radius ?? 6378137,
|
|
18461
|
+
maxAngularRadius: options.maxAngularRadius ?? 30
|
|
18462
|
+
};
|
|
18463
|
+
validateFrame(frame2);
|
|
18464
|
+
return Object.freeze({ ...frame2, center: Object.freeze(frame2.center) });
|
|
18465
|
+
}
|
|
18466
|
+
function projectGeographicTerrainCutout(positions, frame2) {
|
|
18467
|
+
var _a;
|
|
18468
|
+
validateFrame(frame2);
|
|
18469
|
+
validatePositions(positions);
|
|
18470
|
+
const result = new Float64Array(positions.length);
|
|
18471
|
+
const [sin0, cos0] = latitude(frame2.center[1]);
|
|
18472
|
+
const maximum = chartLimit(frame2);
|
|
18473
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
18474
|
+
const lon = positions[i], lat = positions[i + 1];
|
|
18475
|
+
if (lat < -90 || lat > 90)
|
|
18476
|
+
throw new RangeError("Invalid geographic terrain latitude");
|
|
18477
|
+
const sin = Math.sin(lat * RAD);
|
|
18478
|
+
const cos = Math.abs(lat) === 90 ? 0 : Math.cos(lat * RAD);
|
|
18479
|
+
const delta = wrap2(wrap2(lon) - frame2.center[0]) * RAD;
|
|
18480
|
+
const dot5 = sin0 * sin + cos0 * cos * Math.cos(delta);
|
|
18481
|
+
const x = cos * Math.sin(delta) / dot5;
|
|
18482
|
+
const y = (cos0 * sin - sin0 * cos * Math.cos(delta)) / dot5;
|
|
18483
|
+
if (!(dot5 > 0) || Math.hypot(x, y) > maximum)
|
|
18484
|
+
throw new RangeError("Terrain coordinate exceeds geographic cutout chart");
|
|
18485
|
+
result[i] = frame2.radius * x;
|
|
18486
|
+
result[i + 1] = frame2.radius * y;
|
|
18487
|
+
result[i] || (result[i] = 0);
|
|
18488
|
+
result[_a = i + 1] || (result[_a] = 0);
|
|
18489
|
+
result[i + 2] = positions[i + 2];
|
|
18490
|
+
}
|
|
18491
|
+
if (!result.every(Number.isFinite))
|
|
18492
|
+
throw new RangeError("Geographic terrain projection overflow");
|
|
18493
|
+
return result;
|
|
18494
|
+
}
|
|
18495
|
+
function unprojectGeographicTerrainCutout(positions, frame2) {
|
|
18496
|
+
validateFrame(frame2);
|
|
18497
|
+
validatePositions(positions);
|
|
18498
|
+
const result = new Float64Array(positions.length);
|
|
18499
|
+
const [sin0, cos0] = latitude(frame2.center[1]);
|
|
18500
|
+
const maximum = chartLimit(frame2);
|
|
18501
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
18502
|
+
const x = positions[i] / frame2.radius, y = positions[i + 1] / frame2.radius;
|
|
18503
|
+
const distance = Math.hypot(x, y);
|
|
18504
|
+
if (!Number.isFinite(distance) || distance > maximum)
|
|
18505
|
+
throw new RangeError("Terrain coordinate exceeds geographic cutout chart");
|
|
18506
|
+
const horizontal = cos0 - y * sin0;
|
|
18507
|
+
const vertical = sin0 + y * cos0;
|
|
18508
|
+
const lat = Math.atan2(vertical, Math.hypot(horizontal, x)) / RAD;
|
|
18509
|
+
result[i] = Math.abs(lat) === 90 ? frame2.center[0] : wrap2(frame2.center[0] + Math.atan2(x, horizontal) / RAD);
|
|
18510
|
+
result[i + 1] = lat;
|
|
18511
|
+
result[i + 2] = positions[i + 2];
|
|
18512
|
+
}
|
|
18513
|
+
return result;
|
|
18514
|
+
}
|
|
18515
|
+
function wrap2(longitude) {
|
|
18516
|
+
const result = longitude % 360;
|
|
18517
|
+
return result >= 180 ? result - 360 : result < -180 ? result + 360 : result;
|
|
18518
|
+
}
|
|
18519
|
+
function latitude(degrees2) {
|
|
18520
|
+
return [Math.sin(degrees2 * RAD), Math.abs(degrees2) === 90 ? 0 : Math.cos(degrees2 * RAD)];
|
|
18521
|
+
}
|
|
18522
|
+
function validateFrame(frame2) {
|
|
18523
|
+
if (frame2.center.length !== 2 || !frame2.center.every(Number.isFinite) || frame2.center[0] < -180 || frame2.center[0] >= 180 || Math.abs(frame2.center[1]) > 90 || !Number.isFinite(frame2.radius) || frame2.radius <= 0 || !Number.isFinite(frame2.maxAngularRadius) || frame2.maxAngularRadius <= 0 || frame2.maxAngularRadius > 80)
|
|
18524
|
+
throw new RangeError("Invalid geographic terrain cutout frame");
|
|
18525
|
+
}
|
|
18526
|
+
function validatePositions(positions) {
|
|
18527
|
+
if (!(positions instanceof Float32Array || positions instanceof Float64Array) || positions.length % 3 || !positions.every(Number.isFinite))
|
|
18528
|
+
throw new RangeError("Invalid geographic terrain cutout positions");
|
|
18529
|
+
}
|
|
18530
|
+
function chartLimit(frame2) {
|
|
18531
|
+
const distance = Math.tan(frame2.maxAngularRadius * RAD);
|
|
18532
|
+
return distance + 16 * Number.EPSILON * (1 + distance);
|
|
18533
|
+
}
|
|
18534
|
+
|
|
18535
|
+
// dist/terrain/cutout-polygons.js
|
|
18536
|
+
function prepareTerrainCutoutPolygons(polygons2, { maxEdges = 2048, maxWork = 4e6 } = {}) {
|
|
18537
|
+
if (![maxEdges, maxWork].every((n) => Number.isSafeInteger(n) && n >= 0) || !polygons2.length)
|
|
18538
|
+
throw new RangeError("Invalid terrain cutout polygon limits or empty set");
|
|
18539
|
+
let work = 0, edgeCount = 0;
|
|
18540
|
+
const charge = (amount) => {
|
|
18541
|
+
work += amount;
|
|
18542
|
+
if (work > maxWork)
|
|
18543
|
+
throw new RangeError("Terrain cutout polygon work budget exceeded");
|
|
18544
|
+
};
|
|
18545
|
+
if (polygons2.length > Math.floor(maxEdges / 3))
|
|
18546
|
+
throw new RangeError("Terrain cutout polygon edge budget exceeded");
|
|
18547
|
+
const regions = polygons2.map((p) => {
|
|
18548
|
+
var _a;
|
|
18549
|
+
if (1 + (((_a = p.holes) == null ? void 0 : _a.length) ?? 0) > Math.floor((maxEdges - edgeCount) / 3))
|
|
18550
|
+
throw new RangeError("Terrain cutout polygon edge budget exceeded");
|
|
18551
|
+
return [p.outer, ...p.holes ?? []].map((ring) => {
|
|
18552
|
+
edgeCount += ring.length;
|
|
18553
|
+
if (edgeCount > maxEdges)
|
|
18554
|
+
throw new RangeError("Terrain cutout polygon edge budget exceeded");
|
|
18555
|
+
charge(ring.length);
|
|
18556
|
+
if (ring.length < 3 || ring.some((p2) => p2.length !== 2 || !p2.every(Number.isFinite)))
|
|
18557
|
+
throw new RangeError("Invalid terrain cutout polygon ring");
|
|
18558
|
+
return ring.map((p2) => Object.freeze([p2[0], p2[1]]));
|
|
18559
|
+
});
|
|
18560
|
+
});
|
|
18561
|
+
const rings = regions.flat();
|
|
18562
|
+
for (const ring of rings) {
|
|
18563
|
+
let area = 0;
|
|
18564
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18565
|
+
charge(1);
|
|
18566
|
+
const a = ring[i], b = ring[(i + 1) % ring.length], c = ring[(i + 2) % ring.length];
|
|
18567
|
+
if (equal(a, b))
|
|
18568
|
+
throw new RangeError("Duplicate terrain cutout ring vertex");
|
|
18569
|
+
area += orient2(ring[0], a, b);
|
|
18570
|
+
if (orient2(a, b, c) === 0 && (a[0] - b[0]) * (c[0] - b[0]) + (a[1] - b[1]) * (c[1] - b[1]) >= 0)
|
|
18571
|
+
throw new RangeError("Backtracking terrain cutout ring edge");
|
|
18572
|
+
for (let j = i + 1; j < ring.length; j++) {
|
|
18573
|
+
if (j === i + 1 || i === 0 && j === ring.length - 1)
|
|
18574
|
+
continue;
|
|
18575
|
+
charge(1);
|
|
18576
|
+
if (intersects2(a, b, ring[j], ring[(j + 1) % ring.length]))
|
|
18577
|
+
throw new RangeError("Self-intersecting terrain cutout ring");
|
|
18578
|
+
}
|
|
18579
|
+
}
|
|
18580
|
+
if (!Number.isFinite(area) || area === 0)
|
|
18581
|
+
throw new RangeError("Degenerate terrain cutout ring");
|
|
18582
|
+
}
|
|
18583
|
+
for (let i = 0; i < rings.length; i++)
|
|
18584
|
+
for (let j = i + 1; j < rings.length; j++) {
|
|
18585
|
+
const a = rings[i], b = rings[j];
|
|
18586
|
+
for (let x = 0; x < a.length; x++)
|
|
18587
|
+
for (let y = 0; y < b.length; y++) {
|
|
18588
|
+
charge(1);
|
|
18589
|
+
if (intersects2(a[x], a[(x + 1) % a.length], b[y], b[(y + 1) % b.length]))
|
|
18590
|
+
throw new RangeError("Terrain cutout rings must not touch or intersect");
|
|
18591
|
+
}
|
|
18592
|
+
}
|
|
18593
|
+
for (const region of regions)
|
|
18594
|
+
for (let i = 1; i < region.length; i++) {
|
|
18595
|
+
if (contains2(region[0], region[i][0], charge) !== 1)
|
|
18596
|
+
throw new RangeError("Terrain cutout hole must be strictly inside its outer ring");
|
|
18597
|
+
for (let j = 1; j < i; j++)
|
|
18598
|
+
if (contains2(region[j], region[i][0], charge) === 1 || contains2(region[i], region[j][0], charge) === 1)
|
|
18599
|
+
throw new RangeError("Nested terrain cutout holes are not supported");
|
|
18600
|
+
}
|
|
18601
|
+
function inRegion(region, point2, budget) {
|
|
18602
|
+
const outer = contains2(region[0], point2, budget);
|
|
18603
|
+
if (outer !== 1)
|
|
18604
|
+
return outer;
|
|
18605
|
+
for (let i = 1; i < region.length; i++) {
|
|
18606
|
+
const hole = contains2(region[i], point2, budget);
|
|
18607
|
+
if (hole === 0)
|
|
18608
|
+
return 0;
|
|
18609
|
+
if (hole === 1)
|
|
18610
|
+
return -1;
|
|
18611
|
+
}
|
|
18612
|
+
return 1;
|
|
18613
|
+
}
|
|
18614
|
+
for (let i = 0; i < regions.length; i++)
|
|
18615
|
+
for (let j = i + 1; j < regions.length; j++) {
|
|
18616
|
+
if (inRegion(regions[i], regions[j][0][0], charge) === 1 || inRegion(regions[j], regions[i][0][0], charge) === 1)
|
|
18617
|
+
throw new RangeError("Overlapping terrain cutout polygon domains");
|
|
18618
|
+
}
|
|
18619
|
+
const lines = [];
|
|
18620
|
+
for (const ring of rings)
|
|
18621
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18622
|
+
const a = ring[i], b = ring[(i + 1) % ring.length];
|
|
18623
|
+
if (lines.some(([u, v]) => {
|
|
18624
|
+
charge(1);
|
|
18625
|
+
return orient2(u, v, a) === 0 && orient2(u, v, b) === 0;
|
|
18626
|
+
}))
|
|
18627
|
+
continue;
|
|
18628
|
+
lines.push(a[0] < b[0] || a[0] === b[0] && a[1] < b[1] ? [a, b] : [b, a]);
|
|
18629
|
+
}
|
|
18630
|
+
return createTerrainCutoutPlan({
|
|
18631
|
+
lines: Object.freeze(lines.map((line) => Object.freeze(line))),
|
|
18632
|
+
classify(point2, budget) {
|
|
18633
|
+
for (let i = 0; i < regions.length; i++) {
|
|
18634
|
+
const result = inRegion(regions[i], point2, budget);
|
|
18635
|
+
if (result === 0)
|
|
18636
|
+
throw new RangeError("Unrepresentable terrain cutout fragment interior");
|
|
18637
|
+
if (result === 1)
|
|
18638
|
+
return i;
|
|
18639
|
+
}
|
|
18640
|
+
return -1;
|
|
18641
|
+
}
|
|
18642
|
+
});
|
|
18643
|
+
}
|
|
18644
|
+
function equal(a, b) {
|
|
18645
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
18646
|
+
}
|
|
18647
|
+
function orient2(a, b, c) {
|
|
18648
|
+
const value3 = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
18649
|
+
if (!Number.isFinite(value3))
|
|
18650
|
+
throw new RangeError("Terrain cutout polygon coordinate overflow");
|
|
18651
|
+
return value3;
|
|
18652
|
+
}
|
|
18653
|
+
function onSegment2(a, b, p) {
|
|
18654
|
+
return p[0] >= Math.min(a[0], b[0]) && p[0] <= Math.max(a[0], b[0]) && p[1] >= Math.min(a[1], b[1]) && p[1] <= Math.max(a[1], b[1]);
|
|
18655
|
+
}
|
|
18656
|
+
function intersects2(a, b, c, d) {
|
|
18657
|
+
const abC = orient2(a, b, c), abD = orient2(a, b, d), cdA = orient2(c, d, a), cdB = orient2(c, d, b);
|
|
18658
|
+
return abC === 0 && onSegment2(a, b, c) || abD === 0 && onSegment2(a, b, d) || cdA === 0 && onSegment2(c, d, a) || cdB === 0 && onSegment2(c, d, b) || (abC > 0 && abD < 0 || abC < 0 && abD > 0) && (cdA > 0 && cdB < 0 || cdA < 0 && cdB > 0);
|
|
18659
|
+
}
|
|
18660
|
+
function contains2(ring, p, charge) {
|
|
18661
|
+
let winding3 = 0;
|
|
18662
|
+
for (let i = 0; i < ring.length; i++) {
|
|
18663
|
+
charge(1);
|
|
18664
|
+
const a = ring[i], b = ring[(i + 1) % ring.length], cross7 = orient2(a, b, p);
|
|
18665
|
+
if (cross7 === 0 && onSegment2(a, b, p))
|
|
18666
|
+
return 0;
|
|
18667
|
+
if (a[1] <= p[1] && b[1] > p[1] && cross7 > 0)
|
|
18668
|
+
winding3++;
|
|
18669
|
+
if (a[1] > p[1] && b[1] <= p[1] && cross7 < 0)
|
|
18670
|
+
winding3--;
|
|
18671
|
+
}
|
|
18672
|
+
return winding3 === 0 ? -1 : 1;
|
|
18673
|
+
}
|
|
16718
18674
|
//# sourceMappingURL=index.cjs.map
|