@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
package/src/coordinates.ts
CHANGED
|
@@ -22,3 +22,8 @@ export {
|
|
|
22
22
|
parseMGRSZone
|
|
23
23
|
} from './coordinates/mgrs';
|
|
24
24
|
export type {MGRSCoordinate, MGRSZone} from './coordinates/mgrs';
|
|
25
|
+
|
|
26
|
+
export {LocalReferenceFrame} from './local-reference-frame';
|
|
27
|
+
export type {LocalReferenceFrameOptions, HeadingPitchRoll} from './local-reference-frame';
|
|
28
|
+
export {eastNorthUpToFixedFrame, localFrameToFixedFrame} from './ellipsoid-transforms';
|
|
29
|
+
export type {AxisDirection} from './ellipsoid-transforms';
|
package/src/entries/ellipsoid.ts
CHANGED
|
@@ -5,40 +5,15 @@
|
|
|
5
5
|
export {Ellipsoid} from '../ellipsoid';
|
|
6
6
|
export {EllipsoidTangentPlane} from '../ellipsoid-tangent-plane';
|
|
7
7
|
export {isWGS84} from '../type-utils';
|
|
8
|
-
export type {SpheroidParameters} from '@math.gl/core';
|
|
9
|
-
export {EllipsoidGeodesic} from '../ellipsoid-geodesic';
|
|
10
|
-
export type {
|
|
11
|
-
GeodesicResult,
|
|
12
|
-
GeodesicLine,
|
|
13
|
-
GeodesicParameters,
|
|
14
|
-
GeodesicOptions
|
|
15
|
-
} from '../ellipsoid-geodesic';
|
|
16
|
-
export {LocalReferenceFrame} from '../local-reference-frame';
|
|
17
|
-
export type {LocalReferenceFrameOptions, HeadingPitchRoll} from '../local-reference-frame';
|
|
8
|
+
export type {SpheroidParameters} from '@math.gl/core/types';
|
|
18
9
|
export type {TangentPlaneProjectionMode, TangentPlaneProjection} from '../ellipsoid-tangent-plane';
|
|
19
10
|
|
|
20
11
|
export {EllipsoidMetrics} from '../ellipsoid-metrics';
|
|
21
12
|
export type {AuxiliaryLatitude} from '../ellipsoid-metrics';
|
|
22
|
-
export {
|
|
23
|
-
export type {GeodesicPolygonResult, GeodesicPolygonOptions} from '../geodesic-polygon';
|
|
24
|
-
|
|
25
|
-
export {EllipsoidRhumb, RhumbDomainError} from '../ellipsoid-rhumb';
|
|
26
|
-
export type {RhumbOptions, RhumbResult, RhumbLine} from '../ellipsoid-rhumb';
|
|
27
|
-
export {RhumbPolygon} from '../rhumb-polygon';
|
|
28
|
-
export type {RhumbPolygonOptions, RhumbPolygonResult, RhumbPointOptions} from '../rhumb-polygon';
|
|
29
|
-
export {GeodesicIntersections} from '../geodesic-intersections';
|
|
13
|
+
export {TriaxialEllipsoid} from '../triaxial';
|
|
30
14
|
export type {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
SegmentIntersection
|
|
37
|
-
} from '../geodesic-intersections';
|
|
38
|
-
export {GeodesicPath} from '../geodesic-path';
|
|
39
|
-
export type {GeodesicPathOptions} from '../geodesic-path';
|
|
40
|
-
export {RhumbPath} from '../rhumb-path';
|
|
41
|
-
export type {RhumbPathOptions} from '../rhumb-path';
|
|
42
|
-
|
|
43
|
-
export {eastNorthUpToFixedFrame, localFrameToFixedFrame} from '../ellipsoid-transforms';
|
|
44
|
-
export type {AxisDirection} from '../ellipsoid-transforms';
|
|
15
|
+
TriaxialCoordinates,
|
|
16
|
+
TriaxialParameters,
|
|
17
|
+
CartesianGeodesicState,
|
|
18
|
+
TriaxialGeodesicLine
|
|
19
|
+
} from '../triaxial';
|
package/src/geodesics.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export {EllipsoidGeodesicExact, GeodesicPolygonExact} from './geodesic-exact';
|
|
6
|
+
export type {ExactGeodesicOptions, ExactPolygonOptions, ExactPolygonResult} from './geodesic-exact';
|
|
7
|
+
export {
|
|
8
|
+
GEODESIC_BUFFER_FIELDS,
|
|
9
|
+
RHUMB_BUFFER_FIELDS,
|
|
10
|
+
GeodesicLineBuffer,
|
|
11
|
+
RhumbLineBuffer
|
|
12
|
+
} from './geodesic-buffer';
|
|
13
|
+
|
|
14
|
+
export {EllipsoidGeodesic} from './ellipsoid-geodesic';
|
|
15
|
+
export type {
|
|
16
|
+
GeodesicResult,
|
|
17
|
+
GeodesicLine,
|
|
18
|
+
GeodesicParameters,
|
|
19
|
+
GeodesicOptions
|
|
20
|
+
} from './ellipsoid-geodesic';
|
|
21
|
+
export {GeodesicPolygon} from './geodesic-polygon';
|
|
22
|
+
export type {GeodesicPolygonResult, GeodesicPolygonOptions} from './geodesic-polygon';
|
|
23
|
+
|
|
24
|
+
export {EllipsoidRhumb, RhumbDomainError} from './ellipsoid-rhumb';
|
|
25
|
+
export type {RhumbOptions, RhumbResult, RhumbLine} from './ellipsoid-rhumb';
|
|
26
|
+
export {RhumbPolygon} from './rhumb-polygon';
|
|
27
|
+
export type {RhumbPolygonOptions, RhumbPolygonResult, RhumbPointOptions} from './rhumb-polygon';
|
|
28
|
+
export {GeodesicIntersections} from './geodesic-intersections';
|
|
29
|
+
export type {
|
|
30
|
+
GeodesicPath as GeodesicIntersectionPath,
|
|
31
|
+
IntersectionPoint,
|
|
32
|
+
IntersectionSearchOptions,
|
|
33
|
+
IntersectionSearch,
|
|
34
|
+
ClosestIntersection,
|
|
35
|
+
SegmentIntersection
|
|
36
|
+
} from './geodesic-intersections';
|
|
37
|
+
export {GeodesicPath} from './geodesic-path';
|
|
38
|
+
export type {GeodesicPathOptions} from './geodesic-path';
|
|
39
|
+
export {RhumbPath} from './rhumb-path';
|
|
40
|
+
export type {RhumbPathOptions} from './rhumb-path';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
subdividePolyline,
|
|
7
7
|
type SubdividePolylineOptions,
|
|
8
8
|
type SubdividedPolyline
|
|
9
|
-
} from '@math.gl/geometry';
|
|
9
|
+
} from '@math.gl/geometry/polygon';
|
|
10
10
|
import {Context, same, type Edge} from '../geographic-seams/edge';
|
|
11
11
|
import {GeographicSeamError} from '../geographic-seams/types';
|
|
12
12
|
import type {GeodesicParameters} from '../ellipsoid-geodesic';
|
package/src/geographic-cuts.ts
CHANGED
|
@@ -112,3 +112,24 @@ export type {
|
|
|
112
112
|
SubdivideGeographicCutRingOptions,
|
|
113
113
|
SubdividedGeographicCutRing
|
|
114
114
|
} from './geographic-seams/subdivide-cut';
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
createOrthographicCutAtlas,
|
|
118
|
+
createOctahedralCutGraph,
|
|
119
|
+
createOctahedralCutAtlas,
|
|
120
|
+
GeographicCutAtlas
|
|
121
|
+
} from './geographic-atlas';
|
|
122
|
+
export type {
|
|
123
|
+
AtlasSubdivisionOptions,
|
|
124
|
+
SubdividedAtlasRing,
|
|
125
|
+
SubdividedAtlasPolyline,
|
|
126
|
+
GeographicAtlasOptions,
|
|
127
|
+
GeographicAtlasBoundary,
|
|
128
|
+
GeographicAtlasChart,
|
|
129
|
+
GeographicCutGraph,
|
|
130
|
+
GeographicAtlasSource,
|
|
131
|
+
GeographicAtlasEdge,
|
|
132
|
+
GeographicAtlasRing,
|
|
133
|
+
GeographicAtlasPolygon,
|
|
134
|
+
GeographicAtlasPolyline
|
|
135
|
+
} from './geographic-atlas';
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type SubdividePolylineOptions,
|
|
8
8
|
type SubdividedPolyline,
|
|
9
9
|
type PolylineEdgeSampler
|
|
10
|
-
} from '@math.gl/geometry';
|
|
10
|
+
} from '@math.gl/geometry/polygon';
|
|
11
11
|
import {GeodesicPath} from '../geodesic-path';
|
|
12
12
|
import {RhumbPath} from '../rhumb-path';
|
|
13
13
|
import {EllipsoidGeodesic} from '../ellipsoid-geodesic';
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import {distanceToPlanarSegment} from './spatial-planar';
|
|
6
7
|
|
|
7
8
|
/** One vertex in planar XY coordinates. */
|
|
8
9
|
type Position = readonly number[];
|
|
@@ -25,21 +26,8 @@ function removeRepeated(path: Path, tolerance: number): Path {
|
|
|
25
26
|
return kept;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
/** Measures the distance to a finite segment, including its endpoints. */
|
|
29
|
-
function distanceToSegment(p: Position, a: Position, b: Position): number {
|
|
30
|
-
const dx = b[0]! - a[0]!,
|
|
31
|
-
dy = b[1]! - a[1]!;
|
|
32
|
-
const length = Math.hypot(dx, dy);
|
|
33
|
-
const px = p[0]! - a[0]!,
|
|
34
|
-
py = p[1]! - a[1]!;
|
|
35
|
-
const t = length
|
|
36
|
-
? Math.max(0, Math.min(1, (px * (dx / length) + py * (dy / length)) / length))
|
|
37
|
-
: 0;
|
|
38
|
-
return Math.hypot(px - t * dx, py - t * dy);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
29
|
/** Iterative Douglas-Peucker simplification of a single planar line. */
|
|
42
|
-
function
|
|
30
|
+
export function simplifyLine(path: Path, tolerance: number): Path {
|
|
43
31
|
if (!path.length) return path;
|
|
44
32
|
const last = path.length - 1;
|
|
45
33
|
const kept = new Uint8Array(path.length);
|
|
@@ -51,7 +39,7 @@ function simplify(path: Path, tolerance: number): Path {
|
|
|
51
39
|
let split = start,
|
|
52
40
|
maximum = tolerance;
|
|
53
41
|
for (let i = start + 1; i < end; i++) {
|
|
54
|
-
const distance =
|
|
42
|
+
const distance = distanceToPlanarSegment(path[i]!, path[start]!, path[end]!);
|
|
55
43
|
if (distance > maximum) {
|
|
56
44
|
maximum = distance;
|
|
57
45
|
split = i;
|
|
@@ -82,7 +70,7 @@ export function reduceLineVertices(
|
|
|
82
70
|
(geometry.type === 'MultiLineString' && geometry.coordinates.every(path => !path.length)))
|
|
83
71
|
)
|
|
84
72
|
return geometry;
|
|
85
|
-
const reduce = mode === 'simplify' ?
|
|
73
|
+
const reduce = mode === 'simplify' ? simplifyLine : removeRepeated;
|
|
86
74
|
if (geometry.type === 'LineString') {
|
|
87
75
|
const coordinates = reduce(geometry.coordinates, tolerance);
|
|
88
76
|
return coordinates.length || mode === 'removeRepeated'
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import {orient2d} from 'robust-predicates';
|
|
6
7
|
|
|
7
8
|
/** Ordered planar XY coordinates of a route. */
|
|
8
9
|
|
|
@@ -58,8 +59,21 @@ export function lineSubstring(
|
|
|
58
59
|
return {type: 'LineString', coordinates};
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
62
|
+
/** Nearest route coordinate, gap, and fraction of the total planar length. */
|
|
63
|
+
type LineProjection = {
|
|
64
|
+
/** Snapped XY coordinate in the route's coordinate system. */
|
|
65
|
+
coordinate: readonly number[];
|
|
66
|
+
/** Cartesian distance from the observation in coordinate units. */
|
|
67
|
+
distance: number;
|
|
68
|
+
/** Fraction in [0, 1] along the route, or zero for a zero-length route. */
|
|
69
|
+
fraction: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Projects a point onto the nearest route segment, taking the first candidate on ties. */
|
|
73
|
+
export function projectPointToLine(
|
|
74
|
+
line: WellKnownGeometry,
|
|
75
|
+
point: WellKnownGeometry
|
|
76
|
+
): LineProjection | null {
|
|
63
77
|
if (
|
|
64
78
|
line.type !== 'LineString' ||
|
|
65
79
|
!line.coordinates.length ||
|
|
@@ -68,27 +82,41 @@ export function lineLocatePoint(line: WellKnownGeometry, point: WellKnownGeometr
|
|
|
68
82
|
!Number.isFinite(point.coordinates[1])
|
|
69
83
|
)
|
|
70
84
|
return null;
|
|
71
|
-
const path = line.coordinates
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
const path = line.coordinates;
|
|
86
|
+
const x = point.coordinates[0]!;
|
|
87
|
+
const y = point.coordinates[1]!;
|
|
88
|
+
let coordinate = path[0]!;
|
|
89
|
+
let nearest = Math.hypot(x - coordinate[0]!, y - coordinate[1]!);
|
|
90
|
+
let total = 0;
|
|
91
|
+
let position = 0;
|
|
76
92
|
for (let i = 1; i < path.length; i++) {
|
|
77
|
-
const a = path[i - 1]
|
|
78
|
-
|
|
79
|
-
const dx = b[0]! - a[0]
|
|
80
|
-
|
|
93
|
+
const a = path[i - 1]!;
|
|
94
|
+
const b = path[i]!;
|
|
95
|
+
const dx = b[0]! - a[0]!;
|
|
96
|
+
const dy = b[1]! - a[1]!;
|
|
81
97
|
const length = Math.hypot(dx, dy);
|
|
82
98
|
if (!length) continue;
|
|
83
|
-
const ux = dx / length
|
|
84
|
-
|
|
85
|
-
const along = Math.max(0, Math.min(length, (x
|
|
86
|
-
|
|
99
|
+
const ux = dx / length;
|
|
100
|
+
const uy = dy / length;
|
|
101
|
+
const along = Math.max(0, Math.min(length, (x - a[0]!) * ux + (y - a[1]!) * uy));
|
|
102
|
+
let px = along === length ? b[0]! : a[0]! + along * ux;
|
|
103
|
+
let py = along === length ? b[1]! : a[1]! + along * uy;
|
|
104
|
+
if (along > 0 && along < length && orient2d(a[0]!, a[1]!, b[0]!, b[1]!, x, y) === 0) {
|
|
105
|
+
px = x;
|
|
106
|
+
py = y;
|
|
107
|
+
}
|
|
108
|
+
const distance = Math.hypot(x - px, y - py);
|
|
87
109
|
if (distance < nearest) {
|
|
88
110
|
nearest = distance;
|
|
111
|
+
coordinate = [px, py];
|
|
89
112
|
position = total + along;
|
|
90
113
|
}
|
|
91
114
|
total += length;
|
|
92
115
|
}
|
|
93
|
-
return total ? position / total : 0;
|
|
116
|
+
return {coordinate, distance: nearest, fraction: total ? position / total : 0};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Returns the fraction of the route length at the projected point. */
|
|
120
|
+
export function lineLocatePoint(line: WellKnownGeometry, point: WellKnownGeometry): number | null {
|
|
121
|
+
return projectPointToLine(line, point)?.fraction ?? null;
|
|
94
122
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Matrix4} from '@math.gl/core/matrix';
|
|
6
|
-
import {HingeTree, type HingePanel} from '@math.gl/geometry';
|
|
6
|
+
import {HingeTree, type HingePanel} from '@math.gl/geometry/primitives';
|
|
7
7
|
import {
|
|
8
8
|
center,
|
|
9
9
|
cross,
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WellKnownDimension, WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
|
|
7
|
+
/** Vertex coordinates in the input geometry's declared dimension. */
|
|
8
|
+
type Position = readonly number[];
|
|
9
|
+
/** Ordered coordinates for one independent route component. */
|
|
10
|
+
type Path = readonly Position[];
|
|
11
|
+
/** Dimensions with a semantic measure ordinate. */
|
|
12
|
+
type MeasuredDimension = 'xym' | 'xyzm';
|
|
13
|
+
|
|
14
|
+
/** Extracts the paths of a linear geometry without connecting multipart gaps. */
|
|
15
|
+
function pathsOf(geometry: WellKnownGeometry): readonly Path[] {
|
|
16
|
+
if (geometry.type === 'LineString') return [geometry.coordinates];
|
|
17
|
+
if (geometry.type === 'MultiLineString') return geometry.coordinates;
|
|
18
|
+
throw new Error('Measured routes require a LineString or MultiLineString');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Returns the measure dimension or rejects unmeasured linework. */
|
|
22
|
+
export function measuredDimension(dimension: WellKnownDimension): MeasuredDimension {
|
|
23
|
+
if (dimension === 'xym' || dimension === 'xyzm') return dimension;
|
|
24
|
+
throw new Error('Input geometry requires a measure (M) ordinate');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Assigns measures by accumulated XY path length, retaining any Z ordinate. */
|
|
28
|
+
export function addMeasure(
|
|
29
|
+
geometry: WellKnownGeometry,
|
|
30
|
+
dimension: WellKnownDimension,
|
|
31
|
+
start: number,
|
|
32
|
+
end: number
|
|
33
|
+
): {geometry: WellKnownGeometry; dimension: MeasuredDimension} {
|
|
34
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) throw new Error('Expected finite measures');
|
|
35
|
+
const paths = pathsOf(geometry);
|
|
36
|
+
let total = 0;
|
|
37
|
+
const distances = paths.map(path =>
|
|
38
|
+
path.map((point, i) => {
|
|
39
|
+
if (i > 0) {
|
|
40
|
+
const previous = path[i - 1]!;
|
|
41
|
+
total += Math.hypot(point[0]! - previous[0]!, point[1]! - previous[1]!);
|
|
42
|
+
}
|
|
43
|
+
return total;
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
if (!Number.isFinite(total)) throw new Error('Expected finite route length');
|
|
47
|
+
const spatialSize = dimension.includes('z') ? 3 : 2;
|
|
48
|
+
const coordinates = paths.map((path, part) =>
|
|
49
|
+
path.map((point, i) => {
|
|
50
|
+
const fraction = total ? distances[part]![i]! / total : 0;
|
|
51
|
+
return [...point.slice(0, spatialSize), (1 - fraction) * start + fraction * end];
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
return {
|
|
55
|
+
geometry:
|
|
56
|
+
geometry.type === 'LineString'
|
|
57
|
+
? {type: 'LineString', coordinates: coordinates[0]!}
|
|
58
|
+
: {type: 'MultiLineString', coordinates},
|
|
59
|
+
dimension: spatialSize === 3 ? 'xyzm' : 'xym'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Tests equality of every ordinate, including dimensions other than XY. */
|
|
64
|
+
function samePosition(a: Position, b: Position): boolean {
|
|
65
|
+
return a.every((value, i) => value === b[i]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Interpolates XY and optional Z while setting M exactly to the requested value. */
|
|
69
|
+
function atMeasure(a: Position, b: Position, index: number, measure: number): Position {
|
|
70
|
+
const from = a[index]!;
|
|
71
|
+
const to = b[index]!;
|
|
72
|
+
if (from !== to) {
|
|
73
|
+
if (measure === from) return a;
|
|
74
|
+
if (measure === to) return b;
|
|
75
|
+
}
|
|
76
|
+
const span = to - from;
|
|
77
|
+
const fraction =
|
|
78
|
+
span === 0
|
|
79
|
+
? 0.5
|
|
80
|
+
: Number.isFinite(span)
|
|
81
|
+
? (measure - from) / span
|
|
82
|
+
: (measure / 2 - from / 2) / (to / 2 - from / 2);
|
|
83
|
+
return a.map((value, i) => (i === index ? measure : (1 - fraction) * value + fraction * b[i]!));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Reads the measure ordinate and rejects invalid measured vertices. */
|
|
87
|
+
function measureAt(position: Position, index: number): number {
|
|
88
|
+
const value = position[index]!;
|
|
89
|
+
if (!Number.isFinite(value)) throw new Error('Expected finite route measures');
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Finds each matching location. Constant-measure segments contribute their midpoint. */
|
|
94
|
+
export function locateAlong(
|
|
95
|
+
geometry: WellKnownGeometry,
|
|
96
|
+
dimension: MeasuredDimension,
|
|
97
|
+
measure: number
|
|
98
|
+
): WellKnownGeometry {
|
|
99
|
+
if (!Number.isFinite(measure)) throw new Error('Expected a finite measure');
|
|
100
|
+
const index = dimension.indexOf('m');
|
|
101
|
+
const coordinates: Position[] = [];
|
|
102
|
+
for (const path of pathsOf(geometry)) {
|
|
103
|
+
let previousEndsAtVertex = false;
|
|
104
|
+
for (let i = 1; i < path.length; i++) {
|
|
105
|
+
const a = path[i - 1]!;
|
|
106
|
+
const b = path[i]!;
|
|
107
|
+
const from = measureAt(a, index);
|
|
108
|
+
const to = measureAt(b, index);
|
|
109
|
+
if (measure < Math.min(from, to) || measure > Math.max(from, to)) {
|
|
110
|
+
previousEndsAtVertex = false;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const startsAtVertex = from !== to && measure === from;
|
|
114
|
+
if (!previousEndsAtVertex || !startsAtVertex) {
|
|
115
|
+
coordinates.push(atMeasure(a, b, index, measure));
|
|
116
|
+
}
|
|
117
|
+
previousEndsAtVertex = from !== to && measure === to;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {type: 'MultiPoint', coordinates};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Appends a clipped point or line when a contiguous portion is complete. */
|
|
124
|
+
function appendPortion(parts: WellKnownGeometry[], path: Position[]): void {
|
|
125
|
+
if (path.length === 1) parts.push({type: 'Point', coordinates: path[0]!});
|
|
126
|
+
else if (path.length > 1) parts.push({type: 'LineString', coordinates: path});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Clips each component in measure space, preserving direction and disjoint visits. */
|
|
130
|
+
export function locateBetween(
|
|
131
|
+
geometry: WellKnownGeometry,
|
|
132
|
+
dimension: MeasuredDimension,
|
|
133
|
+
start: number,
|
|
134
|
+
end: number
|
|
135
|
+
): WellKnownGeometry {
|
|
136
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) throw new Error('Expected finite measures');
|
|
137
|
+
const low = Math.min(start, end);
|
|
138
|
+
const high = Math.max(start, end);
|
|
139
|
+
const index = dimension.indexOf('m');
|
|
140
|
+
const parts: WellKnownGeometry[] = [];
|
|
141
|
+
for (const path of pathsOf(geometry)) {
|
|
142
|
+
let portion: Position[] = [];
|
|
143
|
+
for (let i = 1; i < path.length; i++) {
|
|
144
|
+
const a = path[i - 1]!;
|
|
145
|
+
const b = path[i]!;
|
|
146
|
+
const from = measureAt(a, index);
|
|
147
|
+
const to = measureAt(b, index);
|
|
148
|
+
const begin = Math.max(low, Math.min(from, to));
|
|
149
|
+
const finish = Math.min(high, Math.max(from, to));
|
|
150
|
+
if (begin > finish) continue;
|
|
151
|
+
const first = from === to ? a : atMeasure(a, b, index, from <= to ? begin : finish);
|
|
152
|
+
const last = from === to ? b : atMeasure(a, b, index, from <= to ? finish : begin);
|
|
153
|
+
if (!portion.length) portion.push(first);
|
|
154
|
+
if (!samePosition(portion[portion.length - 1]!, last)) portion.push(last);
|
|
155
|
+
if (to < low || to > high) {
|
|
156
|
+
appendPortion(parts, portion);
|
|
157
|
+
portion = [];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
appendPortion(parts, portion);
|
|
161
|
+
}
|
|
162
|
+
return parts.every(part => part.type === 'LineString')
|
|
163
|
+
? {type: 'MultiLineString', coordinates: parts.map(part => part.coordinates)}
|
|
164
|
+
: {type: 'GeometryCollection', geometries: parts};
|
|
165
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
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 {orient2d} from 'robust-predicates';
|
|
7
|
+
import {simplifyLine} from './line-simplification';
|
|
8
|
+
import {planarBounds} from './spatial-planar';
|
|
9
|
+
import {planarIntersects, segmentsMeet} from './spatial-planar-intersects';
|
|
10
|
+
|
|
11
|
+
/** One planar vertex. */
|
|
12
|
+
type Position = readonly number[];
|
|
13
|
+
/** Vertices of a closed ring, including its repeated endpoint. */
|
|
14
|
+
type Ring = readonly Position[];
|
|
15
|
+
/** One component with a shell followed by its holes. */
|
|
16
|
+
type Polygon = readonly Ring[];
|
|
17
|
+
/** Axis-aligned XY bounds. */
|
|
18
|
+
type Bounded = {
|
|
19
|
+
/** Minimum X and Y followed by maximum X and Y. */
|
|
20
|
+
bounds: readonly number[];
|
|
21
|
+
};
|
|
22
|
+
/** An indexed ring segment for the intersection sweep. */
|
|
23
|
+
type Edge = Bounded & {
|
|
24
|
+
/** First endpoint. */
|
|
25
|
+
a: Position;
|
|
26
|
+
/** Second endpoint. */
|
|
27
|
+
b: Position;
|
|
28
|
+
/** Identity of the containing ring. */
|
|
29
|
+
ring: Ring;
|
|
30
|
+
/** Index of the first endpoint in that ring. */
|
|
31
|
+
index: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Estimates the active interval count relative to the extent of the sweep. */
|
|
35
|
+
function intervalDensity(items: readonly Bounded[], axis: number): number {
|
|
36
|
+
let minimum = Infinity;
|
|
37
|
+
let maximum = -Infinity;
|
|
38
|
+
let length = 0;
|
|
39
|
+
for (const {bounds} of items) {
|
|
40
|
+
const low = bounds[axis]!;
|
|
41
|
+
const high = bounds[axis + 2]!;
|
|
42
|
+
minimum = Math.min(minimum, low);
|
|
43
|
+
maximum = Math.max(maximum, high);
|
|
44
|
+
length += high - low;
|
|
45
|
+
}
|
|
46
|
+
return maximum > minimum ? length / (maximum - minimum) : Infinity;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Visits overlapping bounding boxes along the axis with fewer expected candidates. */
|
|
50
|
+
function anyOverlap<T extends Bounded>(items: T[], reject: (a: T, b: T) => boolean): boolean {
|
|
51
|
+
const axis = intervalDensity(items, 0) > intervalDensity(items, 1) ? 1 : 0;
|
|
52
|
+
const other = 1 - axis;
|
|
53
|
+
items.sort((a, b) => a.bounds[axis]! - b.bounds[axis]!);
|
|
54
|
+
for (let i = 0; i < items.length; i++) {
|
|
55
|
+
const a = items[i]!;
|
|
56
|
+
for (let j = i + 1; j < items.length && items[j]!.bounds[axis]! <= a.bounds[axis + 2]!; j++) {
|
|
57
|
+
const b = items[j]!;
|
|
58
|
+
if (
|
|
59
|
+
b.bounds[other]! <= a.bounds[other + 2]! &&
|
|
60
|
+
a.bounds[other]! <= b.bounds[other + 2]! &&
|
|
61
|
+
reject(a, b)
|
|
62
|
+
)
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Compares two XY positions. */
|
|
70
|
+
function samePoint(a: Position, b: Position): boolean {
|
|
71
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Computes translated signed area for the winding and collapse check. */
|
|
75
|
+
function signedArea(ring: Ring): number {
|
|
76
|
+
const [x, y] = ring[0]!;
|
|
77
|
+
let area = 0;
|
|
78
|
+
for (let i = 1; i + 1 < ring.length; i++) {
|
|
79
|
+
const a = ring[i]!;
|
|
80
|
+
const b = ring[i + 1]!;
|
|
81
|
+
area += (a[0]! - x!) * (b[1]! - y!) - (a[1]! - y!) * (b[0]! - x!);
|
|
82
|
+
}
|
|
83
|
+
return area;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Rejects invalid, self-touching, or mutually touching boundaries conservatively. */
|
|
87
|
+
function separatedBoundaries(rings: readonly Ring[]): boolean {
|
|
88
|
+
const edges: Edge[] = [];
|
|
89
|
+
for (const ring of rings) {
|
|
90
|
+
const size = ring.length - 1;
|
|
91
|
+
if (size < 3 || !samePoint(ring[0]!, ring[size]!)) return false;
|
|
92
|
+
for (let i = 0; i < size; i++) {
|
|
93
|
+
const a = ring[i]!;
|
|
94
|
+
const b = ring[i + 1]!;
|
|
95
|
+
const c = ring[(i + 2) % size]!;
|
|
96
|
+
if (!Number.isFinite(a[0]) || !Number.isFinite(a[1]) || samePoint(a, b)) return false;
|
|
97
|
+
if (
|
|
98
|
+
orient2d(a[0]!, a[1]!, b[0]!, b[1]!, c[0]!, c[1]!) === 0 &&
|
|
99
|
+
(a[0]! - b[0]!) * (c[0]! - b[0]!) + (a[1]! - b[1]!) * (c[1]! - b[1]!) > 0
|
|
100
|
+
)
|
|
101
|
+
return false;
|
|
102
|
+
edges.push({
|
|
103
|
+
a,
|
|
104
|
+
b,
|
|
105
|
+
ring,
|
|
106
|
+
index: i,
|
|
107
|
+
bounds: [
|
|
108
|
+
Math.min(a[0]!, b[0]!),
|
|
109
|
+
Math.min(a[1]!, b[1]!),
|
|
110
|
+
Math.max(a[0]!, b[0]!),
|
|
111
|
+
Math.max(a[1]!, b[1]!)
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return !anyOverlap(edges, (a, b) => {
|
|
117
|
+
if (a.ring === b.ring) {
|
|
118
|
+
const gap = Math.abs(a.index - b.index);
|
|
119
|
+
if (gap === 1 || gap === a.ring.length - 2) return false;
|
|
120
|
+
}
|
|
121
|
+
return segmentsMeet(a.a, a.b, b.a, b.b);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Checks containment of one ring by another after ruling out boundary contact. */
|
|
126
|
+
function contains(outer: Ring, inner: Ring): boolean {
|
|
127
|
+
return planarIntersects(
|
|
128
|
+
{type: 'Polygon', coordinates: [outer]},
|
|
129
|
+
{type: 'Point', coordinates: inner[0]!}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Checks that all shell, hole, and island containment relationships remain the same. */
|
|
134
|
+
function preservesNesting(before: Ring[], after: Ring[]): boolean {
|
|
135
|
+
const rings = before.map((original, index) => ({
|
|
136
|
+
original,
|
|
137
|
+
simplified: after[index]!,
|
|
138
|
+
bounds: planarBounds({type: 'LineString', coordinates: original})!
|
|
139
|
+
}));
|
|
140
|
+
return !anyOverlap(
|
|
141
|
+
rings,
|
|
142
|
+
(a, b) =>
|
|
143
|
+
contains(a.original, b.original) !== contains(a.simplified, b.simplified) ||
|
|
144
|
+
contains(b.original, a.original) !== contains(b.simplified, a.simplified)
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Keeps the original ring if simplification would collapse it or reverse its winding. */
|
|
149
|
+
function simplifyRing(ring: Ring, tolerance: number): Ring {
|
|
150
|
+
const reduced = simplifyLine(ring, tolerance);
|
|
151
|
+
if (reduced.length < 4 || reduced.length === ring.length) return ring;
|
|
152
|
+
const before = signedArea(ring);
|
|
153
|
+
const after = signedArea(reduced);
|
|
154
|
+
return Number.isFinite(before) &&
|
|
155
|
+
Number.isFinite(after) &&
|
|
156
|
+
after &&
|
|
157
|
+
Math.sign(before) === Math.sign(after)
|
|
158
|
+
? reduced
|
|
159
|
+
: ring;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Simplifies closed rings only when boundary and nesting checks prove topology is preserved. */
|
|
163
|
+
export function simplifyPolygonTopology(
|
|
164
|
+
geometry: Extract<WellKnownGeometry, {type: 'Polygon' | 'MultiPolygon'}>,
|
|
165
|
+
tolerance: number
|
|
166
|
+
): typeof geometry {
|
|
167
|
+
if (!Number.isFinite(tolerance) || tolerance < 0)
|
|
168
|
+
throw new Error('Expected a finite nonnegative tolerance');
|
|
169
|
+
if (!tolerance) return geometry;
|
|
170
|
+
const polygons: readonly Polygon[] =
|
|
171
|
+
geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates;
|
|
172
|
+
const before = polygons.flat();
|
|
173
|
+
const reduced = polygons.map(polygon => polygon.map(ring => simplifyRing(ring, tolerance)));
|
|
174
|
+
const after = reduced.flat();
|
|
175
|
+
if (before.every((ring, index) => ring === after[index])) return geometry;
|
|
176
|
+
if (
|
|
177
|
+
!separatedBoundaries(before) ||
|
|
178
|
+
!separatedBoundaries(after) ||
|
|
179
|
+
!preservesNesting(before, after)
|
|
180
|
+
)
|
|
181
|
+
return geometry;
|
|
182
|
+
return geometry.type === 'Polygon'
|
|
183
|
+
? {type: 'Polygon', coordinates: reduced[0]!}
|
|
184
|
+
: {type: 'MultiPolygon', coordinates: reduced};
|
|
185
|
+
}
|
|
@@ -52,7 +52,7 @@ export type {ProjectionDescriptor} from './projection-descriptor';
|
|
|
52
52
|
|
|
53
53
|
export type {ProjectionCoordinate, ProjectionOutput} from './scalar-output';
|
|
54
54
|
|
|
55
|
-
export type {SpheroidParameters} from '@math.gl/core';
|
|
55
|
+
export type {SpheroidParameters} from '@math.gl/core/types';
|
|
56
56
|
|
|
57
57
|
export {
|
|
58
58
|
ConfigurableProjectionEngine,
|
|
@@ -7,7 +7,7 @@ import type {ProjectionDescriptor} from '../projection-descriptor';
|
|
|
7
7
|
export const lazyAlbersEqualArea: ProjectionDescriptor = /* @__PURE__ */ createProjectionDescriptor(
|
|
8
8
|
{name: 'aea', aliases: ['Albers_Conic_Equal_Area', 'Albers_Equal_Area', 'Albers']},
|
|
9
9
|
async () => {
|
|
10
|
-
const projectionModule = await import('@math.gl/geospatial/projection
|
|
10
|
+
const projectionModule = await import('@math.gl/geospatial/projection-projections-aea');
|
|
11
11
|
return projectionModule.albersEqualArea;
|
|
12
12
|
}
|
|
13
13
|
);
|