@math.gl/geospatial 5.0.0-rc.2 → 5.0.0
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/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/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/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 +2 -2
- package/dist/terrain/index.cjs.map +1 -1
- package/dist/tiles.cjs +354 -0
- package/dist/tiles.cjs.map +6 -0
- package/package.json +139 -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/maps/myriahedral/unfold.ts +1 -1
- 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/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/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
|
@@ -19,211 +19,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// dist/projection/experimental/core.js
|
|
20
20
|
var core_exports = {};
|
|
21
21
|
__export(core_exports, {
|
|
22
|
-
ConfigurableProjectionEngine: () => ConfigurableProjectionEngine,
|
|
23
|
-
ProjectionTransform: () => ProjectionTransform,
|
|
24
|
-
TypeScriptCRSError: () => TypeScriptCRSError,
|
|
25
|
-
checkProjectionCompatibility: () => checkProjectionCompatibility,
|
|
22
|
+
ConfigurableProjectionEngine: () => import_projection_engine.ConfigurableProjectionEngine,
|
|
23
|
+
ProjectionTransform: () => import_typescript_projection.ProjectionTransform,
|
|
24
|
+
TypeScriptCRSError: () => import_types3.TypeScriptCRSError,
|
|
25
|
+
checkProjectionCompatibility: () => import_typescript_projection.checkProjectionCompatibility,
|
|
26
26
|
createProjectionDescriptor: () => createProjectionDescriptor,
|
|
27
|
-
createProjectionEngine: () => createProjectionEngine,
|
|
27
|
+
createProjectionEngine: () => import_projection_engine.createProjectionEngine,
|
|
28
28
|
getLoadedProjection: () => getLoadedProjection,
|
|
29
29
|
normalizeCRS: () => normalizeCRS,
|
|
30
30
|
preloadProjection: () => preloadProjection
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(core_exports);
|
|
33
|
-
|
|
34
|
-
// dist/projection/experimental/rendering-profile/geographic-bounds.js
|
|
35
|
-
var RADIANS = Math.PI / 180;
|
|
36
|
-
function createAngularRanges(west, south, east, north) {
|
|
37
|
-
return [
|
|
38
|
-
[west, south],
|
|
39
|
-
[east, north]
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
function normalizeLongitude(longitude) {
|
|
43
|
-
return longitude >= -180 && longitude < 180 ? longitude : ((longitude + 180) % 360 + 360) % 360 - 180;
|
|
44
|
-
}
|
|
45
|
-
function getLongitudeSpan(bounds) {
|
|
46
|
-
const span = bounds[2] - bounds[0];
|
|
47
|
-
return span < 0 ? span + 360 : span;
|
|
48
|
-
}
|
|
49
|
-
function containsGeographicPoint(bounds, point) {
|
|
50
|
-
const [west, south, east, north] = bounds;
|
|
51
|
-
const longitude = normalizeLongitude(point[0]);
|
|
52
|
-
return point[1] >= south && point[1] <= north && (west <= east ? longitude >= west && longitude <= east || longitude === -180 && east === 180 : longitude >= west || longitude <= east);
|
|
53
|
-
}
|
|
54
|
-
function clampGeographicPoint(bounds, point) {
|
|
55
|
-
let longitude = normalizeLongitude(point[0]);
|
|
56
|
-
const latitude = Math.max(bounds[1], Math.min(bounds[3], point[1]));
|
|
57
|
-
if (!containsGeographicPoint(bounds, [longitude, latitude])) {
|
|
58
|
-
const westDistance = Math.abs(normalizeLongitude(longitude - bounds[0]));
|
|
59
|
-
const eastDistance = Math.abs(normalizeLongitude(longitude - bounds[2]));
|
|
60
|
-
longitude = westDistance <= eastDistance ? bounds[0] : bounds[2];
|
|
61
|
-
}
|
|
62
|
-
return [longitude, latitude];
|
|
63
|
-
}
|
|
64
|
-
function getAngularRanges(bounds, primeMeridian2 = 0, origin = 0) {
|
|
65
|
-
const width = getLongitudeSpan(bounds);
|
|
66
|
-
const west = bounds[0] * RADIANS - primeMeridian2;
|
|
67
|
-
const middle = west + width * RADIANS / 2;
|
|
68
|
-
const shift = Math.round((origin - middle) / (2 * Math.PI)) * 2 * Math.PI;
|
|
69
|
-
return createAngularRanges(width === 360 ? origin - Math.PI : west + shift, bounds[1] * RADIANS, width === 360 ? origin + Math.PI : west + shift + width * RADIANS, bounds[3] * RADIANS);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// dist/projection/experimental/rendering-profile/rendering-profile.js
|
|
73
|
-
function resolveRenderingProfile(getRenderingProfile, coverage) {
|
|
74
|
-
if (coverage) {
|
|
75
|
-
try {
|
|
76
|
-
const profile2 = getRenderingProfile(coverage);
|
|
77
|
-
return resolveBounds(profile2);
|
|
78
|
-
} catch {
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const profile = getRenderingProfile();
|
|
82
|
-
return resolveBounds(profile);
|
|
83
|
-
}
|
|
84
|
-
function resolveBounds(profile) {
|
|
85
|
-
var _a2;
|
|
86
|
-
const bounds = profile.bounds;
|
|
87
|
-
if (bounds.some((corner) => corner.some((value) => !Number.isFinite(value))))
|
|
88
|
-
throw new Error("Projection rendering bounds must be finite");
|
|
89
|
-
return { bounds, normalize: (_a2 = profile.normalize) == null ? void 0 : _a2.bind(profile) };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// dist/projection/experimental/rendering-profile/identity-rendering-profile.js
|
|
93
|
-
function getIdentityRenderingProfile() {
|
|
94
|
-
return {
|
|
95
|
-
bounds: [
|
|
96
|
-
[-1, -1, 0],
|
|
97
|
-
[1, 1, 0]
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// dist/projection/experimental/projection-descriptor.js
|
|
103
|
-
var CACHE_KEY = /* @__PURE__ */ Symbol.for("@math.gl/projection/projection-implementations");
|
|
104
|
-
function cache() {
|
|
105
|
-
const scope = globalThis;
|
|
106
|
-
scope[CACHE_KEY] || (scope[CACHE_KEY] = /* @__PURE__ */ new WeakMap());
|
|
107
|
-
return scope[CACHE_KEY];
|
|
108
|
-
}
|
|
109
|
-
function getLoadedProjection(projection) {
|
|
110
|
-
var _a2;
|
|
111
|
-
return "create" in projection ? projection : (_a2 = cache().get(projection)) == null ? void 0 : _a2.implementation;
|
|
112
|
-
}
|
|
113
|
-
function preloadProjection(projection) {
|
|
114
|
-
if ("create" in projection)
|
|
115
|
-
return Promise.resolve(projection);
|
|
116
|
-
let state = cache().get(projection);
|
|
117
|
-
if (!state) {
|
|
118
|
-
state = { load: () => projection.preload() };
|
|
119
|
-
cache().set(projection, state);
|
|
120
|
-
}
|
|
121
|
-
if (state.implementation)
|
|
122
|
-
return Promise.resolve(state.implementation);
|
|
123
|
-
const entry = state;
|
|
124
|
-
entry.pending || (entry.pending = Promise.resolve().then(entry.load).then((plugin) => {
|
|
125
|
-
const key = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
|
|
126
|
-
const supported = new Set([plugin.name, ...plugin.aliases || []].map(key));
|
|
127
|
-
if (typeof plugin.create !== "function" || ![projection.name, ...projection.aliases || []].every((name) => supported.has(key(name))))
|
|
128
|
-
throw new Error("Loaded projection does not match descriptor: " + projection.name);
|
|
129
|
-
entry.implementation = plugin;
|
|
130
|
-
return plugin;
|
|
131
|
-
}).catch((error) => {
|
|
132
|
-
entry.pending = void 0;
|
|
133
|
-
throw error;
|
|
134
|
-
}));
|
|
135
|
-
return entry.pending;
|
|
136
|
-
}
|
|
137
|
-
function createProjectionDescriptor(metadata, load) {
|
|
138
|
-
const descriptor = Object.freeze({
|
|
139
|
-
name: metadata.name,
|
|
140
|
-
aliases: metadata.aliases && Object.freeze([...metadata.aliases]),
|
|
141
|
-
preload: () => preloadProjection(descriptor)
|
|
142
|
-
});
|
|
143
|
-
cache().set(descriptor, { load });
|
|
144
|
-
return descriptor;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// dist/projection/experimental/projection-scratch.js
|
|
148
|
-
function createPoint() {
|
|
149
|
-
return { x: 0, y: 0, z: 0 };
|
|
150
|
-
}
|
|
151
|
-
var ProjectionScratch = class {
|
|
152
|
-
constructor() {
|
|
153
|
-
this.point = createPoint();
|
|
154
|
-
this.points = [this.point];
|
|
155
|
-
this.active = 0;
|
|
156
|
-
}
|
|
157
|
-
get depth() {
|
|
158
|
-
return this.active;
|
|
159
|
-
}
|
|
160
|
-
acquire() {
|
|
161
|
-
var _a2;
|
|
162
|
-
const index = this.active++;
|
|
163
|
-
(_a2 = this.points)[index] || (_a2[index] = createPoint());
|
|
164
|
-
return this.points[index];
|
|
165
|
-
}
|
|
166
|
-
release(point) {
|
|
167
|
-
if (this.active > 0 && this.points[this.active - 1] === point)
|
|
168
|
-
this.active--;
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// dist/projection/experimental/mutable-projection.js
|
|
173
|
-
function projectionOperation(implementation, inverse, geocentric = false) {
|
|
174
|
-
const mutable = inverse ? implementation.inverseInPlace : implementation.forwardInPlace;
|
|
175
|
-
if (mutable)
|
|
176
|
-
return mutable.bind(implementation);
|
|
177
|
-
if (geocentric) {
|
|
178
|
-
const operation2 = inverse ? implementation.inverse3D : implementation.forward3D;
|
|
179
|
-
return (point) => {
|
|
180
|
-
const output = operation2.call(implementation, [point.x, point.y, point.z]);
|
|
181
|
-
point.x = output[0];
|
|
182
|
-
point.y = output[1];
|
|
183
|
-
point.z = output[2];
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
const operation = inverse ? implementation.inverse : implementation.forward;
|
|
187
|
-
return (point) => {
|
|
188
|
-
const output = operation.call(implementation, point.x, point.y);
|
|
189
|
-
point.x = output[0];
|
|
190
|
-
point.y = output[1];
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// dist/projection/experimental/scalar-output.js
|
|
195
|
-
var FLOAT32_MAX = 34028234663852886e22;
|
|
196
|
-
function validateScalarOutput(coordinate, output, length) {
|
|
197
|
-
if (!(Array.isArray(coordinate) || coordinate instanceof Float32Array || coordinate instanceof Float64Array))
|
|
198
|
-
throw new Error("Scalar input requires a number array, Float32Array or Float64Array");
|
|
199
|
-
if (!(Array.isArray(output) || output instanceof Float32Array || output instanceof Float64Array) || output.length < length)
|
|
200
|
-
throw new Error("Scalar output requires a preallocated number array, Float32Array or Float64Array with sufficient capacity");
|
|
201
|
-
if (coordinate === output || Array.isArray(coordinate) || Array.isArray(output))
|
|
202
|
-
return;
|
|
203
|
-
const input = coordinate;
|
|
204
|
-
const result = output;
|
|
205
|
-
const shared = typeof SharedArrayBuffer !== "undefined" && input.buffer instanceof SharedArrayBuffer && result.buffer instanceof SharedArrayBuffer;
|
|
206
|
-
if ((input.buffer === result.buffer || shared) && input.byteOffset < result.byteOffset + length * result.BYTES_PER_ELEMENT && result.byteOffset < input.byteOffset + input.byteLength)
|
|
207
|
-
throw new Error("Scalar input/output views overlap; use the same view for in-place projection");
|
|
208
|
-
}
|
|
209
|
-
function writeScalarOutput(coordinate, output, point, length) {
|
|
210
|
-
if (output instanceof Float32Array) {
|
|
211
|
-
if (Math.abs(point.x) > FLOAT32_MAX || Math.abs(point.y) > FLOAT32_MAX || length >= 3 && Math.abs(point.z) > FLOAT32_MAX)
|
|
212
|
-
throw new Error("Projected coordinate exceeds Float32 range");
|
|
213
|
-
for (let i = 3; i < coordinate.length; i++) {
|
|
214
|
-
const value = coordinate[i];
|
|
215
|
-
if (Number.isFinite(value) && Math.abs(value) > FLOAT32_MAX)
|
|
216
|
-
throw new Error("Trailing ordinate exceeds Float32 range");
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
for (let i = 3; i < coordinate.length; i++)
|
|
220
|
-
output[i] = coordinate[i];
|
|
221
|
-
output[0] = point.x;
|
|
222
|
-
output[1] = point.y;
|
|
223
|
-
if (length >= 3)
|
|
224
|
-
output[2] = point.z;
|
|
225
|
-
return output;
|
|
226
|
-
}
|
|
33
|
+
var import_typescript_projection = require("./typescript-projection.shared.cjs");
|
|
227
34
|
|
|
228
35
|
// dist/crs/spatial-reference.js
|
|
229
36
|
function inferCRSRepresentation(definition) {
|
|
@@ -369,27 +176,8 @@ function getSourceLocation(source, offset) {
|
|
|
369
176
|
return { line, column };
|
|
370
177
|
}
|
|
371
178
|
|
|
372
|
-
// dist/projection/experimental/crs/types.js
|
|
373
|
-
var _a;
|
|
374
|
-
var CRS_ERROR = /* @__PURE__ */ Symbol.for("@math.gl/projection/TypeScriptCRSError");
|
|
375
|
-
var TypeScriptCRSError = class _TypeScriptCRSError extends Error {
|
|
376
|
-
static [(_a = CRS_ERROR, Symbol.hasInstance)](value) {
|
|
377
|
-
if (this !== _TypeScriptCRSError)
|
|
378
|
-
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
379
|
-
return value instanceof Error && value[CRS_ERROR] === true;
|
|
380
|
-
}
|
|
381
|
-
constructor(reason, message) {
|
|
382
|
-
super(message);
|
|
383
|
-
this.reason = reason;
|
|
384
|
-
this[_a] = true;
|
|
385
|
-
this.name = "TypeScriptCRSError";
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
function unsupportedStage(message) {
|
|
389
|
-
throw new TypeScriptCRSError("missing-transform-stage", message);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
179
|
// dist/projection/experimental/crs/spatial-reference.js
|
|
180
|
+
var import_types = require("./crs/types.shared.cjs");
|
|
393
181
|
function resolveCRSInput(input, options) {
|
|
394
182
|
if (typeof input === "string" || "type" in input)
|
|
395
183
|
return { definition: input, lossy: false };
|
|
@@ -397,19 +185,19 @@ function resolveCRSInput(input, options) {
|
|
|
397
185
|
const spatialReference = "crs" in metadata ? metadata : void 0;
|
|
398
186
|
const reference = "crs" in metadata ? metadata.crs : metadata;
|
|
399
187
|
if (reference.state !== "explicit" && reference.state !== "default")
|
|
400
|
-
throw new TypeScriptCRSError("unknown-syntax", "Cannot transform an " + reference.state + " CRS reference");
|
|
188
|
+
throw new import_types.TypeScriptCRSError("unknown-syntax", "Cannot transform an " + reference.state + " CRS reference");
|
|
401
189
|
let lossy = false;
|
|
402
190
|
if ((spatialReference == null ? void 0 : spatialReference.coordinateEpoch) !== void 0)
|
|
403
|
-
unsupportedStage("Coordinate epochs require a time-dependent transformation");
|
|
191
|
+
(0, import_types.unsupportedStage)("Coordinate epochs require a time-dependent transformation");
|
|
404
192
|
if ((spatialReference == null ? void 0 : spatialReference.vertical) && spatialReference.vertical.state !== "absent") {
|
|
405
193
|
if (options.mode !== "horizontal")
|
|
406
|
-
unsupportedStage("A separately declared vertical CRS requires explicit horizontal extraction");
|
|
194
|
+
(0, import_types.unsupportedStage)("A separately declared vertical CRS requires explicit horizontal extraction");
|
|
407
195
|
lossy = true;
|
|
408
196
|
}
|
|
409
197
|
return { definition: reference.definition, spatialReference, lossy };
|
|
410
198
|
}
|
|
411
199
|
function applySpatialReference(crs, reference) {
|
|
412
|
-
var
|
|
200
|
+
var _a;
|
|
413
201
|
if (!reference)
|
|
414
202
|
return crs;
|
|
415
203
|
if (reference.coordinateFrame !== "unknown" && reference.coordinateFrame !== crs.kind)
|
|
@@ -434,11 +222,11 @@ function applySpatialReference(crs, reference) {
|
|
|
434
222
|
if (storedAxis.length === 2)
|
|
435
223
|
storedAxis += "u";
|
|
436
224
|
if (storedAxis.length !== 3 || !storedAxis.includes("e") || !storedAxis.includes("n") || !storedAxis.includes("u"))
|
|
437
|
-
unsupportedStage("Unsupported SpatialReference coordinate order");
|
|
225
|
+
(0, import_types.unsupportedStage)("Unsupported SpatialReference coordinate order");
|
|
438
226
|
if (order.length > 4 || order.length > 3 && !["m", "measure"].includes(order[3]))
|
|
439
|
-
unsupportedStage("Unsupported fourth coordinate component");
|
|
227
|
+
(0, import_types.unsupportedStage)("Unsupported fourth coordinate component");
|
|
440
228
|
}
|
|
441
|
-
if ((
|
|
229
|
+
if ((_a = reference.units) == null ? void 0 : _a.length) {
|
|
442
230
|
const units = {
|
|
443
231
|
m: 1,
|
|
444
232
|
meter: 1,
|
|
@@ -458,7 +246,7 @@ function applySpatialReference(crs, reference) {
|
|
|
458
246
|
const vertical = (storedAxis || "enu")[i] === "u";
|
|
459
247
|
const expected = crs.kind === "geocentric" ? crs.toMeter : vertical ? crs.verticalUnit : crs.kind === "geographic" ? crs.angularUnit : crs.toMeter;
|
|
460
248
|
if (Math.abs((units[reference.units[i]] ?? NaN) - expected) > 1e-12 || units[reference.units[i]] === void 0)
|
|
461
|
-
unsupportedStage("SpatialReference units disagree with its CRS");
|
|
249
|
+
(0, import_types.unsupportedStage)("SpatialReference units disagree with its CRS");
|
|
462
250
|
}
|
|
463
251
|
}
|
|
464
252
|
return Object.freeze({ ...crs, storedAxis });
|
|
@@ -478,12 +266,6 @@ function numberParameter(parameters, name, fallback) {
|
|
|
478
266
|
throw new Error(`Invalid numeric PROJ parameter: +${name}`);
|
|
479
267
|
return number;
|
|
480
268
|
}
|
|
481
|
-
function wrapLongitude(longitude, over = false) {
|
|
482
|
-
if (over || Math.abs(longitude) <= Math.PI)
|
|
483
|
-
return longitude;
|
|
484
|
-
const circle = 2 * Math.PI;
|
|
485
|
-
return ((longitude + Math.PI) % circle + circle) % circle - Math.PI;
|
|
486
|
-
}
|
|
487
269
|
|
|
488
270
|
// dist/projection/experimental/crs/datum-catalog.js
|
|
489
271
|
var wgs84 = { towgs84: "0,0,0", ellipse: "WGS84" };
|
|
@@ -497,8 +279,8 @@ var builtins = {
|
|
|
497
279
|
var resolved = /* @__PURE__ */ new WeakMap();
|
|
498
280
|
var datumNameKey = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
|
|
499
281
|
function getDatumDefinitions(options) {
|
|
500
|
-
var
|
|
501
|
-
if (!((
|
|
282
|
+
var _a;
|
|
283
|
+
if (!((_a = options.datumCatalogs) == null ? void 0 : _a.length))
|
|
502
284
|
return builtins;
|
|
503
285
|
const cached = resolved.get(options);
|
|
504
286
|
if ((cached == null ? void 0 : cached.catalogs) === options.datumCatalogs)
|
|
@@ -794,23 +576,8 @@ var linearUnits = {
|
|
|
794
576
|
"us-yd": { name: "us-survey-yards", metersPerUnit: 0.914401828803658 }
|
|
795
577
|
};
|
|
796
578
|
|
|
797
|
-
// dist/crs/crs-metadata.js
|
|
798
|
-
function getCRSSignature(crs) {
|
|
799
|
-
return JSON.stringify([
|
|
800
|
-
crs.coordinateFrame,
|
|
801
|
-
crs.projection,
|
|
802
|
-
Object.keys(crs.parameters).sort().map((key) => [key, crs.parameters[key]]),
|
|
803
|
-
[crs.ellipsoid.semiMajorAxis, crs.ellipsoid.semiMinorAxis],
|
|
804
|
-
crs.axis,
|
|
805
|
-
[crs.xUnit.name, crs.xUnit.metersPerUnit, crs.xUnit.degreesPerUnit],
|
|
806
|
-
[crs.yUnit.name, crs.yUnit.metersPerUnit, crs.yUnit.degreesPerUnit],
|
|
807
|
-
[crs.zUnit.name, crs.zUnit.metersPerUnit, crs.zUnit.degreesPerUnit],
|
|
808
|
-
crs.lossy,
|
|
809
|
-
crs.areaOfUse
|
|
810
|
-
]);
|
|
811
|
-
}
|
|
812
|
-
|
|
813
579
|
// dist/projection/experimental/crs/normalize.js
|
|
580
|
+
var import_types2 = require("./crs/types.shared.cjs");
|
|
814
581
|
var ALIASES = {
|
|
815
582
|
WGS84: "+proj=longlat +datum=WGS84",
|
|
816
583
|
"EPSG:4326": "+proj=longlat +datum=WGS84",
|
|
@@ -823,31 +590,6 @@ var ALIASES = {
|
|
|
823
590
|
"EPSG:900913": "EPSG:3857",
|
|
824
591
|
"EPSG:102113": "EPSG:3857"
|
|
825
592
|
};
|
|
826
|
-
var CORE_PARAMETERS = [
|
|
827
|
-
"proj",
|
|
828
|
-
"datum",
|
|
829
|
-
"ellps",
|
|
830
|
-
"a",
|
|
831
|
-
"b",
|
|
832
|
-
"rf",
|
|
833
|
-
"f",
|
|
834
|
-
"R",
|
|
835
|
-
"units",
|
|
836
|
-
"to_meter",
|
|
837
|
-
"vunits",
|
|
838
|
-
"vto_meter",
|
|
839
|
-
"no_defs",
|
|
840
|
-
"type",
|
|
841
|
-
"title",
|
|
842
|
-
"towgs84",
|
|
843
|
-
"nadgrids",
|
|
844
|
-
"geoidgrids",
|
|
845
|
-
"axis",
|
|
846
|
-
"pm",
|
|
847
|
-
"over",
|
|
848
|
-
"lon_wrap"
|
|
849
|
-
];
|
|
850
|
-
var CORE_FLAGS = ["no_defs", "over"];
|
|
851
593
|
var own = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
852
594
|
var keyOf = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
|
|
853
595
|
function lookup(table, name) {
|
|
@@ -900,7 +642,7 @@ function resolveLocalCRSDefinition(input, options = {}) {
|
|
|
900
642
|
return definition;
|
|
901
643
|
}
|
|
902
644
|
function normalizeCRS(input, options = {}) {
|
|
903
|
-
var
|
|
645
|
+
var _a;
|
|
904
646
|
const datums = getDatumDefinitions(options);
|
|
905
647
|
const resolved2 = resolveCRSInput(input, options);
|
|
906
648
|
const definition = resolveLocalCRSDefinition(resolved2.definition, options);
|
|
@@ -914,10 +656,10 @@ function normalizeCRS(input, options = {}) {
|
|
|
914
656
|
}
|
|
915
657
|
parsed = { parameters: parameters2 };
|
|
916
658
|
} else {
|
|
917
|
-
const parser = (
|
|
659
|
+
const parser = (_a = options.parsers) == null ? void 0 : _a.find((candidate) => candidate.canParse(definition));
|
|
918
660
|
if (!parser) {
|
|
919
661
|
const serialized = ["wkt", "projjson"].includes(inferCRSRepresentation(definition));
|
|
920
|
-
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");
|
|
662
|
+
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");
|
|
921
663
|
}
|
|
922
664
|
parsed = parser.parse(definition, options);
|
|
923
665
|
}
|
|
@@ -958,7 +700,7 @@ function normalizeCRS(input, options = {}) {
|
|
|
958
700
|
const datumName = parameters["datum"];
|
|
959
701
|
const datum = datumName && datumName !== "none" ? lookup(datums, datumName) : void 0;
|
|
960
702
|
if (datumName && datumName !== "none" && !datum)
|
|
961
|
-
unsupportedStage("Unknown datum: " + datumName + "; register a datumCatalogs plugin");
|
|
703
|
+
(0, import_types2.unsupportedStage)("Unknown datum: " + datumName + "; register a datumCatalogs plugin");
|
|
962
704
|
const ellipsoid = getEllipsoid(parameters, datum == null ? void 0 : datum.ellipse);
|
|
963
705
|
const grids = parameters["nadgrids"] ?? (datum == null ? void 0 : datum.nadgrids);
|
|
964
706
|
const gridReferences = grids === void 0 ? void 0 : grids.split(",").map((entry) => {
|
|
@@ -1048,1050 +790,54 @@ function getEllipsoid(parameters, datumEllipsoid) {
|
|
|
1048
790
|
});
|
|
1049
791
|
}
|
|
1050
792
|
|
|
1051
|
-
// dist/projection/experimental/
|
|
1052
|
-
var
|
|
1053
|
-
var ARC_SECOND = Math.PI / (180 * 3600);
|
|
1054
|
-
var WGS84 = {
|
|
1055
|
-
ellipsoid: {
|
|
1056
|
-
semiMajorAxis: 6378137,
|
|
1057
|
-
semiMinorAxis: 6356752314245179e-9,
|
|
1058
|
-
eccentricitySquared: 0.0066943799901413165
|
|
1059
|
-
},
|
|
1060
|
-
towgs84: [0, 0, 0]
|
|
1061
|
-
};
|
|
1062
|
-
function geodeticToGeocentricInPlace(point, ellipsoid) {
|
|
1063
|
-
if (Math.abs(point.y) > Math.PI / 2)
|
|
1064
|
-
throw new Error("Latitude outside geocentric domain");
|
|
1065
|
-
if (!(0, import_matrix.spheroidToCartesian)(point, ellipsoid))
|
|
1066
|
-
throw new Error("Geocentric coordinate must be finite");
|
|
1067
|
-
}
|
|
1068
|
-
function geocentricToGeodeticInPlace(point, ellipsoid) {
|
|
1069
|
-
const x = point.x, y = point.y, z = point.z;
|
|
1070
|
-
const { semiMajorAxis: a, semiMinorAxis: b, eccentricitySquared: es } = ellipsoid;
|
|
1071
|
-
if (x === 0 && y === 0 && z === 0)
|
|
1072
|
-
throw new Error("Geodetic coordinates are undefined at the Earth center");
|
|
1073
|
-
if (es !== 0 && Math.abs(x) < 1e-12 * a && Math.abs(y) < 1e-12 * a && Math.hypot(x, y) < 1e-12 * a) {
|
|
1074
|
-
if (!Number.isFinite(Math.hypot(x, y, z)))
|
|
1075
|
-
throw new Error("Geocentric radius must be finite");
|
|
1076
|
-
point.x = 0;
|
|
1077
|
-
point.y = Math.sign(z) * Math.PI / 2;
|
|
1078
|
-
point.z = Math.abs(z) - b;
|
|
1079
|
-
return;
|
|
1080
|
-
}
|
|
1081
|
-
if (!(0, import_matrix.cartesianToSpheroid)(point, ellipsoid)) {
|
|
1082
|
-
if (!Number.isFinite(Math.hypot(x, y, z)))
|
|
1083
|
-
throw new Error("Geocentric radius must be finite");
|
|
1084
|
-
throw new Error("Geocentric inverse did not converge");
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
function createHelmert(values, inverse) {
|
|
1088
|
-
const dx = values[0], dy = values[1], dz = values[2];
|
|
1089
|
-
const rx = (values[3] || 0) * ARC_SECOND, ry = (values[4] || 0) * ARC_SECOND, rz = (values[5] || 0) * ARC_SECOND;
|
|
1090
|
-
const scale = 1 + (values[6] || 0) / 1e6;
|
|
1091
|
-
return inverse ? (point) => {
|
|
1092
|
-
const x = (point.x - dx) / scale, y = (point.y - dy) / scale, z = (point.z - dz) / scale;
|
|
1093
|
-
point.x = x + rz * y - ry * z;
|
|
1094
|
-
point.y = -rz * x + y + rx * z;
|
|
1095
|
-
point.z = ry * x - rx * y + z;
|
|
1096
|
-
} : (point) => {
|
|
1097
|
-
const x = point.x, y = point.y, z = point.z;
|
|
1098
|
-
point.x = scale * (x - rz * y + ry * z) + dx;
|
|
1099
|
-
point.y = scale * (rz * x + y - rx * z) + dy;
|
|
1100
|
-
point.z = scale * (-ry * x + rx * y + z) + dz;
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
function shifted(datum) {
|
|
1104
|
-
var _a2;
|
|
1105
|
-
return Boolean((_a2 = datum.towgs84) == null ? void 0 : _a2.some((value) => value !== 0));
|
|
1106
|
-
}
|
|
1107
|
-
function createDatumTransform(source, destination) {
|
|
1108
|
-
if (!source.towgs84 || !destination.towgs84)
|
|
1109
|
-
return void 0;
|
|
1110
|
-
if (source.grids || destination.grids) {
|
|
1111
|
-
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))
|
|
1112
|
-
return void 0;
|
|
1113
|
-
const middle = createDatumTransform(source.grids ? WGS84 : source, destination.grids ? WGS84 : destination);
|
|
1114
|
-
return (point) => {
|
|
1115
|
-
if (source.grids)
|
|
1116
|
-
applyDatumGrids(point, source, false);
|
|
1117
|
-
middle == null ? void 0 : middle(point);
|
|
1118
|
-
if (destination.grids)
|
|
1119
|
-
applyDatumGrids(point, destination, true);
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
if (shifted(source) || shifted(destination)) {
|
|
1123
|
-
const first = convertDatum(source, WGS84), second = convertDatum(WGS84, destination);
|
|
1124
|
-
return (point) => {
|
|
1125
|
-
first == null ? void 0 : first(point);
|
|
1126
|
-
second == null ? void 0 : second(point);
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
|
-
return convertDatum(source, destination);
|
|
1130
|
-
}
|
|
1131
|
-
function convertDatum(from, to) {
|
|
1132
|
-
if (!from.towgs84 || !to.towgs84)
|
|
1133
|
-
return void 0;
|
|
1134
|
-
const a = from.ellipsoid, b = to.ellipsoid;
|
|
1135
|
-
let sameParameters = true;
|
|
1136
|
-
for (let i = 0; i < 7; i++)
|
|
1137
|
-
if ((from.towgs84[i] || 0) !== (to.towgs84[i] || 0))
|
|
1138
|
-
sameParameters = false;
|
|
1139
|
-
if (a.semiMajorAxis === b.semiMajorAxis && Math.abs(a.eccentricitySquared - b.eccentricitySquared) <= 5e-11 && sameParameters)
|
|
1140
|
-
return void 0;
|
|
1141
|
-
const sourceShift = shifted(from) ? createHelmert(from.towgs84, false) : void 0, targetShift = shifted(to) ? createHelmert(to.towgs84, true) : void 0;
|
|
1142
|
-
return (point) => {
|
|
1143
|
-
geodeticToGeocentricInPlace(point, a);
|
|
1144
|
-
sourceShift == null ? void 0 : sourceShift(point);
|
|
1145
|
-
targetShift == null ? void 0 : targetShift(point);
|
|
1146
|
-
geocentricToGeodeticInPlace(point, b);
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
function applyDatumGrids(point, datum, inverse) {
|
|
1150
|
-
for (const reference of datum.grids) {
|
|
1151
|
-
if (reference.name === "null")
|
|
1152
|
-
return;
|
|
1153
|
-
if (!reference.grid) {
|
|
1154
|
-
if (reference.optional)
|
|
1155
|
-
continue;
|
|
1156
|
-
throw new Error("Required datum grid is not registered: " + reference.name);
|
|
1157
|
-
}
|
|
1158
|
-
let found = false;
|
|
1159
|
-
if (reference.grid.shiftInPlace)
|
|
1160
|
-
found = reference.grid.shiftInPlace(point, inverse);
|
|
1161
|
-
else {
|
|
1162
|
-
const output = reference.grid.shift(point.x, point.y, inverse);
|
|
1163
|
-
if (output) {
|
|
1164
|
-
point.x = output[0];
|
|
1165
|
-
point.y = output[1];
|
|
1166
|
-
found = true;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
if (found) {
|
|
1170
|
-
if (!Number.isFinite(point.x) || !Number.isFinite(point.y) || Math.abs(point.y) > Math.PI / 2)
|
|
1171
|
-
throw new Error("Datum grid produced a coordinate outside the geographic domain");
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
throw new Error("No datum grid covers coordinate: " + datum.grids.map((grid) => grid.name).join(","));
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
// dist/projection/experimental/rendering-profile/rectangular-rendering-profile.js
|
|
1179
|
-
function normalizeCoverage(point, coverage, center = 0, over = false) {
|
|
1180
|
-
const span = getLongitudeSpan(coverage);
|
|
1181
|
-
const west = span === 360 ? center - 180 : coverage[0] + Math.round((center - coverage[0] - span / 2) / 360) * 360;
|
|
1182
|
-
const east = west + span;
|
|
1183
|
-
if (over) {
|
|
1184
|
-
point.x = Math.max(west, Math.min(east, point.x));
|
|
1185
|
-
point.y = Math.max(coverage[1], Math.min(coverage[3], point.y));
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
const best = clampGeographicPoint(coverage, [point.x, point.y]);
|
|
1189
|
-
let longitude = best[0];
|
|
1190
|
-
if (best[0] === normalizeLongitude(point.x) && point.x >= west && point.x <= east)
|
|
1191
|
-
longitude = point.x;
|
|
1192
|
-
else if (longitude < west || longitude > east)
|
|
1193
|
-
longitude += Math.round(((west + east) / 2 - longitude) / 360) * 360;
|
|
1194
|
-
const offset = longitude - center;
|
|
1195
|
-
point.x = Math.abs(offset) <= 180 ? longitude : center + normalizeLongitude(offset);
|
|
1196
|
-
point.y = best[1];
|
|
1197
|
-
}
|
|
1198
|
-
function createRectangleRenderingProfile(resolveBounds2, coverage, origin = 0, primeMeridian2 = 0, over = false) {
|
|
1199
|
-
const center = (origin + primeMeridian2) * 180 / Math.PI;
|
|
1200
|
-
return {
|
|
1201
|
-
get bounds() {
|
|
1202
|
-
return resolveBounds2(getAngularRanges(coverage, primeMeridian2, origin));
|
|
1203
|
-
},
|
|
1204
|
-
normalize(point) {
|
|
1205
|
-
normalizeCoverage(point, coverage, center, over);
|
|
1206
|
-
}
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
// dist/projection/experimental/rendering-profile/rendering-bounds.js
|
|
1211
|
-
function longitudeRange(parameters, origin, over = false) {
|
|
1212
|
-
const low = parameters[0][0] - origin, high = parameters[1][0] - origin;
|
|
1213
|
-
if (over)
|
|
1214
|
-
return [low, high];
|
|
1215
|
-
const span = high - low;
|
|
1216
|
-
if (span >= 2 * Math.PI - 1e-12)
|
|
1217
|
-
return [-Math.PI, Math.PI];
|
|
1218
|
-
let west = wrapLongitude(low);
|
|
1219
|
-
if (span > 0 && Math.abs(west - Math.PI) < 1e-12)
|
|
1220
|
-
west = -Math.PI;
|
|
1221
|
-
const east = west + span;
|
|
1222
|
-
return east > Math.PI + 1e-12 ? [-Math.PI, Math.PI] : [west, Math.min(east, Math.PI)];
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
// dist/projection/experimental/rendering-profile/geographic-rendering-profile.js
|
|
1226
|
-
function createGeographicProfile(parameters, primeMeridian2 = 0) {
|
|
1227
|
-
const center = numberParameter(parameters, "lon_wrap", 0) * DEGREES_TO_RADIANS;
|
|
1228
|
-
return (coverage) => createRectangleRenderingProfile((ranges) => {
|
|
1229
|
-
const longitude = longitudeRange(ranges, center);
|
|
1230
|
-
return [
|
|
1231
|
-
[center + longitude[0], ranges[0][1], 0],
|
|
1232
|
-
[center + longitude[1], ranges[1][1], 0]
|
|
1233
|
-
];
|
|
1234
|
-
}, coverage ?? [-180, -90, 180, 90], center, primeMeridian2);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
// dist/projection/experimental/vertical-datum.js
|
|
1238
|
-
function compileVerticalGrid(names, grids = {}) {
|
|
1239
|
-
if (names === void 0)
|
|
1240
|
-
return void 0;
|
|
1241
|
-
const entries = [];
|
|
1242
|
-
for (const entry of names.split(",")) {
|
|
1243
|
-
const optional = entry.startsWith("@");
|
|
1244
|
-
const name = optional ? entry.slice(1) : entry;
|
|
1245
|
-
if (!name || /\s/.test(name))
|
|
1246
|
-
throw new Error("Invalid vertical grid name");
|
|
1247
|
-
if (name === "null") {
|
|
1248
|
-
entries.push(null);
|
|
1249
|
-
break;
|
|
1250
|
-
}
|
|
1251
|
-
const grid = Object.prototype.hasOwnProperty.call(grids, name) ? grids[name] : void 0;
|
|
1252
|
-
if (grid) {
|
|
1253
|
-
if (typeof grid.getOffset !== "function")
|
|
1254
|
-
throw new Error("Invalid vertical grid: " + name);
|
|
1255
|
-
entries.push(grid.getOffset.bind(grid));
|
|
1256
|
-
} else if (!optional)
|
|
1257
|
-
unsupportedStage("Required vertical grid is not registered: " + name);
|
|
1258
|
-
}
|
|
1259
|
-
return (longitude, latitude) => {
|
|
1260
|
-
for (const sample of entries) {
|
|
1261
|
-
if (!sample)
|
|
1262
|
-
return 0;
|
|
1263
|
-
const offset = sample(longitude, latitude);
|
|
1264
|
-
if (offset === void 0)
|
|
1265
|
-
continue;
|
|
1266
|
-
if (!Number.isFinite(offset))
|
|
1267
|
-
throw new Error("Vertical grid returned a non-finite offset");
|
|
1268
|
-
return offset;
|
|
1269
|
-
}
|
|
1270
|
-
throw new Error("No vertical grid covers this coordinate");
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
// dist/projection/experimental/transform-description.js
|
|
1275
|
-
function describeCRS(crs) {
|
|
1276
|
-
const ellipsoid = Object.freeze({ ...crs.ellipsoid });
|
|
1277
|
-
return Object.freeze({
|
|
1278
|
-
kind: crs.kind,
|
|
1279
|
-
projection: crs.projection,
|
|
1280
|
-
parameters: Object.freeze(Object.fromEntries(Object.entries(crs.parameters).map(([name, value]) => [name, value ?? null]))),
|
|
1281
|
-
ellipsoid,
|
|
1282
|
-
datum: Object.freeze({
|
|
1283
|
-
ellipsoid: Object.freeze({ ...crs.datum.ellipsoid }),
|
|
1284
|
-
towgs84: crs.datum.towgs84 && Object.freeze([...crs.datum.towgs84]),
|
|
1285
|
-
grids: crs.datum.grids && Object.freeze(crs.datum.grids.map((reference) => Object.freeze({
|
|
1286
|
-
name: reference.name,
|
|
1287
|
-
optional: reference.optional,
|
|
1288
|
-
loaded: Boolean(reference.grid)
|
|
1289
|
-
})))
|
|
1290
|
-
}),
|
|
1291
|
-
angularUnit: crs.angularUnit,
|
|
1292
|
-
toMeter: crs.toMeter,
|
|
1293
|
-
verticalUnit: crs.verticalUnit,
|
|
1294
|
-
primeMeridian: crs.primeMeridian,
|
|
1295
|
-
axis: crs.axis,
|
|
1296
|
-
storedAxis: crs.storedAxis,
|
|
1297
|
-
longitudeWrap: crs.longitudeWrap,
|
|
1298
|
-
areaOfUse: crs.areaOfUse && Object.freeze([...crs.areaOfUse]),
|
|
1299
|
-
lossy: crs.lossy,
|
|
1300
|
-
algorithm: crs.algorithm && Object.freeze({ ...crs.algorithm })
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1303
|
-
function describeTransform(source, target, forward, inverse) {
|
|
1304
|
-
const opaqueReasons = [];
|
|
1305
|
-
if (!source.algorithm)
|
|
1306
|
-
opaqueReasons.push("source-algorithm");
|
|
1307
|
-
if (!target.algorithm)
|
|
1308
|
-
opaqueReasons.push("target-algorithm");
|
|
1309
|
-
if (source.datum.grids || target.datum.grids || source.parameters["geoidgrids"] || target.parameters["geoidgrids"])
|
|
1310
|
-
opaqueReasons.push("grid-resource");
|
|
1311
|
-
return Object.freeze({
|
|
1312
|
-
version: 1,
|
|
1313
|
-
source,
|
|
1314
|
-
target,
|
|
1315
|
-
forward,
|
|
1316
|
-
inverse,
|
|
1317
|
-
lossy: source.lossy || target.lossy,
|
|
1318
|
-
complete: opaqueReasons.length === 0,
|
|
1319
|
-
opaqueReasons: Object.freeze(opaqueReasons)
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
// dist/projection/experimental/typescript-projection.js
|
|
1324
|
-
var ProjectionTransform = class _ProjectionTransform {
|
|
1325
|
-
/** Resolve required descriptors once, then return an ordinary synchronous instance. */
|
|
1326
|
-
static async create(options = {}) {
|
|
1327
|
-
const projections = await Promise.all(requiredProjections(options).map(preloadProjection));
|
|
1328
|
-
return new _ProjectionTransform({ ...options, projections });
|
|
1329
|
-
}
|
|
1330
|
-
get targetProfile() {
|
|
1331
|
-
return this.getTargetRenderingProfile(this.targetCoverage);
|
|
1332
|
-
}
|
|
1333
|
-
/** Resolve target rendering policy independently from coordinate conversion. @internal */
|
|
1334
|
-
getTargetRenderingProfile(coverage) {
|
|
1335
|
-
return this.targetRenderingProfile && resolveRenderingProfile(this.targetRenderingProfile, coverage);
|
|
1336
|
-
}
|
|
1337
|
-
/** Deferred transforms expose metadata only once their implementations are prepared. */
|
|
1338
|
-
get description() {
|
|
1339
|
-
var _a2, _b;
|
|
1340
|
-
return ((_b = (_a2 = this.deferred) == null ? void 0 : _a2.implementation) == null ? void 0 : _b.description) ?? this.resolvedDescription;
|
|
1341
|
-
}
|
|
1342
|
-
constructor(options = {}) {
|
|
1343
|
-
var _a2, _b, _c;
|
|
1344
|
-
this.coordinateScratch = new ProjectionScratch();
|
|
1345
|
-
this.targetLongitudeOrigin = 0;
|
|
1346
|
-
const registrations = options.projections || [];
|
|
1347
|
-
const plugins = registry(registrations);
|
|
1348
|
-
if (registrations.some((projection) => !("create" in projection))) {
|
|
1349
|
-
const from = normalizeCRS(options.from ?? "WGS84", options);
|
|
1350
|
-
const to = normalizeCRS(options.to ?? "WGS84", options);
|
|
1351
|
-
this.lossy = from.lossy || to.lossy;
|
|
1352
|
-
this.deferred = { options: { ...options, projections: [...registrations] } };
|
|
1353
|
-
} else {
|
|
1354
|
-
const eager = options;
|
|
1355
|
-
const eagerPlugins = plugins;
|
|
1356
|
-
const from = compileCRS(eager.from ?? "WGS84", eagerPlugins, eager);
|
|
1357
|
-
const to = compileCRS(eager.to ?? "WGS84", eagerPlugins, eager);
|
|
1358
|
-
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);
|
|
1359
|
-
this.targetCoverage = to.areaOfUse;
|
|
1360
|
-
this.targetLongitudeOrigin = ((_c = to.implementation) == null ? void 0 : _c.longitudeOrigin) ?? (to.kind === "geographic" ? to.longitudeWrap ?? 0 : 0);
|
|
1361
|
-
this.lossy = from.lossy || to.lossy;
|
|
1362
|
-
if (this.lossy && (from.kind === "geocentric" || to.kind === "geocentric"))
|
|
1363
|
-
unsupportedStage("Horizontal extraction cannot supply ellipsoidal height for geocentric coordinates");
|
|
1364
|
-
if (this.lossy && (from.verticalGrid || to.verticalGrid))
|
|
1365
|
-
unsupportedStage("Horizontal extraction cannot be combined with vertical grids");
|
|
1366
|
-
this.forwardTransform = compileTransform(from, to, Boolean(options.enforceAxis));
|
|
1367
|
-
this.inverseTransform = compileTransform(to, from, Boolean(options.enforceAxis));
|
|
1368
|
-
this.resolvedDescription = describeTransform(describeCRS(from), describeCRS(to), this.forwardTransform.description, this.inverseTransform.description);
|
|
1369
|
-
}
|
|
1370
|
-
this.project = this.project.bind(this);
|
|
1371
|
-
this.unproject = this.unproject.bind(this);
|
|
1372
|
-
this.projectTo = this.projectTo.bind(this);
|
|
1373
|
-
this.unprojectTo = this.unprojectTo.bind(this);
|
|
1374
|
-
this.projectToSync = this.projectToSync.bind(this);
|
|
1375
|
-
this.unprojectToSync = this.unprojectToSync.bind(this);
|
|
1376
|
-
this.projectFlat = this.projectFlat.bind(this);
|
|
1377
|
-
this.unprojectFlat = this.unprojectFlat.bind(this);
|
|
1378
|
-
this.projectSync = this.projectSync.bind(this);
|
|
1379
|
-
this.unprojectSync = this.unprojectSync.bind(this);
|
|
1380
|
-
this.projectFlatSync = this.projectFlatSync.bind(this);
|
|
1381
|
-
this.unprojectFlatSync = this.unprojectFlatSync.bind(this);
|
|
1382
|
-
}
|
|
1383
|
-
load() {
|
|
1384
|
-
const state = this.deferred;
|
|
1385
|
-
if (!state)
|
|
1386
|
-
return Promise.resolve(this);
|
|
1387
|
-
if (state.implementation)
|
|
1388
|
-
return Promise.resolve(state.implementation);
|
|
1389
|
-
state.pending || (state.pending = _ProjectionTransform.create(state.options).then((projection) => {
|
|
1390
|
-
state.implementation = projection;
|
|
1391
|
-
return projection;
|
|
1392
|
-
}).catch((error) => {
|
|
1393
|
-
state.pending = void 0;
|
|
1394
|
-
throw error;
|
|
1395
|
-
}));
|
|
1396
|
-
return state.pending;
|
|
1397
|
-
}
|
|
1398
|
-
loadSync() {
|
|
1399
|
-
const state = this.deferred;
|
|
1400
|
-
if (!state)
|
|
1401
|
-
return this;
|
|
1402
|
-
if (!state.implementation) {
|
|
1403
|
-
const projections = requiredProjections(state.options).map((descriptor) => {
|
|
1404
|
-
const plugin = getLoadedProjection(descriptor);
|
|
1405
|
-
if (!plugin)
|
|
1406
|
-
throw new Error("Projection is not preloaded: " + descriptor.name + ". Call preload() first.");
|
|
1407
|
-
return plugin;
|
|
1408
|
-
});
|
|
1409
|
-
state.implementation = new _ProjectionTransform({ ...state.options, projections });
|
|
1410
|
-
}
|
|
1411
|
-
return state.implementation;
|
|
1412
|
-
}
|
|
1413
|
-
/** Synchronous variants never import algorithms; descriptors must be preloaded. */
|
|
1414
|
-
projectSync(coordinate) {
|
|
1415
|
-
return this.deferred ? this.loadSync().project(coordinate) : transformScalar(coordinate, this.forwardTransform, this.coordinateScratch);
|
|
1416
|
-
}
|
|
1417
|
-
unprojectSync(coordinate) {
|
|
1418
|
-
return this.deferred ? this.loadSync().unproject(coordinate) : transformScalar(coordinate, this.inverseTransform, this.coordinateScratch);
|
|
1419
|
-
}
|
|
1420
|
-
projectFlatSync(coordinates, dimension = 2) {
|
|
1421
|
-
return this.deferred ? this.loadSync().projectFlat(coordinates, dimension) : transformInPlace(coordinates, dimension, this.forwardTransform, this.coordinateScratch);
|
|
1422
|
-
}
|
|
1423
|
-
unprojectFlatSync(coordinates, dimension = 2) {
|
|
1424
|
-
return this.deferred ? this.loadSync().unprojectFlat(coordinates, dimension) : transformInPlace(coordinates, dimension, this.inverseTransform, this.coordinateScratch);
|
|
1425
|
-
}
|
|
1426
|
-
/** Optional warm-up. Coordinate methods also load automatically on first use. */
|
|
1427
|
-
async preload() {
|
|
1428
|
-
await this.load();
|
|
1429
|
-
}
|
|
1430
|
-
/** Eager plugins return arrays; descriptor-backed instances return promises. */
|
|
1431
|
-
project(coordinate) {
|
|
1432
|
-
const result = this.deferred ? this.projectLoaded(coordinate, false) : transformScalar(coordinate, this.forwardTransform, this.coordinateScratch);
|
|
1433
|
-
return result;
|
|
1434
|
-
}
|
|
1435
|
-
unproject(coordinate) {
|
|
1436
|
-
const result = this.deferred ? this.projectLoaded(coordinate, true) : transformScalar(coordinate, this.inverseTransform, this.coordinateScratch);
|
|
1437
|
-
return result;
|
|
1438
|
-
}
|
|
1439
|
-
/** Write one coordinate into caller-owned storage; return that same output. */
|
|
1440
|
-
projectTo(coordinate, output) {
|
|
1441
|
-
return this.deferred ? this.projectToLoaded(coordinate, output, false) : this.projectToSync(coordinate, output);
|
|
1442
|
-
}
|
|
1443
|
-
unprojectTo(coordinate, output) {
|
|
1444
|
-
return this.deferred ? this.projectToLoaded(coordinate, output, true) : this.unprojectToSync(coordinate, output);
|
|
1445
|
-
}
|
|
1446
|
-
projectToSync(coordinate, output) {
|
|
1447
|
-
if (this.deferred)
|
|
1448
|
-
return this.loadSync().projectTo(coordinate, output);
|
|
1449
|
-
validateScalarOutput(coordinate, output, Math.max(coordinate.length, this.forwardTransform.geocentricOutput ? 3 : 2));
|
|
1450
|
-
return transformScalar(coordinate, this.forwardTransform, this.coordinateScratch, output);
|
|
1451
|
-
}
|
|
1452
|
-
unprojectToSync(coordinate, output) {
|
|
1453
|
-
if (this.deferred)
|
|
1454
|
-
return this.loadSync().unprojectTo(coordinate, output);
|
|
1455
|
-
validateScalarOutput(coordinate, output, Math.max(coordinate.length, this.inverseTransform.geocentricOutput ? 3 : 2));
|
|
1456
|
-
return transformScalar(coordinate, this.inverseTransform, this.coordinateScratch, output);
|
|
1457
|
-
}
|
|
1458
|
-
projectToLoaded(coordinate, output, inverse) {
|
|
1459
|
-
validateScalarOutput(coordinate, output, coordinate.length);
|
|
1460
|
-
const input = coordinate.slice();
|
|
1461
|
-
return this.load().then((projection) => inverse ? projection.unprojectTo(input, output) : projection.projectTo(input, output));
|
|
1462
|
-
}
|
|
1463
|
-
projectLoaded(coordinate, inverse) {
|
|
1464
|
-
const input = coordinate.slice();
|
|
1465
|
-
return this.load().then((projection) => inverse ? projection.unproject(input) : projection.project(input));
|
|
1466
|
-
}
|
|
1467
|
-
/** In-place; descriptor callers must await completion before reusing the buffer. */
|
|
1468
|
-
projectFlat(coordinates, dimension = 2) {
|
|
1469
|
-
const result = this.deferred ? this.load().then((projection) => projection.projectFlat(coordinates, dimension)) : transformInPlace(coordinates, dimension, this.forwardTransform, this.coordinateScratch);
|
|
1470
|
-
return result;
|
|
1471
|
-
}
|
|
1472
|
-
unprojectFlat(coordinates, dimension = 2) {
|
|
1473
|
-
const result = this.deferred ? this.load().then((projection) => projection.unprojectFlat(coordinates, dimension)) : transformInPlace(coordinates, dimension, this.inverseTransform, this.coordinateScratch);
|
|
1474
|
-
return result;
|
|
1475
|
-
}
|
|
1476
|
-
};
|
|
1477
|
-
function requiredProjections(options) {
|
|
1478
|
-
const available = registry(options.projections || []);
|
|
1479
|
-
const required = /* @__PURE__ */ new Set();
|
|
1480
|
-
for (const definition of [options.from ?? "WGS84", options.to ?? "WGS84"]) {
|
|
1481
|
-
const crs = normalizeCRS(definition, options);
|
|
1482
|
-
if (["geographic", "identity"].includes(crs.kind))
|
|
1483
|
-
continue;
|
|
1484
|
-
const projection = available.get(pluginKey(crs.projection));
|
|
1485
|
-
if (!projection)
|
|
1486
|
-
throw new TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
|
|
1487
|
-
required.add(projection);
|
|
1488
|
-
}
|
|
1489
|
-
return [...required];
|
|
1490
|
-
}
|
|
1491
|
-
function checkProjectionCompatibility(definition, options = {}) {
|
|
1492
|
-
try {
|
|
1493
|
-
const crs = compileCRS(definition, registry(options.projections || []), options);
|
|
1494
|
-
return { status: "supported", lossy: crs.lossy };
|
|
1495
|
-
} catch (error) {
|
|
1496
|
-
const reason = error instanceof TypeScriptCRSError ? error.reason : "invalid-definition";
|
|
1497
|
-
return {
|
|
1498
|
-
status: reason === "unknown-syntax" ? "unknown" : "unsupported",
|
|
1499
|
-
lossy: false,
|
|
1500
|
-
reason,
|
|
1501
|
-
message: error instanceof Error ? error.message : String(error)
|
|
1502
|
-
};
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
var pluginKey = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
|
|
1506
|
-
function registry(projections) {
|
|
1507
|
-
const plugins = /* @__PURE__ */ new Map();
|
|
1508
|
-
for (const plugin of projections) {
|
|
1509
|
-
for (const name of new Set([plugin.name, ...plugin.aliases || []].map(pluginKey))) {
|
|
1510
|
-
if (!name || ["longlat", "latlong", "latlon", "lonlat", "identity"].includes(name) || plugins.has(name))
|
|
1511
|
-
throw new Error("Duplicate or reserved projection plugin: " + name);
|
|
1512
|
-
plugins.set(name, plugin);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
return plugins;
|
|
1516
|
-
}
|
|
1517
|
-
function compileCRS(definition, plugins, options) {
|
|
1518
|
-
var _a2;
|
|
1519
|
-
const crs = normalizeCRS(definition, options);
|
|
1520
|
-
const plugin = plugins.get(pluginKey(crs.projection));
|
|
1521
|
-
if (!["geographic", "identity"].includes(crs.kind) && !plugin)
|
|
1522
|
-
throw new TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
|
|
1523
|
-
const allowed = /* @__PURE__ */ new Set([...CORE_PARAMETERS, ...(plugin == null ? void 0 : plugin.parameters) || []]);
|
|
1524
|
-
for (const key of Object.keys(crs.parameters)) {
|
|
1525
|
-
if (!allowed.has(key))
|
|
1526
|
-
throw new TypeScriptCRSError("missing-transform-stage", "Unsupported PROJ parameter: +" + key);
|
|
1527
|
-
const flag = CORE_FLAGS.includes(key) || ((_a2 = plugin == null ? void 0 : plugin.flags) == null ? void 0 : _a2.includes(key));
|
|
1528
|
-
if (flag && crs.parameters[key] !== void 0)
|
|
1529
|
-
throw new Error("Expected a flag without a value: +" + key);
|
|
1530
|
-
if (!flag && !crs.parameters[key])
|
|
1531
|
-
throw new Error("PROJ parameter requires a value: +" + key);
|
|
1532
|
-
}
|
|
1533
|
-
if (crs.parameters["type"] && crs.parameters["type"] !== "crs")
|
|
1534
|
-
throw new Error("Only +type=crs is supported");
|
|
1535
|
-
const parameters = pluginKey(crs.projection) === "fasttransversemercator" ? Object.freeze({ ...crs.parameters, approx: void 0 }) : crs.parameters;
|
|
1536
|
-
const implementation = plugin == null ? void 0 : plugin.create({
|
|
1537
|
-
...crs.ellipsoid,
|
|
1538
|
-
parameters,
|
|
1539
|
-
primeMeridian: crs.primeMeridian
|
|
1540
|
-
});
|
|
1541
|
-
if (crs.kind === "geocentric" && (!(implementation == null ? void 0 : implementation.forward3D) || !(implementation == null ? void 0 : implementation.inverse3D)))
|
|
1542
|
-
throw new Error("Geocentric plugin must implement 3D operations");
|
|
1543
|
-
const references = crs.datum.grids;
|
|
1544
|
-
const nullIndex = (references == null ? void 0 : references.findIndex((reference) => reference.name === "null")) ?? -1;
|
|
1545
|
-
const grids = references == null ? void 0 : references.slice(0, nullIndex < 0 ? void 0 : nullIndex + 1).map((reference) => {
|
|
1546
|
-
const grid = Object.prototype.hasOwnProperty.call(options.datumGrids || {}, reference.name) ? options.datumGrids[reference.name] : void 0;
|
|
1547
|
-
if (grid && typeof grid.shift !== "function")
|
|
1548
|
-
throw new Error("Invalid prepared datum grid: " + reference.name);
|
|
1549
|
-
return Object.freeze({ ...reference, grid });
|
|
1550
|
-
});
|
|
1551
|
-
for (const reference of grids || []) {
|
|
1552
|
-
if (reference.name === "null")
|
|
1553
|
-
break;
|
|
1554
|
-
if (!reference.optional && !reference.grid)
|
|
1555
|
-
unsupportedStage("Required datum grid is not registered: " + reference.name);
|
|
1556
|
-
}
|
|
1557
|
-
const datum = grids ? Object.freeze({ ...crs.datum, grids: Object.freeze(grids) }) : crs.datum;
|
|
1558
|
-
const verticalGrid = compileVerticalGrid(crs.parameters["geoidgrids"], options.verticalGrids);
|
|
1559
|
-
if (verticalGrid && (crs.kind === "geocentric" || crs.kind === "identity" || crs.lossy))
|
|
1560
|
-
unsupportedStage("Vertical grids require a non-lossy geographic or projected CRS");
|
|
1561
|
-
const algorithm = plugin ? plugin.semantics : { id: "@math.gl/geospatial/" + crs.kind, version: 1 };
|
|
1562
|
-
return { ...crs, datum, implementation, verticalGrid, algorithm };
|
|
1563
|
-
}
|
|
1564
|
-
function finite(point) {
|
|
1565
|
-
return Number.isFinite(point.x) && Number.isFinite(point.y) && Number.isFinite(point.z);
|
|
1566
|
-
}
|
|
1567
|
-
function compileAxis(axis, inverse) {
|
|
1568
|
-
if (axis === "enu")
|
|
1569
|
-
return void 0;
|
|
1570
|
-
const indexes = [0, 0, 0], signs = [0, 0, 0];
|
|
1571
|
-
for (let i = 0; i < 3; i++) {
|
|
1572
|
-
const char = axis[i], component = "ew".includes(char) ? 0 : "ns".includes(char) ? 1 : 2;
|
|
1573
|
-
indexes[inverse ? i : component] = inverse ? component : i;
|
|
1574
|
-
signs[inverse ? i : component] = "wsd".includes(char) ? -1 : 1;
|
|
1575
|
-
}
|
|
1576
|
-
return (point) => {
|
|
1577
|
-
const x = point.x, y = point.y, z = point.z;
|
|
1578
|
-
point.x = signs[0] * (indexes[0] === 0 ? x : indexes[0] === 1 ? y : z);
|
|
1579
|
-
point.y = signs[1] * (indexes[1] === 0 ? x : indexes[1] === 1 ? y : z);
|
|
1580
|
-
point.z = signs[2] * (indexes[2] === 0 ? x : indexes[2] === 1 ? y : z);
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
function compileTransform(from, to, enforceAxis) {
|
|
1584
|
-
var _a2, _b, _c, _d;
|
|
1585
|
-
const fromAxis = from.storedAxis || (enforceAxis ? from.axis : "enu");
|
|
1586
|
-
const toAxis = to.storedAxis || (enforceAxis ? to.axis : "enu");
|
|
1587
|
-
const inputAxis = compileAxis(fromAxis, false), outputAxis = compileAxis(toAxis, true);
|
|
1588
|
-
const source = from.implementation && projectionOperation(from.implementation, true, from.kind === "geocentric");
|
|
1589
|
-
const target = to.implementation && projectionOperation(to.implementation, false, to.kind === "geocentric");
|
|
1590
|
-
const datum = createDatumTransform(from.datum, to.datum);
|
|
1591
|
-
const horizontalOnly = from.lossy || to.lossy;
|
|
1592
|
-
const fromGeocentric = from.kind === "geocentric";
|
|
1593
|
-
const inputScale = from.kind === "geographic" ? from.angularUnit : from.toMeter;
|
|
1594
|
-
const outputScale = to.kind === "geographic" ? to.angularUnit : to.toMeter;
|
|
1595
|
-
const inputVerticalScale = fromGeocentric ? 1 : from.verticalUnit, outputVerticalScale = to.kind === "geocentric" ? outputScale : to.verticalUnit;
|
|
1596
|
-
const fromPrime = from.primeMeridian, toPrime = to.primeMeridian;
|
|
1597
|
-
const longitudeWrap = to.kind === "geographic" ? to.longitudeWrap : void 0;
|
|
1598
|
-
let flat;
|
|
1599
|
-
if (!datum && !from.verticalGrid && !to.verticalGrid && !horizontalOnly && !inputAxis && !outputAxis && !fromPrime && !toPrime && from.verticalUnit === 1 && to.verticalUnit === 1 && longitudeWrap === void 0) {
|
|
1600
|
-
const context = Object.freeze({ inputScale, outputScale });
|
|
1601
|
-
if (from.kind === "geographic" && to.kind === "projected")
|
|
1602
|
-
flat = (_b = (_a2 = to.implementation) == null ? void 0 : _a2.createForwardFlat) == null ? void 0 : _b.call(_a2, context);
|
|
1603
|
-
if (from.kind === "projected" && to.kind === "geographic")
|
|
1604
|
-
flat = (_d = (_c = from.implementation) == null ? void 0 : _c.createInverseFlat) == null ? void 0 : _d.call(_c, context);
|
|
1605
|
-
}
|
|
1606
|
-
const requiresInputZ = Boolean(from.verticalGrid || to.verticalGrid) || from.kind === "geocentric" || /[ud]/.test(fromAxis.slice(0, 2)) || /[ud]/.test(toAxis.slice(0, 2));
|
|
1607
|
-
const stages = [];
|
|
1608
|
-
if (inputAxis)
|
|
1609
|
-
stages.push("input-axis");
|
|
1610
|
-
if (horizontalOnly)
|
|
1611
|
-
stages.push("discard-height");
|
|
1612
|
-
if (inputScale !== 1)
|
|
1613
|
-
stages.push("input-scale");
|
|
1614
|
-
if (source)
|
|
1615
|
-
stages.push("source-inverse");
|
|
1616
|
-
if (inputVerticalScale !== 1)
|
|
1617
|
-
stages.push("input-height-scale");
|
|
1618
|
-
stages.push("geographic-domain-check");
|
|
1619
|
-
if (fromPrime)
|
|
1620
|
-
stages.push("source-prime-meridian");
|
|
1621
|
-
if (from.verticalGrid)
|
|
1622
|
-
stages.push("source-vertical-grid");
|
|
1623
|
-
if (datum)
|
|
1624
|
-
stages.push("datum");
|
|
1625
|
-
if (to.verticalGrid)
|
|
1626
|
-
stages.push("target-vertical-grid");
|
|
1627
|
-
if (toPrime)
|
|
1628
|
-
stages.push("target-prime-meridian");
|
|
1629
|
-
if (longitudeWrap !== void 0)
|
|
1630
|
-
stages.push("longitude-wrap");
|
|
1631
|
-
if (target)
|
|
1632
|
-
stages.push("target-forward");
|
|
1633
|
-
if (outputScale !== 1)
|
|
1634
|
-
stages.push("output-scale");
|
|
1635
|
-
if (outputVerticalScale !== 1)
|
|
1636
|
-
stages.push("output-height-scale");
|
|
1637
|
-
if (horizontalOnly)
|
|
1638
|
-
stages.push("restore-height");
|
|
1639
|
-
if (outputAxis)
|
|
1640
|
-
stages.push("output-axis");
|
|
1641
|
-
return {
|
|
1642
|
-
description: Object.freeze({
|
|
1643
|
-
inputAxis: fromAxis,
|
|
1644
|
-
outputAxis: toAxis,
|
|
1645
|
-
requiresInputZ,
|
|
1646
|
-
geocentricOutput: to.kind === "geocentric",
|
|
1647
|
-
stages: Object.freeze(stages)
|
|
1648
|
-
}),
|
|
1649
|
-
flat,
|
|
1650
|
-
requiresInputZ,
|
|
1651
|
-
geocentricOutput: to.kind === "geocentric",
|
|
1652
|
-
run(point) {
|
|
1653
|
-
if (!finite(point))
|
|
1654
|
-
throw new Error("Coordinates must contain finite x, y and optional z values");
|
|
1655
|
-
inputAxis == null ? void 0 : inputAxis(point);
|
|
1656
|
-
const preservedHeight = point.z;
|
|
1657
|
-
if (horizontalOnly)
|
|
1658
|
-
point.z = 0;
|
|
1659
|
-
if (inputScale !== 1) {
|
|
1660
|
-
point.x *= inputScale;
|
|
1661
|
-
point.y *= inputScale;
|
|
1662
|
-
if (fromGeocentric)
|
|
1663
|
-
point.z *= inputScale;
|
|
1664
|
-
}
|
|
1665
|
-
source == null ? void 0 : source(point);
|
|
1666
|
-
if (inputVerticalScale !== 1)
|
|
1667
|
-
point.z *= inputVerticalScale;
|
|
1668
|
-
if (Math.abs(point.y) > Math.PI / 2 || !finite(point))
|
|
1669
|
-
throw new Error("Coordinate is outside the geographic domain");
|
|
1670
|
-
point.x += fromPrime;
|
|
1671
|
-
if (from.verticalGrid)
|
|
1672
|
-
point.z += from.verticalGrid(point.x, point.y);
|
|
1673
|
-
datum == null ? void 0 : datum(point);
|
|
1674
|
-
if (to.verticalGrid)
|
|
1675
|
-
point.z -= to.verticalGrid(point.x, point.y);
|
|
1676
|
-
point.x -= toPrime;
|
|
1677
|
-
if (longitudeWrap !== void 0)
|
|
1678
|
-
point.x = longitudeWrap + wrapLongitude(point.x - longitudeWrap);
|
|
1679
|
-
target == null ? void 0 : target(point);
|
|
1680
|
-
if (outputScale !== 1) {
|
|
1681
|
-
point.x /= outputScale;
|
|
1682
|
-
point.y /= outputScale;
|
|
1683
|
-
}
|
|
1684
|
-
if (outputVerticalScale !== 1)
|
|
1685
|
-
point.z /= outputVerticalScale;
|
|
1686
|
-
if (horizontalOnly)
|
|
1687
|
-
point.z = preservedHeight;
|
|
1688
|
-
outputAxis == null ? void 0 : outputAxis(point);
|
|
1689
|
-
if (!finite(point))
|
|
1690
|
-
throw new Error("Projection produced non-finite coordinates");
|
|
1691
|
-
}
|
|
1692
|
-
};
|
|
1693
|
-
}
|
|
1694
|
-
function transformScalar(coordinate, operation, scratch, output) {
|
|
1695
|
-
if (coordinate.length < 2)
|
|
1696
|
-
throw new Error("Coordinates must contain finite x, y and optional z values");
|
|
1697
|
-
if (coordinate.length < 3 && operation.requiresInputZ)
|
|
1698
|
-
throw new Error("This transform requires three ordinates");
|
|
1699
|
-
const length = Math.max(coordinate.length, operation.geocentricOutput ? 3 : 2);
|
|
1700
|
-
const point = scratch.acquire();
|
|
1701
|
-
try {
|
|
1702
|
-
point.x = coordinate[0];
|
|
1703
|
-
point.y = coordinate[1];
|
|
1704
|
-
point.z = coordinate.length >= 3 ? coordinate[2] : 0;
|
|
1705
|
-
operation.run(point);
|
|
1706
|
-
if (output)
|
|
1707
|
-
return writeScalarOutput(coordinate, output, point, length);
|
|
1708
|
-
const result = coordinate.slice();
|
|
1709
|
-
result[0] = point.x;
|
|
1710
|
-
result[1] = point.y;
|
|
1711
|
-
if (coordinate.length >= 3 || operation.geocentricOutput)
|
|
1712
|
-
result[2] = point.z;
|
|
1713
|
-
return result;
|
|
1714
|
-
} finally {
|
|
1715
|
-
scratch.release(point);
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
function transformInPlace(coordinates, dimension, operation, scratch) {
|
|
1719
|
-
if (!(coordinates instanceof Float32Array || coordinates instanceof Float64Array))
|
|
1720
|
-
throw new Error("In-place projection requires a Float32Array or Float64Array");
|
|
1721
|
-
if (!Number.isSafeInteger(dimension) || dimension < 2 || coordinates.length % dimension !== 0)
|
|
1722
|
-
throw new Error("Dimension must be an integer >= 2 and divide the typed array length");
|
|
1723
|
-
if (dimension < 3 && (operation.requiresInputZ || operation.geocentricOutput))
|
|
1724
|
-
throw new Error("This transform requires a dimension of at least 3");
|
|
1725
|
-
if (operation.flat) {
|
|
1726
|
-
operation.flat(coordinates, dimension);
|
|
1727
|
-
return coordinates;
|
|
1728
|
-
}
|
|
1729
|
-
const point = scratch.acquire();
|
|
1730
|
-
try {
|
|
1731
|
-
const float32 = coordinates instanceof Float32Array;
|
|
1732
|
-
for (let offset = 0; offset < coordinates.length; offset += dimension) {
|
|
1733
|
-
point.x = coordinates[offset];
|
|
1734
|
-
point.y = coordinates[offset + 1];
|
|
1735
|
-
point.z = dimension >= 3 ? coordinates[offset + 2] : 0;
|
|
1736
|
-
operation.run(point);
|
|
1737
|
-
if (float32 && (Math.abs(point.x) > 34028234663852886e22 || Math.abs(point.y) > 34028234663852886e22 || dimension >= 3 && Math.abs(point.z) > 34028234663852886e22))
|
|
1738
|
-
throw new Error("Projected coordinate exceeds Float32 range");
|
|
1739
|
-
coordinates[offset] = point.x;
|
|
1740
|
-
coordinates[offset + 1] = point.y;
|
|
1741
|
-
if (dimension >= 3)
|
|
1742
|
-
coordinates[offset + 2] = point.z;
|
|
1743
|
-
}
|
|
1744
|
-
return coordinates;
|
|
1745
|
-
} finally {
|
|
1746
|
-
scratch.release(point);
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
// dist/projection/numerical-derivative.js
|
|
1751
|
-
var NumericalDerivative = class {
|
|
1752
|
-
constructor(sample) {
|
|
1753
|
-
this.sample = sample;
|
|
1754
|
-
this.result = [0, 0, 0];
|
|
1755
|
-
this.samples = Array.from({ length: 4 }, () => [0, 0, 0]);
|
|
1756
|
-
this.coarse = [0, 0, 0];
|
|
1757
|
-
this.fine = [0, 0, 0];
|
|
1758
|
-
}
|
|
1759
|
-
evaluate(step, referenceScale, tolerance = 1e-6) {
|
|
1760
|
-
if (!this.difference(step, this.coarse) || !this.difference(step / 2, this.fine))
|
|
1761
|
-
return false;
|
|
1762
|
-
const bound = tolerance * Math.max(referenceScale, Math.abs(this.fine[0]), Math.abs(this.fine[1]), Math.abs(this.fine[2]));
|
|
1763
|
-
for (let i = 0; i < 3; i++) {
|
|
1764
|
-
if (Math.abs(this.coarse[i] - this.fine[i]) > bound)
|
|
1765
|
-
return false;
|
|
1766
|
-
this.fine[i] += (this.fine[i] - this.coarse[i]) / 15;
|
|
1767
|
-
if (!Number.isFinite(this.fine[i]))
|
|
1768
|
-
return false;
|
|
1769
|
-
}
|
|
1770
|
-
for (let i = 0; i < 3; i++)
|
|
1771
|
-
this.result[i] = this.fine[i];
|
|
1772
|
-
return true;
|
|
1773
|
-
}
|
|
1774
|
-
difference(step, output) {
|
|
1775
|
-
const [a, b, c, d] = this.samples;
|
|
1776
|
-
if (!this.sample(-2 * step, a) || !this.sample(-step, b) || !this.sample(step, c) || !this.sample(2 * step, d))
|
|
1777
|
-
return false;
|
|
1778
|
-
for (let i = 0; i < 3; i++) {
|
|
1779
|
-
output[i] = (a[i] - d[i] + 8 * (c[i] - b[i])) / (12 * step);
|
|
1780
|
-
if (!Number.isFinite(output[i]))
|
|
1781
|
-
return false;
|
|
1782
|
-
}
|
|
1783
|
-
return true;
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
793
|
+
// dist/projection/experimental/core.js
|
|
794
|
+
var import_types3 = require("./crs/types.shared.cjs");
|
|
1786
795
|
|
|
1787
|
-
// dist/projection/experimental/
|
|
1788
|
-
var
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
796
|
+
// dist/projection/experimental/projection-descriptor.js
|
|
797
|
+
var CACHE_KEY = /* @__PURE__ */ Symbol.for("@math.gl/projection/projection-implementations");
|
|
798
|
+
function cache() {
|
|
799
|
+
const scope = globalThis;
|
|
800
|
+
scope[CACHE_KEY] || (scope[CACHE_KEY] = /* @__PURE__ */ new WeakMap());
|
|
801
|
+
return scope[CACHE_KEY];
|
|
1792
802
|
}
|
|
1793
|
-
function
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
return scale;
|
|
803
|
+
function getLoadedProjection(projection) {
|
|
804
|
+
var _a;
|
|
805
|
+
return "create" in projection ? projection : (_a = cache().get(projection)) == null ? void 0 : _a.implementation;
|
|
1797
806
|
}
|
|
1798
|
-
function
|
|
1799
|
-
if (
|
|
1800
|
-
return
|
|
1801
|
-
|
|
1802
|
-
|
|
807
|
+
function preloadProjection(projection) {
|
|
808
|
+
if ("create" in projection)
|
|
809
|
+
return Promise.resolve(projection);
|
|
810
|
+
let state = cache().get(projection);
|
|
811
|
+
if (!state) {
|
|
812
|
+
state = { load: () => projection.preload() };
|
|
813
|
+
cache().set(projection, state);
|
|
1803
814
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
const
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
output[0] = delta * longitudeMeters;
|
|
1818
|
-
output[1] = (sample[1] - geographic[1]) * latitudeMeters;
|
|
1819
|
-
output[2] = sample[2] - geographic[2];
|
|
1820
|
-
return output.every(Number.isFinite);
|
|
1821
|
-
});
|
|
1822
|
-
return (coordinate) => {
|
|
1823
|
-
if (busy || coordinate.length < 2)
|
|
1824
|
-
return null;
|
|
1825
|
-
busy = true;
|
|
1826
|
-
let scale;
|
|
1827
|
-
try {
|
|
1828
|
-
anchor[0] = coordinate[0];
|
|
1829
|
-
anchor[1] = coordinate[1];
|
|
1830
|
-
anchor[2] = coordinate[2] ?? 0;
|
|
1831
|
-
if (!anchor.every(Number.isFinite))
|
|
1832
|
-
return null;
|
|
1833
|
-
projection.unprojectTo(anchor, geographic);
|
|
1834
|
-
const latitude = geographic[1] * RADIANS2;
|
|
1835
|
-
const a = body.semiMajorAxis, es = body.eccentricitySquared;
|
|
1836
|
-
const denominator = 1 - es * Math.sin(latitude) ** 2;
|
|
1837
|
-
longitudeMeters = a * Math.cos(latitude) / Math.sqrt(denominator) * RADIANS2;
|
|
1838
|
-
latitudeMeters = a * (1 - es) / denominator ** 1.5 * RADIANS2;
|
|
1839
|
-
if (!(longitudeMeters > a * RADIANS2 * 1e-8) || !(latitudeMeters > 0))
|
|
1840
|
-
return null;
|
|
1841
|
-
const offset = ((geographic[0] - center + 180) % 360 + 360) % 360 - 180;
|
|
1842
|
-
const hasLongitudeSeam = crs.kind === "geographic" ? crs.longitudeWrap !== void 0 : !Object.prototype.hasOwnProperty.call(crs.parameters, "over");
|
|
1843
|
-
if (hasLongitudeSeam && Math.abs(offset) + 2 / longitudeMeters >= 180 || Math.abs(geographic[1]) + 2 / latitudeMeters >= 90)
|
|
1844
|
-
return null;
|
|
1845
|
-
for (component = 0; component < 3; component++) {
|
|
1846
|
-
const direction = axis[component];
|
|
1847
|
-
const nominalMeters = /[ud]/.test(direction) ? crs.verticalUnit : crs.kind === "geographic" ? (/[ew]/.test(direction) ? longitudeMeters : latitudeMeters) * crs.angularUnit / RADIANS2 : crs.toMeter;
|
|
1848
|
-
if (!numerical.evaluate(1 / nominalMeters, nominalMeters))
|
|
1849
|
-
return null;
|
|
1850
|
-
for (let i = 0; i < 3; i++)
|
|
1851
|
-
derivatives[component][i] = numerical.result[i];
|
|
1852
|
-
}
|
|
1853
|
-
scale = derivatives.map((derivative) => Math.hypot(...derivative));
|
|
1854
|
-
if (crs.kind === "projected") {
|
|
1855
|
-
const east = derivatives[axis.search(/[ew]/)];
|
|
1856
|
-
const north = derivatives[axis.search(/[ns]/)];
|
|
1857
|
-
const inverseArea = Math.abs(east[0] * north[1] - east[1] * north[0]) / crs.toMeter ** 2;
|
|
1858
|
-
scale[axis.search(/[ud]/)] = crs.verticalUnit * Math.sqrt(inverseArea);
|
|
1859
|
-
}
|
|
1860
|
-
} catch {
|
|
1861
|
-
return null;
|
|
1862
|
-
} finally {
|
|
1863
|
-
busy = false;
|
|
1864
|
-
}
|
|
1865
|
-
return validateScale(scale);
|
|
1866
|
-
};
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
// dist/projection/experimental/crs-descriptor.js
|
|
1870
|
-
var ANGULAR_UNITS = {
|
|
1871
|
-
degrees: Math.PI / 180,
|
|
1872
|
-
radians: 1,
|
|
1873
|
-
gradians: Math.PI / 200
|
|
1874
|
-
};
|
|
1875
|
-
var LINEAR_UNITS = {
|
|
1876
|
-
...Object.fromEntries(Object.values(linearUnits).map((unit) => [unit.name, unit.metersPerUnit]))
|
|
1877
|
-
};
|
|
1878
|
-
async function resolveCRSDescriptor(engine, definition, normalization, options = {}, useDefinitionSignature = false, prepareInput) {
|
|
1879
|
-
const captured = typeof definition === "string" ? definition : JSON.parse(JSON.stringify(definition));
|
|
1880
|
-
const conventions = {
|
|
1881
|
-
enforceAxis: normalization.enforceAxis,
|
|
1882
|
-
mode: normalization.mode,
|
|
1883
|
-
...options,
|
|
1884
|
-
converters: options.converters && [...options.converters]
|
|
1885
|
-
};
|
|
1886
|
-
const input = prepareInput ? await prepareInput(captured, { ...normalization, ...conventions }) : captured;
|
|
1887
|
-
const crs = normalizeCRS(input, { ...normalization, ...conventions });
|
|
1888
|
-
const projection = await engine.createProjectionAsync({
|
|
1889
|
-
...conventions,
|
|
1890
|
-
from: "WGS84",
|
|
1891
|
-
to: input
|
|
1892
|
-
});
|
|
1893
|
-
const axis = crs.storedAxis || (conventions.enforceAxis ? crs.axis : "enu");
|
|
1894
|
-
const horizontalUnit = getUnit(crs.kind === "geographic" ? crs.angularUnit : crs.toMeter, crs.kind === "geographic");
|
|
1895
|
-
const heightUnit = getUnit(crs.verticalUnit, false);
|
|
1896
|
-
const units = [...axis].map((direction) => crs.kind !== "geocentric" && /[ud]/.test(direction) ? heightUnit : horizontalUnit);
|
|
1897
|
-
const profile = projection.targetProfile;
|
|
1898
|
-
if (!profile)
|
|
1899
|
-
throw new Error("Projection must define a rendering profile for CRS retrieval");
|
|
1900
|
-
const center = (projection.targetLongitudeOrigin + crs.primeMeridian) * 180 / Math.PI;
|
|
1901
|
-
const bounds = adaptBounds(profile, crs, axis);
|
|
1902
|
-
const normalizeWGS84 = createNormalization(profile.normalize);
|
|
1903
|
-
const renderingScale = createRenderingScale(crs, projection, axis, center);
|
|
1904
|
-
const sources = [.../* @__PURE__ */ new Set(["WGS84", ...conventions.converters || []])];
|
|
1905
|
-
if (sources.some((source) => typeof source !== "string" || !source.trim()))
|
|
1906
|
-
throw new Error("Converter source CRS must be a nonempty string");
|
|
1907
|
-
const entries = await Promise.all(sources.map(async (source) => {
|
|
1908
|
-
if (source === "WGS84")
|
|
1909
|
-
return [source, createConverter(projection, normalizeWGS84)];
|
|
1910
|
-
const [pair, geographic] = await Promise.all([
|
|
1911
|
-
engine.createProjectionAsync({ ...conventions, from: source, to: input }),
|
|
1912
|
-
engine.createProjectionAsync({ ...conventions, from: "WGS84", to: source })
|
|
1913
|
-
]);
|
|
1914
|
-
return [
|
|
1915
|
-
source,
|
|
1916
|
-
createConverter(pair, createSourceNormalization(geographic, normalizeWGS84))
|
|
1917
|
-
];
|
|
815
|
+
if (state.implementation)
|
|
816
|
+
return Promise.resolve(state.implementation);
|
|
817
|
+
const entry = state;
|
|
818
|
+
entry.pending || (entry.pending = Promise.resolve().then(entry.load).then((plugin) => {
|
|
819
|
+
const key = (value) => value.toLowerCase().replace(/[\s_-]/g, "");
|
|
820
|
+
const supported = new Set([plugin.name, ...plugin.aliases || []].map(key));
|
|
821
|
+
if (typeof plugin.create !== "function" || ![projection.name, ...projection.aliases || []].every((name) => supported.has(key(name))))
|
|
822
|
+
throw new Error("Loaded projection does not match descriptor: " + projection.name);
|
|
823
|
+
entry.implementation = plugin;
|
|
824
|
+
return plugin;
|
|
825
|
+
}).catch((error) => {
|
|
826
|
+
entry.pending = void 0;
|
|
827
|
+
throw error;
|
|
1918
828
|
}));
|
|
1919
|
-
|
|
1920
|
-
const metadata = {
|
|
1921
|
-
coordinateFrame: crs.kind,
|
|
1922
|
-
projection: crs.projection,
|
|
1923
|
-
parameters: crs.parameters,
|
|
1924
|
-
ellipsoid: {
|
|
1925
|
-
semiMajorAxis: crs.ellipsoid.semiMajorAxis,
|
|
1926
|
-
semiMinorAxis: crs.ellipsoid.semiMinorAxis
|
|
1927
|
-
},
|
|
1928
|
-
axis,
|
|
1929
|
-
xUnit: units[0],
|
|
1930
|
-
yUnit: units[1],
|
|
1931
|
-
zUnit: units[2],
|
|
1932
|
-
areaOfUse: crs.areaOfUse,
|
|
1933
|
-
lossy: crs.lossy
|
|
1934
|
-
};
|
|
1935
|
-
return {
|
|
1936
|
-
...metadata,
|
|
1937
|
-
// Exact caller identity is sufficient under default execution conventions.
|
|
1938
|
-
// Additional source converters do not change the target CRS.
|
|
1939
|
-
signature: useDefinitionSignature && typeof input === "string" && !conventions.enforceAxis && !crs.lossy ? input : getCRSSignature(metadata),
|
|
1940
|
-
renderingBounds: bounds,
|
|
1941
|
-
renderingScale,
|
|
1942
|
-
getRenderingScale: (coordinate) => typeof renderingScale === "function" ? renderingScale(coordinate) : renderingScale,
|
|
1943
|
-
converter
|
|
1944
|
-
};
|
|
1945
|
-
}
|
|
1946
|
-
function createConverter(projection, normalize) {
|
|
1947
|
-
return {
|
|
1948
|
-
from: createConversion(projection.project.bind(projection), projection.projectTo.bind(projection)),
|
|
1949
|
-
to: createConversion(projection.unproject.bind(projection), projection.unprojectTo.bind(projection)),
|
|
1950
|
-
normalize
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
|
-
function createSourceNormalization(geographic, normalizeWGS84) {
|
|
1954
|
-
function normalize(coordinate, output) {
|
|
1955
|
-
if (output !== void 0)
|
|
1956
|
-
validateScalarOutput(coordinate, output, coordinate.length);
|
|
1957
|
-
const wgs842 = geographic.unproject(Array.from(coordinate));
|
|
1958
|
-
const [longitude, latitude, altitude] = wgs842;
|
|
1959
|
-
normalizeWGS84(wgs842, wgs842);
|
|
1960
|
-
if (wgs842[0] === longitude && wgs842[1] === latitude && wgs842[2] === altitude) {
|
|
1961
|
-
return output === void 0 ? Array.from(coordinate) : writeScalarOutput(coordinate, output, { x: coordinate[0], y: coordinate[1], z: coordinate[2] ?? 0 }, coordinate.length);
|
|
1962
|
-
}
|
|
1963
|
-
return output === void 0 ? geographic.project(wgs842) : geographic.projectTo(wgs842, output);
|
|
1964
|
-
}
|
|
1965
|
-
return normalize;
|
|
1966
|
-
}
|
|
1967
|
-
function createConversion(allocate, write) {
|
|
1968
|
-
function convert(coordinate, output) {
|
|
1969
|
-
return output === void 0 ? allocate(Array.isArray(coordinate) ? coordinate : Array.from(coordinate)) : write(coordinate, output);
|
|
1970
|
-
}
|
|
1971
|
-
return convert;
|
|
1972
|
-
}
|
|
1973
|
-
function createNormalization(normalizeDomain) {
|
|
1974
|
-
function normalize(coordinate, output) {
|
|
1975
|
-
const result = output ?? new Array(coordinate.length);
|
|
1976
|
-
validateScalarOutput(coordinate, result, coordinate.length);
|
|
1977
|
-
const longitude = coordinate[0], latitude = coordinate[1], altitude = coordinate[2] ?? 0;
|
|
1978
|
-
if (coordinate.length < 2 || !Number.isFinite(longitude) || !Number.isFinite(latitude) || !Number.isFinite(altitude))
|
|
1979
|
-
throw new Error("Normalization requires finite longitude, latitude and altitude");
|
|
1980
|
-
const point = { x: longitude, y: latitude, z: altitude };
|
|
1981
|
-
normalizeDomain == null ? void 0 : normalizeDomain(point);
|
|
1982
|
-
return writeScalarOutput(coordinate, result, point, coordinate.length);
|
|
1983
|
-
}
|
|
1984
|
-
return normalize;
|
|
1985
|
-
}
|
|
1986
|
-
function adaptBounds(profile, crs, axis) {
|
|
1987
|
-
const horizontalUnit = crs.kind === "geographic" ? crs.angularUnit : crs.toMeter;
|
|
1988
|
-
const units = [
|
|
1989
|
-
horizontalUnit,
|
|
1990
|
-
horizontalUnit,
|
|
1991
|
-
crs.kind === "geocentric" ? crs.toMeter : crs.verticalUnit
|
|
1992
|
-
];
|
|
1993
|
-
const bounds = profile.bounds;
|
|
1994
|
-
const limits = [...axis].map((direction) => {
|
|
1995
|
-
const index = /[ew]/.test(direction) ? 0 : /[ns]/.test(direction) ? 1 : 2;
|
|
1996
|
-
const minimum = bounds[0][index] / units[index];
|
|
1997
|
-
const maximum = bounds[1][index] / units[index];
|
|
1998
|
-
return /[wsd]/.test(direction) ? [-maximum, -minimum] : [minimum, maximum];
|
|
1999
|
-
});
|
|
2000
|
-
return [
|
|
2001
|
-
[limits[0][0], limits[1][0], limits[2][0]],
|
|
2002
|
-
[limits[0][1], limits[1][1], limits[2][1]]
|
|
2003
|
-
];
|
|
2004
|
-
}
|
|
2005
|
-
function getUnit(factor, angular) {
|
|
2006
|
-
const units = angular ? ANGULAR_UNITS : LINEAR_UNITS;
|
|
2007
|
-
const name = Object.keys(units).find((candidate) => units[candidate] === factor) || "custom";
|
|
2008
|
-
return angular ? { name, degreesPerUnit: factor / ANGULAR_UNITS["degrees"] } : { name, metersPerUnit: factor };
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
// dist/projection/experimental/engine-options.js
|
|
2012
|
-
function snapshotEngineOptions(options) {
|
|
2013
|
-
return {
|
|
2014
|
-
...options,
|
|
2015
|
-
projections: options.projections && [...options.projections],
|
|
2016
|
-
parsers: options.parsers && [...options.parsers],
|
|
2017
|
-
datumCatalogs: options.datumCatalogs && [...options.datumCatalogs],
|
|
2018
|
-
aliases: options.aliases && JSON.parse(JSON.stringify(options.aliases)),
|
|
2019
|
-
datumGrids: options.datumGrids && { ...options.datumGrids },
|
|
2020
|
-
verticalGrids: options.verticalGrids && { ...options.verticalGrids }
|
|
2021
|
-
};
|
|
2022
|
-
}
|
|
2023
|
-
function hasCRSOverrides(options) {
|
|
2024
|
-
return Boolean(options.projections || options.parsers || options.datumCatalogs || options.aliases || options.datumGrids || options.verticalGrids || options.resolver);
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
// dist/projection/experimental/crs/resolve.js
|
|
2028
|
-
async function prepareEngineOptions(options) {
|
|
2029
|
-
const captured = {
|
|
2030
|
-
...options,
|
|
2031
|
-
from: capture(options.from ?? "WGS84"),
|
|
2032
|
-
to: capture(options.to ?? "WGS84")
|
|
2033
|
-
};
|
|
2034
|
-
const [from, to] = await Promise.all([
|
|
2035
|
-
prepareCRSInput(captured.from, captured),
|
|
2036
|
-
prepareCRSInput(captured.to, captured)
|
|
2037
|
-
]);
|
|
2038
|
-
return { ...captured, from, to };
|
|
829
|
+
return entry.pending;
|
|
2039
830
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
const representation = local === source.definition && reference ? reference.representation : inferCRSRepresentation(local);
|
|
2046
|
-
if (representation !== "identifier" || ((_a2 = options.parsers) == null ? void 0 : _a2.some((p) => p.canParse(local)))) {
|
|
2047
|
-
return captured;
|
|
2048
|
-
}
|
|
2049
|
-
const result = await options.resolver.resolve({
|
|
2050
|
-
state: "explicit",
|
|
2051
|
-
provenance: (reference == null ? void 0 : reference.provenance) ?? "unknown",
|
|
2052
|
-
definition: local,
|
|
2053
|
-
representation
|
|
831
|
+
function createProjectionDescriptor(metadata, load) {
|
|
832
|
+
const descriptor = Object.freeze({
|
|
833
|
+
name: metadata.name,
|
|
834
|
+
aliases: metadata.aliases && Object.freeze([...metadata.aliases]),
|
|
835
|
+
preload: () => preloadProjection(descriptor)
|
|
2054
836
|
});
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
return definition;
|
|
2058
|
-
const metadata = captured;
|
|
2059
|
-
const resolved2 = {
|
|
2060
|
-
...reference,
|
|
2061
|
-
definition,
|
|
2062
|
-
representation: inferCRSRepresentation(definition),
|
|
2063
|
-
alternatives: [
|
|
2064
|
-
{ definition: reference.definition, representation: reference.representation },
|
|
2065
|
-
...reference.alternatives ?? []
|
|
2066
|
-
]
|
|
2067
|
-
};
|
|
2068
|
-
return "crs" in metadata ? { ...metadata, crs: resolved2 } : resolved2;
|
|
2069
|
-
}
|
|
2070
|
-
function capture(input) {
|
|
2071
|
-
return typeof input === "string" ? input : JSON.parse(JSON.stringify(input));
|
|
837
|
+
cache().set(descriptor, { load });
|
|
838
|
+
return descriptor;
|
|
2072
839
|
}
|
|
2073
840
|
|
|
2074
|
-
// dist/projection/experimental/
|
|
2075
|
-
var
|
|
2076
|
-
constructor(options = {}) {
|
|
2077
|
-
this.options = snapshotEngineOptions(options);
|
|
2078
|
-
this.useDefinitionSignature = !hasCRSOverrides(options);
|
|
2079
|
-
}
|
|
2080
|
-
/** Resolve a CRS and load only its required algorithms before exposing sync conversions. */
|
|
2081
|
-
getCRS(definition, options = {}) {
|
|
2082
|
-
return resolveCRSDescriptor(this, definition, this.options, options, this.useDefinitionSignature, this.options.resolver ? prepareCRSInput : void 0);
|
|
2083
|
-
}
|
|
2084
|
-
/** Compile a CRS pair. Lazy descriptors remain unloaded until the transform is used. */
|
|
2085
|
-
createProjection(options = {}) {
|
|
2086
|
-
return new ProjectionTransform({ ...this.options, ...options });
|
|
2087
|
-
}
|
|
2088
|
-
/** Load only the algorithms required by this CRS pair and return a synchronous transform. */
|
|
2089
|
-
async createProjectionAsync(options = {}) {
|
|
2090
|
-
const config = { ...this.options, ...options };
|
|
2091
|
-
return ProjectionTransform.create(config.resolver ? await prepareEngineOptions(config) : config);
|
|
2092
|
-
}
|
|
2093
|
-
};
|
|
2094
|
-
function createProjectionEngine(options = {}) {
|
|
2095
|
-
return new ConfigurableProjectionEngine(options);
|
|
2096
|
-
}
|
|
841
|
+
// dist/projection/experimental/core.js
|
|
842
|
+
var import_projection_engine = require("./projection-engine.shared.cjs");
|
|
2097
843
|
//# sourceMappingURL=core.cjs.map
|