@math.gl/geospatial 5.0.0-beta.8 → 5.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/crs/crs-descriptor-types.d.ts +2 -1
- package/dist/crs/crs-descriptor-types.d.ts.map +1 -1
- package/dist/crs/index.cjs +54 -0
- package/dist/crs/index.cjs.map +2 -2
- package/dist/crs/index.d.ts +1 -0
- package/dist/crs/index.d.ts.map +1 -1
- package/dist/crs/index.js +1 -0
- package/dist/crs/index.js.map +1 -1
- package/dist/crs/spatial-reference-metadata.d.ts +20 -0
- package/dist/crs/spatial-reference-metadata.d.ts.map +1 -0
- package/dist/crs/spatial-reference-metadata.js +86 -0
- package/dist/crs/spatial-reference-metadata.js.map +1 -0
- package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts +1 -1
- package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts.map +1 -1
- package/dist/ellipsoid-helpers/ellipsoid-transform.js +2 -2
- package/dist/ellipsoid-helpers/ellipsoid-transform.js.map +1 -1
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js +1 -1
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/ellipsoid-helpers/tangent-plane-numerics.d.ts +1 -1
- package/dist/ellipsoid-helpers/tangent-plane-numerics.d.ts.map +1 -1
- package/dist/ellipsoid-tangent-plane.d.ts +2 -2
- package/dist/ellipsoid-tangent-plane.d.ts.map +1 -1
- package/dist/ellipsoid-tangent-plane.js +1 -1
- package/dist/ellipsoid-tangent-plane.js.map +1 -1
- package/dist/ellipsoid-transforms.d.ts +2 -2
- package/dist/ellipsoid-transforms.d.ts.map +1 -1
- package/dist/ellipsoid-transforms.js +1 -1
- package/dist/ellipsoid-transforms.js.map +1 -1
- package/dist/ellipsoid.d.ts +2 -2
- package/dist/ellipsoid.d.ts.map +1 -1
- package/dist/ellipsoid.js +2 -2
- package/dist/ellipsoid.js.map +1 -1
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.d.ts.map +1 -1
- package/dist/expressions.js +1 -1
- package/dist/expressions.js.map +1 -1
- package/dist/geodesic-buffer.d.ts +1 -1
- package/dist/geodesic-buffer.d.ts.map +1 -1
- package/dist/geodesic-path.d.ts +1 -1
- package/dist/geodesic-path.d.ts.map +1 -1
- package/dist/geometry-constructors.d.ts +6 -0
- package/dist/geometry-constructors.d.ts.map +1 -0
- package/dist/geometry-constructors.js +37 -0
- package/dist/geometry-constructors.js.map +1 -0
- package/dist/geometry-inspection.d.ts +8 -0
- package/dist/geometry-inspection.d.ts.map +1 -0
- package/dist/geometry-inspection.js +61 -0
- package/dist/geometry-inspection.js.map +1 -0
- package/dist/index.cjs +3773 -846
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +173 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -1
- package/dist/line-simplification.d.ts +4 -0
- package/dist/line-simplification.d.ts.map +1 -0
- package/dist/line-simplification.js +83 -0
- package/dist/line-simplification.js.map +1 -0
- package/dist/linear-referencing.d.ts +6 -0
- package/dist/linear-referencing.d.ts.map +1 -0
- package/dist/linear-referencing.js +74 -0
- package/dist/linear-referencing.js.map +1 -0
- package/dist/lng-lat-rectangle.d.ts +1 -1
- package/dist/lng-lat-rectangle.d.ts.map +1 -1
- package/dist/lng-lat-rectangle.js +1 -1
- package/dist/lng-lat-rectangle.js.map +1 -1
- package/dist/local-reference-frame.d.ts +3 -3
- package/dist/local-reference-frame.d.ts.map +1 -1
- package/dist/local-reference-frame.js +2 -2
- package/dist/local-reference-frame.js.map +1 -1
- package/dist/make-obb-from-region.d.ts +1 -1
- package/dist/make-obb-from-region.d.ts.map +1 -1
- package/dist/make-obb-from-region.js +1 -1
- package/dist/make-obb-from-region.js.map +1 -1
- package/dist/maps/air-ocean-mesh.js +1 -1
- package/dist/maps/air-ocean-mesh.js.map +1 -1
- package/dist/maps/myriahedral/unfold.d.ts +1 -1
- package/dist/maps/myriahedral/unfold.d.ts.map +1 -1
- package/dist/maps/myriahedral/unfold.js +1 -1
- package/dist/maps/myriahedral/unfold.js.map +1 -1
- package/dist/maps/presets.cjs +6 -6
- package/dist/maps/presets.cjs.map +2 -2
- package/dist/maps.cjs +6 -6
- package/dist/maps.cjs.map +2 -2
- package/dist/projection/deformation.cjs +5 -5
- package/dist/projection/deformation.cjs.map +2 -2
- package/dist/projection/experimental/core.cjs +8 -4
- package/dist/projection/experimental/core.cjs.map +1 -1
- package/dist/projection/experimental/crs/spatial-reference.d.ts.map +1 -1
- package/dist/projection/experimental/crs/spatial-reference.js.map +1 -1
- package/dist/projection/experimental/crs/types.d.ts +1 -1
- package/dist/projection/experimental/crs/types.d.ts.map +1 -1
- package/dist/projection/experimental/crs-rendering-scale.d.ts.map +1 -1
- package/dist/projection/experimental/crs-rendering-scale.js +13 -2
- package/dist/projection/experimental/crs-rendering-scale.js.map +1 -1
- package/dist/projection/experimental/datum.js +1 -1
- package/dist/projection/experimental/datum.js.map +1 -1
- package/dist/projection/experimental/entries/projections/geocent.cjs +3 -3
- package/dist/projection/experimental/entries/projections/geocent.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/aea.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/aea.js +4 -1
- package/dist/projection/experimental/lazy-projections/aea.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.js +4 -1
- package/dist/projection/experimental/lazy-projections/bonne.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/cass.js +4 -1
- package/dist/projection/experimental/lazy-projections/cass.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.js +4 -1
- package/dist/projection/experimental/lazy-projections/eck6.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js +4 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js +4 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/equi.js +4 -1
- package/dist/projection/experimental/lazy-projections/equi.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.js +4 -1
- package/dist/projection/experimental/lazy-projections/geocent.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/geos.js +4 -1
- package/dist/projection/experimental/lazy-projections/geos.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.js +4 -1
- package/dist/projection/experimental/lazy-projections/gnom.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +100 -27
- package/dist/projection/experimental/lazy-projections/index.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/krovak.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.js +4 -1
- package/dist/projection/experimental/lazy-projections/krovak.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/merc.js +4 -1
- package/dist/projection/experimental/lazy-projections/merc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/mill.js +4 -1
- package/dist/projection/experimental/lazy-projections/mill.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/moll.js +4 -1
- package/dist/projection/experimental/lazy-projections/moll.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js +4 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.js +4 -1
- package/dist/projection/experimental/lazy-projections/omerc.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.js +4 -1
- package/dist/projection/experimental/lazy-projections/ortho.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/poly.js +4 -1
- package/dist/projection/experimental/lazy-projections/poly.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/robin.js +4 -1
- package/dist/projection/experimental/lazy-projections/robin.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.js +4 -1
- package/dist/projection/experimental/lazy-projections/sinu.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/stere.js +4 -1
- package/dist/projection/experimental/lazy-projections/stere.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.js +4 -1
- package/dist/projection/experimental/lazy-projections/tpers.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs +4 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.d.ts.map +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.js +4 -1
- package/dist/projection/experimental/lazy-projections/vandg.js.map +1 -1
- package/dist/projection/experimental/spatial-deformation.js +1 -1
- package/dist/projection/experimental/spatial-deformation.js.map +1 -1
- package/dist/projection/index.cjs +8 -4
- package/dist/projection/index.cjs.map +1 -1
- package/dist/projection/index.d.ts.map +1 -1
- package/dist/projection/index.js.map +1 -1
- package/dist/projection/lib/projection.js.map +1 -1
- package/dist/projection/pipeline.cjs +3 -3
- package/dist/projection/pipeline.cjs.map +1 -1
- package/dist/projection/temporal.cjs +5 -5
- package/dist/projection/temporal.cjs.map +2 -2
- package/dist/projection/transform-analysis.cjs +3 -3
- package/dist/projection/transform-analysis.cjs.map +1 -1
- package/dist/rhumb-path.d.ts +1 -1
- package/dist/rhumb-path.d.ts.map +1 -1
- package/dist/spatial-planar-intersects.d.ts +4 -0
- package/dist/spatial-planar-intersects.d.ts.map +1 -0
- package/dist/spatial-planar-intersects.js +108 -0
- package/dist/spatial-planar-intersects.js.map +1 -0
- package/dist/spatial-planar.d.ts +16 -0
- package/dist/spatial-planar.d.ts.map +1 -0
- package/dist/spatial-planar.js +240 -0
- package/dist/spatial-planar.js.map +1 -0
- package/dist/spatial-sql.d.ts +45 -0
- package/dist/spatial-sql.d.ts.map +1 -0
- package/dist/spatial-sql.js +192 -0
- package/dist/spatial-sql.js.map +1 -0
- package/dist/st-functions.cjs +1616 -0
- package/dist/st-functions.cjs.map +6 -0
- package/dist/st-functions.d.ts +307 -0
- package/dist/st-functions.d.ts.map +1 -0
- package/dist/st-functions.js +593 -0
- package/dist/st-functions.js.map +1 -0
- package/dist/subdivide-globe-mesh.js +1 -1
- package/dist/subdivide-globe-mesh.js.map +1 -1
- package/dist/tasks/index.cjs +1266 -155
- package/dist/tasks/index.cjs.map +3 -3
- package/dist/tasks/index.d.ts +12 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +26 -0
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/terrain-coverage-worker.d.ts +2 -0
- package/dist/tasks/terrain-coverage-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage-worker.js +7 -0
- package/dist/tasks/terrain-coverage-worker.js.map +1 -0
- package/dist/tasks/terrain-coverage.d.ts +25 -0
- package/dist/tasks/terrain-coverage.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage.js +15 -0
- package/dist/tasks/terrain-coverage.js.map +1 -0
- package/dist/tasks/terrain-residency-worker.d.ts +2 -0
- package/dist/tasks/terrain-residency-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-residency-worker.js +7 -0
- package/dist/tasks/terrain-residency-worker.js.map +1 -0
- package/dist/tasks/terrain-residency.d.ts +73 -0
- package/dist/tasks/terrain-residency.d.ts.map +1 -0
- package/dist/tasks/terrain-residency.js +203 -0
- package/dist/tasks/terrain-residency.js.map +1 -0
- package/dist/terrain/breakline-mesh.d.ts +18 -0
- package/dist/terrain/breakline-mesh.d.ts.map +1 -0
- package/dist/terrain/breakline-mesh.js +126 -0
- package/dist/terrain/breakline-mesh.js.map +1 -0
- package/dist/terrain/breakline-preprocess.d.ts +11 -0
- package/dist/terrain/breakline-preprocess.d.ts.map +1 -0
- package/dist/terrain/breakline-preprocess.js +94 -0
- package/dist/terrain/breakline-preprocess.js.map +1 -0
- package/dist/terrain/continuous-mesh-error.d.ts +34 -0
- package/dist/terrain/continuous-mesh-error.d.ts.map +1 -0
- package/dist/terrain/continuous-mesh-error.js +221 -0
- package/dist/terrain/continuous-mesh-error.js.map +1 -0
- package/dist/terrain/cutout-polygons.d.ts +21 -0
- package/dist/terrain/cutout-polygons.d.ts.map +1 -0
- package/dist/terrain/cutout-polygons.js +172 -0
- package/dist/terrain/cutout-polygons.js.map +1 -0
- package/dist/terrain/cutout-region.d.ts +34 -0
- package/dist/terrain/cutout-region.d.ts.map +1 -0
- package/dist/terrain/cutout-region.js +33 -0
- package/dist/terrain/cutout-region.js.map +1 -0
- package/dist/terrain/cutout-skirts.d.ts +34 -0
- package/dist/terrain/cutout-skirts.d.ts.map +1 -0
- package/dist/terrain/cutout-skirts.js +29 -0
- package/dist/terrain/cutout-skirts.js.map +1 -0
- package/dist/terrain/depression-fill.d.ts +25 -0
- package/dist/terrain/depression-fill.d.ts.map +1 -0
- package/dist/terrain/depression-fill.js +106 -0
- package/dist/terrain/depression-fill.js.map +1 -0
- package/dist/terrain/geographic-cutout.d.ts +38 -0
- package/dist/terrain/geographic-cutout.d.ts.map +1 -0
- package/dist/terrain/geographic-cutout.js +120 -0
- package/dist/terrain/geographic-cutout.js.map +1 -0
- package/dist/terrain/geographic-lod-seams.d.ts +10 -0
- package/dist/terrain/geographic-lod-seams.d.ts.map +1 -0
- package/dist/terrain/geographic-lod-seams.js +100 -0
- package/dist/terrain/geographic-lod-seams.js.map +1 -0
- package/dist/terrain/geographic-neighbor.d.ts +18 -0
- package/dist/terrain/geographic-neighbor.d.ts.map +1 -0
- package/dist/terrain/geographic-neighbor.js +44 -0
- package/dist/terrain/geographic-neighbor.js.map +1 -0
- package/dist/terrain/geographic-poles.d.ts +24 -0
- package/dist/terrain/geographic-poles.d.ts.map +1 -0
- package/dist/terrain/geographic-poles.js +34 -0
- package/dist/terrain/geographic-poles.js.map +1 -0
- package/dist/terrain/geographic-seam.d.ts +21 -0
- package/dist/terrain/geographic-seam.d.ts.map +1 -0
- package/dist/terrain/geographic-seam.js +52 -0
- package/dist/terrain/geographic-seam.js.map +1 -0
- package/dist/terrain/hydrology.d.ts +42 -0
- package/dist/terrain/hydrology.d.ts.map +1 -0
- package/dist/terrain/hydrology.js +112 -0
- package/dist/terrain/hydrology.js.map +1 -0
- package/dist/terrain/index.cjs +3158 -213
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +32 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +30 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/lod-screen-error.d.ts +28 -0
- package/dist/terrain/lod-screen-error.d.ts.map +1 -0
- package/dist/terrain/lod-screen-error.js +95 -0
- package/dist/terrain/lod-screen-error.js.map +1 -0
- package/dist/terrain/lod-select.d.ts +48 -0
- package/dist/terrain/lod-select.d.ts.map +1 -0
- package/dist/terrain/lod-select.js +73 -0
- package/dist/terrain/lod-select.js.map +1 -0
- package/dist/terrain/lod-stitch.d.ts +15 -0
- package/dist/terrain/lod-stitch.d.ts.map +1 -0
- package/dist/terrain/lod-stitch.js +64 -0
- package/dist/terrain/lod-stitch.js.map +1 -0
- package/dist/terrain/mesh-coverage.d.ts +35 -0
- package/dist/terrain/mesh-coverage.d.ts.map +1 -0
- package/dist/terrain/mesh-coverage.js +186 -0
- package/dist/terrain/mesh-coverage.js.map +1 -0
- package/dist/terrain/mesh-cutout.d.ts +45 -0
- package/dist/terrain/mesh-cutout.d.ts.map +1 -0
- package/dist/terrain/mesh-cutout.js +336 -0
- package/dist/terrain/mesh-cutout.js.map +1 -0
- package/dist/terrain/mesh-regions-data.d.ts +2 -2
- package/dist/terrain/mesh-regions-data.d.ts.map +1 -1
- package/dist/terrain/mesh-regions-data.js +20 -10
- package/dist/terrain/mesh-regions-data.js.map +1 -1
- package/dist/terrain/mesh-skirts.d.ts +8 -2
- package/dist/terrain/mesh-skirts.d.ts.map +1 -1
- package/dist/terrain/mesh-skirts.js +5 -4
- package/dist/terrain/mesh-skirts.js.map +1 -1
- package/dist/terrain/mixed-halo-update.d.ts.map +1 -1
- package/dist/terrain/mixed-halo-update.js +138 -26
- package/dist/terrain/mixed-halo-update.js.map +1 -1
- package/dist/terrain/mixed-vertex-halos.d.ts +34 -1
- package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -1
- package/dist/terrain/mixed-vertex-halos.js +98 -43
- package/dist/terrain/mixed-vertex-halos.js.map +1 -1
- package/dist/terrain/regional-viewshed.d.ts +55 -0
- package/dist/terrain/regional-viewshed.d.ts.map +1 -0
- package/dist/terrain/regional-viewshed.js +119 -0
- package/dist/terrain/regional-viewshed.js.map +1 -0
- package/dist/terrain/surface.d.ts +1 -1
- package/dist/terrain/surface.d.ts.map +1 -1
- package/dist/terrain/surface.js +1 -1
- package/dist/terrain/surface.js.map +1 -1
- package/dist/terrain/sweep-capsule.d.ts +27 -0
- package/dist/terrain/sweep-capsule.d.ts.map +1 -0
- package/dist/terrain/sweep-capsule.js +104 -0
- package/dist/terrain/sweep-capsule.js.map +1 -0
- package/dist/terrain/sweep-cylinder.d.ts +16 -0
- package/dist/terrain/sweep-cylinder.d.ts.map +1 -0
- package/dist/terrain/sweep-cylinder.js +52 -0
- package/dist/terrain/sweep-cylinder.js.map +1 -0
- package/dist/terrain/sweep-plane.d.ts +9 -0
- package/dist/terrain/sweep-plane.d.ts.map +1 -0
- package/dist/terrain/sweep-plane.js +52 -0
- package/dist/terrain/sweep-plane.js.map +1 -0
- package/dist/terrain/sweep-polytope.d.ts +42 -0
- package/dist/terrain/sweep-polytope.d.ts.map +1 -0
- package/dist/terrain/sweep-polytope.js +189 -0
- package/dist/terrain/sweep-polytope.js.map +1 -0
- package/dist/terrain/sweep-rotating-capsule.d.ts +17 -0
- package/dist/terrain/sweep-rotating-capsule.d.ts.map +1 -0
- package/dist/terrain/sweep-rotating-capsule.js +118 -0
- package/dist/terrain/sweep-rotating-capsule.js.map +1 -0
- package/dist/terrain/sweep-rotation.d.ts +35 -0
- package/dist/terrain/sweep-rotation.d.ts.map +1 -0
- package/dist/terrain/sweep-rotation.js +114 -0
- package/dist/terrain/sweep-rotation.js.map +1 -0
- package/dist/terrain/sweep-sphere.d.ts +27 -0
- package/dist/terrain/sweep-sphere.d.ts.map +1 -0
- package/dist/terrain/sweep-sphere.js +69 -0
- package/dist/terrain/sweep-sphere.js.map +1 -0
- package/dist/terrain/tile-cutout-update.d.ts +73 -0
- package/dist/terrain/tile-cutout-update.d.ts.map +1 -0
- package/dist/terrain/tile-cutout-update.js +181 -0
- package/dist/terrain/tile-cutout-update.js.map +1 -0
- package/dist/terrain/tile-cutout.d.ts +33 -0
- package/dist/terrain/tile-cutout.d.ts.map +1 -0
- package/dist/terrain/tile-cutout.js +93 -0
- package/dist/terrain/tile-cutout.js.map +1 -0
- package/dist/terrain/valid-domain-mesh.d.ts +29 -0
- package/dist/terrain/valid-domain-mesh.d.ts.map +1 -0
- package/dist/terrain/valid-domain-mesh.js +183 -0
- package/dist/terrain/valid-domain-mesh.js.map +1 -0
- package/dist/terrain/valid-domain-regions.d.ts +16 -0
- package/dist/terrain/valid-domain-regions.d.ts.map +1 -0
- package/dist/terrain/valid-domain-regions.js +19 -0
- package/dist/terrain/valid-domain-regions.js.map +1 -0
- package/dist/terrain/watershed-accumulation.d.ts +20 -0
- package/dist/terrain/watershed-accumulation.d.ts.map +1 -0
- package/dist/terrain/watershed-accumulation.js +53 -0
- package/dist/terrain/watershed-accumulation.js.map +1 -0
- package/dist/triaxial.d.ts +1 -1
- package/dist/triaxial.d.ts.map +1 -1
- package/dist/turf-expressions.cjs +1997 -0
- package/dist/turf-expressions.cjs.map +6 -0
- package/dist/turf-expressions.d.ts +3 -0
- package/dist/turf-expressions.d.ts.map +1 -0
- package/dist/turf-expressions.js +7 -0
- package/dist/turf-expressions.js.map +1 -0
- package/dist/turf-functions.cjs +743 -0
- package/dist/turf-functions.cjs.map +6 -0
- package/dist/turf-functions.d.ts +90 -0
- package/dist/turf-functions.d.ts.map +1 -0
- package/dist/{turf/expressions.js → turf-functions.js} +51 -5
- package/dist/turf-functions.js.map +1 -0
- package/dist/turf.cjs +25 -25
- package/dist/turf.cjs.map +2 -2
- package/dist/turf.d.ts +1 -1
- package/dist/turf.d.ts.map +1 -1
- package/dist/turf.js +2 -2
- package/dist/turf.js.map +1 -1
- package/dist/type-utils.d.ts +1 -1
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/type-utils.js +1 -1
- package/dist/type-utils.js.map +1 -1
- package/dist/web-mercator/assert.d.ts +2 -0
- package/dist/web-mercator/assert.d.ts.map +1 -0
- package/dist/web-mercator/assert.js +12 -0
- package/dist/web-mercator/assert.js.map +1 -0
- package/dist/web-mercator/fit-bounds.d.ts +52 -0
- package/dist/web-mercator/fit-bounds.d.ts.map +1 -0
- package/dist/web-mercator/fit-bounds.js +70 -0
- package/dist/web-mercator/fit-bounds.js.map +1 -0
- package/dist/web-mercator/fly-to-viewport.d.ts +19 -0
- package/dist/web-mercator/fly-to-viewport.d.ts.map +1 -0
- package/dist/web-mercator/fly-to-viewport.js +94 -0
- package/dist/web-mercator/fly-to-viewport.js.map +1 -0
- package/dist/web-mercator/get-bounds.d.ts +3 -0
- package/dist/web-mercator/get-bounds.d.ts.map +1 -0
- package/dist/web-mercator/get-bounds.js +56 -0
- package/dist/web-mercator/get-bounds.js.map +1 -0
- package/dist/web-mercator/index.cjs +705 -0
- package/dist/web-mercator/index.cjs.map +6 -0
- package/dist/web-mercator/index.d.ts +14 -0
- package/dist/web-mercator/index.d.ts.map +1 -0
- package/dist/web-mercator/index.js +14 -0
- package/dist/web-mercator/index.js.map +1 -0
- package/dist/web-mercator/math-utils.d.ts +7 -0
- package/dist/web-mercator/math-utils.d.ts.map +1 -0
- package/dist/web-mercator/math-utils.js +30 -0
- package/dist/web-mercator/math-utils.js.map +1 -0
- package/dist/web-mercator/mercator-meters.d.ts +29 -0
- package/dist/web-mercator/mercator-meters.d.ts.map +1 -0
- package/dist/web-mercator/mercator-meters.js +61 -0
- package/dist/web-mercator/mercator-meters.js.map +1 -0
- package/dist/web-mercator/normalize-viewport-props.d.ts +16 -0
- package/dist/web-mercator/normalize-viewport-props.d.ts.map +1 -0
- package/dist/web-mercator/normalize-viewport-props.js +45 -0
- package/dist/web-mercator/normalize-viewport-props.js.map +1 -0
- package/dist/web-mercator/web-mercator-utils.d.ts +192 -0
- package/dist/web-mercator/web-mercator-utils.d.ts.map +1 -0
- package/dist/web-mercator/web-mercator-utils.js +321 -0
- package/dist/web-mercator/web-mercator-utils.js.map +1 -0
- package/dist/web-mercator/web-mercator-viewport.d.ts +177 -0
- package/dist/web-mercator/web-mercator-viewport.d.ts.map +1 -0
- package/dist/web-mercator/web-mercator-viewport.js +276 -0
- package/dist/web-mercator/web-mercator-viewport.js.map +1 -0
- package/dist/web-mercator.d.ts +1 -1
- package/dist/web-mercator.d.ts.map +1 -1
- package/dist/web-mercator.js +1 -1
- package/dist/web-mercator.js.map +1 -1
- package/package.json +35 -462
- package/src/crs/crs-descriptor-types.ts +2 -1
- package/src/crs/index.ts +7 -0
- package/src/crs/spatial-reference-metadata.ts +118 -0
- package/src/ellipsoid-helpers/ellipsoid-transform.ts +3 -3
- package/src/ellipsoid-helpers/scale-to-geodetic-surface.ts +1 -1
- package/src/ellipsoid-helpers/tangent-plane-numerics.ts +1 -1
- package/src/ellipsoid-tangent-plane.ts +2 -2
- package/src/ellipsoid-transforms.ts +2 -2
- package/src/ellipsoid.ts +7 -3
- package/src/expressions.ts +2 -2
- package/src/geodesic-buffer.ts +1 -1
- package/src/geodesic-path.ts +1 -1
- package/src/geometry-constructors.ts +36 -0
- package/src/geometry-inspection.ts +66 -0
- package/src/index.ts +314 -4
- package/src/line-simplification.ts +97 -0
- package/src/linear-referencing.ts +94 -0
- package/src/lng-lat-rectangle.ts +1 -1
- package/src/local-reference-frame.ts +4 -4
- package/src/make-obb-from-region.ts +9 -1
- package/src/maps/air-ocean-mesh.ts +1 -1
- package/src/maps/myriahedral/unfold.ts +1 -1
- package/src/projection/experimental/crs/spatial-reference.ts +1 -6
- package/src/projection/experimental/crs/types.ts +2 -2
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/crs-descriptor.ts +1 -1
- package/src/projection/experimental/crs-rendering-scale.ts +16 -4
- package/src/projection/experimental/datum.ts +1 -1
- package/src/projection/experimental/lazy-projections/aea.ts +4 -1
- package/src/projection/experimental/lazy-projections/bonne.ts +4 -1
- package/src/projection/experimental/lazy-projections/cass.ts +4 -1
- package/src/projection/experimental/lazy-projections/eck6.ts +4 -1
- package/src/projection/experimental/lazy-projections/eqdc.ts +4 -1
- package/src/projection/experimental/lazy-projections/eqearth.ts +4 -1
- package/src/projection/experimental/lazy-projections/equi.ts +4 -1
- package/src/projection/experimental/lazy-projections/geocent.ts +4 -1
- package/src/projection/experimental/lazy-projections/geos.ts +4 -1
- package/src/projection/experimental/lazy-projections/gnom.ts +4 -1
- package/src/projection/experimental/lazy-projections/krovak.ts +4 -1
- package/src/projection/experimental/lazy-projections/merc.ts +4 -1
- package/src/projection/experimental/lazy-projections/mill.ts +4 -1
- package/src/projection/experimental/lazy-projections/moll.ts +4 -1
- package/src/projection/experimental/lazy-projections/nzmg.ts +4 -1
- package/src/projection/experimental/lazy-projections/omerc.ts +4 -1
- package/src/projection/experimental/lazy-projections/ortho.ts +4 -1
- package/src/projection/experimental/lazy-projections/poly.ts +4 -1
- package/src/projection/experimental/lazy-projections/robin.ts +4 -1
- package/src/projection/experimental/lazy-projections/sinu.ts +4 -1
- package/src/projection/experimental/lazy-projections/stere.ts +4 -1
- package/src/projection/experimental/lazy-projections/tpers.ts +4 -1
- package/src/projection/experimental/lazy-projections/vandg.ts +4 -1
- package/src/projection/experimental/spatial-deformation.ts +1 -1
- package/src/projection/index.ts +1 -1
- package/src/projection/lib/projection.ts +1 -1
- package/src/rhumb-path.ts +1 -1
- package/src/spatial-planar-intersects.ts +134 -0
- package/src/spatial-planar.ts +266 -0
- package/src/spatial-sql.ts +276 -0
- package/src/st-functions.ts +852 -0
- package/src/subdivide-globe-mesh.ts +1 -1
- package/src/tasks/index.ts +34 -0
- package/src/tasks/terrain-coverage-worker.ts +6 -0
- package/src/tasks/terrain-coverage.ts +25 -0
- package/src/tasks/terrain-residency-worker.ts +6 -0
- package/src/tasks/terrain-residency.ts +250 -0
- package/src/terrain/breakline-mesh.ts +164 -0
- package/src/terrain/breakline-preprocess.ts +106 -0
- package/src/terrain/cdt2d.d.ts +10 -0
- package/src/terrain/continuous-mesh-error.ts +321 -0
- package/src/terrain/cutout-polygons.ts +202 -0
- package/src/terrain/cutout-region.ts +54 -0
- package/src/terrain/cutout-skirts.ts +52 -0
- package/src/terrain/depression-fill.ts +125 -0
- package/src/terrain/geographic-cutout.ts +154 -0
- package/src/terrain/geographic-lod-seams.ts +109 -0
- package/src/terrain/geographic-neighbor.ts +58 -0
- package/src/terrain/geographic-poles.ts +52 -0
- package/src/terrain/geographic-seam.ts +73 -0
- package/src/terrain/hydrology.ts +149 -0
- package/src/terrain/index.ts +160 -0
- package/src/terrain/lod-screen-error.ts +128 -0
- package/src/terrain/lod-select.ts +129 -0
- package/src/terrain/lod-stitch.ts +88 -0
- package/src/terrain/mesh-coverage.ts +215 -0
- package/src/terrain/mesh-cutout.ts +420 -0
- package/src/terrain/mesh-regions-data.ts +21 -13
- package/src/terrain/mesh-skirts.ts +10 -7
- package/src/terrain/mixed-halo-update.ts +147 -25
- package/src/terrain/mixed-vertex-halos.ts +125 -55
- package/src/terrain/regional-viewshed.ts +177 -0
- package/src/terrain/surface.ts +1 -1
- package/src/terrain/sweep-capsule.ts +148 -0
- package/src/terrain/sweep-cylinder.ts +64 -0
- package/src/terrain/sweep-plane.ts +61 -0
- package/src/terrain/sweep-polytope.ts +253 -0
- package/src/terrain/sweep-rotating-capsule.ts +139 -0
- package/src/terrain/sweep-rotation.ts +149 -0
- package/src/terrain/sweep-sphere.ts +100 -0
- package/src/terrain/tile-cutout-update.ts +293 -0
- package/src/terrain/tile-cutout.ts +123 -0
- package/src/terrain/valid-domain-mesh.ts +221 -0
- package/src/terrain/valid-domain-regions.ts +41 -0
- package/src/terrain/watershed-accumulation.ts +67 -0
- package/src/triaxial.ts +1 -1
- package/src/turf-expressions.ts +7 -0
- package/src/{turf/expressions.ts → turf-functions.ts} +121 -6
- package/src/turf.ts +3 -7
- package/src/type-utils.ts +2 -2
- package/src/web-mercator/assert.ts +11 -0
- package/src/web-mercator/fit-bounds.ts +132 -0
- package/src/web-mercator/fly-to-viewport.ts +157 -0
- package/src/web-mercator/get-bounds.ts +62 -0
- package/src/web-mercator/index.ts +49 -0
- package/src/web-mercator/math-utils.ts +35 -0
- package/src/web-mercator/mercator-meters.ts +83 -0
- package/src/web-mercator/normalize-viewport-props.ts +58 -0
- package/src/web-mercator/web-mercator-utils.ts +468 -0
- package/src/web-mercator/web-mercator-viewport.ts +406 -0
- package/src/web-mercator.ts +1 -1
- package/dist/projection/experimental/index.cjs +0 -11707
- package/dist/projection/experimental/index.cjs.map +0 -6
- package/dist/turf/expressions.cjs +0 -87
- package/dist/turf/expressions.cjs.map +0 -6
- package/dist/turf/expressions.d.ts +0 -24
- package/dist/turf/expressions.d.ts.map +0 -1
- package/dist/turf/expressions.js.map +0 -1
|
@@ -0,0 +1,1616 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// dist/st-functions.js
|
|
20
|
+
var st_functions_exports = {};
|
|
21
|
+
__export(st_functions_exports, {
|
|
22
|
+
POSTGIS_SPATIAL_FUNCTIONS: () => POSTGIS_SPATIAL_FUNCTIONS,
|
|
23
|
+
ST_AREA: () => ST_AREA,
|
|
24
|
+
ST_AZIMUTH: () => ST_AZIMUTH,
|
|
25
|
+
ST_CENTROID: () => ST_CENTROID,
|
|
26
|
+
ST_COLLECT: () => ST_COLLECT,
|
|
27
|
+
ST_CONTAINS: () => ST_CONTAINS,
|
|
28
|
+
ST_COVEREDBY: () => ST_COVEREDBY,
|
|
29
|
+
ST_COVERS: () => ST_COVERS,
|
|
30
|
+
ST_DISTANCE: () => ST_DISTANCE,
|
|
31
|
+
ST_DWITHIN: () => ST_DWITHIN,
|
|
32
|
+
ST_ENDPOINT: () => ST_ENDPOINT,
|
|
33
|
+
ST_ENVELOPE: () => ST_ENVELOPE,
|
|
34
|
+
ST_EXTENT: () => ST_EXTENT,
|
|
35
|
+
ST_FORCE2D: () => ST_FORCE2D,
|
|
36
|
+
ST_GEOMETRYN: () => ST_GEOMETRYN,
|
|
37
|
+
ST_GEOMETRYTYPE: () => ST_GEOMETRYTYPE,
|
|
38
|
+
ST_INTERSECTS: () => ST_INTERSECTS,
|
|
39
|
+
ST_ISEMPTY: () => ST_ISEMPTY,
|
|
40
|
+
ST_LENGTH: () => ST_LENGTH,
|
|
41
|
+
ST_LINEINTERPOLATEPOINT: () => ST_LINEINTERPOLATEPOINT,
|
|
42
|
+
ST_LINELOCATEPOINT: () => ST_LINELOCATEPOINT,
|
|
43
|
+
ST_LINESUBSTRING: () => ST_LINESUBSTRING,
|
|
44
|
+
ST_M: () => ST_M,
|
|
45
|
+
ST_MAKEENVELOPE: () => ST_MAKEENVELOPE,
|
|
46
|
+
ST_MAKELINE: () => ST_MAKELINE,
|
|
47
|
+
ST_MAKEPOINT: () => ST_MAKEPOINT,
|
|
48
|
+
ST_NPOINTS: () => ST_NPOINTS,
|
|
49
|
+
ST_NUMGEOMETRIES: () => ST_NUMGEOMETRIES,
|
|
50
|
+
ST_POINTN: () => ST_POINTN,
|
|
51
|
+
ST_POINTONSURFACE: () => ST_POINTONSURFACE,
|
|
52
|
+
ST_REMOVEREPEATEDPOINTS: () => ST_REMOVEREPEATEDPOINTS,
|
|
53
|
+
ST_SETSRID: () => ST_SETSRID,
|
|
54
|
+
ST_SIMPLIFY: () => ST_SIMPLIFY,
|
|
55
|
+
ST_SRID: () => ST_SRID,
|
|
56
|
+
ST_STARTPOINT: () => ST_STARTPOINT,
|
|
57
|
+
ST_TILEENVELOPE: () => ST_TILEENVELOPE,
|
|
58
|
+
ST_TRANSFORM: () => ST_TRANSFORM,
|
|
59
|
+
ST_WITHIN: () => ST_WITHIN,
|
|
60
|
+
ST_X: () => ST_X,
|
|
61
|
+
ST_Y: () => ST_Y,
|
|
62
|
+
ST_Z: () => ST_Z
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(st_functions_exports);
|
|
65
|
+
var import_apache_arrow2 = require("apache-arrow");
|
|
66
|
+
var import_arrow4 = require("@math.gl/core/arrow");
|
|
67
|
+
|
|
68
|
+
// dist/spatial-planar-intersects.js
|
|
69
|
+
var import_robust_predicates = require("robust-predicates");
|
|
70
|
+
|
|
71
|
+
// dist/spatial-planar.js
|
|
72
|
+
function visitSegments(path, closed, visit) {
|
|
73
|
+
for (let i = 1; i < path.length; i++)
|
|
74
|
+
visit(path[i - 1], path[i]);
|
|
75
|
+
if (closed && path.length > 1)
|
|
76
|
+
visit(path[path.length - 1], path[0]);
|
|
77
|
+
}
|
|
78
|
+
function isPresentPoint(position) {
|
|
79
|
+
return Number.isFinite(position[0]) && Number.isFinite(position[1]);
|
|
80
|
+
}
|
|
81
|
+
function visitPaths(geometry, visit) {
|
|
82
|
+
switch (geometry.type) {
|
|
83
|
+
case "Point":
|
|
84
|
+
if (isPresentPoint(geometry.coordinates))
|
|
85
|
+
visit([geometry.coordinates]);
|
|
86
|
+
break;
|
|
87
|
+
case "MultiPoint":
|
|
88
|
+
visit(geometry.coordinates.filter(isPresentPoint));
|
|
89
|
+
break;
|
|
90
|
+
case "LineString":
|
|
91
|
+
visit(geometry.coordinates);
|
|
92
|
+
break;
|
|
93
|
+
case "MultiLineString":
|
|
94
|
+
case "Polygon":
|
|
95
|
+
geometry.coordinates.forEach(visit);
|
|
96
|
+
break;
|
|
97
|
+
case "MultiPolygon":
|
|
98
|
+
geometry.coordinates.forEach((polygon) => polygon.forEach(visit));
|
|
99
|
+
break;
|
|
100
|
+
case "GeometryCollection":
|
|
101
|
+
geometry.geometries.forEach((child) => visitPaths(child, visit));
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function ringMoments(ring, origin) {
|
|
106
|
+
let weight = 0;
|
|
107
|
+
let x = 0;
|
|
108
|
+
let y = 0;
|
|
109
|
+
visitSegments(ring, true, (a, b) => {
|
|
110
|
+
const ax = a[0] - origin[0];
|
|
111
|
+
const ay = a[1] - origin[1];
|
|
112
|
+
const bx = b[0] - origin[0];
|
|
113
|
+
const by = b[1] - origin[1];
|
|
114
|
+
const cross = ax * by - bx * ay;
|
|
115
|
+
weight += cross;
|
|
116
|
+
x += (ax + bx) * cross;
|
|
117
|
+
y += (ay + by) * cross;
|
|
118
|
+
});
|
|
119
|
+
return { x: x / 6, y: y / 6, weight: weight / 2 };
|
|
120
|
+
}
|
|
121
|
+
function polygonMoments(rings, origin) {
|
|
122
|
+
const total = { x: 0, y: 0, weight: 0 };
|
|
123
|
+
rings.forEach((ring, index) => {
|
|
124
|
+
const ringResult = ringMoments(ring, origin);
|
|
125
|
+
const sign = Math.sign(ringResult.weight) * (index === 0 ? 1 : -1);
|
|
126
|
+
total.weight += sign * ringResult.weight;
|
|
127
|
+
total.x += sign * ringResult.x;
|
|
128
|
+
total.y += sign * ringResult.y;
|
|
129
|
+
});
|
|
130
|
+
return total;
|
|
131
|
+
}
|
|
132
|
+
function planarArea(geometry) {
|
|
133
|
+
const polygons2 = geometry.type === "Polygon" ? [geometry.coordinates] : geometry.type === "MultiPolygon" ? geometry.coordinates : [];
|
|
134
|
+
return polygons2.reduce((total, rings) => {
|
|
135
|
+
var _a;
|
|
136
|
+
return total + polygonMoments(rings, ((_a = rings[0]) == null ? void 0 : _a[0]) ?? [0, 0]).weight;
|
|
137
|
+
}, 0);
|
|
138
|
+
}
|
|
139
|
+
function planarLength(geometry) {
|
|
140
|
+
if (geometry.type !== "LineString" && geometry.type !== "MultiLineString")
|
|
141
|
+
return 0;
|
|
142
|
+
let length = 0;
|
|
143
|
+
visitPaths(geometry, (path) => {
|
|
144
|
+
visitSegments(path, false, (a, b) => {
|
|
145
|
+
length += Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
return length;
|
|
149
|
+
}
|
|
150
|
+
function planarCentroid(geometry) {
|
|
151
|
+
const polygons2 = geometry.type === "Polygon" ? [geometry.coordinates] : geometry.type === "MultiPolygon" ? geometry.coordinates : [];
|
|
152
|
+
const points2 = { x: 0, y: 0, weight: 0 };
|
|
153
|
+
const lines = { x: 0, y: 0, weight: 0 };
|
|
154
|
+
const areas = { x: 0, y: 0, weight: 0 };
|
|
155
|
+
let origin;
|
|
156
|
+
visitPaths(geometry, (path) => {
|
|
157
|
+
if (!path.length)
|
|
158
|
+
return;
|
|
159
|
+
origin ?? (origin = path[0]);
|
|
160
|
+
const ox = origin[0];
|
|
161
|
+
const oy = origin[1];
|
|
162
|
+
if (geometry.type !== "MultiPoint") {
|
|
163
|
+
visitSegments(path, polygons2.length > 0, (a, b) => {
|
|
164
|
+
const weight2 = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
165
|
+
lines.x += (a[0] - ox + (b[0] - ox)) / 2 * weight2;
|
|
166
|
+
lines.y += (a[1] - oy + (b[1] - oy)) / 2 * weight2;
|
|
167
|
+
lines.weight += weight2;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
for (const point2 of path) {
|
|
171
|
+
points2.x += point2[0] - ox;
|
|
172
|
+
points2.y += point2[1] - oy;
|
|
173
|
+
points2.weight++;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
if (!origin)
|
|
177
|
+
return { type: "Point", coordinates: [] };
|
|
178
|
+
for (const polygon of polygons2) {
|
|
179
|
+
const part = polygonMoments(polygon, origin);
|
|
180
|
+
areas.x += part.x;
|
|
181
|
+
areas.y += part.y;
|
|
182
|
+
areas.weight += part.weight;
|
|
183
|
+
}
|
|
184
|
+
const { x, y, weight } = areas.weight ? areas : lines.weight ? lines : points2;
|
|
185
|
+
return {
|
|
186
|
+
type: "Point",
|
|
187
|
+
coordinates: [origin[0] + x / weight, origin[1] + y / weight]
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function planarBounds(geometry) {
|
|
191
|
+
let minX = Infinity;
|
|
192
|
+
let minY = Infinity;
|
|
193
|
+
let maxX = -Infinity;
|
|
194
|
+
let maxY = -Infinity;
|
|
195
|
+
visitPaths(geometry, (path) => {
|
|
196
|
+
for (const [x, y] of path) {
|
|
197
|
+
minX = Math.min(minX, x);
|
|
198
|
+
minY = Math.min(minY, y);
|
|
199
|
+
maxX = Math.max(maxX, x);
|
|
200
|
+
maxY = Math.max(maxY, y);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return minX <= maxX ? [minX, minY, maxX, maxY] : null;
|
|
204
|
+
}
|
|
205
|
+
function planarEnvelope(geometry) {
|
|
206
|
+
const bounds = planarBounds(geometry);
|
|
207
|
+
if (!bounds)
|
|
208
|
+
return geometry;
|
|
209
|
+
return envelopeFromBounds(bounds);
|
|
210
|
+
}
|
|
211
|
+
function envelopeFromBounds(bounds) {
|
|
212
|
+
const [x0, y0, x1, y1] = bounds;
|
|
213
|
+
if (x0 === x1 && y0 === y1)
|
|
214
|
+
return { type: "Point", coordinates: [x0, y0] };
|
|
215
|
+
if (x0 === x1 || y0 === y1) {
|
|
216
|
+
return {
|
|
217
|
+
type: "LineString",
|
|
218
|
+
coordinates: [
|
|
219
|
+
[x0, y0],
|
|
220
|
+
[x1, y1]
|
|
221
|
+
]
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
type: "Polygon",
|
|
226
|
+
coordinates: [
|
|
227
|
+
[
|
|
228
|
+
[x0, y0],
|
|
229
|
+
[x0, y1],
|
|
230
|
+
[x1, y1],
|
|
231
|
+
[x1, y0],
|
|
232
|
+
[x0, y0]
|
|
233
|
+
]
|
|
234
|
+
]
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function planarPolygonPointOnSurface(geometry) {
|
|
238
|
+
const polygons2 = geometry.type === "MultiPolygon" ? geometry.coordinates : geometry.type === "Polygon" ? [geometry.coordinates] : [];
|
|
239
|
+
let coordinates = [];
|
|
240
|
+
let widest = -1;
|
|
241
|
+
for (const rings of polygons2) {
|
|
242
|
+
const shell = rings[0];
|
|
243
|
+
if (!(shell == null ? void 0 : shell.length))
|
|
244
|
+
continue;
|
|
245
|
+
let low = Infinity;
|
|
246
|
+
let high = -Infinity;
|
|
247
|
+
for (const point2 of shell) {
|
|
248
|
+
low = Math.min(low, point2[1]);
|
|
249
|
+
high = Math.max(high, point2[1]);
|
|
250
|
+
}
|
|
251
|
+
const center = low / 2 + high / 2;
|
|
252
|
+
for (const ring of rings) {
|
|
253
|
+
for (const point2 of ring) {
|
|
254
|
+
const y2 = point2[1];
|
|
255
|
+
if (y2 <= center)
|
|
256
|
+
low = Math.max(low, y2);
|
|
257
|
+
else
|
|
258
|
+
high = Math.min(high, y2);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const y = low / 2 + high / 2;
|
|
262
|
+
const crossings = [];
|
|
263
|
+
for (const ring of rings) {
|
|
264
|
+
visitSegments(ring, true, (a, b) => {
|
|
265
|
+
if (a[1] > y === b[1] > y)
|
|
266
|
+
return;
|
|
267
|
+
const t = (y - a[1]) / (b[1] - a[1]);
|
|
268
|
+
crossings.push((1 - t) * a[0] + t * b[0]);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
crossings.sort((a, b) => a - b);
|
|
272
|
+
if (widest < 0)
|
|
273
|
+
coordinates = [...shell[0]];
|
|
274
|
+
for (let i = 1; i < crossings.length; i += 2) {
|
|
275
|
+
const start = crossings[i - 1];
|
|
276
|
+
const end = crossings[i];
|
|
277
|
+
if (end - start > widest) {
|
|
278
|
+
widest = end - start;
|
|
279
|
+
coordinates = [start / 2 + end / 2, y];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return { type: "Point", coordinates };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// dist/spatial-planar-intersects.js
|
|
287
|
+
function* primitives(geometry) {
|
|
288
|
+
switch (geometry.type) {
|
|
289
|
+
case "MultiPoint":
|
|
290
|
+
for (const coordinates of geometry.coordinates)
|
|
291
|
+
yield { type: "Point", coordinates };
|
|
292
|
+
break;
|
|
293
|
+
case "MultiLineString":
|
|
294
|
+
for (const coordinates of geometry.coordinates)
|
|
295
|
+
yield { type: "LineString", coordinates };
|
|
296
|
+
break;
|
|
297
|
+
case "MultiPolygon":
|
|
298
|
+
for (const coordinates of geometry.coordinates)
|
|
299
|
+
yield { type: "Polygon", coordinates };
|
|
300
|
+
break;
|
|
301
|
+
case "GeometryCollection":
|
|
302
|
+
for (const child of geometry.geometries)
|
|
303
|
+
yield* primitives(child);
|
|
304
|
+
break;
|
|
305
|
+
default:
|
|
306
|
+
yield geometry;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function side(a, b, c) {
|
|
310
|
+
return Math.sign((0, import_robust_predicates.orient2d)(a[0], a[1], b[0], b[1], c[0], c[1]));
|
|
311
|
+
}
|
|
312
|
+
function inBounds(p, a, b) {
|
|
313
|
+
return p[0] >= Math.min(a[0], b[0]) && p[0] <= Math.max(a[0], b[0]) && p[1] >= Math.min(a[1], b[1]) && p[1] <= Math.max(a[1], b[1]);
|
|
314
|
+
}
|
|
315
|
+
function segmentsMeet(a, b, c, d) {
|
|
316
|
+
const cSide = side(a, b, c), dSide = side(a, b, d);
|
|
317
|
+
const aSide = side(c, d, a), bSide = side(c, d, b);
|
|
318
|
+
return cSide * dSide < 0 && aSide * bSide < 0 || !cSide && inBounds(c, a, b) || !dSide && inBounds(d, a, b) || !aSide && inBounds(a, c, d) || !bSide && inBounds(b, c, d);
|
|
319
|
+
}
|
|
320
|
+
function anyEdge(path, closed, match) {
|
|
321
|
+
for (let i = closed ? 0 : 1; i < path.length; i++) {
|
|
322
|
+
if (match(path[i ? i - 1 : path.length - 1], path[i]))
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
function meetsPoint(point2, geometry) {
|
|
328
|
+
if (!Number.isFinite(point2[0]) || !Number.isFinite(point2[1]))
|
|
329
|
+
return false;
|
|
330
|
+
if (geometry.type === "Point")
|
|
331
|
+
return point2[0] === geometry.coordinates[0] && point2[1] === geometry.coordinates[1];
|
|
332
|
+
if (geometry.type === "LineString")
|
|
333
|
+
return anyEdge(geometry.coordinates, false, (a, b) => inBounds(point2, a, b) && !side(a, b, point2));
|
|
334
|
+
let inside = false;
|
|
335
|
+
for (const ring of geometry.coordinates) {
|
|
336
|
+
if (anyEdge(ring, true, (a, b) => {
|
|
337
|
+
const orientation = side(a, b, point2);
|
|
338
|
+
if (!orientation && inBounds(point2, a, b))
|
|
339
|
+
return true;
|
|
340
|
+
if (a[1] > point2[1] !== b[1] > point2[1] && orientation < 0 === b[1] > a[1])
|
|
341
|
+
inside = !inside;
|
|
342
|
+
return false;
|
|
343
|
+
}))
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
return inside;
|
|
347
|
+
}
|
|
348
|
+
function primitivesMeet(a, b) {
|
|
349
|
+
if (a.type === "Point")
|
|
350
|
+
return meetsPoint(a.coordinates, b);
|
|
351
|
+
if (b.type === "Point")
|
|
352
|
+
return meetsPoint(b.coordinates, a);
|
|
353
|
+
const pathsA = a.type === "LineString" ? [a.coordinates] : a.coordinates;
|
|
354
|
+
const pathsB = b.type === "LineString" ? [b.coordinates] : b.coordinates;
|
|
355
|
+
for (const path of pathsA) {
|
|
356
|
+
if (b.type === "Polygon" && path[0] && meetsPoint(path[0], b))
|
|
357
|
+
return true;
|
|
358
|
+
if (anyEdge(path, a.type === "Polygon", (p, q) => pathsB.some((other) => anyEdge(other, b.type === "Polygon", (r, s) => segmentsMeet(p, q, r, s)))))
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
return a.type === "Polygon" && pathsB.some((path) => Boolean(path[0] && meetsPoint(path[0], a)));
|
|
362
|
+
}
|
|
363
|
+
function planarIntersects(a, b) {
|
|
364
|
+
const x = planarBounds(a), y = planarBounds(b);
|
|
365
|
+
if (!x || !y || x[2] < y[0] || x[0] > y[2] || x[3] < y[1] || x[1] > y[3])
|
|
366
|
+
return false;
|
|
367
|
+
for (const left of primitives(a)) {
|
|
368
|
+
for (const right of primitives(b))
|
|
369
|
+
if (primitivesMeet(left, right))
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// dist/linear-referencing.js
|
|
376
|
+
function cumulativeDistances(path) {
|
|
377
|
+
const distances = [0];
|
|
378
|
+
for (let i = 1; i < path.length; i++) {
|
|
379
|
+
const a = path[i - 1], b = path[i];
|
|
380
|
+
distances.push(distances[i - 1] + Math.hypot(b[0] - a[0], b[1] - a[1]));
|
|
381
|
+
}
|
|
382
|
+
return distances;
|
|
383
|
+
}
|
|
384
|
+
function coordinateAt(path, distances, target) {
|
|
385
|
+
for (let i = 0; i < path.length; i++) {
|
|
386
|
+
if (target === distances[i])
|
|
387
|
+
return path[i];
|
|
388
|
+
if (target < distances[i]) {
|
|
389
|
+
const t = (target - distances[i - 1]) / (distances[i] - distances[i - 1]);
|
|
390
|
+
const a = path[i - 1], b = path[i];
|
|
391
|
+
return [(1 - t) * a[0] + t * b[0], (1 - t) * a[1] + t * b[1]];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return path[path.length - 1];
|
|
395
|
+
}
|
|
396
|
+
function lineSubstring(line, start, end) {
|
|
397
|
+
if (!(start >= 0 && end <= 1 && start <= end))
|
|
398
|
+
throw new Error("Expected ordered route fractions in [0, 1]");
|
|
399
|
+
if (line.type !== "LineString" || !line.coordinates.length)
|
|
400
|
+
return null;
|
|
401
|
+
const path = line.coordinates;
|
|
402
|
+
const distances = cumulativeDistances(path);
|
|
403
|
+
const total = distances[distances.length - 1];
|
|
404
|
+
const from = start * total, to = end * total;
|
|
405
|
+
const first = coordinateAt(path, distances, from);
|
|
406
|
+
if (from === to)
|
|
407
|
+
return { type: "Point", coordinates: first };
|
|
408
|
+
const coordinates = [first];
|
|
409
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
410
|
+
if (distances[i] > from && distances[i] < to && distances[i] !== distances[i - 1])
|
|
411
|
+
coordinates.push(path[i]);
|
|
412
|
+
}
|
|
413
|
+
coordinates.push(coordinateAt(path, distances, to));
|
|
414
|
+
return { type: "LineString", coordinates };
|
|
415
|
+
}
|
|
416
|
+
function lineLocatePoint(line, point2) {
|
|
417
|
+
if (line.type !== "LineString" || !line.coordinates.length || point2.type !== "Point" || !Number.isFinite(point2.coordinates[0]) || !Number.isFinite(point2.coordinates[1]))
|
|
418
|
+
return null;
|
|
419
|
+
const path = line.coordinates, [x, y] = point2.coordinates;
|
|
420
|
+
let total = 0, nearest = Infinity, position = 0;
|
|
421
|
+
for (let i = 1; i < path.length; i++) {
|
|
422
|
+
const a = path[i - 1], b = path[i];
|
|
423
|
+
const dx = b[0] - a[0], dy = b[1] - a[1];
|
|
424
|
+
const length = Math.hypot(dx, dy);
|
|
425
|
+
if (!length)
|
|
426
|
+
continue;
|
|
427
|
+
const ux = dx / length, uy = dy / length;
|
|
428
|
+
const along = Math.max(0, Math.min(length, (x - a[0]) * ux + (y - a[1]) * uy));
|
|
429
|
+
const distance = Math.hypot(x - (a[0] + along * ux), y - (a[1] + along * uy));
|
|
430
|
+
if (distance < nearest) {
|
|
431
|
+
nearest = distance;
|
|
432
|
+
position = total + along;
|
|
433
|
+
}
|
|
434
|
+
total += length;
|
|
435
|
+
}
|
|
436
|
+
return total ? position / total : 0;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// dist/crs/crs-identifier.js
|
|
440
|
+
var WMS_CRS_CODES = /* @__PURE__ */ new Map([
|
|
441
|
+
["84", "CRS84"],
|
|
442
|
+
["83", "CRS83"],
|
|
443
|
+
["27", "CRS27"]
|
|
444
|
+
]);
|
|
445
|
+
var KNOWN_AUTHORITIES = /* @__PURE__ */ new Set(["EPSG", "OGC", "ESRI", "IAU"]);
|
|
446
|
+
var OGC_CRS_CODES = /* @__PURE__ */ new Map([
|
|
447
|
+
["CRS84", "CRS84"],
|
|
448
|
+
["CRS83", "CRS83"],
|
|
449
|
+
["CRS27", "CRS27"],
|
|
450
|
+
["CRS84H", "CRS84h"]
|
|
451
|
+
]);
|
|
452
|
+
var AUTHORITY_CODE = /^([A-Z][A-Z0-9_-]*):([A-Z0-9_.-]+)$/i;
|
|
453
|
+
var OGC_URN = /^urn:ogc:def:crs:([A-Z][A-Z0-9_-]*):([^:]*):([A-Z0-9_.-]+)$/i;
|
|
454
|
+
var OGC_URI = /^https?:\/\/www\.opengis\.net\/def\/crs\/([A-Z][A-Z0-9_-]*)\/([^/]+)\/([A-Z0-9_.-]+)\/?$/i;
|
|
455
|
+
function normalizeCRSIdentifier(identifier) {
|
|
456
|
+
const text = identifier.trim();
|
|
457
|
+
const authorityCode = AUTHORITY_CODE.exec(text);
|
|
458
|
+
if (authorityCode) {
|
|
459
|
+
const [, authority, code] = authorityCode;
|
|
460
|
+
if (authority.toUpperCase() === "CRS") {
|
|
461
|
+
const ogcCode = WMS_CRS_CODES.get(code);
|
|
462
|
+
return ogcCode ? `OGC:${ogcCode}` : identifier;
|
|
463
|
+
}
|
|
464
|
+
return formatIdentifier(authority, code);
|
|
465
|
+
}
|
|
466
|
+
const versioned = OGC_URN.exec(text) || OGC_URI.exec(text);
|
|
467
|
+
if (versioned) {
|
|
468
|
+
const [, authority, version, code] = versioned;
|
|
469
|
+
return isUnversioned(authority, version, code) ? formatIdentifier(authority, code) : identifier;
|
|
470
|
+
}
|
|
471
|
+
return identifier;
|
|
472
|
+
}
|
|
473
|
+
function isUnversioned(authority, version, code) {
|
|
474
|
+
if (version === "" || version === "0")
|
|
475
|
+
return true;
|
|
476
|
+
const ogcCode = code.toUpperCase();
|
|
477
|
+
return authority.toUpperCase() === "OGC" && version === "1.3" && Array.from(WMS_CRS_CODES.values()).includes(ogcCode);
|
|
478
|
+
}
|
|
479
|
+
function formatIdentifier(authority, code) {
|
|
480
|
+
const upperAuthority = authority.toUpperCase();
|
|
481
|
+
const canonicalAuthority = KNOWN_AUTHORITIES.has(upperAuthority) ? upperAuthority : authority;
|
|
482
|
+
const canonicalCode = canonicalAuthority === "OGC" ? OGC_CRS_CODES.get(code.toUpperCase()) || code : code;
|
|
483
|
+
return `${canonicalAuthority}:${canonicalCode}`;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// dist/web-mercator/mercator-meters.js
|
|
487
|
+
var PI = Math.PI;
|
|
488
|
+
var DEGREES_TO_RADIANS = PI / 180;
|
|
489
|
+
var RADIANS_TO_DEGREES = 180 / PI;
|
|
490
|
+
var EPSG3857_EARTH_RADIUS = 6378137;
|
|
491
|
+
var EPSG3857_HALF_CIRCUMFERENCE = PI * EPSG3857_EARTH_RADIUS;
|
|
492
|
+
var EPSG3857_MAX_LATITUDE = Math.atan(Math.sinh(PI)) * RADIANS_TO_DEGREES;
|
|
493
|
+
var EPSG3857_UNITS_PER_METER = 512 / (2 * EPSG3857_HALF_CIRCUMFERENCE);
|
|
494
|
+
function lngLatToEPSG3857(lngLatZ, options = {}) {
|
|
495
|
+
const [longitude, latitude, z] = lngLatZ;
|
|
496
|
+
const { clampLatitude = true } = options;
|
|
497
|
+
if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {
|
|
498
|
+
throw new Error("Invalid longitude or latitude");
|
|
499
|
+
}
|
|
500
|
+
if (lngLatZ.length >= 3 && !Number.isFinite(z)) {
|
|
501
|
+
throw new Error("Invalid elevation");
|
|
502
|
+
}
|
|
503
|
+
const projectedLatitude = clampLatitude ? Math.max(-EPSG3857_MAX_LATITUDE, Math.min(EPSG3857_MAX_LATITUDE, latitude)) : latitude;
|
|
504
|
+
if (projectedLatitude < -EPSG3857_MAX_LATITUDE || projectedLatitude > EPSG3857_MAX_LATITUDE) {
|
|
505
|
+
throw new Error("Latitude is outside the finite EPSG:3857 range");
|
|
506
|
+
}
|
|
507
|
+
const x = EPSG3857_EARTH_RADIUS * longitude * DEGREES_TO_RADIANS;
|
|
508
|
+
const y = EPSG3857_EARTH_RADIUS * Math.log(Math.tan(PI / 4 + projectedLatitude * DEGREES_TO_RADIANS / 2));
|
|
509
|
+
return lngLatZ.length >= 3 ? [x, y, z] : [x, y];
|
|
510
|
+
}
|
|
511
|
+
function EPSG3857ToLngLat(xyz) {
|
|
512
|
+
const [x, y, z] = xyz;
|
|
513
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
514
|
+
throw new Error("Invalid EPSG:3857 coordinate");
|
|
515
|
+
}
|
|
516
|
+
if (xyz.length >= 3 && !Number.isFinite(z)) {
|
|
517
|
+
throw new Error("Invalid elevation");
|
|
518
|
+
}
|
|
519
|
+
const longitude = x / EPSG3857_EARTH_RADIUS * RADIANS_TO_DEGREES;
|
|
520
|
+
const latitude = Math.atan(Math.sinh(y / EPSG3857_EARTH_RADIUS)) * RADIANS_TO_DEGREES;
|
|
521
|
+
return xyz.length >= 3 ? [longitude, latitude, z] : [longitude, latitude];
|
|
522
|
+
}
|
|
523
|
+
var EPSG4326ToEPSG3857 = lngLatToEPSG3857;
|
|
524
|
+
|
|
525
|
+
// dist/geometry-inspection.js
|
|
526
|
+
function hasPosition(position) {
|
|
527
|
+
return position.length > 0 && !position.every(Number.isNaN);
|
|
528
|
+
}
|
|
529
|
+
function vertexCount(g) {
|
|
530
|
+
switch (g.type) {
|
|
531
|
+
case "Point":
|
|
532
|
+
return Number(hasPosition(g.coordinates));
|
|
533
|
+
case "MultiPoint":
|
|
534
|
+
return g.coordinates.reduce((sum, p) => sum + Number(hasPosition(p)), 0);
|
|
535
|
+
case "LineString":
|
|
536
|
+
return g.coordinates.length;
|
|
537
|
+
case "Polygon":
|
|
538
|
+
case "MultiLineString":
|
|
539
|
+
return g.coordinates.reduce((sum, path) => sum + path.length, 0);
|
|
540
|
+
case "MultiPolygon":
|
|
541
|
+
return g.coordinates.reduce((sum, polygon) => sum + polygon.reduce((count, ring) => count + ring.length, 0), 0);
|
|
542
|
+
case "GeometryCollection":
|
|
543
|
+
return g.geometries.reduce((sum, child) => sum + vertexCount(child), 0);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function memberCount(g) {
|
|
547
|
+
if (!vertexCount(g))
|
|
548
|
+
return 0;
|
|
549
|
+
switch (g.type) {
|
|
550
|
+
case "GeometryCollection":
|
|
551
|
+
return g.geometries.length;
|
|
552
|
+
case "MultiPoint":
|
|
553
|
+
case "MultiLineString":
|
|
554
|
+
case "MultiPolygon":
|
|
555
|
+
return g.coordinates.length;
|
|
556
|
+
default:
|
|
557
|
+
return 1;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function geometryMember(g, position) {
|
|
561
|
+
if (!Number.isInteger(position))
|
|
562
|
+
throw new Error("ST_GeometryN requires an integer position");
|
|
563
|
+
if (!vertexCount(g))
|
|
564
|
+
return null;
|
|
565
|
+
const index = position - 1;
|
|
566
|
+
switch (g.type) {
|
|
567
|
+
case "GeometryCollection":
|
|
568
|
+
return g.geometries[index] ?? null;
|
|
569
|
+
case "MultiPoint":
|
|
570
|
+
return g.coordinates[index] ? { type: "Point", coordinates: g.coordinates[index] } : null;
|
|
571
|
+
case "MultiLineString":
|
|
572
|
+
return g.coordinates[index] ? { type: "LineString", coordinates: g.coordinates[index] } : null;
|
|
573
|
+
case "MultiPolygon":
|
|
574
|
+
return g.coordinates[index] ? { type: "Polygon", coordinates: g.coordinates[index] } : null;
|
|
575
|
+
default:
|
|
576
|
+
return position === 1 ? g : null;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// dist/line-simplification.js
|
|
581
|
+
function removeRepeated(path, tolerance) {
|
|
582
|
+
if (path.length <= 2)
|
|
583
|
+
return path;
|
|
584
|
+
const kept = [path[0]];
|
|
585
|
+
for (let i = 1; i < path.length; i++) {
|
|
586
|
+
const current = path[i], last = kept[kept.length - 1];
|
|
587
|
+
const close = Math.hypot(current[0] - last[0], current[1] - last[1]) <= tolerance;
|
|
588
|
+
if (i === path.length - 1) {
|
|
589
|
+
if (close && kept.length > 1)
|
|
590
|
+
kept.pop();
|
|
591
|
+
} else if (close)
|
|
592
|
+
continue;
|
|
593
|
+
kept.push(current);
|
|
594
|
+
}
|
|
595
|
+
return kept;
|
|
596
|
+
}
|
|
597
|
+
function distanceToSegment(p, a, b) {
|
|
598
|
+
const dx = b[0] - a[0], dy = b[1] - a[1];
|
|
599
|
+
const length = Math.hypot(dx, dy);
|
|
600
|
+
const px = p[0] - a[0], py = p[1] - a[1];
|
|
601
|
+
const t = length ? Math.max(0, Math.min(1, (px * (dx / length) + py * (dy / length)) / length)) : 0;
|
|
602
|
+
return Math.hypot(px - t * dx, py - t * dy);
|
|
603
|
+
}
|
|
604
|
+
function simplify(path, tolerance) {
|
|
605
|
+
if (!path.length)
|
|
606
|
+
return path;
|
|
607
|
+
const last = path.length - 1;
|
|
608
|
+
const kept = new Uint8Array(path.length);
|
|
609
|
+
kept[0] = kept[last] = 1;
|
|
610
|
+
const spans = [0, last];
|
|
611
|
+
while (spans.length) {
|
|
612
|
+
const end = spans.pop(), start = spans.pop();
|
|
613
|
+
let split = start, maximum = tolerance;
|
|
614
|
+
for (let i = start + 1; i < end; i++) {
|
|
615
|
+
const distance = distanceToSegment(path[i], path[start], path[end]);
|
|
616
|
+
if (distance > maximum) {
|
|
617
|
+
maximum = distance;
|
|
618
|
+
split = i;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if (split !== start) {
|
|
622
|
+
kept[split] = 1;
|
|
623
|
+
spans.push(start, split, split, end);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
const result2 = path.filter((_, i) => kept[i]);
|
|
627
|
+
if (result2.length === 2 && result2[0][0] === result2[1][0] && result2[0][1] === result2[1][1])
|
|
628
|
+
return [];
|
|
629
|
+
return result2;
|
|
630
|
+
}
|
|
631
|
+
function reduceLineVertices(geometry, tolerance, mode) {
|
|
632
|
+
if (!Number.isFinite(tolerance) || tolerance < 0)
|
|
633
|
+
throw new Error("Expected a finite nonnegative tolerance");
|
|
634
|
+
if ((geometry.type === "LineString" || geometry.type === "MultiLineString") && (!geometry.coordinates.length || geometry.type === "MultiLineString" && geometry.coordinates.every((path) => !path.length)))
|
|
635
|
+
return geometry;
|
|
636
|
+
const reduce = mode === "simplify" ? simplify : removeRepeated;
|
|
637
|
+
if (geometry.type === "LineString") {
|
|
638
|
+
const coordinates2 = reduce(geometry.coordinates, tolerance);
|
|
639
|
+
return coordinates2.length || mode === "removeRepeated" ? { type: "LineString", coordinates: coordinates2 } : null;
|
|
640
|
+
}
|
|
641
|
+
if (geometry.type !== "MultiLineString")
|
|
642
|
+
throw new Error("Expected line geometry");
|
|
643
|
+
const reduced = geometry.coordinates.map((path) => reduce(path, tolerance));
|
|
644
|
+
if (mode === "removeRepeated")
|
|
645
|
+
return { type: "MultiLineString", coordinates: reduced };
|
|
646
|
+
const coordinates = reduced.filter((path) => path.length);
|
|
647
|
+
return coordinates.length ? { type: "MultiLineString", coordinates } : null;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// dist/geometry-constructors.js
|
|
651
|
+
function collectPair(a, b) {
|
|
652
|
+
if (a.type === "Point" && b.type === "Point")
|
|
653
|
+
return { type: "MultiPoint", coordinates: [a.coordinates, b.coordinates] };
|
|
654
|
+
if (a.type === "LineString" && b.type === "LineString")
|
|
655
|
+
return { type: "MultiLineString", coordinates: [a.coordinates, b.coordinates] };
|
|
656
|
+
if (a.type === "Polygon" && b.type === "Polygon")
|
|
657
|
+
return { type: "MultiPolygon", coordinates: [a.coordinates, b.coordinates] };
|
|
658
|
+
return { type: "GeometryCollection", geometries: [a, b] };
|
|
659
|
+
}
|
|
660
|
+
function makeLine(parts) {
|
|
661
|
+
const coordinates = [];
|
|
662
|
+
for (const part of parts) {
|
|
663
|
+
if (part.type === "Point") {
|
|
664
|
+
if (part.coordinates.length)
|
|
665
|
+
coordinates.push(part.coordinates);
|
|
666
|
+
} else if (part.type === "MultiPoint") {
|
|
667
|
+
for (const point2 of part.coordinates)
|
|
668
|
+
if (point2.length && !point2.every(Number.isNaN))
|
|
669
|
+
coordinates.push(point2);
|
|
670
|
+
} else if (part.type === "LineString") {
|
|
671
|
+
const previous = coordinates[coordinates.length - 1];
|
|
672
|
+
const first = part.coordinates[0];
|
|
673
|
+
const shared = previous && first && previous[0] === first[0] && previous[1] === first[1];
|
|
674
|
+
for (let i = shared ? 1 : 0; i < part.coordinates.length; i++)
|
|
675
|
+
coordinates.push(part.coordinates[i]);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return { type: "LineString", coordinates };
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// dist/spatial-sql.js
|
|
682
|
+
var import_apache_arrow = require("apache-arrow");
|
|
683
|
+
var import_arrow3 = require("@math.gl/core/arrow");
|
|
684
|
+
|
|
685
|
+
// dist/turf.js
|
|
686
|
+
var import_arrow = require("@math.gl/core/arrow");
|
|
687
|
+
var import_arrow2 = require("@math.gl/core/arrow");
|
|
688
|
+
var RAD = Math.PI / 180;
|
|
689
|
+
var depths = {
|
|
690
|
+
"geoarrow.point": 0,
|
|
691
|
+
"geoarrow.multipoint": 1,
|
|
692
|
+
"geoarrow.linestring": 1,
|
|
693
|
+
"geoarrow.multilinestring": 2,
|
|
694
|
+
"geoarrow.polygon": 2,
|
|
695
|
+
"geoarrow.multipolygon": 3
|
|
696
|
+
};
|
|
697
|
+
function rows(column2, allowed) {
|
|
698
|
+
if (!allowed.includes(column2.encoding))
|
|
699
|
+
throw new Error(`Unsupported GeoArrow encoding ${column2.encoding}; expected ${allowed.join(", ")}`);
|
|
700
|
+
const result2 = [];
|
|
701
|
+
for (const array of column2.chunks)
|
|
702
|
+
for (let index = 0; index < array.length; index++)
|
|
703
|
+
result2.push({ array, index, valid: (0, import_arrow.isGeoArrowValueValid)(array.validity, index) });
|
|
704
|
+
return result2;
|
|
705
|
+
}
|
|
706
|
+
function range(array, index) {
|
|
707
|
+
if (array.kind !== "list")
|
|
708
|
+
throw new Error("Invalid GeoArrow list storage");
|
|
709
|
+
const i = (array.offset || 0) + index;
|
|
710
|
+
const base = Number(array.offsetBase ?? 0);
|
|
711
|
+
const a = Number(array.offsets[i]) - base, b = Number(array.offsets[i + 1]) - base;
|
|
712
|
+
if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b))
|
|
713
|
+
throw new Error("Invalid GeoArrow list offsets");
|
|
714
|
+
return [a, b];
|
|
715
|
+
}
|
|
716
|
+
function scalar(array, index) {
|
|
717
|
+
if (array.kind !== "primitive")
|
|
718
|
+
throw new Error("Invalid GeoArrow coordinate");
|
|
719
|
+
if (!(0, import_arrow.isGeoArrowValueValid)(array.validity, index))
|
|
720
|
+
return NaN;
|
|
721
|
+
return Number(array.values[(array.offset || 0) + index * (array.stride || 1)]);
|
|
722
|
+
}
|
|
723
|
+
function point(array, index) {
|
|
724
|
+
if (!(0, import_arrow.isGeoArrowValueValid)(array.validity, index))
|
|
725
|
+
return null;
|
|
726
|
+
if (array.kind === "fixed-size-list") {
|
|
727
|
+
const i = ((array.offset || 0) + index) * array.size;
|
|
728
|
+
const x = scalar(array.child, i), y = scalar(array.child, i + 1);
|
|
729
|
+
return !Number.isFinite(x) || !Number.isFinite(y) ? null : [x, y];
|
|
730
|
+
}
|
|
731
|
+
if (array.kind === "struct") {
|
|
732
|
+
const i = (array.offset || 0) + index;
|
|
733
|
+
const x = scalar(array.children["x"], i), y = scalar(array.children["y"], i);
|
|
734
|
+
return !Number.isFinite(x) || !Number.isFinite(y) ? null : [x, y];
|
|
735
|
+
}
|
|
736
|
+
throw new Error("Invalid GeoArrow coordinate storage");
|
|
737
|
+
}
|
|
738
|
+
function valid(bitmap, i) {
|
|
739
|
+
bitmap[i >> 3] |= 1 << (i & 7);
|
|
740
|
+
}
|
|
741
|
+
function result(n, boolean = false) {
|
|
742
|
+
return {
|
|
743
|
+
values: boolean ? new Uint8Array(n) : new Float64Array(n),
|
|
744
|
+
validity: new Uint8Array(Math.ceil(n / 8))
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function paired(a, b) {
|
|
748
|
+
if (a.length === b.length)
|
|
749
|
+
return a.length;
|
|
750
|
+
if (a.length === 1)
|
|
751
|
+
return b.length;
|
|
752
|
+
if (b.length === 1)
|
|
753
|
+
return a.length;
|
|
754
|
+
throw new Error("GeoArrow batch lengths must match or one input must contain one row");
|
|
755
|
+
}
|
|
756
|
+
var native = Object.keys(depths);
|
|
757
|
+
var points = ["geoarrow.point"];
|
|
758
|
+
var polygons = ["geoarrow.polygon", "geoarrow.multipolygon"];
|
|
759
|
+
function ringContains(array, a, b, p) {
|
|
760
|
+
let inside = false;
|
|
761
|
+
for (let i = a, j = b - 1; i < b; j = i++) {
|
|
762
|
+
const u = point(array, i), v = point(array, j);
|
|
763
|
+
if (!u || !v)
|
|
764
|
+
continue;
|
|
765
|
+
const cross = (p[0] - u[0]) * (v[1] - u[1]) - (p[1] - u[1]) * (v[0] - u[0]);
|
|
766
|
+
if (cross === 0 && p[0] >= Math.min(u[0], v[0]) && p[0] <= Math.max(u[0], v[0]) && p[1] >= Math.min(u[1], v[1]) && p[1] <= Math.max(u[1], v[1]))
|
|
767
|
+
return 0;
|
|
768
|
+
if (u[1] > p[1] !== v[1] > p[1] && p[0] < (v[0] - u[0]) * (p[1] - u[1]) / (v[1] - u[1]) + u[0])
|
|
769
|
+
inside = !inside;
|
|
770
|
+
}
|
|
771
|
+
return inside ? 1 : -1;
|
|
772
|
+
}
|
|
773
|
+
function polygonContains(array, index, p) {
|
|
774
|
+
const [a, b] = range(array, index);
|
|
775
|
+
if (array.kind !== "list")
|
|
776
|
+
throw new Error("Invalid polygon");
|
|
777
|
+
if (a === b || !(0, import_arrow.isGeoArrowValueValid)(array.child.validity, a))
|
|
778
|
+
return -1;
|
|
779
|
+
for (let i = a; i < b; i++) {
|
|
780
|
+
if (!(0, import_arrow.isGeoArrowValueValid)(array.child.validity, i))
|
|
781
|
+
continue;
|
|
782
|
+
const [x, y] = range(array.child, i);
|
|
783
|
+
if (array.child.kind !== "list")
|
|
784
|
+
throw new Error("Invalid polygon ring");
|
|
785
|
+
const c = ringContains(array.child.child, x, y, p);
|
|
786
|
+
if (c === 0)
|
|
787
|
+
return 0;
|
|
788
|
+
if (i === a && c < 0 || i > a && c > 0)
|
|
789
|
+
return -1;
|
|
790
|
+
}
|
|
791
|
+
return a === b ? -1 : 1;
|
|
792
|
+
}
|
|
793
|
+
function booleanPointInPolygon(pointColumn, polygonColumn, options = {}) {
|
|
794
|
+
const a = rows(pointColumn, points), b = rows(polygonColumn, polygons), n = paired(a, b), out = result(n, true);
|
|
795
|
+
for (let i = 0; i < n; i++) {
|
|
796
|
+
const x = a[a.length === 1 ? 0 : i], y = b[b.length === 1 ? 0 : i];
|
|
797
|
+
if (!x.valid || !y.valid)
|
|
798
|
+
continue;
|
|
799
|
+
const p = point(x.array, x.index);
|
|
800
|
+
if (!p)
|
|
801
|
+
continue;
|
|
802
|
+
let hit = false;
|
|
803
|
+
if (polygonColumn.encoding === "geoarrow.polygon") {
|
|
804
|
+
const c = polygonContains(y.array, y.index, p);
|
|
805
|
+
hit = c > 0 || c === 0 && !options.ignoreBoundary;
|
|
806
|
+
} else {
|
|
807
|
+
const [start, end] = range(y.array, y.index);
|
|
808
|
+
if (y.array.kind !== "list")
|
|
809
|
+
throw new Error("Invalid multipolygon");
|
|
810
|
+
for (let j = start; j < end; j++) {
|
|
811
|
+
if (!(0, import_arrow.isGeoArrowValueValid)(y.array.child.validity, j))
|
|
812
|
+
continue;
|
|
813
|
+
const c = polygonContains(y.array.child, j, p);
|
|
814
|
+
if (c > 0 || c === 0 && !options.ignoreBoundary) {
|
|
815
|
+
hit = true;
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
out.values[i] = Number(hit);
|
|
821
|
+
valid(out.validity, i);
|
|
822
|
+
}
|
|
823
|
+
return out;
|
|
824
|
+
}
|
|
825
|
+
var lineFamilies = ["geoarrow.linestring", "geoarrow.multilinestring", ...polygons];
|
|
826
|
+
|
|
827
|
+
// dist/spatial-sql.js
|
|
828
|
+
var EXTENSION_NAME = "ARROW:extension:name";
|
|
829
|
+
var EXTENSION_METADATA = "ARROW:extension:metadata";
|
|
830
|
+
var geometryTypes = [
|
|
831
|
+
"Point",
|
|
832
|
+
"MultiPoint",
|
|
833
|
+
"LineString",
|
|
834
|
+
"MultiLineString",
|
|
835
|
+
"Polygon",
|
|
836
|
+
"MultiPolygon"
|
|
837
|
+
];
|
|
838
|
+
var pointKinds = ["Point"];
|
|
839
|
+
var lineKinds = ["LineString", "MultiLineString"];
|
|
840
|
+
var polygonKinds = ["Polygon", "MultiPolygon"];
|
|
841
|
+
function readGeometryValue(vector, field, active, value, captureMembers = false) {
|
|
842
|
+
if (import_apache_arrow.DataType.isBinary(field.type) || import_apache_arrow.DataType.isLargeBinary(field.type)) {
|
|
843
|
+
return (row) => {
|
|
844
|
+
const { geometry, dimension, srid, members } = (0, import_arrow3.parseWKB)(vector.get(row), {
|
|
845
|
+
captureMembers
|
|
846
|
+
});
|
|
847
|
+
if (srid)
|
|
848
|
+
throw new Error("Use GeoArrow field metadata for CRS information instead of EWKB SRIDs");
|
|
849
|
+
return value(geometry.type === "Point" && geometry.coordinates.every(Number.isNaN) ? { type: "Point", coordinates: [] } : geometry, dimension, members);
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
const column2 = readActiveGeoArrowColumn(vector, field, active);
|
|
853
|
+
const geometries = (0, import_arrow3.materializeGeoArrowRows)(column2);
|
|
854
|
+
return (row) => value(geometries[row], column2.dimension);
|
|
855
|
+
}
|
|
856
|
+
function readActiveGeoArrowColumn(vector, field, active) {
|
|
857
|
+
const column2 = (0, import_arrow3.makeGeoArrowColumnFromArrowVector)(vector, { field });
|
|
858
|
+
let offset = 0;
|
|
859
|
+
const chunks = column2.chunks.map((chunk) => {
|
|
860
|
+
const start = offset;
|
|
861
|
+
offset += chunk.length;
|
|
862
|
+
let needsMask = false;
|
|
863
|
+
for (let row = 0; row < chunk.length; row++) {
|
|
864
|
+
if (!active[start + row] && (0, import_arrow3.isGeoArrowValueValid)(chunk.validity, row)) {
|
|
865
|
+
needsMask = true;
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (!needsMask)
|
|
870
|
+
return chunk;
|
|
871
|
+
const values = new Uint8Array(Math.ceil(chunk.length / 8));
|
|
872
|
+
for (let row = 0; row < chunk.length; row++) {
|
|
873
|
+
if (active[start + row] && (0, import_arrow3.isGeoArrowValueValid)(chunk.validity, row)) {
|
|
874
|
+
values[row >> 3] |= 1 << (row & 7);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return { ...chunk, validity: { values } };
|
|
878
|
+
});
|
|
879
|
+
return { ...column2, chunks };
|
|
880
|
+
}
|
|
881
|
+
function planarGeometry(geometry, dimension) {
|
|
882
|
+
if (dimension !== "xy")
|
|
883
|
+
throw new Error("Spatial SQL functions require 2D geometry");
|
|
884
|
+
return geometry;
|
|
885
|
+
}
|
|
886
|
+
function spatialFunction(name, signatures, type, evaluate, numericArguments = 0, allDimensions = false, skipNullGeometries = false) {
|
|
887
|
+
return {
|
|
888
|
+
kind: "scalar",
|
|
889
|
+
name,
|
|
890
|
+
prototypes: [],
|
|
891
|
+
/** Binds the allowed geometry types and result metadata to a call. */
|
|
892
|
+
resolvePrototype(fields) {
|
|
893
|
+
var _a;
|
|
894
|
+
if (fields.length !== signatures.length + numericArguments)
|
|
895
|
+
return void 0;
|
|
896
|
+
const geometryFields = fields.slice(0, signatures.length);
|
|
897
|
+
const numberFields = fields.slice(signatures.length).map((field) => {
|
|
898
|
+
if (field && !import_apache_arrow.DataType.isInt(field.type) && !import_apache_arrow.DataType.isFloat(field.type))
|
|
899
|
+
throw new Error(`${name} requires numeric arguments`);
|
|
900
|
+
return field ?? new import_apache_arrow.Field("number", new import_apache_arrow.Float64(), true);
|
|
901
|
+
});
|
|
902
|
+
const extensions = geometryFields.map((field, index) => {
|
|
903
|
+
if (!field)
|
|
904
|
+
return void 0;
|
|
905
|
+
const extension = (0, import_arrow3.getGeoArrowFieldInfo)(field);
|
|
906
|
+
const encoding = extension == null ? void 0 : extension.encoding;
|
|
907
|
+
const kinds = signatures[index];
|
|
908
|
+
if (encoding === "geoarrow.wkb" && (import_apache_arrow.DataType.isBinary(field.type) || import_apache_arrow.DataType.isLargeBinary(field.type))) {
|
|
909
|
+
} else if (kinds.some((kind) => encoding === "geoarrow." + kind.toLowerCase())) {
|
|
910
|
+
if (!allDimensions && (extension == null ? void 0 : extension.dimension) !== "xy")
|
|
911
|
+
throw new Error(`${name} requires 2D geometry`);
|
|
912
|
+
} else {
|
|
913
|
+
throw new Error(`${name} argument ${index + 1} requires GeoArrow ${kinds.join(" or ")}`);
|
|
914
|
+
}
|
|
915
|
+
if (name.startsWith("ST_") && name !== "ST_SRID" && name !== "ST_SetSRID" && (extension == null ? void 0 : extension.metadata["edges"]) === "spherical")
|
|
916
|
+
throw new Error(`${name} requires planar geometry`);
|
|
917
|
+
return extension;
|
|
918
|
+
});
|
|
919
|
+
const crsValues = extensions.map((extension) => extension == null ? void 0 : extension.metadata["crs"]).filter((crs) => crs !== void 0 && crs !== null);
|
|
920
|
+
if (name.startsWith("ST_") && crsValues.some((crs) => JSON.stringify(crs) !== JSON.stringify(crsValues[0]))) {
|
|
921
|
+
throw new Error(`${name} requires arguments in the same CRS`);
|
|
922
|
+
}
|
|
923
|
+
const metadata = /* @__PURE__ */ new Map();
|
|
924
|
+
if (import_apache_arrow.DataType.isBinary(type)) {
|
|
925
|
+
metadata.set(EXTENSION_NAME, "geoarrow.wkb");
|
|
926
|
+
const inputMetadata = (_a = geometryFields.find((field) => field == null ? void 0 : field.metadata.has(EXTENSION_METADATA))) == null ? void 0 : _a.metadata.get(EXTENSION_METADATA);
|
|
927
|
+
if (inputMetadata)
|
|
928
|
+
metadata.set(EXTENSION_METADATA, inputMetadata);
|
|
929
|
+
}
|
|
930
|
+
const arguments_ = [
|
|
931
|
+
...geometryFields.map((field) => field ?? new import_apache_arrow.Field("geometry", new import_apache_arrow.Binary(), true)),
|
|
932
|
+
...numberFields
|
|
933
|
+
];
|
|
934
|
+
return {
|
|
935
|
+
arguments: arguments_,
|
|
936
|
+
nullHandling: skipNullGeometries ? "call" : "propagate",
|
|
937
|
+
result: new import_apache_arrow.Field(name, type, true, metadata),
|
|
938
|
+
/** Evaluates active rows and retains their positions in the output batch. */
|
|
939
|
+
evaluate(vectors, { activeRows, length: rowCount }) {
|
|
940
|
+
const numbers = vectors.slice(signatures.length);
|
|
941
|
+
const readers = vectors.slice(0, signatures.length).map((vector, index) => readGeometryValue(vector, arguments_[index], activeRows, allDimensions ? (g, dimension, members) => ({ ...g, dimension, members }) : planarGeometry, name === "ST_GeometryN"));
|
|
942
|
+
const values = new Array(rowCount).fill(null);
|
|
943
|
+
for (let row = 0; row < rowCount; row++) {
|
|
944
|
+
if (!activeRows[row])
|
|
945
|
+
continue;
|
|
946
|
+
const geometries = [];
|
|
947
|
+
for (let index = 0; index < readers.length; index++) {
|
|
948
|
+
if (skipNullGeometries && !vectors[index].isValid(row))
|
|
949
|
+
continue;
|
|
950
|
+
const geometry = readers[index](row);
|
|
951
|
+
if (!signatures[index].includes(geometry.type))
|
|
952
|
+
throw new Error(`${name} argument ${index + 1} does not support ${geometry.type} at row ${row}`);
|
|
953
|
+
geometries.push(geometry);
|
|
954
|
+
}
|
|
955
|
+
values[row] = evaluate(geometries, ...numbers.map((vector) => Number(vector.get(row))));
|
|
956
|
+
}
|
|
957
|
+
return (0, import_apache_arrow.vectorFromArray)(values, type);
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function pointCoordinates(geometry) {
|
|
964
|
+
return geometry.type === "Point" && Number.isFinite(geometry.coordinates[0]) && Number.isFinite(geometry.coordinates[1]) ? geometry.coordinates : null;
|
|
965
|
+
}
|
|
966
|
+
function column(geometry) {
|
|
967
|
+
return (0, import_arrow3.makeGeoArrowColumnFromGeometryRows)([geometry], { dimension: "xy" });
|
|
968
|
+
}
|
|
969
|
+
function scalar2(result2) {
|
|
970
|
+
return result2.validity[0] & 1 ? result2.values[0] : null;
|
|
971
|
+
}
|
|
972
|
+
function pointInPolygon(point2, polygon, ignoreBoundary = false) {
|
|
973
|
+
if (!pointCoordinates(point2))
|
|
974
|
+
return null;
|
|
975
|
+
const value = scalar2(booleanPointInPolygon(column(point2), column(polygon), { ignoreBoundary }));
|
|
976
|
+
return value === null ? null : value === 1;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// dist/st-functions.js
|
|
980
|
+
var ST_MAKEPOINT = {
|
|
981
|
+
kind: "scalar",
|
|
982
|
+
name: "ST_MakePoint",
|
|
983
|
+
prototypes: [],
|
|
984
|
+
/** Binds two to four numeric ordinate fields and declares a WKB result. */
|
|
985
|
+
resolvePrototype(fields) {
|
|
986
|
+
if (fields.length < 2 || fields.length > 4)
|
|
987
|
+
return void 0;
|
|
988
|
+
const arguments_ = fields.map((field) => {
|
|
989
|
+
if (field && !import_apache_arrow2.DataType.isInt(field.type) && !import_apache_arrow2.DataType.isFloat(field.type))
|
|
990
|
+
throw new Error("ST_MakePoint requires numeric coordinates");
|
|
991
|
+
return field ?? new import_apache_arrow2.Field("coordinate", new import_apache_arrow2.Float64(), true);
|
|
992
|
+
});
|
|
993
|
+
const type = new import_apache_arrow2.Binary();
|
|
994
|
+
return {
|
|
995
|
+
arguments: arguments_,
|
|
996
|
+
result: new import_apache_arrow2.Field("ST_MakePoint", type, true, /* @__PURE__ */ new Map([[EXTENSION_NAME, "geoarrow.wkb"]])),
|
|
997
|
+
/** Writes one point per active row, retaining nulls in all other rows. */
|
|
998
|
+
evaluate(vectors, { activeRows, length }) {
|
|
999
|
+
const values = new Array(length).fill(null);
|
|
1000
|
+
for (let row = 0; row < length; row++) {
|
|
1001
|
+
if (activeRows[row]) {
|
|
1002
|
+
const coordinates = vectors.map((vector) => Number(vector.get(row)));
|
|
1003
|
+
values[row] = (0, import_arrow4.writeWKB)({ type: "Point", coordinates });
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return (0, import_apache_arrow2.vectorFromArray)(values, type);
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
function tileEnvelope(zoom, x, y, bounds, margin) {
|
|
1012
|
+
if (!Number.isInteger(zoom) || zoom < 0 || zoom > 31)
|
|
1013
|
+
throw new Error("ST_TileEnvelope zoom must be an integer in [0,31]");
|
|
1014
|
+
const count = 2 ** zoom;
|
|
1015
|
+
if (![x, y].every((index) => Number.isInteger(index) && index >= 0 && index < count))
|
|
1016
|
+
throw new Error("ST_TileEnvelope tile index outside zoom level");
|
|
1017
|
+
if (!Number.isFinite(margin) || margin < -0.5)
|
|
1018
|
+
throw new Error("Invalid ST_TileEnvelope margin");
|
|
1019
|
+
const [west, south, east, north] = bounds;
|
|
1020
|
+
const width = (east - west) / count, height = (north - south) / count;
|
|
1021
|
+
if (!(width > 0 && height > 0 && Number.isFinite(width) && Number.isFinite(height)))
|
|
1022
|
+
throw new Error("ST_TileEnvelope requires nondegenerate bounds");
|
|
1023
|
+
const fullWidth = 1 + 2 * margin > count;
|
|
1024
|
+
const left = fullWidth ? west : Math.max(west, west + (x - margin) * width);
|
|
1025
|
+
const right = fullWidth ? east : Math.min(east, west + (x + 1 + margin) * width);
|
|
1026
|
+
const bottom = Math.max(south, north - (y + 1 + margin) * height);
|
|
1027
|
+
const top = Math.min(north, north - (y - margin) * height);
|
|
1028
|
+
return (0, import_arrow4.writeWKB)({
|
|
1029
|
+
type: "Polygon",
|
|
1030
|
+
coordinates: [
|
|
1031
|
+
[
|
|
1032
|
+
[left, bottom],
|
|
1033
|
+
[left, top],
|
|
1034
|
+
[right, top],
|
|
1035
|
+
[right, bottom],
|
|
1036
|
+
[left, bottom]
|
|
1037
|
+
]
|
|
1038
|
+
]
|
|
1039
|
+
}, "xy");
|
|
1040
|
+
}
|
|
1041
|
+
var ST_TILEENVELOPE = {
|
|
1042
|
+
kind: "scalar",
|
|
1043
|
+
name: "ST_TileEnvelope",
|
|
1044
|
+
prototypes: [],
|
|
1045
|
+
/** Binds numeric tile indices and the optional GeoArrow root extent. */
|
|
1046
|
+
resolvePrototype(fields) {
|
|
1047
|
+
if (fields.length < 3 || fields.length > 5)
|
|
1048
|
+
return void 0;
|
|
1049
|
+
const custom = fields.length >= 4;
|
|
1050
|
+
const root = fields[3];
|
|
1051
|
+
if (custom)
|
|
1052
|
+
ST_ENVELOPE.resolvePrototype([root]);
|
|
1053
|
+
const args = fields.map((field, i) => {
|
|
1054
|
+
if (i === 3)
|
|
1055
|
+
return field ?? new import_apache_arrow2.Field("bounds", new import_apache_arrow2.Binary(), true);
|
|
1056
|
+
if (field && !import_apache_arrow2.DataType.isInt(field.type) && !import_apache_arrow2.DataType.isFloat(field.type))
|
|
1057
|
+
throw new Error("ST_TileEnvelope requires numeric indices and margin");
|
|
1058
|
+
return field ?? new import_apache_arrow2.Field("number", new import_apache_arrow2.Float64(), true);
|
|
1059
|
+
});
|
|
1060
|
+
const metadata = /* @__PURE__ */ new Map([[EXTENSION_NAME, "geoarrow.wkb"]]);
|
|
1061
|
+
const crs = custom ? root == null ? void 0 : root.metadata.get(EXTENSION_METADATA) : '{"crs_type":"authority_code","crs":"EPSG:3857"}';
|
|
1062
|
+
if (crs)
|
|
1063
|
+
metadata.set(EXTENSION_METADATA, crs);
|
|
1064
|
+
const type = new import_apache_arrow2.Binary();
|
|
1065
|
+
const r = EPSG3857_HALF_CIRCUMFERENCE;
|
|
1066
|
+
const world = [-r, -r, r, r];
|
|
1067
|
+
return {
|
|
1068
|
+
arguments: args,
|
|
1069
|
+
result: new import_apache_arrow2.Field("ST_TileEnvelope", type, true, metadata),
|
|
1070
|
+
/** Computes bounds for active rows using the top-left XYZ origin. */
|
|
1071
|
+
evaluate(vectors, { activeRows, length }) {
|
|
1072
|
+
const values = new Array(length).fill(null);
|
|
1073
|
+
const read = root ? readGeometryValue(vectors[3], root, activeRows, planarGeometry) : void 0;
|
|
1074
|
+
for (let row = 0; row < length; row++) {
|
|
1075
|
+
if (!activeRows[row])
|
|
1076
|
+
continue;
|
|
1077
|
+
const bounds = read ? planarBounds(read(row)) : world;
|
|
1078
|
+
if (!bounds)
|
|
1079
|
+
throw new Error("ST_TileEnvelope requires nonempty bounds");
|
|
1080
|
+
values[row] = tileEnvelope(Number(vectors[0].get(row)), Number(vectors[1].get(row)), Number(vectors[2].get(row)), bounds, vectors[4] ? Number(vectors[4].get(row)) : 0);
|
|
1081
|
+
}
|
|
1082
|
+
return (0, import_apache_arrow2.vectorFromArray)(values, type);
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
function pointOrdinate(ordinate) {
|
|
1088
|
+
const name = "ST_" + ordinate.toUpperCase();
|
|
1089
|
+
return {
|
|
1090
|
+
kind: "scalar",
|
|
1091
|
+
name,
|
|
1092
|
+
prototypes: [],
|
|
1093
|
+
/** Accepts native Points or WKB whose geometry kind is checked per active row. */
|
|
1094
|
+
resolvePrototype(fields) {
|
|
1095
|
+
if (fields.length !== 1)
|
|
1096
|
+
return void 0;
|
|
1097
|
+
const field = fields[0] ?? new import_apache_arrow2.Field("point", new import_apache_arrow2.Binary(), true, /* @__PURE__ */ new Map([[EXTENSION_NAME, "geoarrow.wkb"]]));
|
|
1098
|
+
const extension = (0, import_arrow4.getGeoArrowFieldInfo)(field);
|
|
1099
|
+
if ((extension == null ? void 0 : extension.metadata["edges"]) === "spherical")
|
|
1100
|
+
throw new Error(`${name} requires planar geometry`);
|
|
1101
|
+
const encoding = extension == null ? void 0 : extension.encoding;
|
|
1102
|
+
if (encoding !== "geoarrow.point" && !(encoding === "geoarrow.wkb" && (import_apache_arrow2.DataType.isBinary(field.type) || import_apache_arrow2.DataType.isLargeBinary(field.type))))
|
|
1103
|
+
throw new Error(`${name} requires a GeoArrow Point`);
|
|
1104
|
+
const type = new import_apache_arrow2.Float64();
|
|
1105
|
+
return {
|
|
1106
|
+
arguments: [field],
|
|
1107
|
+
result: new import_apache_arrow2.Field(name, type, true),
|
|
1108
|
+
/** Extracts ordinates using the WKB row or native field dimension. */
|
|
1109
|
+
evaluate([vector], { length, activeRows }) {
|
|
1110
|
+
if (encoding === "geoarrow.point") {
|
|
1111
|
+
const column2 = readActiveGeoArrowColumn(vector, field, activeRows);
|
|
1112
|
+
const result2 = new Array(length).fill(null);
|
|
1113
|
+
const index = column2.dimension.indexOf(ordinate);
|
|
1114
|
+
if (index >= 0) {
|
|
1115
|
+
(0, import_arrow4.visitGeoArrowCoordinates)(column2, (coordinate, row) => {
|
|
1116
|
+
if (Number.isFinite(coordinate[0]) && Number.isFinite(coordinate[1])) {
|
|
1117
|
+
result2[row] = coordinate[index] ?? null;
|
|
1118
|
+
}
|
|
1119
|
+
return coordinate;
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
return (0, import_apache_arrow2.vectorFromArray)(result2, type);
|
|
1123
|
+
}
|
|
1124
|
+
const read = readGeometryValue(vector, field, activeRows, (geometry, dimension) => {
|
|
1125
|
+
var _a;
|
|
1126
|
+
if (geometry.type !== "Point")
|
|
1127
|
+
throw new Error(`${name} requires a Point`);
|
|
1128
|
+
return ((_a = pointCoordinates(geometry)) == null ? void 0 : _a[dimension.indexOf(ordinate)]) ?? null;
|
|
1129
|
+
});
|
|
1130
|
+
return (0, import_apache_arrow2.vectorFromArray)(Array.from({ length }, (_, i) => activeRows[i] ? read(i) : null), type);
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
var ST_X = /* @__PURE__ */ pointOrdinate("x");
|
|
1137
|
+
var ST_Y = /* @__PURE__ */ pointOrdinate("y");
|
|
1138
|
+
var ST_Z = /* @__PURE__ */ pointOrdinate("z");
|
|
1139
|
+
var ST_M = /* @__PURE__ */ pointOrdinate("m");
|
|
1140
|
+
var ST_STARTPOINT = /* @__PURE__ */ spatialFunction(
|
|
1141
|
+
"ST_StartPoint",
|
|
1142
|
+
[["LineString"]],
|
|
1143
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1144
|
+
([line]) => {
|
|
1145
|
+
if ((line == null ? void 0 : line.type) !== "LineString" || !line.coordinates.length)
|
|
1146
|
+
return null;
|
|
1147
|
+
return (0, import_arrow4.writeWKB)({ type: "Point", coordinates: line.coordinates[0] }, "xy");
|
|
1148
|
+
}
|
|
1149
|
+
);
|
|
1150
|
+
var ST_ENDPOINT = /* @__PURE__ */ spatialFunction(
|
|
1151
|
+
"ST_EndPoint",
|
|
1152
|
+
[["LineString"]],
|
|
1153
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1154
|
+
([line]) => {
|
|
1155
|
+
if ((line == null ? void 0 : line.type) !== "LineString" || !line.coordinates.length)
|
|
1156
|
+
return null;
|
|
1157
|
+
return (0, import_arrow4.writeWKB)({ type: "Point", coordinates: line.coordinates[line.coordinates.length - 1] }, "xy");
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
var ST_CONTAINS = /* @__PURE__ */ spatialFunction(
|
|
1161
|
+
"ST_Contains",
|
|
1162
|
+
[polygonKinds, pointKinds],
|
|
1163
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1164
|
+
([polygon, point2]) => pointInPolygon(point2, polygon, true) ?? false
|
|
1165
|
+
);
|
|
1166
|
+
var ST_COVERS = /* @__PURE__ */ spatialFunction(
|
|
1167
|
+
"ST_Covers",
|
|
1168
|
+
[polygonKinds, pointKinds],
|
|
1169
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1170
|
+
([polygon, point2]) => pointInPolygon(point2, polygon) ?? false
|
|
1171
|
+
);
|
|
1172
|
+
var ST_WITHIN = /* @__PURE__ */ spatialFunction(
|
|
1173
|
+
"ST_Within",
|
|
1174
|
+
[pointKinds, polygonKinds],
|
|
1175
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1176
|
+
([p, polygon]) => pointInPolygon(p, polygon, true) ?? false
|
|
1177
|
+
);
|
|
1178
|
+
var ST_COVEREDBY = /* @__PURE__ */ spatialFunction(
|
|
1179
|
+
"ST_CoveredBy",
|
|
1180
|
+
[pointKinds, polygonKinds],
|
|
1181
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1182
|
+
([p, polygon]) => pointInPolygon(p, polygon) ?? false
|
|
1183
|
+
);
|
|
1184
|
+
var ST_POINTN = /* @__PURE__ */ spatialFunction(
|
|
1185
|
+
"ST_PointN",
|
|
1186
|
+
[["LineString"]],
|
|
1187
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1188
|
+
([line], position) => {
|
|
1189
|
+
if (!Number.isInteger(position))
|
|
1190
|
+
throw new Error("ST_PointN requires an integer position");
|
|
1191
|
+
if ((line == null ? void 0 : line.type) !== "LineString" || !position)
|
|
1192
|
+
return null;
|
|
1193
|
+
const index = position > 0 ? position - 1 : line.coordinates.length + position;
|
|
1194
|
+
const coordinates = line.coordinates[index];
|
|
1195
|
+
return coordinates ? (0, import_arrow4.writeWKB)({ type: "Point", coordinates }, "xy") : null;
|
|
1196
|
+
},
|
|
1197
|
+
1
|
|
1198
|
+
);
|
|
1199
|
+
var ST_MAKEENVELOPE = /* @__PURE__ */ spatialFunction(
|
|
1200
|
+
"ST_MakeEnvelope",
|
|
1201
|
+
[],
|
|
1202
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1203
|
+
(_, xmin, ymin, xmax, ymax) => (0, import_arrow4.writeWKB)({
|
|
1204
|
+
type: "Polygon",
|
|
1205
|
+
coordinates: [
|
|
1206
|
+
[
|
|
1207
|
+
[xmin, ymin],
|
|
1208
|
+
[xmin, ymax],
|
|
1209
|
+
[xmax, ymax],
|
|
1210
|
+
[xmax, ymin],
|
|
1211
|
+
[xmin, ymin]
|
|
1212
|
+
]
|
|
1213
|
+
]
|
|
1214
|
+
}, "xy"),
|
|
1215
|
+
4
|
|
1216
|
+
);
|
|
1217
|
+
var ST_DISTANCE = /* @__PURE__ */ spatialFunction(
|
|
1218
|
+
"ST_Distance",
|
|
1219
|
+
[pointKinds, pointKinds],
|
|
1220
|
+
/* @__PURE__ */ new import_apache_arrow2.Float64(),
|
|
1221
|
+
([a, b]) => {
|
|
1222
|
+
const p = pointCoordinates(a);
|
|
1223
|
+
const q = pointCoordinates(b);
|
|
1224
|
+
return p && q ? Math.hypot(q[0] - p[0], q[1] - p[1]) : null;
|
|
1225
|
+
}
|
|
1226
|
+
);
|
|
1227
|
+
var ST_DWITHIN = /* @__PURE__ */ spatialFunction(
|
|
1228
|
+
"ST_DWithin",
|
|
1229
|
+
[pointKinds, pointKinds],
|
|
1230
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1231
|
+
([a, b], radius) => {
|
|
1232
|
+
if (radius < 0)
|
|
1233
|
+
throw new Error("ST_DWithin distance must be nonnegative");
|
|
1234
|
+
const p = pointCoordinates(a);
|
|
1235
|
+
const q = pointCoordinates(b);
|
|
1236
|
+
return Boolean(p && q && Math.hypot(q[0] - p[0], q[1] - p[1]) <= radius);
|
|
1237
|
+
},
|
|
1238
|
+
1
|
|
1239
|
+
);
|
|
1240
|
+
var ST_INTERSECTS = /* @__PURE__ */ spatialFunction(
|
|
1241
|
+
"ST_Intersects",
|
|
1242
|
+
[
|
|
1243
|
+
[...geometryTypes, "GeometryCollection"],
|
|
1244
|
+
[...geometryTypes, "GeometryCollection"]
|
|
1245
|
+
],
|
|
1246
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1247
|
+
([a, b]) => planarIntersects(a, b)
|
|
1248
|
+
);
|
|
1249
|
+
var ST_LINEINTERPOLATEPOINT = /* @__PURE__ */ spatialFunction(
|
|
1250
|
+
"ST_LineInterpolatePoint",
|
|
1251
|
+
[["LineString"]],
|
|
1252
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1253
|
+
([line], fraction) => (0, import_arrow4.writeWKB)(lineSubstring(line, fraction, fraction) ?? { type: "Point", coordinates: [] }, "xy"),
|
|
1254
|
+
1
|
|
1255
|
+
);
|
|
1256
|
+
var ST_LINELOCATEPOINT = /* @__PURE__ */ spatialFunction(
|
|
1257
|
+
"ST_LineLocatePoint",
|
|
1258
|
+
[["LineString"], pointKinds],
|
|
1259
|
+
/* @__PURE__ */ new import_apache_arrow2.Float64(),
|
|
1260
|
+
([line, point2]) => lineLocatePoint(line, point2)
|
|
1261
|
+
);
|
|
1262
|
+
var ST_LINESUBSTRING = /* @__PURE__ */ spatialFunction(
|
|
1263
|
+
"ST_LineSubstring",
|
|
1264
|
+
[["LineString"]],
|
|
1265
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1266
|
+
([line], start, end) => {
|
|
1267
|
+
const result2 = lineSubstring(line, start, end);
|
|
1268
|
+
return result2 ? (0, import_arrow4.writeWKB)(result2, "xy") : null;
|
|
1269
|
+
},
|
|
1270
|
+
2
|
|
1271
|
+
);
|
|
1272
|
+
function geometrySRID(crs) {
|
|
1273
|
+
let identifier = typeof crs === "string" ? normalizeCRSIdentifier(crs) : "";
|
|
1274
|
+
if (crs && typeof crs === "object" && "id" in crs) {
|
|
1275
|
+
const id = crs.id;
|
|
1276
|
+
if (id && typeof id === "object" && "authority" in id && "code" in id && id.authority === "EPSG")
|
|
1277
|
+
identifier = "EPSG:" + String(id.code);
|
|
1278
|
+
}
|
|
1279
|
+
return /^EPSG:\d+$/.test(identifier) ? Number(identifier.slice(5)) : 0;
|
|
1280
|
+
}
|
|
1281
|
+
function projectGeometry(geometry, project) {
|
|
1282
|
+
const path = (points2) => points2.map(project);
|
|
1283
|
+
switch (geometry.type) {
|
|
1284
|
+
case "Point":
|
|
1285
|
+
return {
|
|
1286
|
+
type: "Point",
|
|
1287
|
+
coordinates: geometry.coordinates.length && !geometry.coordinates.every(Number.isNaN) ? project(geometry.coordinates) : []
|
|
1288
|
+
};
|
|
1289
|
+
case "MultiPoint":
|
|
1290
|
+
return {
|
|
1291
|
+
type: "MultiPoint",
|
|
1292
|
+
coordinates: geometry.coordinates.map((p) => !p.length || p.every(Number.isNaN) ? p : project(p))
|
|
1293
|
+
};
|
|
1294
|
+
case "LineString":
|
|
1295
|
+
return { type: "LineString", coordinates: path(geometry.coordinates) };
|
|
1296
|
+
case "MultiLineString":
|
|
1297
|
+
case "Polygon":
|
|
1298
|
+
return { type: geometry.type, coordinates: geometry.coordinates.map(path) };
|
|
1299
|
+
case "MultiPolygon":
|
|
1300
|
+
return { type: "MultiPolygon", coordinates: geometry.coordinates.map((poly) => poly.map(path)) };
|
|
1301
|
+
case "GeometryCollection":
|
|
1302
|
+
return {
|
|
1303
|
+
type: "GeometryCollection",
|
|
1304
|
+
geometries: geometry.geometries.map((child) => projectGeometry(child, project))
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
function crsFunction(name) {
|
|
1309
|
+
const read = name === "ST_SRID";
|
|
1310
|
+
return {
|
|
1311
|
+
kind: "scalar",
|
|
1312
|
+
name,
|
|
1313
|
+
prototypes: [],
|
|
1314
|
+
/** Resolves the source from field metadata and the target from the SQL literal. */
|
|
1315
|
+
resolvePrototype(fields, literals) {
|
|
1316
|
+
var _a;
|
|
1317
|
+
if (fields.length !== (read ? 1 : 2))
|
|
1318
|
+
return void 0;
|
|
1319
|
+
const metadata = fields[0] && ((_a = (0, import_arrow4.getGeoArrowFieldInfo)(fields[0])) == null ? void 0 : _a.metadata);
|
|
1320
|
+
const source = geometrySRID(metadata == null ? void 0 : metadata["crs"]);
|
|
1321
|
+
const target = (literals == null ? void 0 : literals[1]) ?? 0;
|
|
1322
|
+
if (!read && ((literals == null ? void 0 : literals[1]) === void 0 || !Number.isSafeInteger(target) || target < 0 || target > 998999))
|
|
1323
|
+
throw new Error(name + " requires a constant integer SRID between 0 and 998999");
|
|
1324
|
+
if (name === "ST_Transform" && (![4326, 3857].includes(source) || ![4326, 3857].includes(target)))
|
|
1325
|
+
throw new Error("ST_Transform supports EPSG:4326 and EPSG:3857 source and target CRS");
|
|
1326
|
+
const implementation = spatialFunction(name, [[...geometryTypes, "GeometryCollection"]], read ? new import_apache_arrow2.Int32() : new import_apache_arrow2.Binary(), ([geometry]) => {
|
|
1327
|
+
if (read)
|
|
1328
|
+
return source;
|
|
1329
|
+
const output = name === "ST_Transform" && source !== target ? projectGeometry(geometry, (p) => target === 3857 ? EPSG4326ToEPSG3857([...p], { clampLatitude: false }) : EPSG3857ToLngLat([...p])) : geometry;
|
|
1330
|
+
return (0, import_arrow4.writeWKB)(output, "xy");
|
|
1331
|
+
}, read ? 0 : 1).resolvePrototype(fields);
|
|
1332
|
+
if (!read) {
|
|
1333
|
+
const crsMetadata = { ...metadata };
|
|
1334
|
+
delete crsMetadata["crs_type"];
|
|
1335
|
+
delete crsMetadata["crs"];
|
|
1336
|
+
if (target)
|
|
1337
|
+
Object.assign(crsMetadata, { crs_type: "authority_code", crs: "EPSG:" + target });
|
|
1338
|
+
implementation.result.metadata.set(EXTENSION_METADATA, JSON.stringify(crsMetadata));
|
|
1339
|
+
}
|
|
1340
|
+
return implementation;
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
var ST_SRID = /* @__PURE__ */ crsFunction("ST_SRID");
|
|
1345
|
+
var ST_SETSRID = /* @__PURE__ */ crsFunction("ST_SetSRID");
|
|
1346
|
+
var ST_TRANSFORM = /* @__PURE__ */ crsFunction("ST_Transform");
|
|
1347
|
+
function lineReduction(name, mode) {
|
|
1348
|
+
return {
|
|
1349
|
+
kind: "scalar",
|
|
1350
|
+
name,
|
|
1351
|
+
prototypes: [],
|
|
1352
|
+
/** Binds the geometry and any supplied numeric tolerance. */
|
|
1353
|
+
resolvePrototype(fields) {
|
|
1354
|
+
const numericArguments = mode === "removeRepeated" && fields.length === 1 ? 0 : 1;
|
|
1355
|
+
return spatialFunction(name, [lineKinds], new import_apache_arrow2.Binary(), ([line], tolerance = 0) => {
|
|
1356
|
+
const result2 = reduceLineVertices(line, tolerance, mode);
|
|
1357
|
+
return result2 ? (0, import_arrow4.writeWKB)(result2, "xy") : null;
|
|
1358
|
+
}, numericArguments).resolvePrototype(fields);
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
var ST_REMOVEREPEATEDPOINTS = /* @__PURE__ */ lineReduction("ST_RemoveRepeatedPoints", "removeRepeated");
|
|
1363
|
+
var ST_SIMPLIFY = /* @__PURE__ */ lineReduction("ST_Simplify", "simplify");
|
|
1364
|
+
var ST_AZIMUTH = /* @__PURE__ */ spatialFunction(
|
|
1365
|
+
"ST_Azimuth",
|
|
1366
|
+
[pointKinds, pointKinds],
|
|
1367
|
+
/* @__PURE__ */ new import_apache_arrow2.Float64(),
|
|
1368
|
+
([a, b]) => {
|
|
1369
|
+
const p = pointCoordinates(a);
|
|
1370
|
+
const q = pointCoordinates(b);
|
|
1371
|
+
if (!p || !q)
|
|
1372
|
+
return null;
|
|
1373
|
+
const dx = q[0] - p[0];
|
|
1374
|
+
const dy = q[1] - p[1];
|
|
1375
|
+
if (!dx && !dy)
|
|
1376
|
+
return null;
|
|
1377
|
+
const angle = Math.atan2(dx, dy);
|
|
1378
|
+
return angle < 0 ? angle + 2 * Math.PI : angle;
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1381
|
+
var ST_AREA = /* @__PURE__ */ spatialFunction(
|
|
1382
|
+
"ST_Area",
|
|
1383
|
+
[geometryTypes],
|
|
1384
|
+
/* @__PURE__ */ new import_apache_arrow2.Float64(),
|
|
1385
|
+
([geometry]) => planarArea(geometry)
|
|
1386
|
+
);
|
|
1387
|
+
var ST_LENGTH = /* @__PURE__ */ spatialFunction(
|
|
1388
|
+
"ST_Length",
|
|
1389
|
+
[geometryTypes],
|
|
1390
|
+
/* @__PURE__ */ new import_apache_arrow2.Float64(),
|
|
1391
|
+
([geometry]) => planarLength(geometry)
|
|
1392
|
+
);
|
|
1393
|
+
var ST_CENTROID = /* @__PURE__ */ spatialFunction(
|
|
1394
|
+
"ST_Centroid",
|
|
1395
|
+
[geometryTypes],
|
|
1396
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1397
|
+
([geometry]) => (0, import_arrow4.writeWKB)(planarCentroid(geometry), "xy")
|
|
1398
|
+
);
|
|
1399
|
+
var inspectionKinds = [[...geometryTypes, "GeometryCollection"]];
|
|
1400
|
+
var ST_NPOINTS = /* @__PURE__ */ spatialFunction(
|
|
1401
|
+
"ST_NPoints",
|
|
1402
|
+
inspectionKinds,
|
|
1403
|
+
/* @__PURE__ */ new import_apache_arrow2.Int32(),
|
|
1404
|
+
([g]) => vertexCount(g),
|
|
1405
|
+
0,
|
|
1406
|
+
true
|
|
1407
|
+
);
|
|
1408
|
+
var ST_NUMGEOMETRIES = /* @__PURE__ */ spatialFunction(
|
|
1409
|
+
"ST_NumGeometries",
|
|
1410
|
+
inspectionKinds,
|
|
1411
|
+
/* @__PURE__ */ new import_apache_arrow2.Int32(),
|
|
1412
|
+
([g]) => memberCount(g),
|
|
1413
|
+
0,
|
|
1414
|
+
true
|
|
1415
|
+
);
|
|
1416
|
+
var ST_ISEMPTY = /* @__PURE__ */ spatialFunction(
|
|
1417
|
+
"ST_IsEmpty",
|
|
1418
|
+
inspectionKinds,
|
|
1419
|
+
/* @__PURE__ */ new import_apache_arrow2.Bool(),
|
|
1420
|
+
([g]) => !vertexCount(g),
|
|
1421
|
+
0,
|
|
1422
|
+
true
|
|
1423
|
+
);
|
|
1424
|
+
var ST_GEOMETRYTYPE = /* @__PURE__ */ spatialFunction(
|
|
1425
|
+
"ST_GeometryType",
|
|
1426
|
+
inspectionKinds,
|
|
1427
|
+
/* @__PURE__ */ new import_apache_arrow2.Utf8(),
|
|
1428
|
+
([g]) => "ST_" + g.type,
|
|
1429
|
+
0,
|
|
1430
|
+
true
|
|
1431
|
+
);
|
|
1432
|
+
var ST_FORCE2D = /* @__PURE__ */ spatialFunction(
|
|
1433
|
+
"ST_Force2D",
|
|
1434
|
+
inspectionKinds,
|
|
1435
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1436
|
+
([g]) => (0, import_arrow4.writeWKB)(g, "xy"),
|
|
1437
|
+
0,
|
|
1438
|
+
true
|
|
1439
|
+
);
|
|
1440
|
+
var ST_GEOMETRYN = /* @__PURE__ */ spatialFunction(
|
|
1441
|
+
"ST_GeometryN",
|
|
1442
|
+
inspectionKinds,
|
|
1443
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1444
|
+
([g], position) => {
|
|
1445
|
+
var _a;
|
|
1446
|
+
const part = geometryMember(g, position);
|
|
1447
|
+
return part ? ((_a = g.members) == null ? void 0 : _a[position - 1]) ?? (0, import_arrow4.writeWKB)(part, g.dimension ?? "xy") : null;
|
|
1448
|
+
},
|
|
1449
|
+
1,
|
|
1450
|
+
true
|
|
1451
|
+
);
|
|
1452
|
+
var ST_MAKELINE = /* @__PURE__ */ spatialFunction(
|
|
1453
|
+
"ST_MakeLine",
|
|
1454
|
+
[
|
|
1455
|
+
["Point", "MultiPoint", "LineString"],
|
|
1456
|
+
["Point", "MultiPoint", "LineString"]
|
|
1457
|
+
],
|
|
1458
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1459
|
+
(geometries) => (0, import_arrow4.writeWKB)(makeLine(geometries), "xy")
|
|
1460
|
+
);
|
|
1461
|
+
var ST_COLLECT = /* @__PURE__ */ spatialFunction(
|
|
1462
|
+
"ST_Collect",
|
|
1463
|
+
[
|
|
1464
|
+
[...geometryTypes, "GeometryCollection"],
|
|
1465
|
+
[...geometryTypes, "GeometryCollection"]
|
|
1466
|
+
],
|
|
1467
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1468
|
+
([a, b]) => a ? (0, import_arrow4.writeWKB)(b ? collectPair(a, b) : a, "xy") : null,
|
|
1469
|
+
0,
|
|
1470
|
+
false,
|
|
1471
|
+
true
|
|
1472
|
+
);
|
|
1473
|
+
var ST_POINTONSURFACE = /* @__PURE__ */ spatialFunction(
|
|
1474
|
+
"ST_PointOnSurface",
|
|
1475
|
+
[polygonKinds],
|
|
1476
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1477
|
+
([polygon]) => (0, import_arrow4.writeWKB)(planarPolygonPointOnSurface(polygon), "xy")
|
|
1478
|
+
);
|
|
1479
|
+
function makeEnvelopeFunction() {
|
|
1480
|
+
const envelopeFunction = spatialFunction(
|
|
1481
|
+
"ST_Envelope",
|
|
1482
|
+
[[...geometryTypes, "GeometryCollection"]],
|
|
1483
|
+
/* @__PURE__ */ new import_apache_arrow2.Binary(),
|
|
1484
|
+
([geometry]) => (0, import_arrow4.writeWKB)(planarEnvelope(geometry), "xy")
|
|
1485
|
+
);
|
|
1486
|
+
return {
|
|
1487
|
+
...envelopeFunction,
|
|
1488
|
+
/** Keeps the WKB evaluator and binds the bounds kernel for native columns. */
|
|
1489
|
+
resolvePrototype(fields) {
|
|
1490
|
+
const prototype = envelopeFunction.resolvePrototype(fields);
|
|
1491
|
+
const field = fields[0];
|
|
1492
|
+
if (!prototype || !field || import_apache_arrow2.DataType.isBinary(field.type) || import_apache_arrow2.DataType.isLargeBinary(field.type)) {
|
|
1493
|
+
return prototype;
|
|
1494
|
+
}
|
|
1495
|
+
return {
|
|
1496
|
+
...prototype,
|
|
1497
|
+
/** Evaluates active rows and preserves the type of empty geometries. */
|
|
1498
|
+
evaluate([vector], { activeRows, length }) {
|
|
1499
|
+
const column2 = readActiveGeoArrowColumn(vector, field, activeRows);
|
|
1500
|
+
const bounds = (0, import_arrow4.getGeoArrowRowBounds)(column2);
|
|
1501
|
+
const values = Array.from({ length }, (_, row) => {
|
|
1502
|
+
if (!activeRows[row])
|
|
1503
|
+
return null;
|
|
1504
|
+
const box = bounds[row];
|
|
1505
|
+
if (box)
|
|
1506
|
+
return (0, import_arrow4.writeWKB)(envelopeFromBounds(box), "xy");
|
|
1507
|
+
const [geometry] = (0, import_arrow4.materializeGeoArrowRows)((0, import_arrow4.getGeoArrowColumnView)(column2, row, row + 1));
|
|
1508
|
+
return geometry ? (0, import_arrow4.writeWKB)(geometry, "xy") : null;
|
|
1509
|
+
});
|
|
1510
|
+
return (0, import_apache_arrow2.vectorFromArray)(values, new import_apache_arrow2.Binary());
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
var ST_ENVELOPE = /* @__PURE__ */ makeEnvelopeFunction();
|
|
1517
|
+
var ST_EXTENT = {
|
|
1518
|
+
kind: "aggregate",
|
|
1519
|
+
name: "ST_Extent",
|
|
1520
|
+
/** Binds the input geometry signature and the fixed-size box result. */
|
|
1521
|
+
bind({ arguments: fields }) {
|
|
1522
|
+
const field = fields[0];
|
|
1523
|
+
if (!field || fields.length !== 1)
|
|
1524
|
+
throw new Error("ST_Extent requires one geometry column");
|
|
1525
|
+
ST_ENVELOPE.resolvePrototype([field]);
|
|
1526
|
+
return {
|
|
1527
|
+
outputField: new import_apache_arrow2.Field("ST_Extent", new import_apache_arrow2.FixedSizeList(4, new import_apache_arrow2.Field("value", new import_apache_arrow2.Float64(), false)), true),
|
|
1528
|
+
/** Creates independent bounds for this group. */
|
|
1529
|
+
createAccumulator() {
|
|
1530
|
+
let bounds = null;
|
|
1531
|
+
function include(box) {
|
|
1532
|
+
if (!bounds)
|
|
1533
|
+
bounds = [...box];
|
|
1534
|
+
else {
|
|
1535
|
+
bounds[0] = Math.min(bounds[0], box[0]);
|
|
1536
|
+
bounds[1] = Math.min(bounds[1], box[1]);
|
|
1537
|
+
bounds[2] = Math.max(bounds[2], box[2]);
|
|
1538
|
+
bounds[3] = Math.max(bounds[3], box[3]);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
return {
|
|
1542
|
+
/** Accumulates nonempty geometry bounds from one record batch. */
|
|
1543
|
+
update([vector], { length }) {
|
|
1544
|
+
if (!import_apache_arrow2.DataType.isBinary(field.type) && !import_apache_arrow2.DataType.isLargeBinary(field.type)) {
|
|
1545
|
+
const column2 = (0, import_arrow4.makeGeoArrowColumnFromArrowVector)(vector, { field });
|
|
1546
|
+
const box = (0, import_arrow4.getGeoArrowBounds)(column2);
|
|
1547
|
+
if (box)
|
|
1548
|
+
include(box);
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
const active = Uint8Array.from({ length }, (_, i) => Number(vector.isValid(i)));
|
|
1552
|
+
const read = readGeometryValue(vector, field, active, planarGeometry);
|
|
1553
|
+
for (let i = 0; i < length; i++) {
|
|
1554
|
+
if (!active[i])
|
|
1555
|
+
continue;
|
|
1556
|
+
const box = planarBounds(read(i));
|
|
1557
|
+
if (box)
|
|
1558
|
+
include(box);
|
|
1559
|
+
}
|
|
1560
|
+
},
|
|
1561
|
+
/** Combines bounds from another group partition. */
|
|
1562
|
+
merge(partial) {
|
|
1563
|
+
const box = partial.finalize();
|
|
1564
|
+
if (Array.isArray(box))
|
|
1565
|
+
include(box);
|
|
1566
|
+
},
|
|
1567
|
+
/** Returns a detached snapshot, or null for a group without coordinates. */
|
|
1568
|
+
finalize: () => bounds && [...bounds]
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
var POSTGIS_SPATIAL_FUNCTIONS = /* @__PURE__ */ Object.freeze([
|
|
1575
|
+
ST_X,
|
|
1576
|
+
ST_Y,
|
|
1577
|
+
ST_Z,
|
|
1578
|
+
ST_M,
|
|
1579
|
+
ST_STARTPOINT,
|
|
1580
|
+
ST_ENDPOINT,
|
|
1581
|
+
ST_CONTAINS,
|
|
1582
|
+
ST_COVERS,
|
|
1583
|
+
ST_WITHIN,
|
|
1584
|
+
ST_COVEREDBY,
|
|
1585
|
+
ST_POINTN,
|
|
1586
|
+
ST_MAKEENVELOPE,
|
|
1587
|
+
ST_DISTANCE,
|
|
1588
|
+
ST_DWITHIN,
|
|
1589
|
+
ST_INTERSECTS,
|
|
1590
|
+
ST_SRID,
|
|
1591
|
+
ST_SETSRID,
|
|
1592
|
+
ST_TRANSFORM,
|
|
1593
|
+
ST_REMOVEREPEATEDPOINTS,
|
|
1594
|
+
ST_SIMPLIFY,
|
|
1595
|
+
ST_AZIMUTH,
|
|
1596
|
+
ST_MAKEPOINT,
|
|
1597
|
+
ST_TILEENVELOPE,
|
|
1598
|
+
ST_AREA,
|
|
1599
|
+
ST_LENGTH,
|
|
1600
|
+
ST_LINEINTERPOLATEPOINT,
|
|
1601
|
+
ST_LINELOCATEPOINT,
|
|
1602
|
+
ST_LINESUBSTRING,
|
|
1603
|
+
ST_POINTONSURFACE,
|
|
1604
|
+
ST_CENTROID,
|
|
1605
|
+
ST_NPOINTS,
|
|
1606
|
+
ST_NUMGEOMETRIES,
|
|
1607
|
+
ST_ISEMPTY,
|
|
1608
|
+
ST_GEOMETRYTYPE,
|
|
1609
|
+
ST_FORCE2D,
|
|
1610
|
+
ST_GEOMETRYN,
|
|
1611
|
+
ST_MAKELINE,
|
|
1612
|
+
ST_COLLECT,
|
|
1613
|
+
ST_ENVELOPE,
|
|
1614
|
+
ST_EXTENT
|
|
1615
|
+
]);
|
|
1616
|
+
//# sourceMappingURL=st-functions.cjs.map
|