@math.gl/geospatial 5.0.0-beta.4 → 5.0.0-beta.6
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 +192 -2
- package/THIRD-PARTY-NOTICES.md +192 -20
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.d.ts.map +1 -1
- package/dist/index.cjs +6953 -10021
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +40 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/projection/experimental/common/adjust_lat.js +1 -1
- package/dist/projection/experimental/common/adjust_lat.js.map +1 -1
- package/dist/projection/experimental/common/adjust_lon.js +1 -1
- package/dist/projection/experimental/common/adjust_lon.js.map +1 -1
- package/dist/projection/experimental/common/asinhy.js +1 -1
- package/dist/projection/experimental/common/asinhy.js.map +1 -1
- package/dist/projection/experimental/common/asinz.js +1 -1
- package/dist/projection/experimental/common/asinz.js.map +1 -1
- package/dist/projection/experimental/common/authlat.js +1 -1
- package/dist/projection/experimental/common/authlat.js.map +1 -1
- package/dist/projection/experimental/common/authset.js +1 -1
- package/dist/projection/experimental/common/authset.js.map +1 -1
- package/dist/projection/experimental/common/clens.js +1 -1
- package/dist/projection/experimental/common/clens.js.map +1 -1
- package/dist/projection/experimental/common/clens_cmplx.js +1 -1
- package/dist/projection/experimental/common/clens_cmplx.js.map +1 -1
- package/dist/projection/experimental/common/constants.js +1 -1
- package/dist/projection/experimental/common/constants.js.map +1 -1
- package/dist/projection/experimental/common/cosh.js +1 -1
- package/dist/projection/experimental/common/cosh.js.map +1 -1
- package/dist/projection/experimental/common/e0fn.js +1 -1
- package/dist/projection/experimental/common/e0fn.js.map +1 -1
- package/dist/projection/experimental/common/e1fn.js +1 -1
- package/dist/projection/experimental/common/e1fn.js.map +1 -1
- package/dist/projection/experimental/common/e2fn.js +1 -1
- package/dist/projection/experimental/common/e2fn.js.map +1 -1
- package/dist/projection/experimental/common/e3fn.js +1 -1
- package/dist/projection/experimental/common/e3fn.js.map +1 -1
- package/dist/projection/experimental/common/fL.js +1 -1
- package/dist/projection/experimental/common/fL.js.map +1 -1
- package/dist/projection/experimental/common/gN.js +1 -1
- package/dist/projection/experimental/common/gN.js.map +1 -1
- package/dist/projection/experimental/common/gatg.js +1 -1
- package/dist/projection/experimental/common/gatg.js.map +1 -1
- package/dist/projection/experimental/common/hypot.js +1 -1
- package/dist/projection/experimental/common/hypot.js.map +1 -1
- package/dist/projection/experimental/common/imlfn.js +1 -1
- package/dist/projection/experimental/common/imlfn.js.map +1 -1
- package/dist/projection/experimental/common/invlatiso.js +1 -1
- package/dist/projection/experimental/common/invlatiso.js.map +1 -1
- package/dist/projection/experimental/common/iqsfnz.js +1 -1
- package/dist/projection/experimental/common/iqsfnz.js.map +1 -1
- package/dist/projection/experimental/common/latiso.js +1 -1
- package/dist/projection/experimental/common/latiso.js.map +1 -1
- package/dist/projection/experimental/common/log1py.js +1 -1
- package/dist/projection/experimental/common/log1py.js.map +1 -1
- package/dist/projection/experimental/common/mlfn.js +1 -1
- package/dist/projection/experimental/common/mlfn.js.map +1 -1
- package/dist/projection/experimental/common/msfnz.js +1 -1
- package/dist/projection/experimental/common/msfnz.js.map +1 -1
- package/dist/projection/experimental/common/phi2z.js +1 -1
- package/dist/projection/experimental/common/phi2z.js.map +1 -1
- package/dist/projection/experimental/common/pj_enfn.js +1 -1
- package/dist/projection/experimental/common/pj_enfn.js.map +1 -1
- package/dist/projection/experimental/common/pj_inv_mlfn.js +1 -1
- package/dist/projection/experimental/common/pj_inv_mlfn.js.map +1 -1
- package/dist/projection/experimental/common/pj_mlfn.js +1 -1
- package/dist/projection/experimental/common/pj_mlfn.js.map +1 -1
- package/dist/projection/experimental/common/qsfnz.js +1 -1
- package/dist/projection/experimental/common/qsfnz.js.map +1 -1
- package/dist/projection/experimental/common/sign.js +1 -1
- package/dist/projection/experimental/common/sign.js.map +1 -1
- package/dist/projection/experimental/common/sinh.js +1 -1
- package/dist/projection/experimental/common/sinh.js.map +1 -1
- package/dist/projection/experimental/common/srat.js +1 -1
- package/dist/projection/experimental/common/srat.js.map +1 -1
- package/dist/projection/experimental/common/tsfnz.js +1 -1
- package/dist/projection/experimental/common/tsfnz.js.map +1 -1
- package/dist/projection/experimental/common/vincenty.js +1 -1
- package/dist/projection/experimental/common/vincenty.js.map +1 -1
- package/dist/projection/experimental/core.cjs +100 -2
- package/dist/projection/experimental/core.cjs.map +2 -2
- package/dist/projection/experimental/core.d.ts +1 -0
- package/dist/projection/experimental/core.d.ts.map +1 -1
- package/dist/projection/experimental/crs/datum-table.js +1 -1
- package/dist/projection/experimental/crs/datum-table.js.map +1 -1
- package/dist/projection/experimental/crs/ellipsoid-table.js +1 -1
- package/dist/projection/experimental/crs/ellipsoid-table.js.map +1 -1
- package/dist/projection/experimental/crs/primemeridian-table.js +1 -1
- package/dist/projection/experimental/crs/primemeridian-table.js.map +1 -1
- package/dist/projection/experimental/crs/structured.js +1 -1
- package/dist/projection/experimental/crs/structured.js.map +1 -1
- package/dist/projection/experimental/crs/wkt.js +1 -1
- package/dist/projection/experimental/crs/wkt.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/ellipsoidal-gnomonic.js +1 -1
- package/dist/projection/experimental/ellipsoidal-gnomonic.js.map +1 -1
- package/dist/projection/experimental/entries/projections/eqc.cjs +1 -0
- package/dist/projection/experimental/entries/projections/eqc.cjs.map +1 -1
- package/dist/projection/experimental/entries/projections/merc.cjs +1 -0
- package/dist/projection/experimental/entries/projections/merc.cjs.map +1 -1
- package/dist/projection/experimental/grids/geotiff.js +1 -1
- package/dist/projection/experimental/grids/geotiff.js.map +1 -1
- package/dist/projection/experimental/grids/ntv2.js +1 -1
- package/dist/projection/experimental/grids/ntv2.js.map +1 -1
- package/dist/projection/experimental/index.cjs +102 -2
- package/dist/projection/experimental/index.cjs.map +3 -3
- package/dist/projection/experimental/kernels/aea.js +1 -1
- package/dist/projection/experimental/kernels/aea.js.map +1 -1
- package/dist/projection/experimental/kernels/aeqd.js +1 -1
- package/dist/projection/experimental/kernels/aeqd.js.map +1 -1
- package/dist/projection/experimental/kernels/bonne.js +1 -1
- package/dist/projection/experimental/kernels/bonne.js.map +1 -1
- package/dist/projection/experimental/kernels/cass.js +1 -1
- package/dist/projection/experimental/kernels/cass.js.map +1 -1
- package/dist/projection/experimental/kernels/cea.js +1 -1
- package/dist/projection/experimental/kernels/cea.js.map +1 -1
- package/dist/projection/experimental/kernels/eck6.js +1 -1
- package/dist/projection/experimental/kernels/eck6.js.map +1 -1
- package/dist/projection/experimental/kernels/eqdc.js +1 -1
- package/dist/projection/experimental/kernels/eqdc.js.map +1 -1
- package/dist/projection/experimental/kernels/eqearth.js +1 -1
- package/dist/projection/experimental/kernels/eqearth.js.map +1 -1
- package/dist/projection/experimental/kernels/equi.js +1 -1
- package/dist/projection/experimental/kernels/equi.js.map +1 -1
- package/dist/projection/experimental/kernels/etmerc.js +1 -1
- package/dist/projection/experimental/kernels/etmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/gauss.js +1 -1
- package/dist/projection/experimental/kernels/gauss.js.map +1 -1
- package/dist/projection/experimental/kernels/geos.js +1 -1
- package/dist/projection/experimental/kernels/geos.js.map +1 -1
- package/dist/projection/experimental/kernels/gnom.js +1 -1
- package/dist/projection/experimental/kernels/gnom.js.map +1 -1
- package/dist/projection/experimental/kernels/gstmerc.js +1 -1
- package/dist/projection/experimental/kernels/gstmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/krovak.js +1 -1
- package/dist/projection/experimental/kernels/krovak.js.map +1 -1
- package/dist/projection/experimental/kernels/laea.js +1 -1
- package/dist/projection/experimental/kernels/laea.js.map +1 -1
- package/dist/projection/experimental/kernels/lcc.js +1 -1
- package/dist/projection/experimental/kernels/lcc.js.map +1 -1
- package/dist/projection/experimental/kernels/mill.js +1 -1
- package/dist/projection/experimental/kernels/mill.js.map +1 -1
- package/dist/projection/experimental/kernels/moll.js +1 -1
- package/dist/projection/experimental/kernels/moll.js.map +1 -1
- package/dist/projection/experimental/kernels/nzmg.js +1 -1
- package/dist/projection/experimental/kernels/nzmg.js.map +1 -1
- package/dist/projection/experimental/kernels/omerc.js +1 -1
- package/dist/projection/experimental/kernels/omerc.js.map +1 -1
- package/dist/projection/experimental/kernels/poly.js +1 -1
- package/dist/projection/experimental/kernels/poly.js.map +1 -1
- package/dist/projection/experimental/kernels/qsc.js +1 -1
- package/dist/projection/experimental/kernels/qsc.js.map +1 -1
- package/dist/projection/experimental/kernels/robin.js +1 -1
- package/dist/projection/experimental/kernels/robin.js.map +1 -1
- package/dist/projection/experimental/kernels/sinu.js +1 -1
- package/dist/projection/experimental/kernels/sinu.js.map +1 -1
- package/dist/projection/experimental/kernels/somerc.js +1 -1
- package/dist/projection/experimental/kernels/somerc.js.map +1 -1
- package/dist/projection/experimental/kernels/stere.js +1 -1
- package/dist/projection/experimental/kernels/stere.js.map +1 -1
- package/dist/projection/experimental/kernels/sterea.js +1 -1
- package/dist/projection/experimental/kernels/sterea.js.map +1 -1
- package/dist/projection/experimental/kernels/tmerc.js +1 -1
- package/dist/projection/experimental/kernels/tmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/tpers.js +1 -1
- package/dist/projection/experimental/kernels/tpers.js.map +1 -1
- package/dist/projection/experimental/kernels/vandg.js +1 -1
- package/dist/projection/experimental/kernels/vandg.js.map +1 -1
- package/dist/projection/experimental/kinematic-helmert.js +1 -1
- package/dist/projection/experimental/kinematic-helmert.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +100 -2
- package/dist/projection/experimental/lazy-projections/index.cjs.map +2 -2
- package/dist/projection/experimental/projections/equidistant-cylindrical.d.ts.map +1 -1
- package/dist/projection/experimental/projections/equidistant-cylindrical.js +1 -0
- package/dist/projection/experimental/projections/equidistant-cylindrical.js.map +1 -1
- package/dist/projection/experimental/projections/mercator.d.ts.map +1 -1
- package/dist/projection/experimental/projections/mercator.js +1 -0
- package/dist/projection/experimental/projections/mercator.js.map +1 -1
- package/dist/projection/experimental/transform-description.d.ts +8 -0
- package/dist/projection/experimental/transform-description.d.ts.map +1 -0
- package/dist/projection/experimental/transform-description.js +57 -0
- package/dist/projection/experimental/transform-description.js.map +1 -0
- package/dist/projection/experimental/types.d.ts +5 -0
- package/dist/projection/experimental/types.d.ts.map +1 -1
- package/dist/projection/experimental/typescript-projection.d.ts +4 -0
- package/dist/projection/experimental/typescript-projection.d.ts.map +1 -1
- package/dist/projection/experimental/typescript-projection.js +54 -5
- package/dist/projection/experimental/typescript-projection.js.map +1 -1
- package/dist/projection/index.cjs +102 -2
- package/dist/projection/index.cjs.map +3 -3
- package/dist/projection/transform-analysis.cjs +100 -2
- package/dist/projection/transform-analysis.cjs.map +2 -2
- package/dist/projection/transform-description.d.ts +44 -0
- package/dist/projection/transform-description.d.ts.map +1 -0
- package/dist/projection/transform-description.js +5 -0
- package/dist/projection/transform-description.js.map +1 -0
- package/dist/projection/types.d.ts +4 -0
- package/dist/projection/types.d.ts.map +1 -1
- package/dist/tasks/definitions.d.ts +3 -3
- package/dist/tasks/index.cjs +107 -2
- package/dist/tasks/index.cjs.map +3 -3
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/map-worker.js +1 -1
- package/dist/tasks/map-worker.js.map +1 -1
- package/dist/tasks/operations.d.ts +1 -1
- package/dist/tasks/operations.d.ts.map +1 -1
- package/dist/tasks/projection-worker.js +1 -1
- package/dist/tasks/projection-worker.js.map +1 -1
- package/dist/terrain/bounds-regions.d.ts +15 -0
- package/dist/terrain/bounds-regions.d.ts.map +1 -0
- package/dist/terrain/bounds-regions.js +84 -0
- package/dist/terrain/bounds-regions.js.map +1 -0
- package/dist/terrain/bounds-update.d.ts +11 -0
- package/dist/terrain/bounds-update.d.ts.map +1 -0
- package/dist/terrain/bounds-update.js +10 -0
- package/dist/terrain/bounds-update.js.map +1 -0
- package/dist/terrain/box-index.d.ts +9 -0
- package/dist/terrain/box-index.d.ts.map +1 -0
- package/dist/terrain/box-index.js +43 -0
- package/dist/terrain/box-index.js.map +1 -0
- package/dist/terrain/contour-mixed-weld.d.ts +25 -0
- package/dist/terrain/contour-mixed-weld.d.ts.map +1 -0
- package/dist/terrain/contour-mixed-weld.js +194 -0
- package/dist/terrain/contour-mixed-weld.js.map +1 -0
- package/dist/terrain/contour-simplify.d.ts +1 -0
- package/dist/terrain/contour-simplify.d.ts.map +1 -1
- package/dist/terrain/contour-simplify.js +5 -1
- package/dist/terrain/contour-simplify.js.map +1 -1
- package/dist/terrain/contour-topology.d.ts +30 -0
- package/dist/terrain/contour-topology.d.ts.map +1 -0
- package/dist/terrain/contour-topology.js +236 -0
- package/dist/terrain/contour-topology.js.map +1 -0
- package/dist/terrain/delatin-regions.d.ts +14 -0
- package/dist/terrain/delatin-regions.d.ts.map +1 -0
- package/dist/terrain/delatin-regions.js +15 -0
- package/dist/terrain/delatin-regions.js.map +1 -0
- package/dist/terrain/dirty-regions.d.ts +11 -0
- package/dist/terrain/dirty-regions.d.ts.map +1 -0
- package/dist/terrain/dirty-regions.js +34 -0
- package/dist/terrain/dirty-regions.js.map +1 -0
- package/dist/terrain/gradient-pyramid-regions.d.ts +15 -0
- package/dist/terrain/gradient-pyramid-regions.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid-regions.js +112 -0
- package/dist/terrain/gradient-pyramid-regions.js.map +1 -0
- package/dist/terrain/gradient-pyramid-update.d.ts +11 -0
- package/dist/terrain/gradient-pyramid-update.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid-update.js +17 -0
- package/dist/terrain/gradient-pyramid-update.js.map +1 -0
- package/dist/terrain/height-field.d.ts.map +1 -1
- package/dist/terrain/height-field.js +48 -5
- package/dist/terrain/height-field.js.map +1 -1
- package/dist/terrain/index.cjs +1613 -79
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +40 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +20 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/isobands.d.ts +24 -0
- package/dist/terrain/isobands.d.ts.map +1 -0
- package/dist/terrain/isobands.js +281 -0
- package/dist/terrain/isobands.js.map +1 -0
- package/dist/terrain/lod-morph-evaluate.d.ts +8 -0
- package/dist/terrain/lod-morph-evaluate.d.ts.map +1 -0
- package/dist/terrain/lod-morph-evaluate.js +30 -0
- package/dist/terrain/lod-morph-evaluate.js.map +1 -0
- package/dist/terrain/lod-morph.d.ts +35 -0
- package/dist/terrain/lod-morph.d.ts.map +1 -0
- package/dist/terrain/lod-morph.js +87 -0
- package/dist/terrain/lod-morph.js.map +1 -0
- package/dist/terrain/martini-regions.d.ts +14 -0
- package/dist/terrain/martini-regions.d.ts.map +1 -0
- package/dist/terrain/martini-regions.js +26 -0
- package/dist/terrain/martini-regions.js.map +1 -0
- package/dist/terrain/mesh-error.d.ts.map +1 -1
- package/dist/terrain/mesh-error.js +9 -1
- package/dist/terrain/mesh-error.js.map +1 -1
- package/dist/terrain/mesh-regions-data.d.ts +24 -0
- package/dist/terrain/mesh-regions-data.d.ts.map +1 -0
- package/dist/terrain/mesh-regions-data.js +80 -0
- package/dist/terrain/mesh-regions-data.js.map +1 -0
- package/dist/terrain/mesh-regions.d.ts +12 -0
- package/dist/terrain/mesh-regions.d.ts.map +1 -0
- package/dist/terrain/mesh-regions.js +10 -0
- package/dist/terrain/mesh-regions.js.map +1 -0
- package/dist/terrain/mesh-update.d.ts +11 -0
- package/dist/terrain/mesh-update.d.ts.map +1 -0
- package/dist/terrain/mesh-update.js +10 -0
- package/dist/terrain/mesh-update.js.map +1 -0
- package/dist/terrain/mixed-gradient-update.d.ts +15 -0
- package/dist/terrain/mixed-gradient-update.d.ts.map +1 -0
- package/dist/terrain/mixed-gradient-update.js +24 -0
- package/dist/terrain/mixed-gradient-update.js.map +1 -0
- package/dist/terrain/mixed-halo-update.d.ts +16 -0
- package/dist/terrain/mixed-halo-update.d.ts.map +1 -0
- package/dist/terrain/mixed-halo-update.js +46 -0
- package/dist/terrain/mixed-halo-update.js.map +1 -0
- package/dist/terrain/mixed-vertex-halos.d.ts +32 -0
- package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -0
- package/dist/terrain/mixed-vertex-halos.js +125 -0
- package/dist/terrain/mixed-vertex-halos.js.map +1 -0
- package/dist/terrain/persistent-bounds.d.ts +16 -0
- package/dist/terrain/persistent-bounds.d.ts.map +1 -0
- package/dist/terrain/persistent-bounds.js +51 -0
- package/dist/terrain/persistent-bounds.js.map +1 -0
- package/dist/terrain/persistent-gradients.d.ts +16 -0
- package/dist/terrain/persistent-gradients.d.ts.map +1 -0
- package/dist/terrain/persistent-gradients.js +69 -0
- package/dist/terrain/persistent-gradients.js.map +1 -0
- package/dist/terrain/persistent-hierarchy-data.d.ts +41 -0
- package/dist/terrain/persistent-hierarchy-data.d.ts.map +1 -0
- package/dist/terrain/persistent-hierarchy-data.js +130 -0
- package/dist/terrain/persistent-hierarchy-data.js.map +1 -0
- package/dist/terrain/sample-triangle-height.d.ts +4 -0
- package/dist/terrain/sample-triangle-height.d.ts.map +1 -0
- package/dist/terrain/sample-triangle-height.js +46 -0
- package/dist/terrain/sample-triangle-height.js.map +1 -0
- package/dist/terrain/tile-update-data.d.ts +14 -0
- package/dist/terrain/tile-update-data.d.ts.map +1 -0
- package/dist/terrain/tile-update-data.js +23 -0
- package/dist/terrain/tile-update-data.js.map +1 -0
- package/dist/terrain/tiled.d.ts +10 -2
- package/dist/terrain/tiled.d.ts.map +1 -1
- package/dist/terrain/tiled.js +5 -1
- package/dist/terrain/tiled.js.map +1 -1
- package/dist/terrain/types.d.ts +6 -0
- package/dist/terrain/types.d.ts.map +1 -1
- package/dist/turf.cjs +25 -671
- package/dist/turf.cjs.map +3 -3
- 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/package.json +15 -19
- package/src/expressions.ts +1 -1
- package/src/index.ts +64 -123
- package/src/projection/experimental/common/adjust_lat.ts +1 -1
- package/src/projection/experimental/common/adjust_lon.ts +1 -1
- package/src/projection/experimental/common/asinhy.ts +1 -1
- package/src/projection/experimental/common/asinz.ts +1 -1
- package/src/projection/experimental/common/authlat.ts +1 -1
- package/src/projection/experimental/common/authset.ts +1 -1
- package/src/projection/experimental/common/clens.ts +1 -1
- package/src/projection/experimental/common/clens_cmplx.ts +1 -1
- package/src/projection/experimental/common/constants.ts +1 -1
- package/src/projection/experimental/common/cosh.ts +1 -1
- package/src/projection/experimental/common/e0fn.ts +1 -1
- package/src/projection/experimental/common/e1fn.ts +1 -1
- package/src/projection/experimental/common/e2fn.ts +1 -1
- package/src/projection/experimental/common/e3fn.ts +1 -1
- package/src/projection/experimental/common/fL.ts +1 -1
- package/src/projection/experimental/common/gN.ts +1 -1
- package/src/projection/experimental/common/gatg.ts +1 -1
- package/src/projection/experimental/common/hypot.ts +1 -1
- package/src/projection/experimental/common/imlfn.ts +1 -1
- package/src/projection/experimental/common/invlatiso.ts +1 -1
- package/src/projection/experimental/common/iqsfnz.ts +1 -1
- package/src/projection/experimental/common/latiso.ts +1 -1
- package/src/projection/experimental/common/log1py.ts +1 -1
- package/src/projection/experimental/common/mlfn.ts +1 -1
- package/src/projection/experimental/common/msfnz.ts +1 -1
- package/src/projection/experimental/common/phi2z.ts +1 -1
- package/src/projection/experimental/common/pj_enfn.ts +1 -1
- package/src/projection/experimental/common/pj_inv_mlfn.ts +1 -1
- package/src/projection/experimental/common/pj_mlfn.ts +1 -1
- package/src/projection/experimental/common/qsfnz.ts +1 -1
- package/src/projection/experimental/common/sign.ts +1 -1
- package/src/projection/experimental/common/sinh.ts +1 -1
- package/src/projection/experimental/common/srat.ts +1 -1
- package/src/projection/experimental/common/tsfnz.ts +1 -1
- package/src/projection/experimental/common/vincenty.ts +1 -1
- package/src/projection/experimental/core.ts +8 -0
- package/src/projection/experimental/crs/datum-table.ts +1 -1
- package/src/projection/experimental/crs/ellipsoid-table.ts +1 -1
- package/src/projection/experimental/crs/primemeridian-table.ts +1 -1
- package/src/projection/experimental/crs/structured.ts +1 -1
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/datum.ts +1 -1
- package/src/projection/experimental/ellipsoidal-gnomonic.ts +1 -1
- package/src/projection/experimental/exact-helmert.ts +1 -1
- package/src/projection/experimental/grids/geotiff.ts +1 -1
- package/src/projection/experimental/grids/grid.ts +1 -1
- package/src/projection/experimental/grids/ntv2.ts +1 -1
- package/src/projection/experimental/helmert-flat.ts +1 -1
- package/src/projection/experimental/kernels/aea.ts +1 -1
- package/src/projection/experimental/kernels/aeqd.ts +1 -1
- package/src/projection/experimental/kernels/bonne.ts +1 -1
- package/src/projection/experimental/kernels/cass.ts +1 -1
- package/src/projection/experimental/kernels/cea.ts +1 -1
- package/src/projection/experimental/kernels/eck6.ts +1 -1
- package/src/projection/experimental/kernels/eqdc.ts +1 -1
- package/src/projection/experimental/kernels/eqearth.ts +1 -1
- package/src/projection/experimental/kernels/equi.ts +1 -1
- package/src/projection/experimental/kernels/etmerc.ts +1 -1
- package/src/projection/experimental/kernels/gauss.ts +1 -1
- package/src/projection/experimental/kernels/geos.ts +1 -1
- package/src/projection/experimental/kernels/gnom.ts +1 -1
- package/src/projection/experimental/kernels/gstmerc.ts +1 -1
- package/src/projection/experimental/kernels/krovak.ts +1 -1
- package/src/projection/experimental/kernels/laea.ts +1 -1
- package/src/projection/experimental/kernels/lcc.ts +1 -1
- package/src/projection/experimental/kernels/mill.ts +1 -1
- package/src/projection/experimental/kernels/moll.ts +1 -1
- package/src/projection/experimental/kernels/nzmg.ts +1 -1
- package/src/projection/experimental/kernels/omerc.ts +1 -1
- package/src/projection/experimental/kernels/ortho.ts +1 -1
- package/src/projection/experimental/kernels/poly.ts +1 -1
- package/src/projection/experimental/kernels/qsc.ts +1 -1
- package/src/projection/experimental/kernels/robin.ts +1 -1
- package/src/projection/experimental/kernels/sinu.ts +1 -1
- package/src/projection/experimental/kernels/somerc.ts +1 -1
- package/src/projection/experimental/kernels/stere.ts +1 -1
- package/src/projection/experimental/kernels/sterea.ts +1 -1
- package/src/projection/experimental/kernels/tmerc.ts +1 -1
- package/src/projection/experimental/kernels/tpers.ts +1 -1
- package/src/projection/experimental/kernels/vandg.ts +1 -1
- package/src/projection/experimental/kinematic-helmert-flat.ts +1 -1
- package/src/projection/experimental/kinematic-helmert.ts +1 -1
- package/src/projection/experimental/projection-pipeline.ts +1 -1
- package/src/projection/experimental/projections/equidistant-cylindrical.ts +1 -0
- package/src/projection/experimental/projections/mercator.ts +1 -0
- package/src/projection/experimental/projections/ob-tran.ts +1 -1
- package/src/projection/experimental/transform-description.ts +82 -0
- package/src/projection/experimental/types.ts +5 -0
- package/src/projection/experimental/typescript-projection.ts +54 -6
- package/src/projection/transform-description.ts +69 -0
- package/src/projection/types.ts +11 -0
- package/src/tasks/definitions.ts +1 -1
- package/src/tasks/index.ts +1 -1
- package/src/tasks/map-worker.ts +1 -1
- package/src/tasks/operations.ts +1 -1
- package/src/tasks/projection-worker.ts +1 -1
- package/src/terrain/bounds-regions.ts +106 -0
- package/src/terrain/bounds-update.ts +19 -0
- package/src/terrain/box-index.ts +47 -0
- package/src/terrain/contour-mixed-weld.ts +254 -0
- package/src/terrain/contour-simplify.ts +10 -2
- package/src/terrain/contour-topology.ts +263 -0
- package/src/terrain/delatin-regions.ts +25 -0
- package/src/terrain/dirty-regions.ts +61 -0
- package/src/terrain/gradient-pyramid-regions.ts +140 -0
- package/src/terrain/gradient-pyramid-update.ts +25 -0
- package/src/terrain/height-field.ts +45 -5
- package/src/terrain/index.ts +58 -0
- package/src/terrain/isobands.ts +348 -0
- package/src/terrain/lod-morph-evaluate.ts +36 -0
- package/src/terrain/lod-morph.ts +138 -0
- package/src/terrain/martini-regions.ts +38 -0
- package/src/terrain/mesh-error.ts +14 -1
- package/src/terrain/mesh-regions-data.ts +113 -0
- package/src/terrain/mesh-regions.ts +18 -0
- package/src/terrain/mesh-update.ts +15 -0
- package/src/terrain/mixed-gradient-update.ts +40 -0
- package/src/terrain/mixed-halo-update.ts +56 -0
- package/src/terrain/mixed-vertex-halos.ts +170 -0
- package/src/terrain/persistent-bounds.ts +95 -0
- package/src/terrain/persistent-gradients.ts +117 -0
- package/src/terrain/persistent-hierarchy-data.ts +196 -0
- package/src/terrain/sample-triangle-height.ts +50 -0
- package/src/terrain/tile-update-data.ts +32 -0
- package/src/terrain/tiled.ts +16 -3
- package/src/terrain/types.ts +9 -1
- package/src/turf.ts +7 -3
- package/crs/README.md +0 -84
- package/crs/schemas/README.md +0 -9
- package/dist/geoarrow/builder-entry.d.ts +0 -4
- package/dist/geoarrow/builder-entry.d.ts.map +0 -1
- package/dist/geoarrow/builder-entry.js +0 -5
- package/dist/geoarrow/builder-entry.js.map +0 -1
- package/dist/geoarrow/builder.d.ts +0 -106
- package/dist/geoarrow/builder.d.ts.map +0 -1
- package/dist/geoarrow/builder.js +0 -668
- package/dist/geoarrow/builder.js.map +0 -1
- package/dist/geoarrow/codecs.d.ts +0 -24
- package/dist/geoarrow/codecs.d.ts.map +0 -1
- package/dist/geoarrow/codecs.js +0 -916
- package/dist/geoarrow/codecs.js.map +0 -1
- package/dist/geoarrow/index.cjs +0 -4352
- package/dist/geoarrow/index.cjs.map +0 -6
- package/dist/geoarrow/index.d.ts +0 -21
- package/dist/geoarrow/index.d.ts.map +0 -1
- package/dist/geoarrow/index.js +0 -15
- package/dist/geoarrow/index.js.map +0 -1
- package/dist/geoarrow/kernels.d.ts +0 -56
- package/dist/geoarrow/kernels.d.ts.map +0 -1
- package/dist/geoarrow/kernels.js +0 -982
- package/dist/geoarrow/kernels.js.map +0 -1
- package/dist/geoarrow/layout.d.ts +0 -66
- package/dist/geoarrow/layout.d.ts.map +0 -1
- package/dist/geoarrow/layout.js +0 -723
- package/dist/geoarrow/layout.js.map +0 -1
- package/dist/geoarrow/stream-tessellate.d.ts +0 -34
- package/dist/geoarrow/stream-tessellate.d.ts.map +0 -1
- package/dist/geoarrow/stream-tessellate.js +0 -171
- package/dist/geoarrow/stream-tessellate.js.map +0 -1
- package/dist/geoarrow/stream.d.ts +0 -29
- package/dist/geoarrow/stream.d.ts.map +0 -1
- package/dist/geoarrow/stream.js +0 -100
- package/dist/geoarrow/stream.js.map +0 -1
- package/dist/geoarrow/tessellate.d.ts +0 -31
- package/dist/geoarrow/tessellate.d.ts.map +0 -1
- package/dist/geoarrow/tessellate.js +0 -102
- package/dist/geoarrow/tessellate.js.map +0 -1
- package/dist/geoarrow/tessellation-entry.d.ts +0 -4
- package/dist/geoarrow/tessellation-entry.d.ts.map +0 -1
- package/dist/geoarrow/tessellation-entry.js +0 -5
- package/dist/geoarrow/tessellation-entry.js.map +0 -1
- package/dist/geoarrow/types.d.ts +0 -155
- package/dist/geoarrow/types.d.ts.map +0 -1
- package/dist/geoarrow/types.js +0 -71
- package/dist/geoarrow/types.js.map +0 -1
- package/dist/geoarrow/views.d.ts +0 -45
- package/dist/geoarrow/views.d.ts.map +0 -1
- package/dist/geoarrow/views.js +0 -114
- package/dist/geoarrow/views.js.map +0 -1
- package/dist/geoarrow/wkb-entry.d.ts +0 -4
- package/dist/geoarrow/wkb-entry.d.ts.map +0 -1
- package/dist/geoarrow/wkb-entry.js +0 -6
- package/dist/geoarrow/wkb-entry.js.map +0 -1
- package/dist/geoarrow/worker.d.ts +0 -11
- package/dist/geoarrow/worker.d.ts.map +0 -1
- package/dist/geoarrow/worker.js +0 -10
- package/dist/geoarrow/worker.js.map +0 -1
- package/dist/wkb/index.d.ts +0 -11
- package/dist/wkb/index.d.ts.map +0 -1
- package/dist/wkb/index.js +0 -9
- package/dist/wkb/index.js.map +0 -1
- package/dist/wkb/types.d.ts +0 -30
- package/dist/wkb/types.d.ts.map +0 -1
- package/dist/wkb/types.js +0 -34
- package/dist/wkb/types.js.map +0 -1
- package/dist/wkb/wkb-builder.d.ts +0 -91
- package/dist/wkb/wkb-builder.d.ts.map +0 -1
- package/dist/wkb/wkb-builder.js +0 -283
- package/dist/wkb/wkb-builder.js.map +0 -1
- package/dist/wkb/wkb-reader.d.ts +0 -74
- package/dist/wkb/wkb-reader.d.ts.map +0 -1
- package/dist/wkb/wkb-reader.js +0 -251
- package/dist/wkb/wkb-reader.js.map +0 -1
- package/dist/wkb/wkb.d.ts +0 -21
- package/dist/wkb/wkb.d.ts.map +0 -1
- package/dist/wkb/wkb.js +0 -204
- package/dist/wkb/wkb.js.map +0 -1
- package/dist/wkb/wkt.d.ts +0 -19
- package/dist/wkb/wkt.d.ts.map +0 -1
- package/dist/wkb/wkt.js +0 -321
- package/dist/wkb/wkt.js.map +0 -1
- package/projection/THIRD-PARTY-NOTICES.md +0 -210
- package/src/discontinuous/elastic/README.md +0 -20
- package/src/discontinuous/spherical-clip/README.md +0 -16
- package/src/discontinuous/world-kernels/README.md +0 -24
- package/src/geoarrow/builder-entry.ts +0 -18
- package/src/geoarrow/builder.ts +0 -860
- package/src/geoarrow/codecs.ts +0 -1268
- package/src/geoarrow/index.ts +0 -111
- package/src/geoarrow/kernels.ts +0 -1290
- package/src/geoarrow/layout.ts +0 -900
- package/src/geoarrow/stream-tessellate.ts +0 -205
- package/src/geoarrow/stream.ts +0 -130
- package/src/geoarrow/tessellate.ts +0 -133
- package/src/geoarrow/tessellation-entry.ts +0 -7
- package/src/geoarrow/types.ts +0 -259
- package/src/geoarrow/views.ts +0 -150
- package/src/geoarrow/wkb-entry.ts +0 -13
- package/src/geoarrow/worker.ts +0 -20
- package/src/terrain/vendor/README.md +0 -20
- package/src/vendor/geographiclib-geodesic/README.md +0 -26
- package/src/wkb/index.ts +0 -38
- package/src/wkb/types.ts +0 -54
- package/src/wkb/wkb-builder.ts +0 -395
- package/src/wkb/wkb-reader.ts +0 -401
- package/src/wkb/wkb.ts +0 -255
- package/src/wkb/wkt.ts +0 -375
- /package/{projection/APACHE-2.0-LICENSE.txt → APACHE-2.0-LICENSE.txt} +0 -0
- /package/{projection/PROJ-LICENSE.txt → PROJ-LICENSE.txt} +0 -0
- /package/{projection/PROJ4-LICENSE.md → PROJ4-LICENSE.md} +0 -0
- /package/{crs/schemas → src/crs}/projjson.schema.json +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {TerrainContours} from './contours';
|
|
6
|
+
import {
|
|
7
|
+
contourPathLimits,
|
|
8
|
+
validateContourData,
|
|
9
|
+
validateContourVertex,
|
|
10
|
+
type TerrainContourPathLimits
|
|
11
|
+
} from './contour-path-data';
|
|
12
|
+
|
|
13
|
+
export type TerrainMixedContourTile = {
|
|
14
|
+
contours: TerrainContours;
|
|
15
|
+
/** Tile minimum in the common finest lattice; integer coordinates. */
|
|
16
|
+
column: number;
|
|
17
|
+
row: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
/** Positive power-of-two spacing in the common lattice. */
|
|
21
|
+
spacing: number;
|
|
22
|
+
};
|
|
23
|
+
export type TerrainMixedContourWeldOptions = TerrainContourPathLimits & {
|
|
24
|
+
maxTiles?: number;
|
|
25
|
+
maxBoundaryTests?: number;
|
|
26
|
+
maxPositionDifference?: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Weld contour graphs from nonoverlapping vertex tiles in a shared affine lattice.
|
|
30
|
+
* Subdivides coincident axis-aligned boundary segments at finer boundary vertices.
|
|
31
|
+
* Only exact lattice intersections at the same level are joined. Differing source
|
|
32
|
+
* surfaces remain open; callers must reconcile elevations before contouring.
|
|
33
|
+
* Coordinates must retain their fractional precision in the common lattice.
|
|
34
|
+
*/
|
|
35
|
+
export function weldTerrainMixedContourTiles(
|
|
36
|
+
tiles: readonly TerrainMixedContourTile[],
|
|
37
|
+
options: TerrainMixedContourWeldOptions = {}
|
|
38
|
+
): TerrainContours {
|
|
39
|
+
const limits = contourPathLimits(options);
|
|
40
|
+
const maxTiles = options.maxTiles ?? 4096;
|
|
41
|
+
const budget = options.maxBoundaryTests ?? 10_000_000;
|
|
42
|
+
const tolerance = options.maxPositionDifference ?? 0;
|
|
43
|
+
if (
|
|
44
|
+
!Number.isSafeInteger(maxTiles) ||
|
|
45
|
+
maxTiles < 1 ||
|
|
46
|
+
!tiles.length ||
|
|
47
|
+
tiles.length > maxTiles ||
|
|
48
|
+
!Number.isSafeInteger(budget) ||
|
|
49
|
+
budget < 0 ||
|
|
50
|
+
!Number.isFinite(tolerance) ||
|
|
51
|
+
tolerance < 0
|
|
52
|
+
)
|
|
53
|
+
throw new Error('Invalid mixed contour capacity or tolerance');
|
|
54
|
+
let tests = 0;
|
|
55
|
+
const charge = () => {
|
|
56
|
+
if (++tests > budget) throw new Error('Mixed contour boundary-test budget exceeded');
|
|
57
|
+
};
|
|
58
|
+
const sorted = [...tiles].sort(
|
|
59
|
+
(a, b) => a.column - b.column || a.row - b.row || a.spacing - b.spacing
|
|
60
|
+
);
|
|
61
|
+
const bounds = sorted.map(t => {
|
|
62
|
+
if (
|
|
63
|
+
![t.column, t.row, t.width, t.height, t.spacing].every(Number.isSafeInteger) ||
|
|
64
|
+
t.width < 2 ||
|
|
65
|
+
t.height < 2 ||
|
|
66
|
+
t.spacing < 1 ||
|
|
67
|
+
2 ** Math.round(Math.log2(t.spacing)) !== t.spacing
|
|
68
|
+
)
|
|
69
|
+
throw new Error('Invalid mixed contour tile lattice');
|
|
70
|
+
const x1 = t.column + (t.width - 1) * t.spacing,
|
|
71
|
+
y1 = t.row + (t.height - 1) * t.spacing;
|
|
72
|
+
if (
|
|
73
|
+
![(t.width - 1) * t.spacing, (t.height - 1) * t.spacing, x1, y1].every(Number.isSafeInteger)
|
|
74
|
+
)
|
|
75
|
+
throw new Error('Mixed contour lattice overflow');
|
|
76
|
+
return [t.column, t.row, x1, y1];
|
|
77
|
+
});
|
|
78
|
+
for (let i = 0; i < bounds.length; i++)
|
|
79
|
+
for (let j = 0; j < i; j++) {
|
|
80
|
+
charge();
|
|
81
|
+
const a = bounds[i],
|
|
82
|
+
b = bounds[j];
|
|
83
|
+
if (
|
|
84
|
+
Math.max(a[0], b[0]) < Math.min(a[2], b[2]) &&
|
|
85
|
+
Math.max(a[1], b[1]) < Math.min(a[3], b[3])
|
|
86
|
+
)
|
|
87
|
+
throw new Error('Mixed contour tile interiors overlap');
|
|
88
|
+
}
|
|
89
|
+
const first = sorted[0].contours,
|
|
90
|
+
origin: [number, number, number] = [...first.origin];
|
|
91
|
+
const positions: number[] = [],
|
|
92
|
+
grid: number[] = [],
|
|
93
|
+
vertexLevels: number[] = [];
|
|
94
|
+
const roundedBoundary = new Map<string, string>();
|
|
95
|
+
const boundary = new Set<number>(),
|
|
96
|
+
shared = new Map<string, number>();
|
|
97
|
+
const edges: {a: number; b: number; level: number; tile: number; seam: boolean}[] = [];
|
|
98
|
+
let inputVertices = 0,
|
|
99
|
+
inputSegments = 0;
|
|
100
|
+
for (let ti = 0; ti < sorted.length; ti++) {
|
|
101
|
+
const tile = sorted[ti],
|
|
102
|
+
data = tile.contours;
|
|
103
|
+
const count = validateContourData(data, limits);
|
|
104
|
+
inputVertices += count;
|
|
105
|
+
if (inputVertices > limits.maxVertices)
|
|
106
|
+
throw new Error('Mixed contour input vertex capacity exceeded');
|
|
107
|
+
if (
|
|
108
|
+
data.heightReference !== first.heightReference ||
|
|
109
|
+
data.levels.length !== first.levels.length ||
|
|
110
|
+
!data.levels.every((v, i) => v === first.levels[i])
|
|
111
|
+
)
|
|
112
|
+
throw new Error('Mixed contour levels or height reference differ');
|
|
113
|
+
if (
|
|
114
|
+
!(data.segments instanceof Uint32Array) ||
|
|
115
|
+
data.segments.length % 2 ||
|
|
116
|
+
!(data.levelIndices instanceof Uint32Array) ||
|
|
117
|
+
data.levelIndices.length !== data.segments.length / 2
|
|
118
|
+
)
|
|
119
|
+
throw new Error('Invalid mixed contour segments');
|
|
120
|
+
inputSegments += data.levelIndices.length;
|
|
121
|
+
if (inputSegments > limits.maxSegments)
|
|
122
|
+
throw new Error('Mixed contour input segment capacity exceeded');
|
|
123
|
+
const assigned = new Uint32Array(count).fill(0xffffffff),
|
|
124
|
+
remap = new Map<number, number>();
|
|
125
|
+
const local = new Set<string>();
|
|
126
|
+
const vertex = (v: number, level: number) => {
|
|
127
|
+
validateContourVertex(data, v, level, assigned);
|
|
128
|
+
const existing = remap.get(v);
|
|
129
|
+
if (existing !== undefined) return existing;
|
|
130
|
+
const x = data.gridCoordinates[2 * v],
|
|
131
|
+
y = data.gridCoordinates[2 * v + 1];
|
|
132
|
+
if (x < 0 || x > tile.width - 1 || y < 0 || y > tile.height - 1)
|
|
133
|
+
throw new Error('Mixed contour vertex outside tile');
|
|
134
|
+
const sx = x * tile.spacing,
|
|
135
|
+
sy = y * tile.spacing;
|
|
136
|
+
const gx = tile.column + sx,
|
|
137
|
+
gy = tile.row + sy;
|
|
138
|
+
// Reject coordinates whose local fraction cannot survive common-frame rebasing.
|
|
139
|
+
if (
|
|
140
|
+
Math.abs(gx - tile.column - sx) > 8 * Number.EPSILON * Math.max(1, Math.abs(sx)) ||
|
|
141
|
+
Math.abs(gy - tile.row - sy) > 8 * Number.EPSILON * Math.max(1, Math.abs(sy))
|
|
142
|
+
)
|
|
143
|
+
throw new Error('Mixed contour lattice loses precision');
|
|
144
|
+
const px = data.positions[3 * v] + (data.origin[0] - origin[0]),
|
|
145
|
+
py = data.positions[3 * v + 1] + (data.origin[1] - origin[1]);
|
|
146
|
+
const pz = data.levels[level] - origin[2];
|
|
147
|
+
if (![gx, gy, px, py, pz].every(Number.isFinite))
|
|
148
|
+
throw new Error('Mixed contour frame overflow');
|
|
149
|
+
const onEdge = x === 0 || y === 0 || x === tile.width - 1 || y === tile.height - 1;
|
|
150
|
+
const xi = Math.floor(sx),
|
|
151
|
+
yi = Math.floor(sy);
|
|
152
|
+
const key = `${level}/${tile.column + xi}/${sx - xi}/${tile.row + yi}/${sy - yi}`;
|
|
153
|
+
if (onEdge) {
|
|
154
|
+
const rounded = `${level}/${gx}/${gy}`;
|
|
155
|
+
const identity = roundedBoundary.get(rounded);
|
|
156
|
+
if (identity !== undefined && identity !== key)
|
|
157
|
+
throw new Error('Mixed contour lattice loses precision');
|
|
158
|
+
roundedBoundary.set(rounded, key);
|
|
159
|
+
}
|
|
160
|
+
if (onEdge && local.has(key)) throw new Error('Duplicate mixed contour boundary vertex');
|
|
161
|
+
if (onEdge) local.add(key);
|
|
162
|
+
let id = onEdge ? shared.get(key) : undefined;
|
|
163
|
+
if (id !== undefined) {
|
|
164
|
+
if (Math.hypot(px - positions[3 * id], py - positions[3 * id + 1]) > tolerance)
|
|
165
|
+
throw new Error('Mixed contour boundary positions disagree');
|
|
166
|
+
} else {
|
|
167
|
+
id = positions.length / 3;
|
|
168
|
+
if (id >= limits.maxVertices) throw new Error('Mixed contour vertex capacity exceeded');
|
|
169
|
+
positions.push(px, py, pz);
|
|
170
|
+
grid.push(gx, gy);
|
|
171
|
+
vertexLevels.push(level);
|
|
172
|
+
if (onEdge) {
|
|
173
|
+
shared.set(key, id);
|
|
174
|
+
boundary.add(id);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
remap.set(v, id);
|
|
178
|
+
return id;
|
|
179
|
+
};
|
|
180
|
+
const localEdges = new Set<string>();
|
|
181
|
+
for (let i = 0; i < data.levelIndices.length; i++) {
|
|
182
|
+
const level = data.levelIndices[i],
|
|
183
|
+
a = vertex(data.segments[2 * i], level),
|
|
184
|
+
b = vertex(data.segments[2 * i + 1], level);
|
|
185
|
+
if (
|
|
186
|
+
a === b ||
|
|
187
|
+
(positions[3 * a] === positions[3 * b] && positions[3 * a + 1] === positions[3 * b + 1])
|
|
188
|
+
)
|
|
189
|
+
throw new Error('Degenerate mixed contour segment');
|
|
190
|
+
const key = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
191
|
+
if (localEdges.has(key)) throw new Error('Duplicate mixed contour segment');
|
|
192
|
+
localEdges.add(key);
|
|
193
|
+
const box = bounds[ti];
|
|
194
|
+
const seam =
|
|
195
|
+
(grid[2 * a] === grid[2 * b] && (grid[2 * a] === box[0] || grid[2 * a] === box[2])) ||
|
|
196
|
+
(grid[2 * a + 1] === grid[2 * b + 1] &&
|
|
197
|
+
(grid[2 * a + 1] === box[1] || grid[2 * a + 1] === box[3]));
|
|
198
|
+
edges.push({a, b, level, tile: ti, seam});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const segments: number[] = [],
|
|
202
|
+
levels: number[] = [],
|
|
203
|
+
emitted = new Map<string, number>();
|
|
204
|
+
for (const edge of edges) {
|
|
205
|
+
const {a, b, level} = edge;
|
|
206
|
+
const axis = grid[2 * a] === grid[2 * b] ? 1 : 0;
|
|
207
|
+
const start = grid[2 * a + axis],
|
|
208
|
+
end = grid[2 * b + axis];
|
|
209
|
+
const cuts = [a, b];
|
|
210
|
+
if (edge.seam)
|
|
211
|
+
for (const v of boundary) {
|
|
212
|
+
charge();
|
|
213
|
+
const value = grid[2 * v + axis];
|
|
214
|
+
if (
|
|
215
|
+
vertexLevels[v] !== level ||
|
|
216
|
+
grid[2 * v + 1 - axis] !== grid[2 * a + 1 - axis] ||
|
|
217
|
+
value <= Math.min(start, end) ||
|
|
218
|
+
value >= Math.max(start, end)
|
|
219
|
+
)
|
|
220
|
+
continue;
|
|
221
|
+
const f = (value - start) / (end - start);
|
|
222
|
+
const px = positions[3 * a] + f * (positions[3 * b] - positions[3 * a]);
|
|
223
|
+
const py = positions[3 * a + 1] + f * (positions[3 * b + 1] - positions[3 * a + 1]);
|
|
224
|
+
if (Math.hypot(px - positions[3 * v], py - positions[3 * v + 1]) > tolerance)
|
|
225
|
+
throw new Error('Mixed contour boundary positions disagree');
|
|
226
|
+
cuts.push(v);
|
|
227
|
+
}
|
|
228
|
+
cuts.sort((u, v) => grid[2 * u + axis] - grid[2 * v + axis]);
|
|
229
|
+
for (let i = 1; i < cuts.length; i++) {
|
|
230
|
+
const u = cuts[i - 1],
|
|
231
|
+
v = cuts[i],
|
|
232
|
+
key = u < v ? `${u}/${v}` : `${v}/${u}`;
|
|
233
|
+
const prior = emitted.get(key);
|
|
234
|
+
if (prior !== undefined) {
|
|
235
|
+
if (prior === edge.tile) throw new Error('Overlapping mixed contour segments within tile');
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (levels.length >= limits.maxSegments)
|
|
239
|
+
throw new Error('Mixed contour output segment capacity exceeded');
|
|
240
|
+
emitted.set(key, edge.tile);
|
|
241
|
+
segments.push(u, v);
|
|
242
|
+
levels.push(level);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
positions: Float64Array.from(positions),
|
|
247
|
+
gridCoordinates: Float64Array.from(grid),
|
|
248
|
+
segments: Uint32Array.from(segments),
|
|
249
|
+
levelIndices: Uint32Array.from(levels),
|
|
250
|
+
levels: first.levels.slice(),
|
|
251
|
+
origin,
|
|
252
|
+
heightReference: first.heightReference
|
|
253
|
+
};
|
|
254
|
+
}
|
|
@@ -24,7 +24,11 @@ export type TerrainSimplifiedContourPaths = TerrainContourPaths & {
|
|
|
24
24
|
*/
|
|
25
25
|
export function simplifyTerrainContourPaths(
|
|
26
26
|
paths: TerrainContourPaths,
|
|
27
|
-
options: TerrainContourPathLimits & {
|
|
27
|
+
options: TerrainContourPathLimits & {
|
|
28
|
+
maxError: number;
|
|
29
|
+
maxDistanceTests?: number;
|
|
30
|
+
protectedVertexIndices?: Uint32Array;
|
|
31
|
+
}
|
|
28
32
|
): TerrainSimplifiedContourPaths {
|
|
29
33
|
const limits = contourPathLimits(options),
|
|
30
34
|
count = validateContourData(paths, limits);
|
|
@@ -87,6 +91,9 @@ export function simplifyTerrainContourPaths(
|
|
|
87
91
|
uses[vertex]++;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
94
|
+
const protectedIds = new Set(options.protectedVertexIndices);
|
|
95
|
+
for (const id of protectedIds)
|
|
96
|
+
if (id >= count) throw new Error('Invalid protected contour vertex');
|
|
90
97
|
const keep = new Uint8Array(paths.indices.length);
|
|
91
98
|
let distanceTests = 0,
|
|
92
99
|
maxDeviation = 0;
|
|
@@ -98,7 +105,8 @@ export function simplifyTerrainContourPaths(
|
|
|
98
105
|
keep[start + Math.floor((end - start) / 3)] = 1;
|
|
99
106
|
keep[start + Math.floor((2 * (end - start)) / 3)] = 1;
|
|
100
107
|
}
|
|
101
|
-
for (let i = start; i <= end; i++)
|
|
108
|
+
for (let i = start; i <= end; i++)
|
|
109
|
+
if (uses[paths.indices[i]] > 1 || protectedIds.has(paths.indices[i])) keep[i] = 1;
|
|
102
110
|
const stack: number[] = [];
|
|
103
111
|
let previous = start;
|
|
104
112
|
for (let i = start + 1; i <= end; i++)
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {createTerrainBoxIndex} from './box-index';
|
|
5
|
+
import {simplifyTerrainContourPaths} from './contour-simplify';
|
|
6
|
+
import type {TerrainContourPaths, TerrainContourPathLimits} from './contour-path-data';
|
|
7
|
+
|
|
8
|
+
// Exact dyadic arithmetic makes orientation independent of coordinate scale.
|
|
9
|
+
const bits = new DataView(new ArrayBuffer(8));
|
|
10
|
+
function integer(x: number): bigint {
|
|
11
|
+
bits.setFloat64(0, x);
|
|
12
|
+
const high = bits.getUint32(0),
|
|
13
|
+
low = bits.getUint32(4);
|
|
14
|
+
const exponent = (high >>> 20) & 2047;
|
|
15
|
+
const mantissa = (BigInt(high & 0xfffff) << 32n) | BigInt(low);
|
|
16
|
+
const value = exponent ? ((1n << 52n) | mantissa) << BigInt(exponent - 1) : mantissa;
|
|
17
|
+
return high >>> 31 ? -value : value;
|
|
18
|
+
}
|
|
19
|
+
type Point = {x: bigint; y: bigint};
|
|
20
|
+
const orientation = (a: Point, b: Point, c: Point) =>
|
|
21
|
+
(b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
22
|
+
const sign = (v: bigint) => (v < 0n ? -1 : v > 0n ? 1 : 0);
|
|
23
|
+
const between = (a: bigint, b: bigint, p: bigint) => p >= (a < b ? a : b) && p <= (a > b ? a : b);
|
|
24
|
+
const on = (a: Point, b: Point, p: Point) =>
|
|
25
|
+
orientation(a, b, p) === 0n && between(a.x, b.x, p.x) && between(a.y, b.y, p.y);
|
|
26
|
+
function intersects(a: Point, b: Point, c: Point, d: Point): boolean {
|
|
27
|
+
return (
|
|
28
|
+
on(a, b, c) ||
|
|
29
|
+
on(a, b, d) ||
|
|
30
|
+
on(c, d, a) ||
|
|
31
|
+
on(c, d, b) ||
|
|
32
|
+
(sign(orientation(a, b, c)) * sign(orientation(a, b, d)) < 0 &&
|
|
33
|
+
sign(orientation(c, d, a)) * sign(orientation(c, d, b)) < 0)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Conservative topology-safe RDP. Rejects invalid input embeddings and falls back
|
|
38
|
+
* to the original geometry if any proposed shortcut crosses/touches another edge
|
|
39
|
+
* or sweeps another vertex. Shared IDs and caller-protected IDs remain anchors.
|
|
40
|
+
* All paths and levels participate in XY topology; no polygon classification is inferred.
|
|
41
|
+
*/
|
|
42
|
+
export function simplifyTerrainContourPathsTopology(
|
|
43
|
+
paths: TerrainContourPaths,
|
|
44
|
+
options: TerrainContourPathLimits & {
|
|
45
|
+
maxError: number;
|
|
46
|
+
maxDistanceTests?: number;
|
|
47
|
+
maxTopologyTests?: number;
|
|
48
|
+
protectedVertexIndices?: Uint32Array;
|
|
49
|
+
rejection?: 'batch' | 'path';
|
|
50
|
+
}
|
|
51
|
+
) {
|
|
52
|
+
if (
|
|
53
|
+
options.rejection !== undefined &&
|
|
54
|
+
options.rejection !== 'batch' &&
|
|
55
|
+
options.rejection !== 'path'
|
|
56
|
+
)
|
|
57
|
+
throw new Error('Invalid contour rejection policy');
|
|
58
|
+
const candidate = simplifyTerrainContourPaths(paths, options);
|
|
59
|
+
const budget = options.maxTopologyTests ?? 1_000_000;
|
|
60
|
+
if (!Number.isSafeInteger(budget) || budget < 0)
|
|
61
|
+
throw new Error('Invalid contour topology budget');
|
|
62
|
+
let topologyTests = 0;
|
|
63
|
+
const charge = () => {
|
|
64
|
+
if (++topologyTests > budget) throw new Error('Contour topology work budget exceeded');
|
|
65
|
+
};
|
|
66
|
+
const points: Point[] = new Array(paths.positions.length / 3);
|
|
67
|
+
for (const i of new Set(paths.indices))
|
|
68
|
+
points[i] = {x: integer(paths.positions[3 * i]), y: integer(paths.positions[3 * i + 1])};
|
|
69
|
+
const edges: {a: number; b: number; p: number; i: number}[] = [];
|
|
70
|
+
for (let p = 0; p < paths.closed.length; p++)
|
|
71
|
+
for (let i = paths.offsets[p]; i + 1 < paths.offsets[p + 1]; i++)
|
|
72
|
+
edges.push({a: paths.indices[i], b: paths.indices[i + 1], p, i});
|
|
73
|
+
const box = (a: number, b: number) => ({
|
|
74
|
+
minX: Math.min(paths.positions[3 * a], paths.positions[3 * b]),
|
|
75
|
+
maxX: Math.max(paths.positions[3 * a], paths.positions[3 * b]),
|
|
76
|
+
minY: Math.min(paths.positions[3 * a + 1], paths.positions[3 * b + 1]),
|
|
77
|
+
maxY: Math.max(paths.positions[3 * a + 1], paths.positions[3 * b + 1])
|
|
78
|
+
});
|
|
79
|
+
const edgeBoxes = edges.map(e => box(e.a, e.b)),
|
|
80
|
+
edgeIndex = createTerrainBoxIndex(edgeBoxes);
|
|
81
|
+
const vertexIds = [...new Set(paths.indices)],
|
|
82
|
+
vertexIndex = createTerrainBoxIndex(vertexIds.map(v => box(v, v)));
|
|
83
|
+
for (let i = 0; i < edges.length; i++)
|
|
84
|
+
for (const j of edgeIndex(edgeBoxes[i], charge)) {
|
|
85
|
+
if (j <= i) continue;
|
|
86
|
+
charge();
|
|
87
|
+
const a = edges[i],
|
|
88
|
+
b = edges[j];
|
|
89
|
+
const common = [a.a, a.b].filter(v => v === b.a || v === b.b);
|
|
90
|
+
if (common.length === 1) {
|
|
91
|
+
const v = common[0],
|
|
92
|
+
x = a.a === v ? a.b : a.a,
|
|
93
|
+
y = b.a === v ? b.b : b.a;
|
|
94
|
+
if (on(points[v], points[x], points[y]) || on(points[v], points[y], points[x]))
|
|
95
|
+
throw new Error('Overlapping contour edges');
|
|
96
|
+
} else if (intersects(points[a.a], points[a.b], points[b.a], points[b.b]))
|
|
97
|
+
throw new Error('Contour input has crossings or unshared touches');
|
|
98
|
+
}
|
|
99
|
+
let rejected = false;
|
|
100
|
+
const rejectedPaths = new Set<number>();
|
|
101
|
+
for (let p = 0; p < paths.closed.length; p++) {
|
|
102
|
+
let start = paths.offsets[p];
|
|
103
|
+
for (let k = candidate.offsets[p] + 1; k < candidate.offsets[p + 1]; k++) {
|
|
104
|
+
const endId = candidate.sourceVertexIndices[candidate.indices[k]];
|
|
105
|
+
let end = start + 1;
|
|
106
|
+
while (paths.indices[end] !== endId) end++;
|
|
107
|
+
if (end > start + 1) {
|
|
108
|
+
const a = paths.indices[start],
|
|
109
|
+
b = paths.indices[end];
|
|
110
|
+
const pa = points[a],
|
|
111
|
+
pb = points[b];
|
|
112
|
+
const axis = pa.x !== pb.x ? 'x' : 'y';
|
|
113
|
+
const direction = sign(pb[axis] - pa[axis]);
|
|
114
|
+
let straight = true;
|
|
115
|
+
for (let i = start + 1; i <= end; i++) {
|
|
116
|
+
charge();
|
|
117
|
+
const q = points[paths.indices[i]],
|
|
118
|
+
prior = points[paths.indices[i - 1]];
|
|
119
|
+
if (!on(pa, pb, q) || sign(q[axis] - prior[axis]) !== direction) straight = false;
|
|
120
|
+
}
|
|
121
|
+
const interior = new Set(Array.from(paths.indices.subarray(start + 1, end)));
|
|
122
|
+
let unsafe = false;
|
|
123
|
+
for (const edgeId of edgeIndex(box(a, b), charge)) {
|
|
124
|
+
const edge = edges[edgeId];
|
|
125
|
+
if (edge.p === p && edge.i >= start && edge.i < end) {
|
|
126
|
+
if (straight) continue;
|
|
127
|
+
charge();
|
|
128
|
+
// The swept chain plus chord must be simple. Endpoint edges may meet
|
|
129
|
+
// the chord only at their endpoint; interior edges must not touch it.
|
|
130
|
+
const others = [edge.a, edge.b].filter(v => v !== a && v !== b);
|
|
131
|
+
if (
|
|
132
|
+
others.some(v => on(points[a], points[b], points[v])) ||
|
|
133
|
+
(others.length === 2 &&
|
|
134
|
+
intersects(points[a], points[b], points[edge.a], points[edge.b]))
|
|
135
|
+
)
|
|
136
|
+
unsafe = true;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
charge();
|
|
140
|
+
// Endpoint contacts at existing shared IDs are allowed; any extra contact is not.
|
|
141
|
+
const others = [edge.a, edge.b].filter(v => v !== a && v !== b);
|
|
142
|
+
if (
|
|
143
|
+
others.some(v => on(points[a], points[b], points[v])) ||
|
|
144
|
+
(others.length === 2 &&
|
|
145
|
+
intersects(points[a], points[b], points[edge.a], points[edge.b]))
|
|
146
|
+
)
|
|
147
|
+
unsafe = true;
|
|
148
|
+
}
|
|
149
|
+
const swept = {minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity};
|
|
150
|
+
for (let i = start; i <= end; i++) {
|
|
151
|
+
const v = paths.indices[i];
|
|
152
|
+
swept.minX = Math.min(swept.minX, paths.positions[3 * v]);
|
|
153
|
+
swept.maxX = Math.max(swept.maxX, paths.positions[3 * v]);
|
|
154
|
+
swept.minY = Math.min(swept.minY, paths.positions[3 * v + 1]);
|
|
155
|
+
swept.maxY = Math.max(swept.maxY, paths.positions[3 * v + 1]);
|
|
156
|
+
}
|
|
157
|
+
for (const vertexId of vertexIndex(swept, charge)) {
|
|
158
|
+
const vertex = vertexIds[vertexId];
|
|
159
|
+
if (vertex === a || vertex === b || interior.has(vertex)) continue;
|
|
160
|
+
let inside = false;
|
|
161
|
+
for (let i = start, j = end; i <= end; j = i++) {
|
|
162
|
+
charge();
|
|
163
|
+
const u = points[paths.indices[i]],
|
|
164
|
+
v = points[paths.indices[j]],
|
|
165
|
+
q = points[vertex];
|
|
166
|
+
if (on(u, v, q)) {
|
|
167
|
+
unsafe = true;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
if (u.y > q.y !== v.y > q.y && orientation(u, v, q) > 0n === v.y > u.y)
|
|
171
|
+
inside = !inside;
|
|
172
|
+
}
|
|
173
|
+
if (inside) unsafe = true;
|
|
174
|
+
}
|
|
175
|
+
if (unsafe) {
|
|
176
|
+
rejected = true;
|
|
177
|
+
rejectedPaths.add(p);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
start = end;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const outputEdges: {a: number; b: number; p: number}[] = [];
|
|
184
|
+
for (let p = 0; p < candidate.closed.length; p++)
|
|
185
|
+
for (let i = candidate.offsets[p]; i + 1 < candidate.offsets[p + 1]; i++)
|
|
186
|
+
outputEdges.push({
|
|
187
|
+
p,
|
|
188
|
+
a: candidate.sourceVertexIndices[candidate.indices[i]],
|
|
189
|
+
b: candidate.sourceVertexIndices[candidate.indices[i + 1]]
|
|
190
|
+
});
|
|
191
|
+
const outputBoxes = outputEdges.map(e => box(e.a, e.b)),
|
|
192
|
+
outputIndex = createTerrainBoxIndex(outputBoxes);
|
|
193
|
+
for (let i = 0; i < outputEdges.length; i++)
|
|
194
|
+
for (const j of outputIndex(outputBoxes[i], charge)) {
|
|
195
|
+
if (j <= i) continue;
|
|
196
|
+
charge();
|
|
197
|
+
const a = outputEdges[i],
|
|
198
|
+
b = outputEdges[j];
|
|
199
|
+
const common = [a.a, a.b].filter(v => v === b.a || v === b.b);
|
|
200
|
+
if (common.length === 1) {
|
|
201
|
+
const v = common[0],
|
|
202
|
+
x = a.a === v ? a.b : a.a,
|
|
203
|
+
y = b.a === v ? b.b : b.a;
|
|
204
|
+
if (on(points[v], points[x], points[y]) || on(points[v], points[y], points[x])) {
|
|
205
|
+
rejected = true;
|
|
206
|
+
rejectedPaths.add(a.p);
|
|
207
|
+
rejectedPaths.add(b.p);
|
|
208
|
+
}
|
|
209
|
+
} else if (intersects(points[a.a], points[a.b], points[b.a], points[b.b])) {
|
|
210
|
+
rejected = true;
|
|
211
|
+
rejectedPaths.add(a.p);
|
|
212
|
+
rejectedPaths.add(b.p);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (rejected && options.rejection === 'path') {
|
|
216
|
+
const indices: number[] = [],
|
|
217
|
+
offsets = [0];
|
|
218
|
+
for (let p = 0; p < paths.closed.length; p++) {
|
|
219
|
+
if (rejectedPaths.has(p))
|
|
220
|
+
for (let i = paths.offsets[p]; i < paths.offsets[p + 1]; i++)
|
|
221
|
+
indices.push(paths.indices[i]);
|
|
222
|
+
else
|
|
223
|
+
for (let i = candidate.offsets[p]; i < candidate.offsets[p + 1]; i++)
|
|
224
|
+
indices.push(candidate.sourceVertexIndices[candidate.indices[i]]);
|
|
225
|
+
offsets.push(indices.length);
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
...paths,
|
|
229
|
+
positions: paths.positions.slice(),
|
|
230
|
+
gridCoordinates: paths.gridCoordinates.slice(),
|
|
231
|
+
indices: Uint32Array.from(indices),
|
|
232
|
+
offsets: Uint32Array.from(offsets),
|
|
233
|
+
closed: paths.closed.slice(),
|
|
234
|
+
levelIndices: paths.levelIndices.slice(),
|
|
235
|
+
levels: paths.levels.slice(),
|
|
236
|
+
origin: Object.freeze([...paths.origin] as [number, number, number]),
|
|
237
|
+
sourceVertexIndices: Uint32Array.from({length: points.length}, (_, i) => i),
|
|
238
|
+
maxDeviation: candidate.maxDeviation,
|
|
239
|
+
requestedMaxError: options.maxError,
|
|
240
|
+
distanceTests: candidate.distanceTests,
|
|
241
|
+
topologyTests,
|
|
242
|
+
rejected: true
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (!rejected) return {...candidate, topologyTests, rejected: false};
|
|
246
|
+
return {
|
|
247
|
+
...paths,
|
|
248
|
+
positions: paths.positions.slice(),
|
|
249
|
+
gridCoordinates: paths.gridCoordinates.slice(),
|
|
250
|
+
indices: paths.indices.slice(),
|
|
251
|
+
offsets: paths.offsets.slice(),
|
|
252
|
+
levelIndices: paths.levelIndices.slice(),
|
|
253
|
+
closed: paths.closed.slice(),
|
|
254
|
+
levels: paths.levels.slice(),
|
|
255
|
+
origin: Object.freeze([...paths.origin] as [number, number, number]),
|
|
256
|
+
sourceVertexIndices: Uint32Array.from({length: points.length}, (_, i) => i),
|
|
257
|
+
maxDeviation: 0,
|
|
258
|
+
requestedMaxError: options.maxError,
|
|
259
|
+
distanceTests: candidate.distanceTests,
|
|
260
|
+
topologyTests,
|
|
261
|
+
rejected: true
|
|
262
|
+
};
|
|
263
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {createDelatinTerrainMesh} from './delatin';
|
|
5
|
+
import {updateMeshRegions, type TerrainMeshRegions} from './mesh-regions-data';
|
|
6
|
+
import type {HeightField} from './height-field';
|
|
7
|
+
import type {AdaptiveTerrainMesh} from './adaptive-mesh-types';
|
|
8
|
+
import type {TerrainDirtyWindow} from './dirty-regions';
|
|
9
|
+
export type TerrainDelatinMeshRegions = TerrainMeshRegions<AdaptiveTerrainMesh | null>;
|
|
10
|
+
/** Missing regions return null. Independent adaptive boundaries require explicit
|
|
11
|
+
* stitchTerrainMeshEdges before treating the regions as a conforming surface. */
|
|
12
|
+
export function updateTerrainDelatinMeshRegions(
|
|
13
|
+
previous: TerrainDelatinMeshRegions | null,
|
|
14
|
+
field: HeightField,
|
|
15
|
+
dirty: readonly TerrainDirtyWindow[],
|
|
16
|
+
options: {maxError: number; cellsPerRegion?: number; maxSamples?: number; maxTests?: number}
|
|
17
|
+
): TerrainDelatinMeshRegions {
|
|
18
|
+
if (!Number.isFinite(options.maxError) || options.maxError < 0)
|
|
19
|
+
throw new Error('Invalid Delatin region error');
|
|
20
|
+
return updateMeshRegions(previous, field, dirty, options, `delatin:${options.maxError}`, f =>
|
|
21
|
+
f.validCount !== f.width * f.height
|
|
22
|
+
? null
|
|
23
|
+
: createDelatinTerrainMesh(f, {maxError: options.maxError})
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import type {HeightField} from './height-field';
|
|
5
|
+
export type TerrainDirtyWindow = {
|
|
6
|
+
minColumn: number;
|
|
7
|
+
minRow: number;
|
|
8
|
+
maxColumn: number;
|
|
9
|
+
maxRow: number;
|
|
10
|
+
};
|
|
11
|
+
export function validateTerrainDirtyWindows(
|
|
12
|
+
windows: readonly TerrainDirtyWindow[],
|
|
13
|
+
width: number,
|
|
14
|
+
height: number,
|
|
15
|
+
maxWindows = 100_000
|
|
16
|
+
): void {
|
|
17
|
+
if (windows.length > maxWindows) throw new Error('Terrain dirty window capacity exceeded');
|
|
18
|
+
for (const w of windows)
|
|
19
|
+
if (
|
|
20
|
+
![w.minColumn, w.minRow, w.maxColumn, w.maxRow].every(Number.isSafeInteger) ||
|
|
21
|
+
w.minColumn < 0 ||
|
|
22
|
+
w.minRow < 0 ||
|
|
23
|
+
w.maxColumn >= width ||
|
|
24
|
+
w.maxRow >= height ||
|
|
25
|
+
w.minColumn > w.maxColumn ||
|
|
26
|
+
w.minRow > w.maxRow
|
|
27
|
+
)
|
|
28
|
+
throw new Error('Invalid terrain dirty sample window');
|
|
29
|
+
}
|
|
30
|
+
export function sameTerrainFrame(a: HeightField, b: HeightField): boolean {
|
|
31
|
+
return (
|
|
32
|
+
a.width === b.width &&
|
|
33
|
+
a.height === b.height &&
|
|
34
|
+
a.registration === b.registration &&
|
|
35
|
+
a.diagonal === b.diagonal &&
|
|
36
|
+
a.heightReference === b.heightReference &&
|
|
37
|
+
a.origin.every((v, i) => v === b.origin[i]) &&
|
|
38
|
+
a.columnStep.every((v, i) => v === b.columnStep[i]) &&
|
|
39
|
+
a.rowStep.every((v, i) => v === b.rowStep[i])
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export function terrainDirtyIndices(
|
|
43
|
+
windows: readonly TerrainDirtyWindow[],
|
|
44
|
+
width: number,
|
|
45
|
+
height: number,
|
|
46
|
+
expand: number,
|
|
47
|
+
charge: () => void
|
|
48
|
+
): Set<number> {
|
|
49
|
+
const ids = new Set<number>();
|
|
50
|
+
for (const w of windows)
|
|
51
|
+
for (let y = Math.max(0, w.minRow - expand); y <= Math.min(height - 1, w.maxRow + expand); y++)
|
|
52
|
+
for (
|
|
53
|
+
let x = Math.max(0, w.minColumn - expand);
|
|
54
|
+
x <= Math.min(width - 1, w.maxColumn + expand);
|
|
55
|
+
x++
|
|
56
|
+
) {
|
|
57
|
+
charge();
|
|
58
|
+
ids.add(y * width + x);
|
|
59
|
+
}
|
|
60
|
+
return ids;
|
|
61
|
+
}
|