@math.gl/geospatial 5.0.0-rc.2 → 5.0.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 +6 -6
- package/dist/coordinates.cjs +2523 -0
- package/dist/coordinates.cjs.map +6 -0
- package/dist/coordinates.d.ts +4 -0
- package/dist/coordinates.d.ts.map +1 -1
- package/dist/coordinates.js +2 -0
- package/dist/coordinates.js.map +1 -1
- package/dist/entries/ellipsoid.cjs +1209 -0
- package/dist/entries/ellipsoid.cjs.map +6 -0
- package/dist/entries/ellipsoid.d.ts +3 -19
- package/dist/entries/ellipsoid.d.ts.map +1 -1
- package/dist/entries/ellipsoid.js +1 -9
- package/dist/entries/ellipsoid.js.map +1 -1
- package/dist/expressions.cjs +726 -0
- package/dist/expressions.cjs.map +6 -0
- package/dist/geodesics.cjs +3195 -0
- package/dist/geodesics.cjs.map +6 -0
- package/dist/geodesics.d.ts +18 -0
- package/dist/geodesics.d.ts.map +1 -0
- package/dist/geodesics.js +13 -0
- package/dist/geodesics.js.map +1 -0
- package/dist/geographic-atlas/sampling.d.ts +1 -1
- package/dist/geographic-atlas/sampling.d.ts.map +1 -1
- package/dist/geographic-atlas/sampling.js +1 -1
- package/dist/geographic-atlas/sampling.js.map +1 -1
- package/dist/geographic-cuts.cjs +4160 -0
- package/dist/geographic-cuts.cjs.map +6 -0
- package/dist/geographic-cuts.d.ts +2 -0
- package/dist/geographic-cuts.d.ts.map +1 -1
- package/dist/geographic-cuts.js +1 -0
- package/dist/geographic-cuts.js.map +1 -1
- package/dist/geographic-seams/subdivide-cut.d.ts +1 -1
- package/dist/geographic-seams/subdivide-cut.d.ts.map +1 -1
- package/dist/geographic-seams/subdivide-cut.js +1 -1
- package/dist/geographic-seams/subdivide-cut.js.map +1 -1
- package/dist/geographic-seams/types.shared.cjs +32 -0
- package/dist/geographic-seams/types.shared.cjs.map +6 -0
- package/dist/globe.cjs +4223 -0
- package/dist/globe.cjs.map +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/line-simplification.d.ts +7 -0
- package/dist/line-simplification.d.ts.map +1 -1
- package/dist/line-simplification.js +4 -13
- package/dist/line-simplification.js.map +1 -1
- package/dist/linear-referencing.d.ts +13 -1
- package/dist/linear-referencing.d.ts.map +1 -1
- package/dist/linear-referencing.js +29 -9
- package/dist/linear-referencing.js.map +1 -1
- package/dist/maps/map-transition.shared.cjs +364 -0
- package/dist/maps/map-transition.shared.cjs.map +6 -0
- 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 +2 -2
- package/dist/maps/presets.cjs.map +2 -2
- package/dist/maps/transitions.cjs +3 -342
- package/dist/maps/transitions.cjs.map +3 -3
- package/dist/maps.cjs +15 -319
- package/dist/maps.cjs.map +3 -3
- package/dist/measure-referencing.d.ts +16 -0
- package/dist/measure-referencing.d.ts.map +1 -0
- package/dist/measure-referencing.js +143 -0
- package/dist/measure-referencing.js.map +1 -0
- package/dist/polygon-simplification.d.ts +6 -0
- package/dist/polygon-simplification.d.ts.map +1 -0
- package/dist/polygon-simplification.js +141 -0
- package/dist/polygon-simplification.js.map +1 -0
- package/dist/projection/experimental/core.cjs +63 -1317
- package/dist/projection/experimental/core.cjs.map +3 -3
- package/dist/projection/experimental/core.d.ts +1 -1
- package/dist/projection/experimental/core.d.ts.map +1 -1
- package/dist/projection/experimental/crs/projjson.cjs +26 -45
- package/dist/projection/experimental/crs/projjson.cjs.map +3 -3
- package/dist/projection/experimental/crs/types.shared.cjs +44 -0
- package/dist/projection/experimental/crs/types.shared.cjs.map +6 -0
- package/dist/projection/experimental/crs/wkt.cjs +36 -52
- package/dist/projection/experimental/crs/wkt.cjs.map +3 -3
- package/dist/projection/experimental/entries/projections/ob_tran.cjs +9 -23
- package/dist/projection/experimental/entries/projections/ob_tran.cjs.map +3 -3
- package/dist/projection/experimental/lazy-projections/aea.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/aea.js +1 -1
- package/dist/projection/experimental/lazy-projections/aeqd.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/aeqd.js +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/bonne.js +1 -1
- package/dist/projection/experimental/lazy-projections/cass.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/cass.js +1 -1
- package/dist/projection/experimental/lazy-projections/cea.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/cea.js +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/eck6.js +1 -1
- package/dist/projection/experimental/lazy-projections/eqc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/eqc.js +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/eqdc.js +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/eqearth.js +1 -1
- package/dist/projection/experimental/lazy-projections/equi.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/equi.js +1 -1
- package/dist/projection/experimental/lazy-projections/etmerc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/etmerc.js +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/geocent.js +1 -1
- package/dist/projection/experimental/lazy-projections/geos.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/geos.js +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/gnom.js +1 -1
- package/dist/projection/experimental/lazy-projections/gstmerc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/gstmerc.js +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +60 -903
- package/dist/projection/experimental/lazy-projections/index.cjs.map +3 -3
- package/dist/projection/experimental/lazy-projections/krovak.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/krovak.js +1 -1
- package/dist/projection/experimental/lazy-projections/laea.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/laea.js +1 -1
- package/dist/projection/experimental/lazy-projections/lcc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/lcc.js +1 -1
- package/dist/projection/experimental/lazy-projections/merc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/merc.js +1 -1
- package/dist/projection/experimental/lazy-projections/mill.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/mill.js +1 -1
- package/dist/projection/experimental/lazy-projections/moll.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/moll.js +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/nzmg.js +1 -1
- package/dist/projection/experimental/lazy-projections/ob_tran.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/ob_tran.js +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/omerc.js +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/ortho.js +1 -1
- package/dist/projection/experimental/lazy-projections/poly.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/poly.js +1 -1
- package/dist/projection/experimental/lazy-projections/qsc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/qsc.js +1 -1
- package/dist/projection/experimental/lazy-projections/robin.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/robin.js +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/sinu.js +1 -1
- package/dist/projection/experimental/lazy-projections/somerc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/somerc.js +1 -1
- package/dist/projection/experimental/lazy-projections/stere.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/stere.js +1 -1
- package/dist/projection/experimental/lazy-projections/sterea.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/sterea.js +1 -1
- package/dist/projection/experimental/lazy-projections/tmerc.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/tmerc.js +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/tpers.js +1 -1
- package/dist/projection/experimental/lazy-projections/utm.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/utm.js +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.cjs +1 -1
- package/dist/projection/experimental/lazy-projections/vandg.js +1 -1
- package/dist/projection/experimental/projection-engine.shared.cjs +1184 -0
- package/dist/projection/experimental/projection-engine.shared.cjs.map +6 -0
- package/dist/projection/experimental/typescript-projection.shared.cjs +1703 -0
- package/dist/projection/experimental/typescript-projection.shared.cjs.map +6 -0
- package/dist/projection/index.cjs +622 -1535
- package/dist/projection/index.cjs.map +3 -3
- package/dist/projection/pipeline.cjs +44 -58
- package/dist/projection/pipeline.cjs.map +3 -3
- package/dist/projection/transform-analysis.cjs +20 -936
- package/dist/projection/transform-analysis.cjs.map +3 -3
- package/dist/spatial-box-clipping.d.ts +9 -0
- package/dist/spatial-box-clipping.d.ts.map +1 -0
- package/dist/spatial-box-clipping.js +123 -0
- package/dist/spatial-box-clipping.js.map +1 -0
- package/dist/spatial-dwithin.d.ts +19 -0
- package/dist/spatial-dwithin.d.ts.map +1 -0
- package/dist/spatial-dwithin.js +107 -0
- package/dist/spatial-dwithin.js.map +1 -0
- package/dist/spatial-hulls.d.ts +6 -0
- package/dist/spatial-hulls.d.ts.map +1 -0
- package/dist/spatial-hulls.js +176 -0
- package/dist/spatial-hulls.js.map +1 -0
- package/dist/spatial-line-intersection-result.d.ts +4 -0
- package/dist/spatial-line-intersection-result.d.ts.map +1 -0
- package/dist/spatial-line-intersection-result.js +79 -0
- package/dist/spatial-line-intersection-result.js.map +1 -0
- package/dist/spatial-line-polygon-intersection.d.ts +4 -0
- package/dist/spatial-line-polygon-intersection.d.ts.map +1 -0
- package/dist/spatial-line-polygon-intersection.js +130 -0
- package/dist/spatial-line-polygon-intersection.js.map +1 -0
- package/dist/spatial-planar-intersects.d.ts +11 -0
- package/dist/spatial-planar-intersects.d.ts.map +1 -1
- package/dist/spatial-planar-intersects.js +20 -12
- package/dist/spatial-planar-intersects.js.map +1 -1
- package/dist/spatial-planar.d.ts +9 -0
- package/dist/spatial-planar.d.ts.map +1 -1
- package/dist/spatial-planar.js +13 -1
- package/dist/spatial-planar.js.map +1 -1
- package/dist/spatial-polygon-overlay.d.ts +5 -0
- package/dist/spatial-polygon-overlay.d.ts.map +1 -0
- package/dist/spatial-polygon-overlay.js +23 -0
- package/dist/spatial-polygon-overlay.js.map +1 -0
- package/dist/spatial-sql.d.ts +13 -2
- package/dist/spatial-sql.d.ts.map +1 -1
- package/dist/spatial-sql.js +30 -12
- package/dist/spatial-sql.js.map +1 -1
- package/dist/spatial-subdivision.d.ts +9 -0
- package/dist/spatial-subdivision.d.ts.map +1 -0
- package/dist/spatial-subdivision.js +61 -0
- package/dist/spatial-subdivision.js.map +1 -0
- package/dist/spatial-touches.d.ts +13 -0
- package/dist/spatial-touches.d.ts.map +1 -0
- package/dist/spatial-touches.js +192 -0
- package/dist/spatial-touches.js.map +1 -0
- package/dist/st-functions.cjs +2411 -112
- package/dist/st-functions.cjs.map +3 -3
- package/dist/st-functions.d.ts +67 -2
- package/dist/st-functions.d.ts.map +1 -1
- package/dist/st-functions.js +195 -12
- package/dist/st-functions.js.map +1 -1
- package/dist/st-geodesic-functions.d.ts +33 -0
- package/dist/st-geodesic-functions.d.ts.map +1 -0
- package/dist/st-geodesic-functions.js +84 -0
- package/dist/st-geodesic-functions.js.map +1 -0
- package/dist/st-hull-functions.cjs +386 -0
- package/dist/st-hull-functions.cjs.map +6 -0
- package/dist/st-hull-functions.d.ts +17 -0
- package/dist/st-hull-functions.d.ts.map +1 -0
- package/dist/st-hull-functions.js +14 -0
- package/dist/st-hull-functions.js.map +1 -0
- package/dist/st-overlay-functions.cjs +621 -0
- package/dist/st-overlay-functions.cjs.map +6 -0
- package/dist/st-overlay-functions.d.ts +36 -0
- package/dist/st-overlay-functions.d.ts.map +1 -0
- package/dist/st-overlay-functions.js +183 -0
- package/dist/st-overlay-functions.js.map +1 -0
- package/dist/st-viewport-functions.cjs +481 -0
- package/dist/st-viewport-functions.cjs.map +6 -0
- package/dist/st-viewport-functions.d.ts +13 -0
- package/dist/st-viewport-functions.d.ts.map +1 -0
- package/dist/st-viewport-functions.js +81 -0
- package/dist/st-viewport-functions.js.map +1 -0
- package/dist/subdivide-geodesic-polyline.d.ts +1 -1
- package/dist/subdivide-geodesic-polyline.d.ts.map +1 -1
- package/dist/subdivide-geodesic-polyline.js +1 -1
- package/dist/subdivide-geodesic-polyline.js.map +1 -1
- package/dist/subdivide-globe-mesh.d.ts +1 -1
- package/dist/subdivide-globe-mesh.d.ts.map +1 -1
- package/dist/subdivide-globe-mesh.js +1 -1
- package/dist/subdivide-globe-mesh.js.map +1 -1
- package/dist/subdivide-rhumb-polyline.d.ts +1 -1
- package/dist/subdivide-rhumb-polyline.d.ts.map +1 -1
- package/dist/subdivide-rhumb-polyline.js +1 -1
- package/dist/subdivide-rhumb-polyline.js.map +1 -1
- package/dist/tasks/index.cjs +808 -2993
- package/dist/tasks/index.cjs.map +3 -3
- package/dist/terrain/geometry.d.ts +1 -1
- package/dist/terrain/geometry.d.ts.map +1 -1
- package/dist/terrain/geometry.js +1 -1
- package/dist/terrain/geometry.js.map +1 -1
- package/dist/terrain/index.cjs +95 -22
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +1 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +1 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/regional-watersheds.d.ts +44 -0
- package/dist/terrain/regional-watersheds.d.ts.map +1 -0
- package/dist/terrain/regional-watersheds.js +108 -0
- package/dist/terrain/regional-watersheds.js.map +1 -0
- package/dist/terrain/tile-cutout-update.d.ts.map +1 -1
- package/dist/terrain/tile-cutout-update.js +28 -22
- package/dist/terrain/tile-cutout-update.js.map +1 -1
- package/dist/tiles.cjs +354 -0
- package/dist/tiles.cjs.map +6 -0
- package/dist/turf-functions.cjs +16 -9
- package/dist/turf-functions.cjs.map +1 -1
- package/package.json +154 -117
- package/src/coordinates.ts +5 -0
- package/src/entries/ellipsoid.ts +7 -32
- package/src/geodesics.ts +40 -0
- package/src/geographic-atlas/sampling.ts +1 -1
- package/src/geographic-cuts.ts +21 -0
- package/src/geographic-seams/subdivide-cut.ts +1 -1
- package/src/index.ts +2 -0
- package/src/line-simplification.ts +4 -16
- package/src/linear-referencing.ts +44 -16
- package/src/maps/myriahedral/unfold.ts +1 -1
- package/src/measure-referencing.ts +165 -0
- package/src/polygon-simplification.ts +185 -0
- package/src/projection/experimental/core.ts +1 -1
- package/src/projection/experimental/lazy-projections/aea.ts +1 -1
- package/src/projection/experimental/lazy-projections/aeqd.ts +1 -1
- package/src/projection/experimental/lazy-projections/bonne.ts +1 -1
- package/src/projection/experimental/lazy-projections/cass.ts +1 -1
- package/src/projection/experimental/lazy-projections/cea.ts +1 -1
- package/src/projection/experimental/lazy-projections/eck6.ts +1 -1
- package/src/projection/experimental/lazy-projections/eqc.ts +1 -1
- package/src/projection/experimental/lazy-projections/eqdc.ts +1 -1
- package/src/projection/experimental/lazy-projections/eqearth.ts +1 -1
- package/src/projection/experimental/lazy-projections/equi.ts +1 -1
- package/src/projection/experimental/lazy-projections/etmerc.ts +1 -1
- package/src/projection/experimental/lazy-projections/geocent.ts +1 -1
- package/src/projection/experimental/lazy-projections/geos.ts +1 -1
- package/src/projection/experimental/lazy-projections/gnom.ts +1 -1
- package/src/projection/experimental/lazy-projections/gstmerc.ts +1 -1
- package/src/projection/experimental/lazy-projections/krovak.ts +1 -1
- package/src/projection/experimental/lazy-projections/laea.ts +1 -1
- package/src/projection/experimental/lazy-projections/lcc.ts +1 -1
- package/src/projection/experimental/lazy-projections/merc.ts +1 -1
- package/src/projection/experimental/lazy-projections/mill.ts +1 -1
- package/src/projection/experimental/lazy-projections/moll.ts +1 -1
- package/src/projection/experimental/lazy-projections/nzmg.ts +1 -1
- package/src/projection/experimental/lazy-projections/ob_tran.ts +1 -1
- package/src/projection/experimental/lazy-projections/omerc.ts +1 -1
- package/src/projection/experimental/lazy-projections/ortho.ts +1 -1
- package/src/projection/experimental/lazy-projections/poly.ts +1 -1
- package/src/projection/experimental/lazy-projections/qsc.ts +1 -1
- package/src/projection/experimental/lazy-projections/robin.ts +1 -1
- package/src/projection/experimental/lazy-projections/sinu.ts +1 -1
- package/src/projection/experimental/lazy-projections/somerc.ts +1 -1
- package/src/projection/experimental/lazy-projections/stere.ts +1 -1
- package/src/projection/experimental/lazy-projections/sterea.ts +1 -1
- package/src/projection/experimental/lazy-projections/tmerc.ts +1 -1
- package/src/projection/experimental/lazy-projections/tpers.ts +1 -1
- package/src/projection/experimental/lazy-projections/utm.ts +1 -1
- package/src/projection/experimental/lazy-projections/vandg.ts +1 -1
- package/src/spatial-box-clipping.ts +140 -0
- package/src/spatial-dwithin.ts +135 -0
- package/src/spatial-hulls.ts +203 -0
- package/src/spatial-line-intersection-result.ts +93 -0
- package/src/spatial-line-polygon-intersection.ts +147 -0
- package/src/spatial-planar-intersects.ts +21 -15
- package/src/spatial-planar.ts +20 -1
- package/src/spatial-polygon-overlay.ts +30 -0
- package/src/spatial-sql.ts +47 -12
- package/src/spatial-subdivision.ts +75 -0
- package/src/spatial-touches.ts +218 -0
- package/src/st-functions.ts +283 -15
- package/src/st-geodesic-functions.ts +121 -0
- package/src/st-hull-functions.ts +25 -0
- package/src/st-overlay-functions.ts +244 -0
- package/src/st-viewport-functions.ts +98 -0
- package/src/subdivide-geodesic-polyline.ts +2 -2
- package/src/subdivide-globe-mesh.ts +2 -2
- package/src/subdivide-rhumb-polyline.ts +2 -2
- package/src/terrain/geometry.ts +1 -1
- package/src/terrain/index.ts +7 -0
- package/src/terrain/regional-watersheds.ts +153 -0
- package/src/terrain/tile-cutout-update.ts +32 -26
- package/dist/index.cjs +0 -18674
- package/dist/index.cjs.map +0 -6
- package/dist/turf-expressions.cjs +0 -1997
- package/dist/turf-expressions.cjs.map +0 -6
- package/dist/turf-expressions.d.ts +0 -3
- package/dist/turf-expressions.d.ts.map +0 -1
- package/dist/turf-expressions.js +0 -7
- package/dist/turf-expressions.js.map +0 -1
- package/src/turf-expressions.ts +0 -7
|
@@ -8,5 +8,5 @@ export const lazyAzimuthalEquidistant: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'aeqd', aliases: ['Azimuthal_Equidistant']},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-aeqd')).azimuthalEquidistant
|
|
12
12
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyBonne: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'bonne', aliases: ['Bonne (Werner lat_1=90)']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-bonne');
|
|
11
11
|
return projectionModule.bonne;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyCassiniSoldner: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'cass', aliases: ['Cassini', 'Cassini_Soldner']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-cass');
|
|
11
11
|
return projectionModule.cassiniSoldner;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -8,5 +8,5 @@ export const lazyCylindricalEqualArea: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'cea', aliases: []},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-cea')).cylindricalEqualArea
|
|
12
12
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyEckertVI: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'eck6', aliases: ['Eckert_VI']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-eck6');
|
|
11
11
|
return projectionModule.eckertVI;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -11,5 +11,5 @@ export const lazyEquidistantCylindrical: ProjectionDescriptor =
|
|
|
11
11
|
aliases: ['Equirectangular', 'Equidistant_Cylindrical', 'Equidistant_Cylindrical_Spherical']
|
|
12
12
|
},
|
|
13
13
|
async () =>
|
|
14
|
-
(await import('@math.gl/geospatial/projection
|
|
14
|
+
(await import('@math.gl/geospatial/projection-projections-eqc')).equidistantCylindrical
|
|
15
15
|
);
|
|
@@ -8,7 +8,7 @@ export const lazyEquidistantConic: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'eqdc', aliases: ['Equidistant_Conic']},
|
|
10
10
|
async () => {
|
|
11
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
11
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-eqdc');
|
|
12
12
|
return projectionModule.equidistantConic;
|
|
13
13
|
}
|
|
14
14
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyEqualEarth: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'eqearth', aliases: ['Equal Earth', 'Equal_Earth']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-eqearth');
|
|
11
11
|
return projectionModule.equalEarth;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyEquirectangular: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'equi', aliases: []},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-equi');
|
|
11
11
|
return projectionModule.equirectangular;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -8,5 +8,5 @@ export const lazyExtendedTransverseMercator: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'etmerc', aliases: ['Extended_Transverse_Mercator', 'Extended Transverse Mercator']},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-etmerc')).extendedTransverseMercator
|
|
12
12
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyGeocentric: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'geocent', aliases: ['Geocentric', 'geocentric', 'Geocent']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-geocent');
|
|
11
11
|
return projectionModule.geocentric;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyGeostationary: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'geos', aliases: ['Geostationary Satellite View', 'Geostationary_Satellite']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-geos');
|
|
11
11
|
return projectionModule.geostationary;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyGnomonic: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'gnom', aliases: []},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-gnom');
|
|
11
11
|
return projectionModule.gnomonic;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -8,6 +8,6 @@ export const lazyGaussSchreiberTransverseMercator: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'gstmerc', aliases: ['gstmerg']},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-gstmerc'))
|
|
12
12
|
.gaussSchreiberTransverseMercator
|
|
13
13
|
);
|
|
@@ -15,7 +15,7 @@ export const lazyKrovak: ProjectionDescriptor = /* @__PURE__ */ createProjection
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
async () => {
|
|
18
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
18
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-krovak');
|
|
19
19
|
return projectionModule.krovak;
|
|
20
20
|
}
|
|
21
21
|
);
|
|
@@ -8,5 +8,5 @@ export const lazyLambertAzimuthalEqualArea: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'laea', aliases: ['Lambert Azimuthal Equal Area', 'Lambert_Azimuthal_Equal_Area']},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-laea')).lambertAzimuthalEqualArea
|
|
12
12
|
);
|
|
@@ -18,5 +18,5 @@ export const lazyLambertConformalConic: ProjectionDescriptor =
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
async () =>
|
|
21
|
-
(await import('@math.gl/geospatial/projection
|
|
21
|
+
(await import('@math.gl/geospatial/projection-projections-lcc')).lambertConformalConic
|
|
22
22
|
);
|
|
@@ -16,7 +16,7 @@ export const lazyMercator: ProjectionDescriptor = /* @__PURE__ */ createProjecti
|
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
async () => {
|
|
19
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
19
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-merc');
|
|
20
20
|
return projectionModule.mercator;
|
|
21
21
|
}
|
|
22
22
|
);
|
|
@@ -8,7 +8,7 @@ export const lazyMillerCylindrical: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'mill', aliases: ['Miller_Cylindrical']},
|
|
10
10
|
async () => {
|
|
11
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
11
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-mill');
|
|
12
12
|
return projectionModule.millerCylindrical;
|
|
13
13
|
}
|
|
14
14
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyMollweide: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'moll', aliases: ['Mollweide']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-moll');
|
|
11
11
|
return projectionModule.mollweide;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -8,7 +8,7 @@ export const lazyNewZealandMapGrid: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'nzmg', aliases: ['New_Zealand_Map_Grid']},
|
|
10
10
|
async () => {
|
|
11
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
11
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-nzmg');
|
|
12
12
|
return projectionModule.newZealandMapGrid;
|
|
13
13
|
}
|
|
14
14
|
);
|
|
@@ -16,7 +16,7 @@ export function lazyObliqueTransformation(
|
|
|
16
16
|
},
|
|
17
17
|
async () => {
|
|
18
18
|
const [{obliqueTransformation}, child] = await Promise.all([
|
|
19
|
-
import('@math.gl/geospatial/projection
|
|
19
|
+
import('@math.gl/geospatial/projection-projections-ob_tran'),
|
|
20
20
|
typeof wrapped === 'string' || 'create' in wrapped ? wrapped : wrapped.preload()
|
|
21
21
|
]);
|
|
22
22
|
return obliqueTransformation(child);
|
|
@@ -19,7 +19,7 @@ export const lazyObliqueMercator: ProjectionDescriptor = /* @__PURE__ */ createP
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
async () => {
|
|
22
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
22
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-omerc');
|
|
23
23
|
return projectionModule.obliqueMercator;
|
|
24
24
|
}
|
|
25
25
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyOrthographic: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'ortho', aliases: []},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-ortho');
|
|
11
11
|
return projectionModule.orthographic;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyPolyconic: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'poly', aliases: ['Polyconic', 'American_Polyconic']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-poly');
|
|
11
11
|
return projectionModule.polyconic;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -11,6 +11,6 @@ export const lazyQuadrilateralizedSphericalCube: ProjectionDescriptor =
|
|
|
11
11
|
aliases: ['Quadrilateralized Spherical Cube', 'Quadrilateralized_Spherical_Cube']
|
|
12
12
|
},
|
|
13
13
|
async () =>
|
|
14
|
-
(await import('@math.gl/geospatial/projection
|
|
14
|
+
(await import('@math.gl/geospatial/projection-projections-qsc'))
|
|
15
15
|
.quadrilateralizedSphericalCube
|
|
16
16
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyRobinson: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'robin', aliases: ['Robinson']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-robin');
|
|
11
11
|
return projectionModule.robinson;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazySinusoidal: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'sinu', aliases: ['Sinusoidal']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-sinu');
|
|
11
11
|
return projectionModule.sinusoidal;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -8,5 +8,5 @@ export const lazySwissObliqueMercator: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'somerc', aliases: []},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-somerc')).swissObliqueMercator
|
|
12
12
|
);
|
|
@@ -15,7 +15,7 @@ export const lazyStereographic: ProjectionDescriptor = /* @__PURE__ */ createPro
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
async () => {
|
|
18
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
18
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-stere');
|
|
19
19
|
return projectionModule.stereographic;
|
|
20
20
|
}
|
|
21
21
|
);
|
|
@@ -16,5 +16,5 @@ export const lazyObliqueStereographic: ProjectionDescriptor =
|
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
async () =>
|
|
19
|
-
(await import('@math.gl/geospatial/projection
|
|
19
|
+
(await import('@math.gl/geospatial/projection-projections-sterea')).obliqueStereographic
|
|
20
20
|
);
|
|
@@ -18,5 +18,5 @@ export const lazyTransverseMercator: ProjectionDescriptor =
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
async () =>
|
|
21
|
-
(await import('@math.gl/geospatial/projection
|
|
21
|
+
(await import('@math.gl/geospatial/projection-projections-tmerc')).transverseMercator
|
|
22
22
|
);
|
|
@@ -8,7 +8,7 @@ export const lazyTiltedPerspective: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'tpers', aliases: ['Tilted_Perspective']},
|
|
10
10
|
async () => {
|
|
11
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
11
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-tpers');
|
|
12
12
|
return projectionModule.tiltedPerspective;
|
|
13
13
|
}
|
|
14
14
|
);
|
|
@@ -8,5 +8,5 @@ export const lazyUniversalTransverseMercator: ProjectionDescriptor =
|
|
|
8
8
|
/* @__PURE__ */ createProjectionDescriptor(
|
|
9
9
|
{name: 'utm', aliases: ['Universal Transverse Mercator System']},
|
|
10
10
|
async () =>
|
|
11
|
-
(await import('@math.gl/geospatial/projection
|
|
11
|
+
(await import('@math.gl/geospatial/projection-projections-utm')).universalTransverseMercator
|
|
12
12
|
);
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyVanDerGrinten: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'vandg', aliases: ['Van_der_Grinten_I', 'VanDerGrinten', 'Van_der_Grinten']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-vandg');
|
|
11
11
|
return projectionModule.vanDerGrinten;
|
|
12
12
|
}
|
|
13
13
|
);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import {clipPolyline} from '@math.gl/geometry/polygon';
|
|
7
|
+
import polygonClipping from 'polygon-clipping';
|
|
8
|
+
import {vertexCount} from './geometry-inspection';
|
|
9
|
+
import {planarBounds} from './spatial-planar';
|
|
10
|
+
|
|
11
|
+
/** Axis-aligned rectangle in planar XY coordinates. */
|
|
12
|
+
export type Box = [number, number, number, number];
|
|
13
|
+
|
|
14
|
+
/** Tests whether a point lies in the interior of the clipping rectangle. */
|
|
15
|
+
function containsPoint(point: readonly number[], [minX, minY, maxX, maxY]: Box): boolean {
|
|
16
|
+
const [x, y] = point;
|
|
17
|
+
return x! > minX && x! < maxX && y! > minY && y! < maxY;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Clips a path without joining fragments across an excursion outside the rectangle. */
|
|
21
|
+
function clipPath(path: readonly (readonly number[])[], box: Box): number[][][] {
|
|
22
|
+
if (path.some(point => !Number.isFinite(point[0]) || !Number.isFinite(point[1]))) {
|
|
23
|
+
throw new Error('ST_ClipByBox2D requires finite line coordinates');
|
|
24
|
+
}
|
|
25
|
+
if (path.every(point => containsPoint(point, box))) return [path.map(point => [...point])];
|
|
26
|
+
const [minX, minY, maxX, maxY] = box;
|
|
27
|
+
const paths: number[][][] = [];
|
|
28
|
+
for (const part of clipPolyline(
|
|
29
|
+
path.flatMap(point => [point[0]!, point[1]!]),
|
|
30
|
+
box
|
|
31
|
+
)) {
|
|
32
|
+
let vertices: number[][] = [];
|
|
33
|
+
for (let i = 2; i < part.length; i += 2) {
|
|
34
|
+
const ax = part[i - 2]!;
|
|
35
|
+
const ay = part[i - 1]!;
|
|
36
|
+
const bx = part[i]!;
|
|
37
|
+
const by = part[i + 1]!;
|
|
38
|
+
if (ax === bx && ay === by) continue;
|
|
39
|
+
const boundary =
|
|
40
|
+
(ax === bx && (ax === minX || ax === maxX)) || (ay === by && (ay === minY || ay === maxY));
|
|
41
|
+
if (boundary) {
|
|
42
|
+
if (vertices.length) paths.push(vertices);
|
|
43
|
+
vertices = [];
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (!vertices.length) vertices.push([ax, ay]);
|
|
47
|
+
vertices.push([bx, by]);
|
|
48
|
+
}
|
|
49
|
+
if (vertices.length) paths.push(vertices);
|
|
50
|
+
}
|
|
51
|
+
return paths;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Clips polygon shells and holes together so disconnected pieces retain their topology. */
|
|
55
|
+
export function clipPolygons(
|
|
56
|
+
polygons: readonly (readonly (readonly (readonly number[])[])[])[],
|
|
57
|
+
[minX, minY, maxX, maxY]: Box
|
|
58
|
+
): polygonClipping.MultiPolygon {
|
|
59
|
+
const subject: polygonClipping.MultiPolygon = polygons
|
|
60
|
+
.filter(polygon => polygon[0]?.length)
|
|
61
|
+
.map(rings => rings.filter(ring => ring.length).map(ring => ring.map(([x, y]) => [x!, y!])));
|
|
62
|
+
if (!subject.length) return [];
|
|
63
|
+
const rectangle: polygonClipping.Polygon = [
|
|
64
|
+
[
|
|
65
|
+
[minX, minY],
|
|
66
|
+
[maxX, minY],
|
|
67
|
+
[maxX, maxY],
|
|
68
|
+
[minX, maxY],
|
|
69
|
+
[minX, minY]
|
|
70
|
+
]
|
|
71
|
+
];
|
|
72
|
+
return polygonClipping.intersection(subject, rectangle);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Individual geometry types emitted by rectangle clipping. */
|
|
76
|
+
type ClipPart = Extract<WellKnownGeometry, {type: 'Point' | 'LineString' | 'Polygon'}>;
|
|
77
|
+
|
|
78
|
+
/** Clips a geometry to atomic parts so the result can be recombined by geometry type. */
|
|
79
|
+
function clipParts(geometry: WellKnownGeometry, box: Box): ClipPart[] {
|
|
80
|
+
switch (geometry.type) {
|
|
81
|
+
case 'Point':
|
|
82
|
+
return containsPoint(geometry.coordinates, box) ? [geometry] : [];
|
|
83
|
+
case 'MultiPoint':
|
|
84
|
+
return geometry.coordinates.flatMap(coordinates =>
|
|
85
|
+
containsPoint(coordinates, box) ? [{type: 'Point', coordinates}] : []
|
|
86
|
+
);
|
|
87
|
+
case 'LineString':
|
|
88
|
+
return geometry.coordinates.length
|
|
89
|
+
? clipPath(geometry.coordinates, box).map(coordinates => ({
|
|
90
|
+
type: 'LineString',
|
|
91
|
+
coordinates
|
|
92
|
+
}))
|
|
93
|
+
: [];
|
|
94
|
+
case 'MultiLineString':
|
|
95
|
+
return geometry.coordinates.flatMap(path =>
|
|
96
|
+
path.length
|
|
97
|
+
? clipPath(path, box).map(coordinates => ({type: 'LineString', coordinates}))
|
|
98
|
+
: []
|
|
99
|
+
);
|
|
100
|
+
case 'Polygon':
|
|
101
|
+
case 'MultiPolygon': {
|
|
102
|
+
const polygons = geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates;
|
|
103
|
+
return clipPolygons(polygons, box).map(coordinates => ({type: 'Polygon', coordinates}));
|
|
104
|
+
}
|
|
105
|
+
case 'GeometryCollection':
|
|
106
|
+
return geometry.geometries.flatMap(child => clipParts(child, box));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Returns a single geometry, a homogeneous multipart, or a mixed collection. */
|
|
111
|
+
function combineParts(parts: ClipPart[]): WellKnownGeometry {
|
|
112
|
+
if (parts.length === 1) return parts[0]!;
|
|
113
|
+
if (parts.length) {
|
|
114
|
+
if (parts.every(part => part.type === 'Point')) {
|
|
115
|
+
return {type: 'MultiPoint', coordinates: parts.map(part => part.coordinates)};
|
|
116
|
+
}
|
|
117
|
+
if (parts.every(part => part.type === 'LineString')) {
|
|
118
|
+
return {type: 'MultiLineString', coordinates: parts.map(part => part.coordinates)};
|
|
119
|
+
}
|
|
120
|
+
if (parts.every(part => part.type === 'Polygon')) {
|
|
121
|
+
return {type: 'MultiPolygon', coordinates: parts.map(part => part.coordinates)};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {type: 'GeometryCollection', geometries: parts};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Derives the rectangle from a bounds geometry and clips a planar feature. */
|
|
128
|
+
export function clipGeometryByBox(
|
|
129
|
+
geometry: WellKnownGeometry,
|
|
130
|
+
boundsGeometry: WellKnownGeometry
|
|
131
|
+
): WellKnownGeometry | null {
|
|
132
|
+
const bounds = planarBounds(boundsGeometry);
|
|
133
|
+
if (!bounds) return null;
|
|
134
|
+
if (!bounds.every(Number.isFinite)) throw new Error('ST_ClipByBox2D requires finite bounds');
|
|
135
|
+
if (!vertexCount(geometry)) return geometry;
|
|
136
|
+
if (bounds[0] === bounds[2] || bounds[1] === bounds[3]) {
|
|
137
|
+
throw new Error('ST_ClipByBox2D requires a rectangle with positive width and height');
|
|
138
|
+
}
|
|
139
|
+
return combineParts(clipParts(geometry, bounds as Box));
|
|
140
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import {BoxIndex} from '@math.gl/geometry/spatial-index';
|
|
7
|
+
import {distanceToPlanarSegment, planarBounds} from './spatial-planar';
|
|
8
|
+
import {planarIntersects, segmentsMeet} from './spatial-planar-intersects';
|
|
9
|
+
|
|
10
|
+
/** One planar coordinate. */
|
|
11
|
+
type Position = readonly number[];
|
|
12
|
+
/** One polyline component. */
|
|
13
|
+
type Path = readonly Position[];
|
|
14
|
+
/** A segment and its two-dimensional bounds. */
|
|
15
|
+
type Segment = {
|
|
16
|
+
/** First endpoint. */
|
|
17
|
+
a: Position;
|
|
18
|
+
/** Second endpoint. */
|
|
19
|
+
b: Position;
|
|
20
|
+
/** Minimum X and Y followed by maximum X and Y. */
|
|
21
|
+
bounds: readonly [number, number, number, number];
|
|
22
|
+
};
|
|
23
|
+
/** 2D geometries with linear components. */
|
|
24
|
+
type Linear = Extract<WellKnownGeometry, {type: 'LineString' | 'MultiLineString'}>;
|
|
25
|
+
/** 2D geometries with polygonal components. */
|
|
26
|
+
type Areal = Extract<WellKnownGeometry, {type: 'Polygon' | 'MultiPolygon'}>;
|
|
27
|
+
/** A single point geometry. */
|
|
28
|
+
type Point = Extract<WellKnownGeometry, {type: 'Point'}>;
|
|
29
|
+
|
|
30
|
+
/** Candidate-pair cutoff above which a spatial index can avoid a full scan. */
|
|
31
|
+
const directPairLimit = 1024;
|
|
32
|
+
|
|
33
|
+
/** Tests a point against the filled area, hole boundaries, and exterior boundaries. */
|
|
34
|
+
export function pointWithinPolygonDistance(point: Point, polygon: Areal, radius: number): boolean {
|
|
35
|
+
const [x, y] = point.coordinates;
|
|
36
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return false;
|
|
37
|
+
const bounds = planarBounds(polygon);
|
|
38
|
+
if (!bounds || !boxesWithin([x!, y!, x!, y!], bounds, radius)) return false;
|
|
39
|
+
if (planarIntersects(point, polygon)) return true;
|
|
40
|
+
if (radius === 0) return false;
|
|
41
|
+
const areas = polygon.type === 'Polygon' ? [polygon.coordinates] : polygon.coordinates;
|
|
42
|
+
for (const area of areas) {
|
|
43
|
+
for (const ring of area) {
|
|
44
|
+
for (let i = 0; i < ring.length; i++) {
|
|
45
|
+
const a = ring[i === 0 ? ring.length - 1 : i - 1]!;
|
|
46
|
+
const b = ring[i]!;
|
|
47
|
+
if (distanceToPlanarSegment(point.coordinates, a, b) <= radius) return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Keeps multiline components separate, including degenerate point-like segments. */
|
|
55
|
+
function lineSegments(geometry: Linear): Segment[] {
|
|
56
|
+
const paths: readonly Path[] =
|
|
57
|
+
geometry.type === 'LineString' ? [geometry.coordinates] : geometry.coordinates;
|
|
58
|
+
const segments: Segment[] = [];
|
|
59
|
+
for (const path of paths) {
|
|
60
|
+
if (path.some(point => !Number.isFinite(point[0]) || !Number.isFinite(point[1])))
|
|
61
|
+
throw new Error('ST_DWithin requires finite line coordinates');
|
|
62
|
+
if (!path.length) continue;
|
|
63
|
+
for (let i = 0; i < Math.max(1, path.length - 1); i++) {
|
|
64
|
+
const a = path[i]!;
|
|
65
|
+
const b = path[i + 1] ?? a;
|
|
66
|
+
segments.push({
|
|
67
|
+
a,
|
|
68
|
+
b,
|
|
69
|
+
bounds: [
|
|
70
|
+
Math.min(a[0]!, b[0]!),
|
|
71
|
+
Math.min(a[1]!, b[1]!),
|
|
72
|
+
Math.max(a[0]!, b[0]!),
|
|
73
|
+
Math.max(a[1]!, b[1]!)
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return segments;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Uses the largest axis gap as a conservative lower bound on Euclidean distance. */
|
|
82
|
+
function boxesWithin(a: readonly number[], b: readonly number[], radius: number): boolean {
|
|
83
|
+
return Math.max(a[0]! - b[2]!, b[0]! - a[2]!, a[1]! - b[3]!, b[1]! - a[3]!) <= radius;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Intersecting segments have zero gap; otherwise a closest pair includes an endpoint. */
|
|
87
|
+
function segmentsWithin(left: Segment, right: Segment, radius: number): boolean {
|
|
88
|
+
if (!boxesWithin(left.bounds, right.bounds, radius)) return false;
|
|
89
|
+
const {a, b} = left;
|
|
90
|
+
const {a: c, b: d} = right;
|
|
91
|
+
return (
|
|
92
|
+
segmentsMeet(a, b, c, d) ||
|
|
93
|
+
(radius > 0 &&
|
|
94
|
+
(distanceToPlanarSegment(a, c, d) <= radius ||
|
|
95
|
+
distanceToPlanarSegment(b, c, d) <= radius ||
|
|
96
|
+
distanceToPlanarSegment(c, a, b) <= radius ||
|
|
97
|
+
distanceToPlanarSegment(d, a, b) <= radius))
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Builds finite search bounds with enough padding to round outward. */
|
|
102
|
+
function expandBound(value: number, radius: number, direction: -1 | 1): number {
|
|
103
|
+
const padding = Math.max(Math.abs(value), radius) * Number.EPSILON;
|
|
104
|
+
return Math.max(
|
|
105
|
+
-Number.MAX_VALUE,
|
|
106
|
+
Math.min(Number.MAX_VALUE, value + direction * (radius + padding))
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Tests line pairs by exact segment refinement after rejecting distant bounds. */
|
|
111
|
+
export function linesWithinDistance(left: Linear, right: Linear, radius: number): boolean {
|
|
112
|
+
const leftBounds = planarBounds(left);
|
|
113
|
+
const rightBounds = planarBounds(right);
|
|
114
|
+
if (!leftBounds || !rightBounds || !boxesWithin(leftBounds, rightBounds, radius)) return false;
|
|
115
|
+
const a = lineSegments(left);
|
|
116
|
+
const b = lineSegments(right);
|
|
117
|
+
if (!a.length || !b.length) return false;
|
|
118
|
+
if (radius === Infinity) return true;
|
|
119
|
+
if (a.length * b.length <= directPairLimit || Math.min(a.length, b.length) < 8) {
|
|
120
|
+
return a.some(segment => b.some(candidate => segmentsWithin(segment, candidate, radius)));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const [indexed, queries] = a.length <= b.length ? [a, b] : [b, a];
|
|
124
|
+
const index = new BoxIndex({dimension: 2, bounds: indexed.flatMap(segment => segment.bounds)});
|
|
125
|
+
for (const segment of queries) {
|
|
126
|
+
const [x0, y0, x1, y1] = segment.bounds;
|
|
127
|
+
const {result} = index.searchQuery(
|
|
128
|
+
[expandBound(x0, radius, -1), expandBound(y0, radius, -1)],
|
|
129
|
+
[expandBound(x1, radius, 1), expandBound(y1, radius, 1)],
|
|
130
|
+
{filter: candidate => segmentsWithin(segment, indexed[candidate]!, radius), maxResults: 1}
|
|
131
|
+
);
|
|
132
|
+
if (result.length) return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|