@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
|
@@ -167,27 +167,8 @@ function getSourceLocation(source, offset) {
|
|
|
167
167
|
return { line, column };
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
// dist/projection/experimental/crs/types.js
|
|
171
|
-
var _a;
|
|
172
|
-
var CRS_ERROR = /* @__PURE__ */ Symbol.for("@math.gl/projection/TypeScriptCRSError");
|
|
173
|
-
var TypeScriptCRSError = class _TypeScriptCRSError extends Error {
|
|
174
|
-
static [(_a = CRS_ERROR, Symbol.hasInstance)](value) {
|
|
175
|
-
if (this !== _TypeScriptCRSError)
|
|
176
|
-
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
177
|
-
return value instanceof Error && value[CRS_ERROR] === true;
|
|
178
|
-
}
|
|
179
|
-
constructor(reason, message) {
|
|
180
|
-
super(message);
|
|
181
|
-
this.reason = reason;
|
|
182
|
-
this[_a] = true;
|
|
183
|
-
this.name = "TypeScriptCRSError";
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
function unsupportedStage(message) {
|
|
187
|
-
throw new TypeScriptCRSError("missing-transform-stage", message);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
170
|
// dist/projection/experimental/crs/spatial-reference.js
|
|
171
|
+
var import_types = require("./experimental/crs/types.shared.cjs");
|
|
191
172
|
function resolveCRSInput(input, options) {
|
|
192
173
|
if (typeof input === "string" || "type" in input)
|
|
193
174
|
return { definition: input, lossy: false };
|
|
@@ -195,19 +176,19 @@ function resolveCRSInput(input, options) {
|
|
|
195
176
|
const spatialReference = "crs" in metadata ? metadata : void 0;
|
|
196
177
|
const reference = "crs" in metadata ? metadata.crs : metadata;
|
|
197
178
|
if (reference.state !== "explicit" && reference.state !== "default")
|
|
198
|
-
throw new TypeScriptCRSError("unknown-syntax", "Cannot transform an " + reference.state + " CRS reference");
|
|
179
|
+
throw new import_types.TypeScriptCRSError("unknown-syntax", "Cannot transform an " + reference.state + " CRS reference");
|
|
199
180
|
let lossy = false;
|
|
200
181
|
if ((spatialReference == null ? void 0 : spatialReference.coordinateEpoch) !== void 0)
|
|
201
|
-
unsupportedStage("Coordinate epochs require a time-dependent transformation");
|
|
182
|
+
(0, import_types.unsupportedStage)("Coordinate epochs require a time-dependent transformation");
|
|
202
183
|
if ((spatialReference == null ? void 0 : spatialReference.vertical) && spatialReference.vertical.state !== "absent") {
|
|
203
184
|
if (options.mode !== "horizontal")
|
|
204
|
-
unsupportedStage("A separately declared vertical CRS requires explicit horizontal extraction");
|
|
185
|
+
(0, import_types.unsupportedStage)("A separately declared vertical CRS requires explicit horizontal extraction");
|
|
205
186
|
lossy = true;
|
|
206
187
|
}
|
|
207
188
|
return { definition: reference.definition, spatialReference, lossy };
|
|
208
189
|
}
|
|
209
190
|
function applySpatialReference(crs, reference) {
|
|
210
|
-
var
|
|
191
|
+
var _a;
|
|
211
192
|
if (!reference)
|
|
212
193
|
return crs;
|
|
213
194
|
if (reference.coordinateFrame !== "unknown" && reference.coordinateFrame !== crs.kind)
|
|
@@ -232,11 +213,11 @@ function applySpatialReference(crs, reference) {
|
|
|
232
213
|
if (storedAxis.length === 2)
|
|
233
214
|
storedAxis += "u";
|
|
234
215
|
if (storedAxis.length !== 3 || !storedAxis.includes("e") || !storedAxis.includes("n") || !storedAxis.includes("u"))
|
|
235
|
-
unsupportedStage("Unsupported SpatialReference coordinate order");
|
|
216
|
+
(0, import_types.unsupportedStage)("Unsupported SpatialReference coordinate order");
|
|
236
217
|
if (order.length > 4 || order.length > 3 && !["m", "measure"].includes(order[3]))
|
|
237
|
-
unsupportedStage("Unsupported fourth coordinate component");
|
|
218
|
+
(0, import_types.unsupportedStage)("Unsupported fourth coordinate component");
|
|
238
219
|
}
|
|
239
|
-
if ((
|
|
220
|
+
if ((_a = reference.units) == null ? void 0 : _a.length) {
|
|
240
221
|
const units = {
|
|
241
222
|
m: 1,
|
|
242
223
|
meter: 1,
|
|
@@ -256,7 +237,7 @@ function applySpatialReference(crs, reference) {
|
|
|
256
237
|
const vertical = (storedAxis || "enu")[i] === "u";
|
|
257
238
|
const expected = crs.kind === "geocentric" ? crs.toMeter : vertical ? crs.verticalUnit : crs.kind === "geographic" ? crs.angularUnit : crs.toMeter;
|
|
258
239
|
if (Math.abs((units[reference.units[i]] ?? NaN) - expected) > 1e-12 || units[reference.units[i]] === void 0)
|
|
259
|
-
unsupportedStage("SpatialReference units disagree with its CRS");
|
|
240
|
+
(0, import_types.unsupportedStage)("SpatialReference units disagree with its CRS");
|
|
260
241
|
}
|
|
261
242
|
}
|
|
262
243
|
return Object.freeze({ ...crs, storedAxis });
|
|
@@ -276,12 +257,6 @@ function numberParameter(parameters, name, fallback) {
|
|
|
276
257
|
throw new Error(`Invalid numeric PROJ parameter: +${name}`);
|
|
277
258
|
return number;
|
|
278
259
|
}
|
|
279
|
-
function wrapLongitude(longitude, over = false) {
|
|
280
|
-
if (over || Math.abs(longitude) <= Math.PI)
|
|
281
|
-
return longitude;
|
|
282
|
-
const circle = 2 * Math.PI;
|
|
283
|
-
return ((longitude + Math.PI) % circle + circle) % circle - Math.PI;
|
|
284
|
-
}
|
|
285
260
|
|
|
286
261
|
// dist/projection/experimental/crs/datum-catalog.js
|
|
287
262
|
var wgs84 = { towgs84: "0,0,0", ellipse: "WGS84" };
|
|
@@ -295,8 +270,8 @@ var builtins = {
|
|
|
295
270
|
var resolved = /* @__PURE__ */ new WeakMap();
|
|
296
271
|
var datumNameKey = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
|
|
297
272
|
function getDatumDefinitions(options) {
|
|
298
|
-
var
|
|
299
|
-
if (!((
|
|
273
|
+
var _a;
|
|
274
|
+
if (!((_a = options.datumCatalogs) == null ? void 0 : _a.length))
|
|
300
275
|
return builtins;
|
|
301
276
|
const cached = resolved.get(options);
|
|
302
277
|
if ((cached == null ? void 0 : cached.catalogs) === options.datumCatalogs)
|
|
@@ -593,6 +568,7 @@ var linearUnits = {
|
|
|
593
568
|
};
|
|
594
569
|
|
|
595
570
|
// dist/projection/experimental/crs/normalize.js
|
|
571
|
+
var import_types2 = require("./experimental/crs/types.shared.cjs");
|
|
596
572
|
var ALIASES = {
|
|
597
573
|
WGS84: "+proj=longlat +datum=WGS84",
|
|
598
574
|
"EPSG:4326": "+proj=longlat +datum=WGS84",
|
|
@@ -605,31 +581,6 @@ var ALIASES = {
|
|
|
605
581
|
"EPSG:900913": "EPSG:3857",
|
|
606
582
|
"EPSG:102113": "EPSG:3857"
|
|
607
583
|
};
|
|
608
|
-
var CORE_PARAMETERS = [
|
|
609
|
-
"proj",
|
|
610
|
-
"datum",
|
|
611
|
-
"ellps",
|
|
612
|
-
"a",
|
|
613
|
-
"b",
|
|
614
|
-
"rf",
|
|
615
|
-
"f",
|
|
616
|
-
"R",
|
|
617
|
-
"units",
|
|
618
|
-
"to_meter",
|
|
619
|
-
"vunits",
|
|
620
|
-
"vto_meter",
|
|
621
|
-
"no_defs",
|
|
622
|
-
"type",
|
|
623
|
-
"title",
|
|
624
|
-
"towgs84",
|
|
625
|
-
"nadgrids",
|
|
626
|
-
"geoidgrids",
|
|
627
|
-
"axis",
|
|
628
|
-
"pm",
|
|
629
|
-
"over",
|
|
630
|
-
"lon_wrap"
|
|
631
|
-
];
|
|
632
|
-
var CORE_FLAGS = ["no_defs", "over"];
|
|
633
584
|
var own = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
634
585
|
var keyOf = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
|
|
635
586
|
function lookup(table, name) {
|
|
@@ -682,7 +633,7 @@ function resolveLocalCRSDefinition(input, options = {}) {
|
|
|
682
633
|
return definition;
|
|
683
634
|
}
|
|
684
635
|
function normalizeCRS(input, options = {}) {
|
|
685
|
-
var
|
|
636
|
+
var _a;
|
|
686
637
|
const datums = getDatumDefinitions(options);
|
|
687
638
|
const resolved2 = resolveCRSInput(input, options);
|
|
688
639
|
const definition = resolveLocalCRSDefinition(resolved2.definition, options);
|
|
@@ -696,10 +647,10 @@ function normalizeCRS(input, options = {}) {
|
|
|
696
647
|
}
|
|
697
648
|
parsed = { parameters: parameters2 };
|
|
698
649
|
} else {
|
|
699
|
-
const parser = (
|
|
650
|
+
const parser = (_a = options.parsers) == null ? void 0 : _a.find((candidate) => candidate.canParse(definition));
|
|
700
651
|
if (!parser) {
|
|
701
652
|
const serialized = ["wkt", "projjson"].includes(inferCRSRepresentation(definition));
|
|
702
|
-
throw new TypeScriptCRSError(serialized ? "missing-parser" : "unknown-syntax", inferCRSRepresentation(definition) === "identifier" ? "Unsupported CRS definition: " + definition + "; resolve it first" : "Unsupported CRS definition; register a WKT or PROJJSON parser for structured definitions");
|
|
653
|
+
throw new import_types2.TypeScriptCRSError(serialized ? "missing-parser" : "unknown-syntax", inferCRSRepresentation(definition) === "identifier" ? "Unsupported CRS definition: " + definition + "; resolve it first" : "Unsupported CRS definition; register a WKT or PROJJSON parser for structured definitions");
|
|
703
654
|
}
|
|
704
655
|
parsed = parser.parse(definition, options);
|
|
705
656
|
}
|
|
@@ -740,7 +691,7 @@ function normalizeCRS(input, options = {}) {
|
|
|
740
691
|
const datumName = parameters["datum"];
|
|
741
692
|
const datum = datumName && datumName !== "none" ? lookup(datums, datumName) : void 0;
|
|
742
693
|
if (datumName && datumName !== "none" && !datum)
|
|
743
|
-
unsupportedStage("Unknown datum: " + datumName + "; register a datumCatalogs plugin");
|
|
694
|
+
(0, import_types2.unsupportedStage)("Unknown datum: " + datumName + "; register a datumCatalogs plugin");
|
|
744
695
|
const ellipsoid = getEllipsoid(parameters, datum == null ? void 0 : datum.ellipse);
|
|
745
696
|
const grids = parameters["nadgrids"] ?? (datum == null ? void 0 : datum.nadgrids);
|
|
746
697
|
const gridReferences = grids === void 0 ? void 0 : grids.split(",").map((entry) => {
|
|
@@ -830,875 +781,8 @@ function getEllipsoid(parameters, datumEllipsoid) {
|
|
|
830
781
|
});
|
|
831
782
|
}
|
|
832
783
|
|
|
833
|
-
// dist/projection/
|
|
834
|
-
var
|
|
835
|
-
function createAngularRanges(west, south, east, north) {
|
|
836
|
-
return [
|
|
837
|
-
[west, south],
|
|
838
|
-
[east, north]
|
|
839
|
-
];
|
|
840
|
-
}
|
|
841
|
-
function normalizeLongitude(longitude) {
|
|
842
|
-
return longitude >= -180 && longitude < 180 ? longitude : ((longitude + 180) % 360 + 360) % 360 - 180;
|
|
843
|
-
}
|
|
844
|
-
function getLongitudeSpan(bounds) {
|
|
845
|
-
const span = bounds[2] - bounds[0];
|
|
846
|
-
return span < 0 ? span + 360 : span;
|
|
847
|
-
}
|
|
848
|
-
function containsGeographicPoint(bounds, point) {
|
|
849
|
-
const [west, south, east, north] = bounds;
|
|
850
|
-
const longitude = normalizeLongitude(point[0]);
|
|
851
|
-
return point[1] >= south && point[1] <= north && (west <= east ? longitude >= west && longitude <= east || longitude === -180 && east === 180 : longitude >= west || longitude <= east);
|
|
852
|
-
}
|
|
853
|
-
function clampGeographicPoint(bounds, point) {
|
|
854
|
-
let longitude = normalizeLongitude(point[0]);
|
|
855
|
-
const latitude = Math.max(bounds[1], Math.min(bounds[3], point[1]));
|
|
856
|
-
if (!containsGeographicPoint(bounds, [longitude, latitude])) {
|
|
857
|
-
const westDistance = Math.abs(normalizeLongitude(longitude - bounds[0]));
|
|
858
|
-
const eastDistance = Math.abs(normalizeLongitude(longitude - bounds[2]));
|
|
859
|
-
longitude = westDistance <= eastDistance ? bounds[0] : bounds[2];
|
|
860
|
-
}
|
|
861
|
-
return [longitude, latitude];
|
|
862
|
-
}
|
|
863
|
-
function getAngularRanges(bounds, primeMeridian2 = 0, origin = 0) {
|
|
864
|
-
const width = getLongitudeSpan(bounds);
|
|
865
|
-
const west = bounds[0] * RADIANS - primeMeridian2;
|
|
866
|
-
const middle = west + width * RADIANS / 2;
|
|
867
|
-
const shift = Math.round((origin - middle) / (2 * Math.PI)) * 2 * Math.PI;
|
|
868
|
-
return createAngularRanges(width === 360 ? origin - Math.PI : west + shift, bounds[1] * RADIANS, width === 360 ? origin + Math.PI : west + shift + width * RADIANS, bounds[3] * RADIANS);
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
// dist/projection/experimental/rendering-profile/rendering-profile.js
|
|
872
|
-
function resolveRenderingProfile(getRenderingProfile, coverage) {
|
|
873
|
-
if (coverage) {
|
|
874
|
-
try {
|
|
875
|
-
const profile2 = getRenderingProfile(coverage);
|
|
876
|
-
return resolveBounds(profile2);
|
|
877
|
-
} catch {
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
const profile = getRenderingProfile();
|
|
881
|
-
return resolveBounds(profile);
|
|
882
|
-
}
|
|
883
|
-
function resolveBounds(profile) {
|
|
884
|
-
var _a2;
|
|
885
|
-
const bounds = profile.bounds;
|
|
886
|
-
if (bounds.some((corner) => corner.some((value) => !Number.isFinite(value))))
|
|
887
|
-
throw new Error("Projection rendering bounds must be finite");
|
|
888
|
-
return { bounds, normalize: (_a2 = profile.normalize) == null ? void 0 : _a2.bind(profile) };
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// dist/projection/experimental/rendering-profile/identity-rendering-profile.js
|
|
892
|
-
function getIdentityRenderingProfile() {
|
|
893
|
-
return {
|
|
894
|
-
bounds: [
|
|
895
|
-
[-1, -1, 0],
|
|
896
|
-
[1, 1, 0]
|
|
897
|
-
]
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
// dist/projection/experimental/projection-descriptor.js
|
|
902
|
-
var CACHE_KEY = /* @__PURE__ */ Symbol.for("@math.gl/projection/projection-implementations");
|
|
903
|
-
function cache() {
|
|
904
|
-
const scope = globalThis;
|
|
905
|
-
scope[CACHE_KEY] || (scope[CACHE_KEY] = /* @__PURE__ */ new WeakMap());
|
|
906
|
-
return scope[CACHE_KEY];
|
|
907
|
-
}
|
|
908
|
-
function getLoadedProjection(projection) {
|
|
909
|
-
var _a2;
|
|
910
|
-
return "create" in projection ? projection : (_a2 = cache().get(projection)) == null ? void 0 : _a2.implementation;
|
|
911
|
-
}
|
|
912
|
-
function preloadProjection(projection) {
|
|
913
|
-
if ("create" in projection)
|
|
914
|
-
return Promise.resolve(projection);
|
|
915
|
-
let state = cache().get(projection);
|
|
916
|
-
if (!state) {
|
|
917
|
-
state = { load: () => projection.preload() };
|
|
918
|
-
cache().set(projection, state);
|
|
919
|
-
}
|
|
920
|
-
if (state.implementation)
|
|
921
|
-
return Promise.resolve(state.implementation);
|
|
922
|
-
const entry = state;
|
|
923
|
-
entry.pending || (entry.pending = Promise.resolve().then(entry.load).then((plugin) => {
|
|
924
|
-
const key = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
|
|
925
|
-
const supported = new Set([plugin.name, ...plugin.aliases || []].map(key));
|
|
926
|
-
if (typeof plugin.create !== "function" || ![projection.name, ...projection.aliases || []].every((name) => supported.has(key(name))))
|
|
927
|
-
throw new Error("Loaded projection does not match descriptor: " + projection.name);
|
|
928
|
-
entry.implementation = plugin;
|
|
929
|
-
return plugin;
|
|
930
|
-
}).catch((error) => {
|
|
931
|
-
entry.pending = void 0;
|
|
932
|
-
throw error;
|
|
933
|
-
}));
|
|
934
|
-
return entry.pending;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
// dist/projection/experimental/projection-scratch.js
|
|
938
|
-
function createPoint() {
|
|
939
|
-
return { x: 0, y: 0, z: 0 };
|
|
940
|
-
}
|
|
941
|
-
var ProjectionScratch = class {
|
|
942
|
-
constructor() {
|
|
943
|
-
this.point = createPoint();
|
|
944
|
-
this.points = [this.point];
|
|
945
|
-
this.active = 0;
|
|
946
|
-
}
|
|
947
|
-
get depth() {
|
|
948
|
-
return this.active;
|
|
949
|
-
}
|
|
950
|
-
acquire() {
|
|
951
|
-
var _a2;
|
|
952
|
-
const index = this.active++;
|
|
953
|
-
(_a2 = this.points)[index] || (_a2[index] = createPoint());
|
|
954
|
-
return this.points[index];
|
|
955
|
-
}
|
|
956
|
-
release(point) {
|
|
957
|
-
if (this.active > 0 && this.points[this.active - 1] === point)
|
|
958
|
-
this.active--;
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
|
|
962
|
-
// dist/projection/experimental/mutable-projection.js
|
|
963
|
-
function projectionOperation(implementation, inverse, geocentric = false) {
|
|
964
|
-
const mutable = inverse ? implementation.inverseInPlace : implementation.forwardInPlace;
|
|
965
|
-
if (mutable)
|
|
966
|
-
return mutable.bind(implementation);
|
|
967
|
-
if (geocentric) {
|
|
968
|
-
const operation2 = inverse ? implementation.inverse3D : implementation.forward3D;
|
|
969
|
-
return (point) => {
|
|
970
|
-
const output = operation2.call(implementation, [point.x, point.y, point.z]);
|
|
971
|
-
point.x = output[0];
|
|
972
|
-
point.y = output[1];
|
|
973
|
-
point.z = output[2];
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
const operation = inverse ? implementation.inverse : implementation.forward;
|
|
977
|
-
return (point) => {
|
|
978
|
-
const output = operation.call(implementation, point.x, point.y);
|
|
979
|
-
point.x = output[0];
|
|
980
|
-
point.y = output[1];
|
|
981
|
-
};
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
// dist/projection/experimental/scalar-output.js
|
|
985
|
-
var FLOAT32_MAX = 34028234663852886e22;
|
|
986
|
-
function validateScalarOutput(coordinate, output, length) {
|
|
987
|
-
if (!(Array.isArray(coordinate) || coordinate instanceof Float32Array || coordinate instanceof Float64Array))
|
|
988
|
-
throw new Error("Scalar input requires a number array, Float32Array or Float64Array");
|
|
989
|
-
if (!(Array.isArray(output) || output instanceof Float32Array || output instanceof Float64Array) || output.length < length)
|
|
990
|
-
throw new Error("Scalar output requires a preallocated number array, Float32Array or Float64Array with sufficient capacity");
|
|
991
|
-
if (coordinate === output || Array.isArray(coordinate) || Array.isArray(output))
|
|
992
|
-
return;
|
|
993
|
-
const input = coordinate;
|
|
994
|
-
const result = output;
|
|
995
|
-
const shared = typeof SharedArrayBuffer !== "undefined" && input.buffer instanceof SharedArrayBuffer && result.buffer instanceof SharedArrayBuffer;
|
|
996
|
-
if ((input.buffer === result.buffer || shared) && input.byteOffset < result.byteOffset + length * result.BYTES_PER_ELEMENT && result.byteOffset < input.byteOffset + input.byteLength)
|
|
997
|
-
throw new Error("Scalar input/output views overlap; use the same view for in-place projection");
|
|
998
|
-
}
|
|
999
|
-
function writeScalarOutput(coordinate, output, point, length) {
|
|
1000
|
-
if (output instanceof Float32Array) {
|
|
1001
|
-
if (Math.abs(point.x) > FLOAT32_MAX || Math.abs(point.y) > FLOAT32_MAX || length >= 3 && Math.abs(point.z) > FLOAT32_MAX)
|
|
1002
|
-
throw new Error("Projected coordinate exceeds Float32 range");
|
|
1003
|
-
for (let i = 3; i < coordinate.length; i++) {
|
|
1004
|
-
const value = coordinate[i];
|
|
1005
|
-
if (Number.isFinite(value) && Math.abs(value) > FLOAT32_MAX)
|
|
1006
|
-
throw new Error("Trailing ordinate exceeds Float32 range");
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
for (let i = 3; i < coordinate.length; i++)
|
|
1010
|
-
output[i] = coordinate[i];
|
|
1011
|
-
output[0] = point.x;
|
|
1012
|
-
output[1] = point.y;
|
|
1013
|
-
if (length >= 3)
|
|
1014
|
-
output[2] = point.z;
|
|
1015
|
-
return output;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
// dist/projection/experimental/datum.js
|
|
1019
|
-
var import_matrix = require("@math.gl/core/matrix");
|
|
1020
|
-
var ARC_SECOND = Math.PI / (180 * 3600);
|
|
1021
|
-
var WGS84 = {
|
|
1022
|
-
ellipsoid: {
|
|
1023
|
-
semiMajorAxis: 6378137,
|
|
1024
|
-
semiMinorAxis: 6356752314245179e-9,
|
|
1025
|
-
eccentricitySquared: 0.0066943799901413165
|
|
1026
|
-
},
|
|
1027
|
-
towgs84: [0, 0, 0]
|
|
1028
|
-
};
|
|
1029
|
-
function geodeticToGeocentricInPlace(point, ellipsoid) {
|
|
1030
|
-
if (Math.abs(point.y) > Math.PI / 2)
|
|
1031
|
-
throw new Error("Latitude outside geocentric domain");
|
|
1032
|
-
if (!(0, import_matrix.spheroidToCartesian)(point, ellipsoid))
|
|
1033
|
-
throw new Error("Geocentric coordinate must be finite");
|
|
1034
|
-
}
|
|
1035
|
-
function geocentricToGeodeticInPlace(point, ellipsoid) {
|
|
1036
|
-
const x = point.x, y = point.y, z = point.z;
|
|
1037
|
-
const { semiMajorAxis: a, semiMinorAxis: b, eccentricitySquared: es } = ellipsoid;
|
|
1038
|
-
if (x === 0 && y === 0 && z === 0)
|
|
1039
|
-
throw new Error("Geodetic coordinates are undefined at the Earth center");
|
|
1040
|
-
if (es !== 0 && Math.abs(x) < 1e-12 * a && Math.abs(y) < 1e-12 * a && Math.hypot(x, y) < 1e-12 * a) {
|
|
1041
|
-
if (!Number.isFinite(Math.hypot(x, y, z)))
|
|
1042
|
-
throw new Error("Geocentric radius must be finite");
|
|
1043
|
-
point.x = 0;
|
|
1044
|
-
point.y = Math.sign(z) * Math.PI / 2;
|
|
1045
|
-
point.z = Math.abs(z) - b;
|
|
1046
|
-
return;
|
|
1047
|
-
}
|
|
1048
|
-
if (!(0, import_matrix.cartesianToSpheroid)(point, ellipsoid)) {
|
|
1049
|
-
if (!Number.isFinite(Math.hypot(x, y, z)))
|
|
1050
|
-
throw new Error("Geocentric radius must be finite");
|
|
1051
|
-
throw new Error("Geocentric inverse did not converge");
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
function createHelmert(values, inverse) {
|
|
1055
|
-
const dx = values[0], dy = values[1], dz = values[2];
|
|
1056
|
-
const rx = (values[3] || 0) * ARC_SECOND, ry = (values[4] || 0) * ARC_SECOND, rz = (values[5] || 0) * ARC_SECOND;
|
|
1057
|
-
const scale = 1 + (values[6] || 0) / 1e6;
|
|
1058
|
-
return inverse ? (point) => {
|
|
1059
|
-
const x = (point.x - dx) / scale, y = (point.y - dy) / scale, z = (point.z - dz) / scale;
|
|
1060
|
-
point.x = x + rz * y - ry * z;
|
|
1061
|
-
point.y = -rz * x + y + rx * z;
|
|
1062
|
-
point.z = ry * x - rx * y + z;
|
|
1063
|
-
} : (point) => {
|
|
1064
|
-
const x = point.x, y = point.y, z = point.z;
|
|
1065
|
-
point.x = scale * (x - rz * y + ry * z) + dx;
|
|
1066
|
-
point.y = scale * (rz * x + y - rx * z) + dy;
|
|
1067
|
-
point.z = scale * (-ry * x + rx * y + z) + dz;
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
function shifted(datum) {
|
|
1071
|
-
var _a2;
|
|
1072
|
-
return Boolean((_a2 = datum.towgs84) == null ? void 0 : _a2.some((value) => value !== 0));
|
|
1073
|
-
}
|
|
1074
|
-
function createDatumTransform(source, destination) {
|
|
1075
|
-
if (!source.towgs84 || !destination.towgs84)
|
|
1076
|
-
return void 0;
|
|
1077
|
-
if (source.grids || destination.grids) {
|
|
1078
|
-
if (source.grids && destination.grids && source.ellipsoid.semiMajorAxis === destination.ellipsoid.semiMajorAxis && source.ellipsoid.eccentricitySquared === destination.ellipsoid.eccentricitySquared && source.grids.length === destination.grids.length && source.grids.every((entry, i) => entry.name === destination.grids[i].name && entry.optional === destination.grids[i].optional && entry.grid === destination.grids[i].grid))
|
|
1079
|
-
return void 0;
|
|
1080
|
-
const middle = createDatumTransform(source.grids ? WGS84 : source, destination.grids ? WGS84 : destination);
|
|
1081
|
-
return (point) => {
|
|
1082
|
-
if (source.grids)
|
|
1083
|
-
applyDatumGrids(point, source, false);
|
|
1084
|
-
middle == null ? void 0 : middle(point);
|
|
1085
|
-
if (destination.grids)
|
|
1086
|
-
applyDatumGrids(point, destination, true);
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
if (shifted(source) || shifted(destination)) {
|
|
1090
|
-
const first = convertDatum(source, WGS84), second = convertDatum(WGS84, destination);
|
|
1091
|
-
return (point) => {
|
|
1092
|
-
first == null ? void 0 : first(point);
|
|
1093
|
-
second == null ? void 0 : second(point);
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
return convertDatum(source, destination);
|
|
1097
|
-
}
|
|
1098
|
-
function convertDatum(from, to) {
|
|
1099
|
-
if (!from.towgs84 || !to.towgs84)
|
|
1100
|
-
return void 0;
|
|
1101
|
-
const a = from.ellipsoid, b = to.ellipsoid;
|
|
1102
|
-
let sameParameters = true;
|
|
1103
|
-
for (let i = 0; i < 7; i++)
|
|
1104
|
-
if ((from.towgs84[i] || 0) !== (to.towgs84[i] || 0))
|
|
1105
|
-
sameParameters = false;
|
|
1106
|
-
if (a.semiMajorAxis === b.semiMajorAxis && Math.abs(a.eccentricitySquared - b.eccentricitySquared) <= 5e-11 && sameParameters)
|
|
1107
|
-
return void 0;
|
|
1108
|
-
const sourceShift = shifted(from) ? createHelmert(from.towgs84, false) : void 0, targetShift = shifted(to) ? createHelmert(to.towgs84, true) : void 0;
|
|
1109
|
-
return (point) => {
|
|
1110
|
-
geodeticToGeocentricInPlace(point, a);
|
|
1111
|
-
sourceShift == null ? void 0 : sourceShift(point);
|
|
1112
|
-
targetShift == null ? void 0 : targetShift(point);
|
|
1113
|
-
geocentricToGeodeticInPlace(point, b);
|
|
1114
|
-
};
|
|
1115
|
-
}
|
|
1116
|
-
function applyDatumGrids(point, datum, inverse) {
|
|
1117
|
-
for (const reference of datum.grids) {
|
|
1118
|
-
if (reference.name === "null")
|
|
1119
|
-
return;
|
|
1120
|
-
if (!reference.grid) {
|
|
1121
|
-
if (reference.optional)
|
|
1122
|
-
continue;
|
|
1123
|
-
throw new Error("Required datum grid is not registered: " + reference.name);
|
|
1124
|
-
}
|
|
1125
|
-
let found = false;
|
|
1126
|
-
if (reference.grid.shiftInPlace)
|
|
1127
|
-
found = reference.grid.shiftInPlace(point, inverse);
|
|
1128
|
-
else {
|
|
1129
|
-
const output = reference.grid.shift(point.x, point.y, inverse);
|
|
1130
|
-
if (output) {
|
|
1131
|
-
point.x = output[0];
|
|
1132
|
-
point.y = output[1];
|
|
1133
|
-
found = true;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
if (found) {
|
|
1137
|
-
if (!Number.isFinite(point.x) || !Number.isFinite(point.y) || Math.abs(point.y) > Math.PI / 2)
|
|
1138
|
-
throw new Error("Datum grid produced a coordinate outside the geographic domain");
|
|
1139
|
-
return;
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
throw new Error("No datum grid covers coordinate: " + datum.grids.map((grid) => grid.name).join(","));
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
// dist/projection/experimental/rendering-profile/rectangular-rendering-profile.js
|
|
1146
|
-
function normalizeCoverage(point, coverage, center = 0, over = false) {
|
|
1147
|
-
const span = getLongitudeSpan(coverage);
|
|
1148
|
-
const west = span === 360 ? center - 180 : coverage[0] + Math.round((center - coverage[0] - span / 2) / 360) * 360;
|
|
1149
|
-
const east = west + span;
|
|
1150
|
-
if (over) {
|
|
1151
|
-
point.x = Math.max(west, Math.min(east, point.x));
|
|
1152
|
-
point.y = Math.max(coverage[1], Math.min(coverage[3], point.y));
|
|
1153
|
-
return;
|
|
1154
|
-
}
|
|
1155
|
-
const best = clampGeographicPoint(coverage, [point.x, point.y]);
|
|
1156
|
-
let longitude = best[0];
|
|
1157
|
-
if (best[0] === normalizeLongitude(point.x) && point.x >= west && point.x <= east)
|
|
1158
|
-
longitude = point.x;
|
|
1159
|
-
else if (longitude < west || longitude > east)
|
|
1160
|
-
longitude += Math.round(((west + east) / 2 - longitude) / 360) * 360;
|
|
1161
|
-
const offset = longitude - center;
|
|
1162
|
-
point.x = Math.abs(offset) <= 180 ? longitude : center + normalizeLongitude(offset);
|
|
1163
|
-
point.y = best[1];
|
|
1164
|
-
}
|
|
1165
|
-
function createRectangleRenderingProfile(resolveBounds2, coverage, origin = 0, primeMeridian2 = 0, over = false) {
|
|
1166
|
-
const center = (origin + primeMeridian2) * 180 / Math.PI;
|
|
1167
|
-
return {
|
|
1168
|
-
get bounds() {
|
|
1169
|
-
return resolveBounds2(getAngularRanges(coverage, primeMeridian2, origin));
|
|
1170
|
-
},
|
|
1171
|
-
normalize(point) {
|
|
1172
|
-
normalizeCoverage(point, coverage, center, over);
|
|
1173
|
-
}
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
// dist/projection/experimental/rendering-profile/rendering-bounds.js
|
|
1178
|
-
function longitudeRange(parameters, origin, over = false) {
|
|
1179
|
-
const low = parameters[0][0] - origin, high = parameters[1][0] - origin;
|
|
1180
|
-
if (over)
|
|
1181
|
-
return [low, high];
|
|
1182
|
-
const span = high - low;
|
|
1183
|
-
if (span >= 2 * Math.PI - 1e-12)
|
|
1184
|
-
return [-Math.PI, Math.PI];
|
|
1185
|
-
let west = wrapLongitude(low);
|
|
1186
|
-
if (span > 0 && Math.abs(west - Math.PI) < 1e-12)
|
|
1187
|
-
west = -Math.PI;
|
|
1188
|
-
const east = west + span;
|
|
1189
|
-
return east > Math.PI + 1e-12 ? [-Math.PI, Math.PI] : [west, Math.min(east, Math.PI)];
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
// dist/projection/experimental/rendering-profile/geographic-rendering-profile.js
|
|
1193
|
-
function createGeographicProfile(parameters, primeMeridian2 = 0) {
|
|
1194
|
-
const center = numberParameter(parameters, "lon_wrap", 0) * DEGREES_TO_RADIANS;
|
|
1195
|
-
return (coverage) => createRectangleRenderingProfile((ranges) => {
|
|
1196
|
-
const longitude = longitudeRange(ranges, center);
|
|
1197
|
-
return [
|
|
1198
|
-
[center + longitude[0], ranges[0][1], 0],
|
|
1199
|
-
[center + longitude[1], ranges[1][1], 0]
|
|
1200
|
-
];
|
|
1201
|
-
}, coverage ?? [-180, -90, 180, 90], center, primeMeridian2);
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
// dist/projection/experimental/vertical-datum.js
|
|
1205
|
-
function compileVerticalGrid(names, grids = {}) {
|
|
1206
|
-
if (names === void 0)
|
|
1207
|
-
return void 0;
|
|
1208
|
-
const entries = [];
|
|
1209
|
-
for (const entry of names.split(",")) {
|
|
1210
|
-
const optional = entry.startsWith("@");
|
|
1211
|
-
const name = optional ? entry.slice(1) : entry;
|
|
1212
|
-
if (!name || /\s/.test(name))
|
|
1213
|
-
throw new Error("Invalid vertical grid name");
|
|
1214
|
-
if (name === "null") {
|
|
1215
|
-
entries.push(null);
|
|
1216
|
-
break;
|
|
1217
|
-
}
|
|
1218
|
-
const grid = Object.prototype.hasOwnProperty.call(grids, name) ? grids[name] : void 0;
|
|
1219
|
-
if (grid) {
|
|
1220
|
-
if (typeof grid.getOffset !== "function")
|
|
1221
|
-
throw new Error("Invalid vertical grid: " + name);
|
|
1222
|
-
entries.push(grid.getOffset.bind(grid));
|
|
1223
|
-
} else if (!optional)
|
|
1224
|
-
unsupportedStage("Required vertical grid is not registered: " + name);
|
|
1225
|
-
}
|
|
1226
|
-
return (longitude, latitude) => {
|
|
1227
|
-
for (const sample of entries) {
|
|
1228
|
-
if (!sample)
|
|
1229
|
-
return 0;
|
|
1230
|
-
const offset = sample(longitude, latitude);
|
|
1231
|
-
if (offset === void 0)
|
|
1232
|
-
continue;
|
|
1233
|
-
if (!Number.isFinite(offset))
|
|
1234
|
-
throw new Error("Vertical grid returned a non-finite offset");
|
|
1235
|
-
return offset;
|
|
1236
|
-
}
|
|
1237
|
-
throw new Error("No vertical grid covers this coordinate");
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
// dist/projection/experimental/transform-description.js
|
|
1242
|
-
function describeCRS(crs) {
|
|
1243
|
-
const ellipsoid = Object.freeze({ ...crs.ellipsoid });
|
|
1244
|
-
return Object.freeze({
|
|
1245
|
-
kind: crs.kind,
|
|
1246
|
-
projection: crs.projection,
|
|
1247
|
-
parameters: Object.freeze(Object.fromEntries(Object.entries(crs.parameters).map(([name, value]) => [name, value ?? null]))),
|
|
1248
|
-
ellipsoid,
|
|
1249
|
-
datum: Object.freeze({
|
|
1250
|
-
ellipsoid: Object.freeze({ ...crs.datum.ellipsoid }),
|
|
1251
|
-
towgs84: crs.datum.towgs84 && Object.freeze([...crs.datum.towgs84]),
|
|
1252
|
-
grids: crs.datum.grids && Object.freeze(crs.datum.grids.map((reference) => Object.freeze({
|
|
1253
|
-
name: reference.name,
|
|
1254
|
-
optional: reference.optional,
|
|
1255
|
-
loaded: Boolean(reference.grid)
|
|
1256
|
-
})))
|
|
1257
|
-
}),
|
|
1258
|
-
angularUnit: crs.angularUnit,
|
|
1259
|
-
toMeter: crs.toMeter,
|
|
1260
|
-
verticalUnit: crs.verticalUnit,
|
|
1261
|
-
primeMeridian: crs.primeMeridian,
|
|
1262
|
-
axis: crs.axis,
|
|
1263
|
-
storedAxis: crs.storedAxis,
|
|
1264
|
-
longitudeWrap: crs.longitudeWrap,
|
|
1265
|
-
areaOfUse: crs.areaOfUse && Object.freeze([...crs.areaOfUse]),
|
|
1266
|
-
lossy: crs.lossy,
|
|
1267
|
-
algorithm: crs.algorithm && Object.freeze({ ...crs.algorithm })
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
function describeTransform(source, target, forward, inverse) {
|
|
1271
|
-
const opaqueReasons = [];
|
|
1272
|
-
if (!source.algorithm)
|
|
1273
|
-
opaqueReasons.push("source-algorithm");
|
|
1274
|
-
if (!target.algorithm)
|
|
1275
|
-
opaqueReasons.push("target-algorithm");
|
|
1276
|
-
if (source.datum.grids || target.datum.grids || source.parameters["geoidgrids"] || target.parameters["geoidgrids"])
|
|
1277
|
-
opaqueReasons.push("grid-resource");
|
|
1278
|
-
return Object.freeze({
|
|
1279
|
-
version: 1,
|
|
1280
|
-
source,
|
|
1281
|
-
target,
|
|
1282
|
-
forward,
|
|
1283
|
-
inverse,
|
|
1284
|
-
lossy: source.lossy || target.lossy,
|
|
1285
|
-
complete: opaqueReasons.length === 0,
|
|
1286
|
-
opaqueReasons: Object.freeze(opaqueReasons)
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
// dist/projection/experimental/typescript-projection.js
|
|
1291
|
-
var ProjectionTransform = class _ProjectionTransform {
|
|
1292
|
-
/** Resolve required descriptors once, then return an ordinary synchronous instance. */
|
|
1293
|
-
static async create(options = {}) {
|
|
1294
|
-
const projections = await Promise.all(requiredProjections(options).map(preloadProjection));
|
|
1295
|
-
return new _ProjectionTransform({ ...options, projections });
|
|
1296
|
-
}
|
|
1297
|
-
get targetProfile() {
|
|
1298
|
-
return this.getTargetRenderingProfile(this.targetCoverage);
|
|
1299
|
-
}
|
|
1300
|
-
/** Resolve target rendering policy independently from coordinate conversion. @internal */
|
|
1301
|
-
getTargetRenderingProfile(coverage) {
|
|
1302
|
-
return this.targetRenderingProfile && resolveRenderingProfile(this.targetRenderingProfile, coverage);
|
|
1303
|
-
}
|
|
1304
|
-
/** Deferred transforms expose metadata only once their implementations are prepared. */
|
|
1305
|
-
get description() {
|
|
1306
|
-
var _a2, _b;
|
|
1307
|
-
return ((_b = (_a2 = this.deferred) == null ? void 0 : _a2.implementation) == null ? void 0 : _b.description) ?? this.resolvedDescription;
|
|
1308
|
-
}
|
|
1309
|
-
constructor(options = {}) {
|
|
1310
|
-
var _a2, _b, _c;
|
|
1311
|
-
this.coordinateScratch = new ProjectionScratch();
|
|
1312
|
-
this.targetLongitudeOrigin = 0;
|
|
1313
|
-
const registrations = options.projections || [];
|
|
1314
|
-
const plugins = registry(registrations);
|
|
1315
|
-
if (registrations.some((projection) => !("create" in projection))) {
|
|
1316
|
-
const from = normalizeCRS(options.from ?? "WGS84", options);
|
|
1317
|
-
const to = normalizeCRS(options.to ?? "WGS84", options);
|
|
1318
|
-
this.lossy = from.lossy || to.lossy;
|
|
1319
|
-
this.deferred = { options: { ...options, projections: [...registrations] } };
|
|
1320
|
-
} else {
|
|
1321
|
-
const eager = options;
|
|
1322
|
-
const eagerPlugins = plugins;
|
|
1323
|
-
const from = compileCRS(eager.from ?? "WGS84", eagerPlugins, eager);
|
|
1324
|
-
const to = compileCRS(eager.to ?? "WGS84", eagerPlugins, eager);
|
|
1325
|
-
this.targetRenderingProfile = ((_b = (_a2 = to.implementation) == null ? void 0 : _a2.getRenderingProfile) == null ? void 0 : _b.bind(to.implementation)) ?? (to.kind === "geographic" ? createGeographicProfile(to.parameters, to.primeMeridian) : to.kind === "identity" ? getIdentityRenderingProfile : void 0);
|
|
1326
|
-
this.targetCoverage = to.areaOfUse;
|
|
1327
|
-
this.targetLongitudeOrigin = ((_c = to.implementation) == null ? void 0 : _c.longitudeOrigin) ?? (to.kind === "geographic" ? to.longitudeWrap ?? 0 : 0);
|
|
1328
|
-
this.lossy = from.lossy || to.lossy;
|
|
1329
|
-
if (this.lossy && (from.kind === "geocentric" || to.kind === "geocentric"))
|
|
1330
|
-
unsupportedStage("Horizontal extraction cannot supply ellipsoidal height for geocentric coordinates");
|
|
1331
|
-
if (this.lossy && (from.verticalGrid || to.verticalGrid))
|
|
1332
|
-
unsupportedStage("Horizontal extraction cannot be combined with vertical grids");
|
|
1333
|
-
this.forwardTransform = compileTransform(from, to, Boolean(options.enforceAxis));
|
|
1334
|
-
this.inverseTransform = compileTransform(to, from, Boolean(options.enforceAxis));
|
|
1335
|
-
this.resolvedDescription = describeTransform(describeCRS(from), describeCRS(to), this.forwardTransform.description, this.inverseTransform.description);
|
|
1336
|
-
}
|
|
1337
|
-
this.project = this.project.bind(this);
|
|
1338
|
-
this.unproject = this.unproject.bind(this);
|
|
1339
|
-
this.projectTo = this.projectTo.bind(this);
|
|
1340
|
-
this.unprojectTo = this.unprojectTo.bind(this);
|
|
1341
|
-
this.projectToSync = this.projectToSync.bind(this);
|
|
1342
|
-
this.unprojectToSync = this.unprojectToSync.bind(this);
|
|
1343
|
-
this.projectFlat = this.projectFlat.bind(this);
|
|
1344
|
-
this.unprojectFlat = this.unprojectFlat.bind(this);
|
|
1345
|
-
this.projectSync = this.projectSync.bind(this);
|
|
1346
|
-
this.unprojectSync = this.unprojectSync.bind(this);
|
|
1347
|
-
this.projectFlatSync = this.projectFlatSync.bind(this);
|
|
1348
|
-
this.unprojectFlatSync = this.unprojectFlatSync.bind(this);
|
|
1349
|
-
}
|
|
1350
|
-
load() {
|
|
1351
|
-
const state = this.deferred;
|
|
1352
|
-
if (!state)
|
|
1353
|
-
return Promise.resolve(this);
|
|
1354
|
-
if (state.implementation)
|
|
1355
|
-
return Promise.resolve(state.implementation);
|
|
1356
|
-
state.pending || (state.pending = _ProjectionTransform.create(state.options).then((projection) => {
|
|
1357
|
-
state.implementation = projection;
|
|
1358
|
-
return projection;
|
|
1359
|
-
}).catch((error) => {
|
|
1360
|
-
state.pending = void 0;
|
|
1361
|
-
throw error;
|
|
1362
|
-
}));
|
|
1363
|
-
return state.pending;
|
|
1364
|
-
}
|
|
1365
|
-
loadSync() {
|
|
1366
|
-
const state = this.deferred;
|
|
1367
|
-
if (!state)
|
|
1368
|
-
return this;
|
|
1369
|
-
if (!state.implementation) {
|
|
1370
|
-
const projections = requiredProjections(state.options).map((descriptor) => {
|
|
1371
|
-
const plugin = getLoadedProjection(descriptor);
|
|
1372
|
-
if (!plugin)
|
|
1373
|
-
throw new Error("Projection is not preloaded: " + descriptor.name + ". Call preload() first.");
|
|
1374
|
-
return plugin;
|
|
1375
|
-
});
|
|
1376
|
-
state.implementation = new _ProjectionTransform({ ...state.options, projections });
|
|
1377
|
-
}
|
|
1378
|
-
return state.implementation;
|
|
1379
|
-
}
|
|
1380
|
-
/** Synchronous variants never import algorithms; descriptors must be preloaded. */
|
|
1381
|
-
projectSync(coordinate) {
|
|
1382
|
-
return this.deferred ? this.loadSync().project(coordinate) : transformScalar(coordinate, this.forwardTransform, this.coordinateScratch);
|
|
1383
|
-
}
|
|
1384
|
-
unprojectSync(coordinate) {
|
|
1385
|
-
return this.deferred ? this.loadSync().unproject(coordinate) : transformScalar(coordinate, this.inverseTransform, this.coordinateScratch);
|
|
1386
|
-
}
|
|
1387
|
-
projectFlatSync(coordinates, dimension = 2) {
|
|
1388
|
-
return this.deferred ? this.loadSync().projectFlat(coordinates, dimension) : transformInPlace(coordinates, dimension, this.forwardTransform, this.coordinateScratch);
|
|
1389
|
-
}
|
|
1390
|
-
unprojectFlatSync(coordinates, dimension = 2) {
|
|
1391
|
-
return this.deferred ? this.loadSync().unprojectFlat(coordinates, dimension) : transformInPlace(coordinates, dimension, this.inverseTransform, this.coordinateScratch);
|
|
1392
|
-
}
|
|
1393
|
-
/** Optional warm-up. Coordinate methods also load automatically on first use. */
|
|
1394
|
-
async preload() {
|
|
1395
|
-
await this.load();
|
|
1396
|
-
}
|
|
1397
|
-
/** Eager plugins return arrays; descriptor-backed instances return promises. */
|
|
1398
|
-
project(coordinate) {
|
|
1399
|
-
const result = this.deferred ? this.projectLoaded(coordinate, false) : transformScalar(coordinate, this.forwardTransform, this.coordinateScratch);
|
|
1400
|
-
return result;
|
|
1401
|
-
}
|
|
1402
|
-
unproject(coordinate) {
|
|
1403
|
-
const result = this.deferred ? this.projectLoaded(coordinate, true) : transformScalar(coordinate, this.inverseTransform, this.coordinateScratch);
|
|
1404
|
-
return result;
|
|
1405
|
-
}
|
|
1406
|
-
/** Write one coordinate into caller-owned storage; return that same output. */
|
|
1407
|
-
projectTo(coordinate, output) {
|
|
1408
|
-
return this.deferred ? this.projectToLoaded(coordinate, output, false) : this.projectToSync(coordinate, output);
|
|
1409
|
-
}
|
|
1410
|
-
unprojectTo(coordinate, output) {
|
|
1411
|
-
return this.deferred ? this.projectToLoaded(coordinate, output, true) : this.unprojectToSync(coordinate, output);
|
|
1412
|
-
}
|
|
1413
|
-
projectToSync(coordinate, output) {
|
|
1414
|
-
if (this.deferred)
|
|
1415
|
-
return this.loadSync().projectTo(coordinate, output);
|
|
1416
|
-
validateScalarOutput(coordinate, output, Math.max(coordinate.length, this.forwardTransform.geocentricOutput ? 3 : 2));
|
|
1417
|
-
return transformScalar(coordinate, this.forwardTransform, this.coordinateScratch, output);
|
|
1418
|
-
}
|
|
1419
|
-
unprojectToSync(coordinate, output) {
|
|
1420
|
-
if (this.deferred)
|
|
1421
|
-
return this.loadSync().unprojectTo(coordinate, output);
|
|
1422
|
-
validateScalarOutput(coordinate, output, Math.max(coordinate.length, this.inverseTransform.geocentricOutput ? 3 : 2));
|
|
1423
|
-
return transformScalar(coordinate, this.inverseTransform, this.coordinateScratch, output);
|
|
1424
|
-
}
|
|
1425
|
-
projectToLoaded(coordinate, output, inverse) {
|
|
1426
|
-
validateScalarOutput(coordinate, output, coordinate.length);
|
|
1427
|
-
const input = coordinate.slice();
|
|
1428
|
-
return this.load().then((projection) => inverse ? projection.unprojectTo(input, output) : projection.projectTo(input, output));
|
|
1429
|
-
}
|
|
1430
|
-
projectLoaded(coordinate, inverse) {
|
|
1431
|
-
const input = coordinate.slice();
|
|
1432
|
-
return this.load().then((projection) => inverse ? projection.unproject(input) : projection.project(input));
|
|
1433
|
-
}
|
|
1434
|
-
/** In-place; descriptor callers must await completion before reusing the buffer. */
|
|
1435
|
-
projectFlat(coordinates, dimension = 2) {
|
|
1436
|
-
const result = this.deferred ? this.load().then((projection) => projection.projectFlat(coordinates, dimension)) : transformInPlace(coordinates, dimension, this.forwardTransform, this.coordinateScratch);
|
|
1437
|
-
return result;
|
|
1438
|
-
}
|
|
1439
|
-
unprojectFlat(coordinates, dimension = 2) {
|
|
1440
|
-
const result = this.deferred ? this.load().then((projection) => projection.unprojectFlat(coordinates, dimension)) : transformInPlace(coordinates, dimension, this.inverseTransform, this.coordinateScratch);
|
|
1441
|
-
return result;
|
|
1442
|
-
}
|
|
1443
|
-
};
|
|
1444
|
-
function requiredProjections(options) {
|
|
1445
|
-
const available = registry(options.projections || []);
|
|
1446
|
-
const required = /* @__PURE__ */ new Set();
|
|
1447
|
-
for (const definition of [options.from ?? "WGS84", options.to ?? "WGS84"]) {
|
|
1448
|
-
const crs = normalizeCRS(definition, options);
|
|
1449
|
-
if (["geographic", "identity"].includes(crs.kind))
|
|
1450
|
-
continue;
|
|
1451
|
-
const projection = available.get(pluginKey(crs.projection));
|
|
1452
|
-
if (!projection)
|
|
1453
|
-
throw new TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
|
|
1454
|
-
required.add(projection);
|
|
1455
|
-
}
|
|
1456
|
-
return [...required];
|
|
1457
|
-
}
|
|
1458
|
-
var pluginKey = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
|
|
1459
|
-
function registry(projections) {
|
|
1460
|
-
const plugins = /* @__PURE__ */ new Map();
|
|
1461
|
-
for (const plugin of projections) {
|
|
1462
|
-
for (const name of new Set([plugin.name, ...plugin.aliases || []].map(pluginKey))) {
|
|
1463
|
-
if (!name || ["longlat", "latlong", "latlon", "lonlat", "identity"].includes(name) || plugins.has(name))
|
|
1464
|
-
throw new Error("Duplicate or reserved projection plugin: " + name);
|
|
1465
|
-
plugins.set(name, plugin);
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
return plugins;
|
|
1469
|
-
}
|
|
1470
|
-
function compileCRS(definition, plugins, options) {
|
|
1471
|
-
var _a2;
|
|
1472
|
-
const crs = normalizeCRS(definition, options);
|
|
1473
|
-
const plugin = plugins.get(pluginKey(crs.projection));
|
|
1474
|
-
if (!["geographic", "identity"].includes(crs.kind) && !plugin)
|
|
1475
|
-
throw new TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
|
|
1476
|
-
const allowed = /* @__PURE__ */ new Set([...CORE_PARAMETERS, ...(plugin == null ? void 0 : plugin.parameters) || []]);
|
|
1477
|
-
for (const key of Object.keys(crs.parameters)) {
|
|
1478
|
-
if (!allowed.has(key))
|
|
1479
|
-
throw new TypeScriptCRSError("missing-transform-stage", "Unsupported PROJ parameter: +" + key);
|
|
1480
|
-
const flag = CORE_FLAGS.includes(key) || ((_a2 = plugin == null ? void 0 : plugin.flags) == null ? void 0 : _a2.includes(key));
|
|
1481
|
-
if (flag && crs.parameters[key] !== void 0)
|
|
1482
|
-
throw new Error("Expected a flag without a value: +" + key);
|
|
1483
|
-
if (!flag && !crs.parameters[key])
|
|
1484
|
-
throw new Error("PROJ parameter requires a value: +" + key);
|
|
1485
|
-
}
|
|
1486
|
-
if (crs.parameters["type"] && crs.parameters["type"] !== "crs")
|
|
1487
|
-
throw new Error("Only +type=crs is supported");
|
|
1488
|
-
const parameters = pluginKey(crs.projection) === "fasttransversemercator" ? Object.freeze({ ...crs.parameters, approx: void 0 }) : crs.parameters;
|
|
1489
|
-
const implementation = plugin == null ? void 0 : plugin.create({
|
|
1490
|
-
...crs.ellipsoid,
|
|
1491
|
-
parameters,
|
|
1492
|
-
primeMeridian: crs.primeMeridian
|
|
1493
|
-
});
|
|
1494
|
-
if (crs.kind === "geocentric" && (!(implementation == null ? void 0 : implementation.forward3D) || !(implementation == null ? void 0 : implementation.inverse3D)))
|
|
1495
|
-
throw new Error("Geocentric plugin must implement 3D operations");
|
|
1496
|
-
const references = crs.datum.grids;
|
|
1497
|
-
const nullIndex = (references == null ? void 0 : references.findIndex((reference) => reference.name === "null")) ?? -1;
|
|
1498
|
-
const grids = references == null ? void 0 : references.slice(0, nullIndex < 0 ? void 0 : nullIndex + 1).map((reference) => {
|
|
1499
|
-
const grid = Object.prototype.hasOwnProperty.call(options.datumGrids || {}, reference.name) ? options.datumGrids[reference.name] : void 0;
|
|
1500
|
-
if (grid && typeof grid.shift !== "function")
|
|
1501
|
-
throw new Error("Invalid prepared datum grid: " + reference.name);
|
|
1502
|
-
return Object.freeze({ ...reference, grid });
|
|
1503
|
-
});
|
|
1504
|
-
for (const reference of grids || []) {
|
|
1505
|
-
if (reference.name === "null")
|
|
1506
|
-
break;
|
|
1507
|
-
if (!reference.optional && !reference.grid)
|
|
1508
|
-
unsupportedStage("Required datum grid is not registered: " + reference.name);
|
|
1509
|
-
}
|
|
1510
|
-
const datum = grids ? Object.freeze({ ...crs.datum, grids: Object.freeze(grids) }) : crs.datum;
|
|
1511
|
-
const verticalGrid = compileVerticalGrid(crs.parameters["geoidgrids"], options.verticalGrids);
|
|
1512
|
-
if (verticalGrid && (crs.kind === "geocentric" || crs.kind === "identity" || crs.lossy))
|
|
1513
|
-
unsupportedStage("Vertical grids require a non-lossy geographic or projected CRS");
|
|
1514
|
-
const algorithm = plugin ? plugin.semantics : { id: "@math.gl/geospatial/" + crs.kind, version: 1 };
|
|
1515
|
-
return { ...crs, datum, implementation, verticalGrid, algorithm };
|
|
1516
|
-
}
|
|
1517
|
-
function finite(point) {
|
|
1518
|
-
return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z);
|
|
1519
|
-
}
|
|
1520
|
-
function compileAxis(axis, inverse) {
|
|
1521
|
-
if (axis === "enu")
|
|
1522
|
-
return void 0;
|
|
1523
|
-
const indexes = [0, 0, 0], signs = [0, 0, 0];
|
|
1524
|
-
for (let i = 0; i < 3; i++) {
|
|
1525
|
-
const char = axis[i], component = "ew".includes(char) ? 0 : "ns".includes(char) ? 1 : 2;
|
|
1526
|
-
indexes[inverse ? i : component] = inverse ? component : i;
|
|
1527
|
-
signs[inverse ? i : component] = "wsd".includes(char) ? -1 : 1;
|
|
1528
|
-
}
|
|
1529
|
-
return (point) => {
|
|
1530
|
-
const x = point.x, y = point.y, z = point.z;
|
|
1531
|
-
point.x = signs[0] * (indexes[0] === 0 ? x : indexes[0] === 1 ? y : z);
|
|
1532
|
-
point.y = signs[1] * (indexes[1] === 0 ? x : indexes[1] === 1 ? y : z);
|
|
1533
|
-
point.z = signs[2] * (indexes[2] === 0 ? x : indexes[2] === 1 ? y : z);
|
|
1534
|
-
};
|
|
1535
|
-
}
|
|
1536
|
-
function compileTransform(from, to, enforceAxis) {
|
|
1537
|
-
var _a2, _b, _c, _d;
|
|
1538
|
-
const fromAxis = from.storedAxis || (enforceAxis ? from.axis : "enu");
|
|
1539
|
-
const toAxis = to.storedAxis || (enforceAxis ? to.axis : "enu");
|
|
1540
|
-
const inputAxis = compileAxis(fromAxis, false), outputAxis = compileAxis(toAxis, true);
|
|
1541
|
-
const source = from.implementation && projectionOperation(from.implementation, true, from.kind === "geocentric");
|
|
1542
|
-
const target = to.implementation && projectionOperation(to.implementation, false, to.kind === "geocentric");
|
|
1543
|
-
const datum = createDatumTransform(from.datum, to.datum);
|
|
1544
|
-
const horizontalOnly = from.lossy || to.lossy;
|
|
1545
|
-
const fromGeocentric = from.kind === "geocentric";
|
|
1546
|
-
const inputScale = from.kind === "geographic" ? from.angularUnit : from.toMeter;
|
|
1547
|
-
const outputScale = to.kind === "geographic" ? to.angularUnit : to.toMeter;
|
|
1548
|
-
const inputVerticalScale = fromGeocentric ? 1 : from.verticalUnit, outputVerticalScale = to.kind === "geocentric" ? outputScale : to.verticalUnit;
|
|
1549
|
-
const fromPrime = from.primeMeridian, toPrime = to.primeMeridian;
|
|
1550
|
-
const longitudeWrap = to.kind === "geographic" ? to.longitudeWrap : void 0;
|
|
1551
|
-
let flat;
|
|
1552
|
-
if (!datum && !from.verticalGrid && !to.verticalGrid && !horizontalOnly && !inputAxis && !outputAxis && !fromPrime && !toPrime && from.verticalUnit === 1 && to.verticalUnit === 1 && longitudeWrap === void 0) {
|
|
1553
|
-
const context = Object.freeze({ inputScale, outputScale });
|
|
1554
|
-
if (from.kind === "geographic" && to.kind === "projected")
|
|
1555
|
-
flat = (_b = (_a2 = to.implementation) == null ? void 0 : _a2.createForwardFlat) == null ? void 0 : _b.call(_a2, context);
|
|
1556
|
-
if (from.kind === "projected" && to.kind === "geographic")
|
|
1557
|
-
flat = (_d = (_c = from.implementation) == null ? void 0 : _c.createInverseFlat) == null ? void 0 : _d.call(_c, context);
|
|
1558
|
-
}
|
|
1559
|
-
const requiresInputZ = Boolean(from.verticalGrid || to.verticalGrid) || from.kind === "geocentric" || /[ud]/.test(fromAxis.slice(0, 2)) || /[ud]/.test(toAxis.slice(0, 2));
|
|
1560
|
-
const stages = [];
|
|
1561
|
-
if (inputAxis)
|
|
1562
|
-
stages.push("input-axis");
|
|
1563
|
-
if (horizontalOnly)
|
|
1564
|
-
stages.push("discard-height");
|
|
1565
|
-
if (inputScale !== 1)
|
|
1566
|
-
stages.push("input-scale");
|
|
1567
|
-
if (source)
|
|
1568
|
-
stages.push("source-inverse");
|
|
1569
|
-
if (inputVerticalScale !== 1)
|
|
1570
|
-
stages.push("input-height-scale");
|
|
1571
|
-
stages.push("geographic-domain-check");
|
|
1572
|
-
if (fromPrime)
|
|
1573
|
-
stages.push("source-prime-meridian");
|
|
1574
|
-
if (from.verticalGrid)
|
|
1575
|
-
stages.push("source-vertical-grid");
|
|
1576
|
-
if (datum)
|
|
1577
|
-
stages.push("datum");
|
|
1578
|
-
if (to.verticalGrid)
|
|
1579
|
-
stages.push("target-vertical-grid");
|
|
1580
|
-
if (toPrime)
|
|
1581
|
-
stages.push("target-prime-meridian");
|
|
1582
|
-
if (longitudeWrap !== void 0)
|
|
1583
|
-
stages.push("longitude-wrap");
|
|
1584
|
-
if (target)
|
|
1585
|
-
stages.push("target-forward");
|
|
1586
|
-
if (outputScale !== 1)
|
|
1587
|
-
stages.push("output-scale");
|
|
1588
|
-
if (outputVerticalScale !== 1)
|
|
1589
|
-
stages.push("output-height-scale");
|
|
1590
|
-
if (horizontalOnly)
|
|
1591
|
-
stages.push("restore-height");
|
|
1592
|
-
if (outputAxis)
|
|
1593
|
-
stages.push("output-axis");
|
|
1594
|
-
return {
|
|
1595
|
-
description: Object.freeze({
|
|
1596
|
-
inputAxis: fromAxis,
|
|
1597
|
-
outputAxis: toAxis,
|
|
1598
|
-
requiresInputZ,
|
|
1599
|
-
geocentricOutput: to.kind === "geocentric",
|
|
1600
|
-
stages: Object.freeze(stages)
|
|
1601
|
-
}),
|
|
1602
|
-
flat,
|
|
1603
|
-
requiresInputZ,
|
|
1604
|
-
geocentricOutput: to.kind === "geocentric",
|
|
1605
|
-
run(point) {
|
|
1606
|
-
if (!finite(point))
|
|
1607
|
-
throw new Error("Coordinates must contain finite x, y and optional z values");
|
|
1608
|
-
inputAxis == null ? void 0 : inputAxis(point);
|
|
1609
|
-
const preservedHeight = point.z;
|
|
1610
|
-
if (horizontalOnly)
|
|
1611
|
-
point.z = 0;
|
|
1612
|
-
if (inputScale !== 1) {
|
|
1613
|
-
point.x *= inputScale;
|
|
1614
|
-
point.y *= inputScale;
|
|
1615
|
-
if (fromGeocentric)
|
|
1616
|
-
point.z *= inputScale;
|
|
1617
|
-
}
|
|
1618
|
-
source == null ? void 0 : source(point);
|
|
1619
|
-
if (inputVerticalScale !== 1)
|
|
1620
|
-
point.z *= inputVerticalScale;
|
|
1621
|
-
if (Math.abs(point.y) > Math.PI / 2 || !finite(point))
|
|
1622
|
-
throw new Error("Coordinate is outside the geographic domain");
|
|
1623
|
-
point.x += fromPrime;
|
|
1624
|
-
if (from.verticalGrid)
|
|
1625
|
-
point.z += from.verticalGrid(point.x, point.y);
|
|
1626
|
-
datum == null ? void 0 : datum(point);
|
|
1627
|
-
if (to.verticalGrid)
|
|
1628
|
-
point.z -= to.verticalGrid(point.x, point.y);
|
|
1629
|
-
point.x -= toPrime;
|
|
1630
|
-
if (longitudeWrap !== void 0)
|
|
1631
|
-
point.x = longitudeWrap + wrapLongitude(point.x - longitudeWrap);
|
|
1632
|
-
target == null ? void 0 : target(point);
|
|
1633
|
-
if (outputScale !== 1) {
|
|
1634
|
-
point.x /= outputScale;
|
|
1635
|
-
point.y /= outputScale;
|
|
1636
|
-
}
|
|
1637
|
-
if (outputVerticalScale !== 1)
|
|
1638
|
-
point.z /= outputVerticalScale;
|
|
1639
|
-
if (horizontalOnly)
|
|
1640
|
-
point.z = preservedHeight;
|
|
1641
|
-
outputAxis == null ? void 0 : outputAxis(point);
|
|
1642
|
-
if (!finite(point))
|
|
1643
|
-
throw new Error("Projection produced non-finite coordinates");
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
function transformScalar(coordinate, operation, scratch, output) {
|
|
1648
|
-
if (coordinate.length < 2)
|
|
1649
|
-
throw new Error("Coordinates must contain finite x, y and optional z values");
|
|
1650
|
-
if (coordinate.length < 3 && operation.requiresInputZ)
|
|
1651
|
-
throw new Error("This transform requires three ordinates");
|
|
1652
|
-
const length = Math.max(coordinate.length, operation.geocentricOutput ? 3 : 2);
|
|
1653
|
-
const point = scratch.acquire();
|
|
1654
|
-
try {
|
|
1655
|
-
point.x = coordinate[0];
|
|
1656
|
-
point.y = coordinate[1];
|
|
1657
|
-
point.z = coordinate.length >= 3 ? coordinate[2] : 0;
|
|
1658
|
-
operation.run(point);
|
|
1659
|
-
if (output)
|
|
1660
|
-
return writeScalarOutput(coordinate, output, point, length);
|
|
1661
|
-
const result = coordinate.slice();
|
|
1662
|
-
result[0] = point.x;
|
|
1663
|
-
result[1] = point.y;
|
|
1664
|
-
if (coordinate.length >= 3 || operation.geocentricOutput)
|
|
1665
|
-
result[2] = point.z;
|
|
1666
|
-
return result;
|
|
1667
|
-
} finally {
|
|
1668
|
-
scratch.release(point);
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
function transformInPlace(coordinates, dimension, operation, scratch) {
|
|
1672
|
-
if (!(coordinates instanceof Float32Array || coordinates instanceof Float64Array))
|
|
1673
|
-
throw new Error("In-place projection requires a Float32Array or Float64Array");
|
|
1674
|
-
if (!Number.isSafeInteger(dimension) || dimension < 2 || coordinates.length % dimension !== 0)
|
|
1675
|
-
throw new Error("Dimension must be an integer >= 2 and divide the typed array length");
|
|
1676
|
-
if (dimension < 3 && (operation.requiresInputZ || operation.geocentricOutput))
|
|
1677
|
-
throw new Error("This transform requires a dimension of at least 3");
|
|
1678
|
-
if (operation.flat) {
|
|
1679
|
-
operation.flat(coordinates, dimension);
|
|
1680
|
-
return coordinates;
|
|
1681
|
-
}
|
|
1682
|
-
const point = scratch.acquire();
|
|
1683
|
-
try {
|
|
1684
|
-
const float32 = coordinates instanceof Float32Array;
|
|
1685
|
-
for (let offset = 0; offset < coordinates.length; offset += dimension) {
|
|
1686
|
-
point.x = coordinates[offset];
|
|
1687
|
-
point.y = coordinates[offset + 1];
|
|
1688
|
-
point.z = dimension >= 3 ? coordinates[offset + 2] : 0;
|
|
1689
|
-
operation.run(point);
|
|
1690
|
-
if (float32 && (Math.abs(point.x) > 34028234663852886e22 || Math.abs(point.y) > 34028234663852886e22 || dimension >= 3 && Math.abs(point.z) > 34028234663852886e22))
|
|
1691
|
-
throw new Error("Projected coordinate exceeds Float32 range");
|
|
1692
|
-
coordinates[offset] = point.x;
|
|
1693
|
-
coordinates[offset + 1] = point.y;
|
|
1694
|
-
if (dimension >= 3)
|
|
1695
|
-
coordinates[offset + 2] = point.z;
|
|
1696
|
-
}
|
|
1697
|
-
return coordinates;
|
|
1698
|
-
} finally {
|
|
1699
|
-
scratch.release(point);
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
784
|
+
// dist/projection/transform-analysis.js
|
|
785
|
+
var import_typescript_projection = require("./experimental/typescript-projection.shared.cjs");
|
|
1702
786
|
|
|
1703
787
|
// dist/projection/numerical-derivative.js
|
|
1704
788
|
var NumericalDerivative = class {
|
|
@@ -1909,13 +993,13 @@ async function createProjectionTransformAnalysis(options) {
|
|
|
1909
993
|
if (geographic.kind !== "geographic" || target.kind !== "projected" || !Number.isFinite(height)) {
|
|
1910
994
|
throw new Error("Transform analysis requires a geographic anchor, planar target and finite height");
|
|
1911
995
|
}
|
|
1912
|
-
const anchorTransform = await ProjectionTransform.create({
|
|
996
|
+
const anchorTransform = await import_typescript_projection.ProjectionTransform.create({
|
|
1913
997
|
...options,
|
|
1914
998
|
from: geographicFrom,
|
|
1915
999
|
to: from,
|
|
1916
1000
|
enforceAxis: true
|
|
1917
1001
|
});
|
|
1918
|
-
const transform = await ProjectionTransform.create({ ...options, enforceAxis: true });
|
|
1002
|
+
const transform = await import_typescript_projection.ProjectionTransform.create({ ...options, enforceAxis: true });
|
|
1919
1003
|
if (anchorTransform.lossy || transform.lossy) {
|
|
1920
1004
|
throw new Error("Transform analysis requires lossless CRS pipelines");
|
|
1921
1005
|
}
|