@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,140 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {createTerrainGradientPyramid, type TerrainGradientPyramid} from './gradient-pyramid';
|
|
5
|
+
import {
|
|
6
|
+
validateTerrainDirtyWindows,
|
|
7
|
+
terrainDirtyIndices,
|
|
8
|
+
type TerrainDirtyWindow
|
|
9
|
+
} from './dirty-regions';
|
|
10
|
+
import type {TerrainGradientGrid} from './derivatives';
|
|
11
|
+
export type TerrainGradientPyramidRegions = {
|
|
12
|
+
source: TerrainGradientGrid;
|
|
13
|
+
pyramid: TerrainGradientPyramid;
|
|
14
|
+
updatedCounts: Uint32Array;
|
|
15
|
+
};
|
|
16
|
+
/** Dirty windows identify changed gradient grid samples, not source-height edits.
|
|
17
|
+
* Expand source-height windows by the derivative stencil radius before use. */
|
|
18
|
+
export function updateTerrainGradientPyramidRegions(
|
|
19
|
+
previous: TerrainGradientPyramidRegions | null,
|
|
20
|
+
grid: TerrainGradientGrid,
|
|
21
|
+
dirty: readonly TerrainDirtyWindow[],
|
|
22
|
+
options: {maxSamples?: number; maxTests?: number} = {}
|
|
23
|
+
): TerrainGradientPyramidRegions {
|
|
24
|
+
const limit = options.maxSamples ?? 4_000_000,
|
|
25
|
+
budget = options.maxTests ?? 10_000_000;
|
|
26
|
+
if (
|
|
27
|
+
![limit, budget].every(Number.isSafeInteger) ||
|
|
28
|
+
limit < 0 ||
|
|
29
|
+
budget < 0 ||
|
|
30
|
+
!Number.isSafeInteger(grid.width) ||
|
|
31
|
+
grid.width < 1 ||
|
|
32
|
+
!Number.isSafeInteger(grid.height) ||
|
|
33
|
+
grid.height < 1 ||
|
|
34
|
+
grid.width * grid.height > limit
|
|
35
|
+
)
|
|
36
|
+
throw new Error('Invalid gradient region capacity');
|
|
37
|
+
if (
|
|
38
|
+
(grid.method !== 'horn' && grid.method !== 'zevenbergen-thorne') ||
|
|
39
|
+
(grid.registration !== 'vertex' && grid.registration !== 'cell') ||
|
|
40
|
+
typeof grid.heightReference !== 'string' ||
|
|
41
|
+
![grid.origin, grid.columnStep, grid.rowStep].every(
|
|
42
|
+
v => v.length === 2 && v.every(Number.isFinite)
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
throw new Error('Invalid gradient region metadata');
|
|
46
|
+
validateTerrainDirtyWindows(dirty, grid.width, grid.height);
|
|
47
|
+
const old = previous?.source;
|
|
48
|
+
if (
|
|
49
|
+
!old ||
|
|
50
|
+
old.width !== grid.width ||
|
|
51
|
+
old.height !== grid.height ||
|
|
52
|
+
old.method !== grid.method ||
|
|
53
|
+
old.registration !== grid.registration ||
|
|
54
|
+
old.heightReference !== grid.heightReference ||
|
|
55
|
+
!old.origin.every((v, i) => v === grid.origin[i]) ||
|
|
56
|
+
!old.columnStep.every((v, i) => v === grid.columnStep[i]) ||
|
|
57
|
+
!old.rowStep.every((v, i) => v === grid.rowStep[i])
|
|
58
|
+
) {
|
|
59
|
+
const pyramid = createTerrainGradientPyramid(grid, {maxSamples: limit});
|
|
60
|
+
return {
|
|
61
|
+
source: grid,
|
|
62
|
+
pyramid,
|
|
63
|
+
updatedCounts: Uint32Array.from(pyramid.levels, l => l.width * l.height)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (
|
|
67
|
+
!(grid.gradients instanceof Float64Array) ||
|
|
68
|
+
grid.gradients.length !== 2 * grid.width * grid.height ||
|
|
69
|
+
!(grid.statuses instanceof Uint8Array) ||
|
|
70
|
+
grid.statuses.length !== grid.width * grid.height
|
|
71
|
+
)
|
|
72
|
+
throw new Error('Invalid gradient region buffers');
|
|
73
|
+
const levels = previous!.pyramid.levels.slice();
|
|
74
|
+
let tests = 0;
|
|
75
|
+
const charge = () => {
|
|
76
|
+
if (++tests > budget) throw new Error('Gradient region work budget exceeded');
|
|
77
|
+
};
|
|
78
|
+
let ids = terrainDirtyIndices(dirty, grid.width, grid.height, 0, charge);
|
|
79
|
+
const counts: number[] = [];
|
|
80
|
+
for (let l = 0; l < levels.length; l++) {
|
|
81
|
+
counts.push(ids.size);
|
|
82
|
+
if (!ids.size) continue;
|
|
83
|
+
const oldLevel = levels[l],
|
|
84
|
+
next = {
|
|
85
|
+
...oldLevel,
|
|
86
|
+
gradients: oldLevel.gradients.slice(),
|
|
87
|
+
validCounts: oldLevel.validCounts.slice(),
|
|
88
|
+
sampleCounts: oldLevel.sampleCounts
|
|
89
|
+
};
|
|
90
|
+
const parents = new Set<number>();
|
|
91
|
+
for (const id of ids) {
|
|
92
|
+
charge();
|
|
93
|
+
const x = id % next.width,
|
|
94
|
+
y = Math.floor(id / next.width);
|
|
95
|
+
next.validCounts[id] = 0;
|
|
96
|
+
next.gradients[2 * id] = next.gradients[2 * id + 1] = 0;
|
|
97
|
+
if (l === 0) {
|
|
98
|
+
if (grid.statuses[id] > 6) throw new Error('Invalid terrain gradient status');
|
|
99
|
+
if (grid.statuses[id] === 0) {
|
|
100
|
+
if (
|
|
101
|
+
!Number.isFinite(grid.gradients[2 * id]) ||
|
|
102
|
+
!Number.isFinite(grid.gradients[2 * id + 1])
|
|
103
|
+
)
|
|
104
|
+
throw new Error('Invalid terrain gradient value');
|
|
105
|
+
next.validCounts[id] = 1;
|
|
106
|
+
next.gradients[2 * id] = grid.gradients[2 * id];
|
|
107
|
+
next.gradients[2 * id + 1] = grid.gradients[2 * id + 1];
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
const child = levels[l - 1];
|
|
111
|
+
for (let dy = 0; dy < 2; dy++)
|
|
112
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
113
|
+
const cx = x * 2 + dx,
|
|
114
|
+
cy = y * 2 + dy;
|
|
115
|
+
if (cx >= child.width || cy >= child.height) continue;
|
|
116
|
+
const i = cy * child.width + cx,
|
|
117
|
+
n = child.validCounts[i],
|
|
118
|
+
count = next.validCounts[id];
|
|
119
|
+
if (n) {
|
|
120
|
+
const total = count + n;
|
|
121
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
122
|
+
const a = next.gradients[2 * id + axis],
|
|
123
|
+
b = child.gradients[2 * i + axis];
|
|
124
|
+
next.gradients[2 * id + axis] = count ? a * (count / total) + b * (n / total) : b;
|
|
125
|
+
}
|
|
126
|
+
next.validCounts[id] = total;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
parents.add(Math.floor(y / 2) * Math.ceil(next.width / 2) + Math.floor(x / 2));
|
|
131
|
+
}
|
|
132
|
+
levels[l] = next;
|
|
133
|
+
ids = parents;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
source: grid,
|
|
137
|
+
pyramid: {...previous!.pyramid, levels},
|
|
138
|
+
updatedCounts: Uint32Array.from(counts)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {createTerrainGradientPyramid, type TerrainGradientPyramid} from './gradient-pyramid';
|
|
5
|
+
import type {TerrainMixedGradientSnapshot} from './mixed-gradient-update';
|
|
6
|
+
export type TerrainGradientPyramidSnapshot = {
|
|
7
|
+
source: TerrainMixedGradientSnapshot['tiles'][number];
|
|
8
|
+
data: TerrainGradientPyramid;
|
|
9
|
+
}[];
|
|
10
|
+
/** Rebuild derivative hierarchies only when the immutable source grid changes. */
|
|
11
|
+
export function updateTerrainGradientPyramids(
|
|
12
|
+
previous: TerrainGradientPyramidSnapshot | null,
|
|
13
|
+
gradients: TerrainMixedGradientSnapshot,
|
|
14
|
+
options: {maxSamples?: number} = {}
|
|
15
|
+
): TerrainGradientPyramidSnapshot {
|
|
16
|
+
const limit = options.maxSamples ?? 4_000_000;
|
|
17
|
+
const count = gradients.tiles.reduce((n, t) => n + t.grid.width * t.grid.height, 0);
|
|
18
|
+
if (!Number.isSafeInteger(limit) || limit < 0 || !Number.isSafeInteger(count) || count > limit)
|
|
19
|
+
throw new Error('Gradient pyramid update sample capacity exceeded');
|
|
20
|
+
const cached = new Map(previous?.map(t => [t.source.grid, t.data]));
|
|
21
|
+
return gradients.tiles.map(source => ({
|
|
22
|
+
source,
|
|
23
|
+
data: cached.get(source.grid) ?? createTerrainGradientPyramid(source.grid, {maxSamples: limit})
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
@@ -144,6 +144,11 @@ export class HeightField {
|
|
|
144
144
|
) {
|
|
145
145
|
throw new Error('Unknown terrain interpolation');
|
|
146
146
|
}
|
|
147
|
+
const domain = options?.domain ?? 'samples';
|
|
148
|
+
const noData = options?.noData ?? 'cell';
|
|
149
|
+
if (domain !== 'samples' && domain !== 'footprint')
|
|
150
|
+
throw new Error('Unknown terrain sample domain');
|
|
151
|
+
if (noData !== 'cell' && noData !== 'support') throw new Error('Unknown terrain nodata policy');
|
|
147
152
|
if (!Number.isFinite(x) || !Number.isFinite(y)) return result;
|
|
148
153
|
const dx = x - this.origin[0];
|
|
149
154
|
const dy = y - this.origin[1];
|
|
@@ -162,16 +167,30 @@ export class HeightField {
|
|
|
162
167
|
tolerance + Math.abs(this.inverse[0]) * errorX + Math.abs(this.inverse[1]) * errorY;
|
|
163
168
|
const toleranceV =
|
|
164
169
|
tolerance + Math.abs(this.inverse[2]) * errorX + Math.abs(this.inverse[3]) * errorY;
|
|
170
|
+
const margin = domain === 'footprint' && this.registration === 'cell' ? 0.5 : 0;
|
|
165
171
|
if (
|
|
166
|
-
u < -toleranceU ||
|
|
167
|
-
v < -toleranceV ||
|
|
168
|
-
u > this.width - 1 + toleranceU ||
|
|
169
|
-
v > this.height - 1 + toleranceV
|
|
172
|
+
u < -margin - toleranceU ||
|
|
173
|
+
v < -margin - toleranceV ||
|
|
174
|
+
u > this.width - 1 + margin + toleranceU ||
|
|
175
|
+
v > this.height - 1 + margin + toleranceV
|
|
170
176
|
) {
|
|
171
177
|
return resetSample(result, Status.OUTSIDE_DOMAIN);
|
|
172
178
|
}
|
|
179
|
+
// Preserve endpoint one-sided derivatives within bounded coordinate roundoff.
|
|
180
|
+
const edgeToleranceU = Math.min(1e-6, toleranceU);
|
|
181
|
+
const edgeToleranceV = Math.min(1e-6, toleranceV);
|
|
182
|
+
const clampedColumn =
|
|
183
|
+
margin > 0 && (u < -edgeToleranceU || u > this.width - 1 + edgeToleranceU);
|
|
184
|
+
const clampedRow = margin > 0 && (v < -edgeToleranceV || v > this.height - 1 + edgeToleranceV);
|
|
173
185
|
u = Math.max(0, Math.min(this.width - 1, u));
|
|
174
186
|
v = Math.max(0, Math.min(this.height - 1, v));
|
|
187
|
+
if (noData === 'support' && interpolation === 'bilinear') {
|
|
188
|
+
// Do not let world-coordinate roundoff give an adjacent missing sample a tiny weight.
|
|
189
|
+
const column = Math.round(u),
|
|
190
|
+
row = Math.round(v);
|
|
191
|
+
if (Math.abs(u - column) <= Math.min(1e-6, toleranceU)) u = column;
|
|
192
|
+
if (Math.abs(v - row) <= Math.min(1e-6, toleranceV)) v = row;
|
|
193
|
+
}
|
|
175
194
|
if (interpolation === 'nearest') {
|
|
176
195
|
const value = this.getHeight(Math.floor(u + 0.5), Math.floor(v + 0.5));
|
|
177
196
|
if (value === undefined) return resetSample(result, Status.NO_DATA);
|
|
@@ -197,7 +216,25 @@ export class HeightField {
|
|
|
197
216
|
let dv: number;
|
|
198
217
|
if (interpolation === 'bilinear') {
|
|
199
218
|
if (!this.validity[a] || !this.validity[b] || !this.validity[c] || !this.validity[d]) {
|
|
200
|
-
return resetSample(result, Status.NO_DATA);
|
|
219
|
+
if (noData === 'cell') return resetSample(result, Status.NO_DATA);
|
|
220
|
+
const weightA = (1 - u) * (1 - v);
|
|
221
|
+
const weightB = u * (1 - v);
|
|
222
|
+
const weightC = (1 - u) * v;
|
|
223
|
+
const weightD = u * v;
|
|
224
|
+
if (
|
|
225
|
+
(weightA > 0 && !this.validity[a]) ||
|
|
226
|
+
(weightB > 0 && !this.validity[b]) ||
|
|
227
|
+
(weightC > 0 && !this.validity[c]) ||
|
|
228
|
+
(weightD > 0 && !this.validity[d])
|
|
229
|
+
)
|
|
230
|
+
return resetSample(result, Status.NO_DATA);
|
|
231
|
+
// Invalid samples are normalized to zero by construction; no temporary arrays are needed.
|
|
232
|
+
const height = weightA * za + weightB * zb + weightC * zc + weightD * zd;
|
|
233
|
+
if (!Number.isFinite(height)) return resetSample(result, Status.NUMERIC_ERROR);
|
|
234
|
+
result.status = Status.VALID;
|
|
235
|
+
result.height = height;
|
|
236
|
+
result.gradientStatus = Status.NO_DATA;
|
|
237
|
+
return result;
|
|
201
238
|
}
|
|
202
239
|
result.height = (1 - v) * ((1 - u) * za + u * zb) + v * ((1 - u) * zc + u * zd);
|
|
203
240
|
du = (1 - v) * (zb - za) + v * (zd - zc);
|
|
@@ -227,6 +264,9 @@ export class HeightField {
|
|
|
227
264
|
}
|
|
228
265
|
if (!Number.isFinite(result.height)) return resetSample(result, Status.NUMERIC_ERROR);
|
|
229
266
|
result.status = Status.VALID;
|
|
267
|
+
// Compose interpolation with the footprint clamp before mapping to world derivatives.
|
|
268
|
+
if (clampedColumn) du = 0;
|
|
269
|
+
if (clampedRow) dv = 0;
|
|
230
270
|
const gx = du * this.inverse[0] + dv * this.inverse[2];
|
|
231
271
|
const gy = du * this.inverse[1] + dv * this.inverse[3];
|
|
232
272
|
if (!Number.isFinite(gx) || !Number.isFinite(gy)) {
|
package/src/terrain/index.ts
CHANGED
|
@@ -102,3 +102,61 @@ export type {
|
|
|
102
102
|
} from './vertex-tiles';
|
|
103
103
|
export {stitchTerrainMeshEdges} from './mesh-stitch';
|
|
104
104
|
export type {TerrainSeamMesh, TerrainMeshStitchOptions} from './mesh-stitch';
|
|
105
|
+
export {weldTerrainMixedContourTiles} from './contour-mixed-weld';
|
|
106
|
+
export type {TerrainMixedContourTile, TerrainMixedContourWeldOptions} from './contour-mixed-weld';
|
|
107
|
+
|
|
108
|
+
export {createTerrainMixedVertexTileHalos} from './mixed-vertex-halos';
|
|
109
|
+
export type {TerrainMixedVertexTile} from './mixed-vertex-halos';
|
|
110
|
+
|
|
111
|
+
export {updateTerrainMixedVertexTileHalos} from './mixed-halo-update';
|
|
112
|
+
|
|
113
|
+
export {updateTerrainMixedGradientGrids} from './mixed-gradient-update';
|
|
114
|
+
|
|
115
|
+
export {simplifyTerrainContourPathsTopology} from './contour-topology';
|
|
116
|
+
export type {TerrainMixedHaloSnapshot} from './mixed-halo-update';
|
|
117
|
+
export type {TerrainMixedGradientSnapshot} from './mixed-gradient-update';
|
|
118
|
+
|
|
119
|
+
export {createTerrainIsobands} from './isobands';
|
|
120
|
+
export type {TerrainIsobands} from './isobands';
|
|
121
|
+
|
|
122
|
+
export {updateTerrainMeshes} from './mesh-update';
|
|
123
|
+
export type {TerrainMeshSnapshot} from './mesh-update';
|
|
124
|
+
|
|
125
|
+
export {updateTerrainBounds} from './bounds-update';
|
|
126
|
+
export type {TerrainBoundsSnapshot} from './bounds-update';
|
|
127
|
+
|
|
128
|
+
export {updateTerrainGradientPyramids} from './gradient-pyramid-update';
|
|
129
|
+
export type {TerrainGradientPyramidSnapshot} from './gradient-pyramid-update';
|
|
130
|
+
export type {TerrainFieldTile} from './tile-update-data';
|
|
131
|
+
|
|
132
|
+
export {updateTerrainMeshRegions} from './mesh-regions';
|
|
133
|
+
export type {TerrainRegularMeshRegions} from './mesh-regions';
|
|
134
|
+
|
|
135
|
+
export {updateTerrainMartiniMeshRegions} from './martini-regions';
|
|
136
|
+
export type {TerrainMartiniMeshRegions} from './martini-regions';
|
|
137
|
+
|
|
138
|
+
export {updateTerrainDelatinMeshRegions} from './delatin-regions';
|
|
139
|
+
export type {TerrainDelatinMeshRegions} from './delatin-regions';
|
|
140
|
+
|
|
141
|
+
export {updateTerrainBoundsRegions} from './bounds-regions';
|
|
142
|
+
export type {TerrainBoundsRegions} from './bounds-regions';
|
|
143
|
+
|
|
144
|
+
export {updateTerrainGradientPyramidRegions} from './gradient-pyramid-regions';
|
|
145
|
+
export type {TerrainGradientPyramidRegions} from './gradient-pyramid-regions';
|
|
146
|
+
export type {TerrainDirtyWindow} from './dirty-regions';
|
|
147
|
+
|
|
148
|
+
export {updateTerrainPersistentBounds} from './persistent-bounds';
|
|
149
|
+
export type {TerrainPersistentBounds} from './persistent-bounds';
|
|
150
|
+
|
|
151
|
+
export {updateTerrainPersistentGradients} from './persistent-gradients';
|
|
152
|
+
export type {TerrainPersistentGradients} from './persistent-gradients';
|
|
153
|
+
|
|
154
|
+
export {getTerrainHierarchyNode} from './persistent-hierarchy-data';
|
|
155
|
+
export type {TerrainPersistentLevel} from './persistent-hierarchy-data';
|
|
156
|
+
|
|
157
|
+
export {createTerrainLodMorph} from './lod-morph';
|
|
158
|
+
export type {TerrainLodMorph} from './lod-morph';
|
|
159
|
+
|
|
160
|
+
export {evaluateTerrainLodMorph} from './lod-morph-evaluate';
|
|
161
|
+
export {TerrainMorphStatus} from './lod-morph';
|
|
162
|
+
export type {TerrainHierarchyBlock, TerrainHierarchyUpdateStats} from './persistent-hierarchy-data';
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {createTerrainBoxIndex} from './box-index';
|
|
5
|
+
import type {HeightField} from './height-field';
|
|
6
|
+
|
|
7
|
+
export type TerrainIsobands = {
|
|
8
|
+
/** World XY polygon footprint vertices. */
|
|
9
|
+
positions: Float64Array;
|
|
10
|
+
indices: Uint32Array;
|
|
11
|
+
offsets: Uint32Array;
|
|
12
|
+
bandIndices: Uint32Array;
|
|
13
|
+
/** -1 for outer rings; otherwise the containing outer ring index. */
|
|
14
|
+
parents: Int32Array;
|
|
15
|
+
levels: Float64Array;
|
|
16
|
+
heightReference: string;
|
|
17
|
+
};
|
|
18
|
+
type Vertex = {x: number; y: number; z: number; key: string; support: string[]};
|
|
19
|
+
|
|
20
|
+
/** Polygonize intervals of the regular triangle surface. Adjacent conforming tiles
|
|
21
|
+
* share exact XY samples; mixed-resolution seams require prior reconciliation.
|
|
22
|
+
* Incomplete triangles are omitted. Rings include domain and nodata boundaries.
|
|
23
|
+
*/
|
|
24
|
+
export function createTerrainIsobands(
|
|
25
|
+
fields: readonly HeightField[],
|
|
26
|
+
levels: readonly number[],
|
|
27
|
+
options: {
|
|
28
|
+
maxTriangles?: number;
|
|
29
|
+
maxVertices?: number;
|
|
30
|
+
maxEdges?: number;
|
|
31
|
+
maxTests?: number;
|
|
32
|
+
maxLevels?: number;
|
|
33
|
+
} = {}
|
|
34
|
+
): TerrainIsobands {
|
|
35
|
+
const maxLevels = options.maxLevels ?? 256;
|
|
36
|
+
if (!Number.isSafeInteger(maxLevels) || maxLevels < 2 || levels.length > maxLevels)
|
|
37
|
+
throw new Error('Isoband level capacity exceeded');
|
|
38
|
+
if (
|
|
39
|
+
levels.length < 2 ||
|
|
40
|
+
levels.some((v, i) => !Number.isFinite(v) || (i > 0 && v <= levels[i - 1]))
|
|
41
|
+
)
|
|
42
|
+
throw new Error('Invalid isoband levels');
|
|
43
|
+
const maxTriangles = options.maxTriangles ?? 2_000_000,
|
|
44
|
+
maxVertices = options.maxVertices ?? 2_000_000,
|
|
45
|
+
maxEdges = options.maxEdges ?? 6 * maxTriangles,
|
|
46
|
+
maxTests = options.maxTests ?? 32 * maxTriangles;
|
|
47
|
+
if (
|
|
48
|
+
![maxTriangles, maxVertices, maxEdges, maxTests].every(n => Number.isSafeInteger(n) && n >= 0)
|
|
49
|
+
)
|
|
50
|
+
throw new Error('Invalid isoband capacity');
|
|
51
|
+
const count = fields.reduce((n, f) => n + 2 * (f.width - 1) * (f.height - 1), 0);
|
|
52
|
+
if (!Number.isSafeInteger(count) || count > maxTriangles)
|
|
53
|
+
throw new Error('Isoband triangle capacity exceeded');
|
|
54
|
+
const originals = new Map<string, Vertex>(),
|
|
55
|
+
vertices = new Map<string, Vertex>();
|
|
56
|
+
const frame = fields[0];
|
|
57
|
+
for (const f of fields)
|
|
58
|
+
if (f.heightReference !== frame.heightReference)
|
|
59
|
+
throw new Error('Isoband height references differ');
|
|
60
|
+
let tests = 0,
|
|
61
|
+
edgeCount = 0;
|
|
62
|
+
const charge = () => {
|
|
63
|
+
if (++tests > maxTests) throw new Error('Isoband work budget exceeded');
|
|
64
|
+
};
|
|
65
|
+
// Only conforming same-resolution sample rectangles may be assembled directly.
|
|
66
|
+
const rectangles = fields.map(f => {
|
|
67
|
+
if (
|
|
68
|
+
f.registration !== frame.registration ||
|
|
69
|
+
f.columnStep.some((v, i) => v !== frame.columnStep[i]) ||
|
|
70
|
+
f.rowStep.some((v, i) => v !== frame.rowStep[i])
|
|
71
|
+
)
|
|
72
|
+
throw new Error('Isoband tiles require a conforming common frame');
|
|
73
|
+
const dx = f.origin[0] - frame.origin[0],
|
|
74
|
+
dy = f.origin[1] - frame.origin[1];
|
|
75
|
+
const determinant =
|
|
76
|
+
frame.columnStep[0] * frame.rowStep[1] - frame.columnStep[1] * frame.rowStep[0];
|
|
77
|
+
const x = Math.round((dx * frame.rowStep[1] - dy * frame.rowStep[0]) / determinant),
|
|
78
|
+
y = Math.round((dy * frame.columnStep[0] - dx * frame.columnStep[1]) / determinant);
|
|
79
|
+
if (!Number.isSafeInteger(x) || !Number.isSafeInteger(y))
|
|
80
|
+
throw new Error('Isoband tiles require integral lattice origins');
|
|
81
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
82
|
+
const a = x * frame.columnStep[axis],
|
|
83
|
+
b = y * frame.rowStep[axis];
|
|
84
|
+
const expected = frame.origin[axis] + a + b;
|
|
85
|
+
const tolerance = Math.min(
|
|
86
|
+
16 *
|
|
87
|
+
Number.EPSILON *
|
|
88
|
+
Math.max(
|
|
89
|
+
1,
|
|
90
|
+
Math.abs(f.origin[axis]),
|
|
91
|
+
Math.abs(frame.origin[axis]),
|
|
92
|
+
Math.abs(a),
|
|
93
|
+
Math.abs(b)
|
|
94
|
+
),
|
|
95
|
+
1e-9 * Math.max(Math.abs(frame.columnStep[axis]), Math.abs(frame.rowStep[axis]))
|
|
96
|
+
);
|
|
97
|
+
if (!Number.isFinite(expected) || Math.abs(f.origin[axis] - expected) > tolerance)
|
|
98
|
+
throw new Error('Isoband tiles require integral lattice origins');
|
|
99
|
+
}
|
|
100
|
+
return {x, y, right: x + f.width - 1, top: y + f.height - 1};
|
|
101
|
+
});
|
|
102
|
+
const rectangleBoxes = rectangles.map(r => ({minX: r.x, minY: r.y, maxX: r.right, maxY: r.top})),
|
|
103
|
+
rectangleIndex = createTerrainBoxIndex(rectangleBoxes);
|
|
104
|
+
const rangeIndex = createTerrainBoxIndex(
|
|
105
|
+
fields.map(f => ({
|
|
106
|
+
minX: f.heightRange?.[0] ?? Infinity,
|
|
107
|
+
maxX: f.heightRange?.[1] ?? -Infinity,
|
|
108
|
+
minY: 0,
|
|
109
|
+
maxY: 0
|
|
110
|
+
}))
|
|
111
|
+
);
|
|
112
|
+
for (let i = 0; i < rectangles.length; i++)
|
|
113
|
+
for (const j of rectangleIndex(rectangleBoxes[i], charge)) {
|
|
114
|
+
if (j <= i) continue;
|
|
115
|
+
charge();
|
|
116
|
+
const a = rectangles[i],
|
|
117
|
+
b = rectangles[j];
|
|
118
|
+
if (a.x < b.right && b.x < a.right && a.y < b.top && b.y < a.top)
|
|
119
|
+
throw new Error('Overlapping isoband tiles');
|
|
120
|
+
// Validate every shared sample even if a field is later excluded by range.
|
|
121
|
+
for (let y = Math.max(a.y, b.y); y <= Math.min(a.top, b.top); y++)
|
|
122
|
+
for (let x = Math.max(a.x, b.x); x <= Math.min(a.right, b.right); x++) {
|
|
123
|
+
charge();
|
|
124
|
+
const u = fields[i].getHeight(x - a.x, y - a.y),
|
|
125
|
+
v = fields[j].getHeight(x - b.x, y - b.y);
|
|
126
|
+
if (u !== undefined && v !== undefined && u !== v)
|
|
127
|
+
throw new Error('Isoband shared heights differ');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const rings: Vertex[][] = [],
|
|
131
|
+
bands: number[] = [];
|
|
132
|
+
const register = (v: Vertex) => {
|
|
133
|
+
if (!vertices.has(v.key)) {
|
|
134
|
+
if (vertices.size >= maxVertices) throw new Error('Isoband vertex capacity exceeded');
|
|
135
|
+
vertices.set(v.key, v);
|
|
136
|
+
}
|
|
137
|
+
return vertices.get(v.key)!;
|
|
138
|
+
};
|
|
139
|
+
const clip = (poly: Vertex[], level: number, above: boolean): Vertex[] => {
|
|
140
|
+
const out: Vertex[] = [];
|
|
141
|
+
for (let i = 0; i < poly.length; i++) {
|
|
142
|
+
charge();
|
|
143
|
+
const a = poly[i],
|
|
144
|
+
b = poly[(i + 1) % poly.length],
|
|
145
|
+
ia = above ? a.z >= level : a.z <= level,
|
|
146
|
+
ib = above ? b.z >= level : b.z <= level;
|
|
147
|
+
if (ia) out.push(a);
|
|
148
|
+
if (ia !== ib) {
|
|
149
|
+
if (a.z === level) {
|
|
150
|
+
out.push(a);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (b.z === level) {
|
|
154
|
+
out.push(b);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const support = [...new Set([...a.support, ...b.support])].sort();
|
|
158
|
+
if (support.length !== 2) throw new Error('Invalid isoband intersection support');
|
|
159
|
+
const u = originals.get(support[0])!,
|
|
160
|
+
v = originals.get(support[1])!;
|
|
161
|
+
const scale = Math.max(Math.abs(u.z), Math.abs(v.z), Math.abs(level), 1);
|
|
162
|
+
const t = (level / scale - u.z / scale) / (v.z / scale - u.z / scale);
|
|
163
|
+
const point = {
|
|
164
|
+
x: u.x * (1 - t) + v.x * t,
|
|
165
|
+
y: u.y * (1 - t) + v.y * t,
|
|
166
|
+
z: level,
|
|
167
|
+
key: `e:${support.join('|')}:${level}`,
|
|
168
|
+
support
|
|
169
|
+
};
|
|
170
|
+
if (![point.x, point.y, t].every(Number.isFinite))
|
|
171
|
+
throw new Error('Isoband arithmetic overflow');
|
|
172
|
+
out.push(register(point));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return out.filter((v, i) => v.key !== out[(i + 1) % out.length].key);
|
|
176
|
+
};
|
|
177
|
+
for (let band = 0; band + 1 < levels.length; band++) {
|
|
178
|
+
const edges = new Map<string, {a: Vertex; b: Vertex}>();
|
|
179
|
+
for (const fieldId of rangeIndex(
|
|
180
|
+
{minX: levels[band], maxX: levels[band + 1], minY: 0, maxY: 0},
|
|
181
|
+
charge
|
|
182
|
+
))
|
|
183
|
+
for (let y = 0; y < fields[fieldId].height - 1; y++)
|
|
184
|
+
for (let x = 0; x < fields[fieldId].width - 1; x++) {
|
|
185
|
+
const f = fields[fieldId];
|
|
186
|
+
const nodes = [
|
|
187
|
+
[x, y],
|
|
188
|
+
[x + 1, y],
|
|
189
|
+
[x, y + 1],
|
|
190
|
+
[x + 1, y + 1]
|
|
191
|
+
].map(([c, r]) => {
|
|
192
|
+
const z = f.getHeight(c, r);
|
|
193
|
+
if (z === undefined) return undefined;
|
|
194
|
+
const shift = f.registration === 'cell' ? 0.5 : 0;
|
|
195
|
+
const px =
|
|
196
|
+
frame.origin[0] +
|
|
197
|
+
(rectangles[fieldId].x + c + shift) * frame.columnStep[0] +
|
|
198
|
+
(rectangles[fieldId].y + r + shift) * frame.rowStep[0],
|
|
199
|
+
py =
|
|
200
|
+
frame.origin[1] +
|
|
201
|
+
(rectangles[fieldId].x + c + shift) * frame.columnStep[1] +
|
|
202
|
+
(rectangles[fieldId].y + r + shift) * frame.rowStep[1];
|
|
203
|
+
if (![px, py].every(Number.isFinite)) throw new Error('Isoband coordinate overflow');
|
|
204
|
+
const key = `v:${px},${py}`,
|
|
205
|
+
v = {x: px, y: py, z, key, support: [key]};
|
|
206
|
+
const old = originals.get(key);
|
|
207
|
+
if (old && old.z !== z) throw new Error('Isoband shared heights differ');
|
|
208
|
+
originals.set(key, v);
|
|
209
|
+
return v;
|
|
210
|
+
});
|
|
211
|
+
for (const ids of f.diagonal === '00-11'
|
|
212
|
+
? [
|
|
213
|
+
[0, 1, 3],
|
|
214
|
+
[0, 3, 2]
|
|
215
|
+
]
|
|
216
|
+
: [
|
|
217
|
+
[0, 1, 2],
|
|
218
|
+
[1, 3, 2]
|
|
219
|
+
]) {
|
|
220
|
+
charge();
|
|
221
|
+
if (ids.some(i => !nodes[i])) continue;
|
|
222
|
+
let poly = ids.map(i => nodes[i]!);
|
|
223
|
+
// Constant-height triangles belong to exactly one interval (last upper endpoint inclusive).
|
|
224
|
+
if (poly.every(v => v.z === levels[band + 1]) && band + 2 < levels.length) continue;
|
|
225
|
+
if (
|
|
226
|
+
(poly[1].x - poly[0].x) * (poly[2].y - poly[0].y) -
|
|
227
|
+
(poly[1].y - poly[0].y) * (poly[2].x - poly[0].x) <
|
|
228
|
+
0
|
|
229
|
+
)
|
|
230
|
+
poly.reverse();
|
|
231
|
+
poly = clip(clip(poly, levels[band], true), levels[band + 1], false);
|
|
232
|
+
if (poly.length < 3) continue;
|
|
233
|
+
const area = poly.reduce((n, a, i) => {
|
|
234
|
+
const b = poly[(i + 1) % poly.length],
|
|
235
|
+
o = poly[0];
|
|
236
|
+
return n + (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);
|
|
237
|
+
}, 0);
|
|
238
|
+
if (!Number.isFinite(area)) throw new Error('Isoband area arithmetic overflow');
|
|
239
|
+
if (area === 0) continue;
|
|
240
|
+
for (let i = 0; i < poly.length; i++) {
|
|
241
|
+
const a = register(poly[i]),
|
|
242
|
+
b = register(poly[(i + 1) % poly.length]);
|
|
243
|
+
if (++edgeCount > maxEdges) throw new Error('Isoband edge capacity exceeded');
|
|
244
|
+
const key = `${a.key}>${b.key}`,
|
|
245
|
+
reverse = `${b.key}>${a.key}`;
|
|
246
|
+
if (edges.has(reverse)) edges.delete(reverse);
|
|
247
|
+
else {
|
|
248
|
+
if (edges.has(key)) throw new Error('Overlapping isoband tiles');
|
|
249
|
+
edges.set(key, {a, b});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const outgoing = new Map<string, Set<string>>();
|
|
255
|
+
for (const [key, e] of edges) {
|
|
256
|
+
if (!outgoing.has(e.a.key)) outgoing.set(e.a.key, new Set());
|
|
257
|
+
outgoing.get(e.a.key)!.add(key);
|
|
258
|
+
}
|
|
259
|
+
while (edges.size) {
|
|
260
|
+
const first = edges.values().next().value!,
|
|
261
|
+
ring: Vertex[] = [];
|
|
262
|
+
let edge = first;
|
|
263
|
+
for (;;) {
|
|
264
|
+
charge();
|
|
265
|
+
ring.push(edge.a);
|
|
266
|
+
edges.delete(`${edge.a.key}>${edge.b.key}`);
|
|
267
|
+
outgoing.get(edge.a.key)!.delete(`${edge.a.key}>${edge.b.key}`);
|
|
268
|
+
if (edge.b.key === first.a.key) break;
|
|
269
|
+
const choices = [...(outgoing.get(edge.b.key) ?? [])].map(k => edges.get(k)!);
|
|
270
|
+
if (!choices.length) throw new Error('Open isoband boundary');
|
|
271
|
+
const angle = (e: typeof edge) =>
|
|
272
|
+
Math.atan2(
|
|
273
|
+
(edge.b.x - edge.a.x) * (e.b.y - e.a.y) - (edge.b.y - edge.a.y) * (e.b.x - e.a.x),
|
|
274
|
+
(edge.b.x - edge.a.x) * (e.b.x - e.a.x) + (edge.b.y - edge.a.y) * (e.b.y - e.a.y)
|
|
275
|
+
);
|
|
276
|
+
choices.sort((a, b) => angle(b) - angle(a) || a.b.key.localeCompare(b.b.key));
|
|
277
|
+
edge = choices[0];
|
|
278
|
+
}
|
|
279
|
+
rings.push(ring);
|
|
280
|
+
bands.push(band);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const area = (ring: Vertex[]) =>
|
|
284
|
+
ring.reduce((n, a, i) => {
|
|
285
|
+
const b = ring[(i + 1) % ring.length],
|
|
286
|
+
o = ring[0];
|
|
287
|
+
return n + (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);
|
|
288
|
+
}, 0);
|
|
289
|
+
const areas = rings.map(area),
|
|
290
|
+
parents = new Int32Array(rings.length).fill(-1);
|
|
291
|
+
const ringBoxes = rings.map(r =>
|
|
292
|
+
r.reduce(
|
|
293
|
+
(b, v) => ({
|
|
294
|
+
minX: Math.min(b.minX, v.x),
|
|
295
|
+
minY: Math.min(b.minY, v.y),
|
|
296
|
+
maxX: Math.max(b.maxX, v.x),
|
|
297
|
+
maxY: Math.max(b.maxY, v.y)
|
|
298
|
+
}),
|
|
299
|
+
{minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity}
|
|
300
|
+
)
|
|
301
|
+
);
|
|
302
|
+
const ringIndex = createTerrainBoxIndex(ringBoxes);
|
|
303
|
+
for (let i = 0; i < rings.length; i++)
|
|
304
|
+
if (areas[i] < 0) {
|
|
305
|
+
let best = Infinity;
|
|
306
|
+
const q = rings[i][0];
|
|
307
|
+
for (const j of ringIndex({minX: q.x, maxX: q.x, minY: q.y, maxY: q.y}, charge))
|
|
308
|
+
if (bands[j] === bands[i] && areas[j] > 0) {
|
|
309
|
+
let inside = false;
|
|
310
|
+
const ring = rings[j];
|
|
311
|
+
for (let k = 0, l = ring.length - 1; k < ring.length; l = k++) {
|
|
312
|
+
charge();
|
|
313
|
+
const a = ring[k],
|
|
314
|
+
b = ring[l];
|
|
315
|
+
if (a.y > q.y !== b.y > q.y && q.x < ((b.x - a.x) * (q.y - a.y)) / (b.y - a.y) + a.x)
|
|
316
|
+
inside = !inside;
|
|
317
|
+
}
|
|
318
|
+
if (inside && areas[j] < best) {
|
|
319
|
+
parents[i] = j;
|
|
320
|
+
best = areas[j];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (parents[i] < 0) throw new Error('Uncontained isoband hole');
|
|
324
|
+
}
|
|
325
|
+
const used = new Map<string, number>(),
|
|
326
|
+
positions: number[] = [],
|
|
327
|
+
indices: number[] = [],
|
|
328
|
+
offsets = [0];
|
|
329
|
+
for (const ring of rings) {
|
|
330
|
+
for (const v of [...ring, ring[0]]) {
|
|
331
|
+
if (!used.has(v.key)) {
|
|
332
|
+
used.set(v.key, used.size);
|
|
333
|
+
positions.push(v.x, v.y);
|
|
334
|
+
}
|
|
335
|
+
indices.push(used.get(v.key)!);
|
|
336
|
+
}
|
|
337
|
+
offsets.push(indices.length);
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
positions: Float64Array.from(positions),
|
|
341
|
+
indices: Uint32Array.from(indices),
|
|
342
|
+
offsets: Uint32Array.from(offsets),
|
|
343
|
+
bandIndices: Uint32Array.from(bands),
|
|
344
|
+
parents,
|
|
345
|
+
levels: Float64Array.from(levels),
|
|
346
|
+
heightReference: frame?.heightReference ?? 'unknown'
|
|
347
|
+
};
|
|
348
|
+
}
|