@math.gl/geospatial 5.0.0-beta.8 → 5.0.0-beta.9
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/dist/index.cjs +1354 -383
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/tasks/index.cjs +1135 -142
- package/dist/tasks/index.cjs.map +3 -3
- package/dist/tasks/index.d.ts +12 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +26 -0
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/terrain-coverage-worker.d.ts +2 -0
- package/dist/tasks/terrain-coverage-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage-worker.js +7 -0
- package/dist/tasks/terrain-coverage-worker.js.map +1 -0
- package/dist/tasks/terrain-coverage.d.ts +25 -0
- package/dist/tasks/terrain-coverage.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage.js +15 -0
- package/dist/tasks/terrain-coverage.js.map +1 -0
- package/dist/tasks/terrain-residency-worker.d.ts +2 -0
- package/dist/tasks/terrain-residency-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-residency-worker.js +7 -0
- package/dist/tasks/terrain-residency-worker.js.map +1 -0
- package/dist/tasks/terrain-residency.d.ts +64 -0
- package/dist/tasks/terrain-residency.d.ts.map +1 -0
- package/dist/tasks/terrain-residency.js +124 -0
- package/dist/tasks/terrain-residency.js.map +1 -0
- package/dist/terrain/breakline-mesh.d.ts +18 -0
- package/dist/terrain/breakline-mesh.d.ts.map +1 -0
- package/dist/terrain/breakline-mesh.js +126 -0
- package/dist/terrain/breakline-mesh.js.map +1 -0
- package/dist/terrain/breakline-preprocess.d.ts +11 -0
- package/dist/terrain/breakline-preprocess.d.ts.map +1 -0
- package/dist/terrain/breakline-preprocess.js +94 -0
- package/dist/terrain/breakline-preprocess.js.map +1 -0
- package/dist/terrain/continuous-mesh-error.d.ts +34 -0
- package/dist/terrain/continuous-mesh-error.d.ts.map +1 -0
- package/dist/terrain/continuous-mesh-error.js +221 -0
- package/dist/terrain/continuous-mesh-error.js.map +1 -0
- package/dist/terrain/geographic-seam.d.ts +21 -0
- package/dist/terrain/geographic-seam.d.ts.map +1 -0
- package/dist/terrain/geographic-seam.js +52 -0
- package/dist/terrain/geographic-seam.js.map +1 -0
- package/dist/terrain/index.cjs +1104 -133
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +10 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +9 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/lod-select.d.ts +32 -0
- package/dist/terrain/lod-select.d.ts.map +1 -0
- package/dist/terrain/lod-select.js +60 -0
- package/dist/terrain/lod-select.js.map +1 -0
- package/dist/terrain/lod-stitch.d.ts +13 -0
- package/dist/terrain/lod-stitch.d.ts.map +1 -0
- package/dist/terrain/lod-stitch.js +49 -0
- package/dist/terrain/lod-stitch.js.map +1 -0
- package/dist/terrain/mesh-coverage.d.ts +35 -0
- package/dist/terrain/mesh-coverage.d.ts.map +1 -0
- package/dist/terrain/mesh-coverage.js +186 -0
- package/dist/terrain/mesh-coverage.js.map +1 -0
- package/dist/terrain/mesh-regions-data.d.ts +2 -2
- package/dist/terrain/mesh-regions-data.d.ts.map +1 -1
- package/dist/terrain/mesh-regions-data.js +20 -10
- package/dist/terrain/mesh-regions-data.js.map +1 -1
- package/dist/terrain/mixed-halo-update.d.ts.map +1 -1
- package/dist/terrain/mixed-halo-update.js +93 -16
- package/dist/terrain/mixed-halo-update.js.map +1 -1
- package/dist/terrain/mixed-vertex-halos.d.ts +11 -1
- package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -1
- package/dist/terrain/mixed-vertex-halos.js +43 -5
- package/dist/terrain/mixed-vertex-halos.js.map +1 -1
- package/dist/terrain/valid-domain-mesh.d.ts +29 -0
- package/dist/terrain/valid-domain-mesh.d.ts.map +1 -0
- package/dist/terrain/valid-domain-mesh.js +183 -0
- package/dist/terrain/valid-domain-mesh.js.map +1 -0
- package/dist/terrain/valid-domain-regions.d.ts +16 -0
- package/dist/terrain/valid-domain-regions.d.ts.map +1 -0
- package/dist/terrain/valid-domain-regions.js +19 -0
- package/dist/terrain/valid-domain-regions.js.map +1 -0
- package/package.json +9 -8
- package/src/index.ts +43 -0
- package/src/tasks/index.ts +34 -0
- package/src/tasks/terrain-coverage-worker.ts +6 -0
- package/src/tasks/terrain-coverage.ts +25 -0
- package/src/tasks/terrain-residency-worker.ts +6 -0
- package/src/tasks/terrain-residency.ts +154 -0
- package/src/terrain/breakline-mesh.ts +164 -0
- package/src/terrain/breakline-preprocess.ts +106 -0
- package/src/terrain/cdt2d.d.ts +10 -0
- package/src/terrain/continuous-mesh-error.ts +321 -0
- package/src/terrain/geographic-seam.ts +73 -0
- package/src/terrain/index.ts +39 -0
- package/src/terrain/lod-select.ts +95 -0
- package/src/terrain/lod-stitch.ts +70 -0
- package/src/terrain/mesh-coverage.ts +215 -0
- package/src/terrain/mesh-regions-data.ts +21 -13
- package/src/terrain/mixed-halo-update.ts +105 -17
- package/src/terrain/mixed-vertex-halos.ts +58 -4
- package/src/terrain/valid-domain-mesh.ts +221 -0
- package/src/terrain/valid-domain-regions.ts +41 -0
package/dist/tasks/index.cjs
CHANGED
|
@@ -18,9 +18,9 @@ var __export = (target, all) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __copyProps = (to, from, except, desc) => {
|
|
20
20
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let
|
|
22
|
-
if (!__hasOwnProp.call(to,
|
|
23
|
-
__defProp(to,
|
|
21
|
+
for (let key3 of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key3) && key3 !== except)
|
|
23
|
+
__defProp(to, key3, { get: () => from[key3], enumerable: !(desc = __getOwnPropDesc(from, key3)) || desc.enumerable });
|
|
24
24
|
}
|
|
25
25
|
return to;
|
|
26
26
|
};
|
|
@@ -34,6 +34,854 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
));
|
|
35
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
36
|
|
|
37
|
+
// dist/terrain/box-index.js
|
|
38
|
+
function createTerrainBoxIndex(boxes) {
|
|
39
|
+
const build = (ids) => {
|
|
40
|
+
const box = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
|
|
41
|
+
for (const id of ids) {
|
|
42
|
+
const b = boxes[id];
|
|
43
|
+
box.minX = Math.min(box.minX, b.minX);
|
|
44
|
+
box.minY = Math.min(box.minY, b.minY);
|
|
45
|
+
box.maxX = Math.max(box.maxX, b.maxX);
|
|
46
|
+
box.maxY = Math.max(box.maxY, b.maxY);
|
|
47
|
+
}
|
|
48
|
+
if (ids.length <= 8)
|
|
49
|
+
return { ...box, ids };
|
|
50
|
+
const axis = box.maxX - box.minX >= box.maxY - box.minY ? "X" : "Y";
|
|
51
|
+
ids.sort((a, b) => boxes[a][`min${axis}`] / 2 + boxes[a][`max${axis}`] / 2 - (boxes[b][`min${axis}`] / 2 + boxes[b][`max${axis}`] / 2) || a - b);
|
|
52
|
+
const mid = ids.length >>> 1;
|
|
53
|
+
return { ...box, left: build(ids.slice(0, mid)), right: build(ids.slice(mid)) };
|
|
54
|
+
};
|
|
55
|
+
const root = build(boxes.map((_, i) => i));
|
|
56
|
+
return (query, charge) => {
|
|
57
|
+
const found = [], stack = [root];
|
|
58
|
+
while (stack.length) {
|
|
59
|
+
charge();
|
|
60
|
+
const node = stack.pop();
|
|
61
|
+
if (!overlaps(node, query))
|
|
62
|
+
continue;
|
|
63
|
+
if (node.ids) {
|
|
64
|
+
for (const id of node.ids) {
|
|
65
|
+
charge();
|
|
66
|
+
if (overlaps(boxes[id], query))
|
|
67
|
+
found.push(id);
|
|
68
|
+
}
|
|
69
|
+
} else
|
|
70
|
+
stack.push(node.right, node.left);
|
|
71
|
+
}
|
|
72
|
+
return found.sort((a, b) => a - b);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
var overlaps;
|
|
76
|
+
var init_box_index = __esm({
|
|
77
|
+
"dist/terrain/box-index.js"() {
|
|
78
|
+
overlaps = (a, b) => a.minX <= b.maxX && b.minX <= a.maxX && a.minY <= b.maxY && b.minY <= a.maxY;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// dist/terrain/types.js
|
|
83
|
+
var TerrainSampleStatus;
|
|
84
|
+
var init_types = __esm({
|
|
85
|
+
"dist/terrain/types.js"() {
|
|
86
|
+
TerrainSampleStatus = {
|
|
87
|
+
VALID: 0,
|
|
88
|
+
OUTSIDE_DOMAIN: 1,
|
|
89
|
+
NO_DATA: 2,
|
|
90
|
+
INVALID_INPUT: 3,
|
|
91
|
+
NUMERIC_ERROR: 4,
|
|
92
|
+
UNAVAILABLE: 5,
|
|
93
|
+
NOT_RESIDENT: 6
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// dist/terrain/height-field.js
|
|
99
|
+
var height_field_exports = {};
|
|
100
|
+
__export(height_field_exports, {
|
|
101
|
+
HeightField: () => HeightField
|
|
102
|
+
});
|
|
103
|
+
function copyVector(value2) {
|
|
104
|
+
if (value2.length !== 2 || !value2.every(Number.isFinite))
|
|
105
|
+
throw new Error("Grid vectors must be finite XY pairs");
|
|
106
|
+
return Object.freeze([value2[0], value2[1]]);
|
|
107
|
+
}
|
|
108
|
+
function createSample() {
|
|
109
|
+
return {
|
|
110
|
+
status: TerrainSampleStatus.NO_DATA,
|
|
111
|
+
height: 0,
|
|
112
|
+
gradientStatus: TerrainSampleStatus.NO_DATA,
|
|
113
|
+
gradientX: 0,
|
|
114
|
+
gradientY: 0,
|
|
115
|
+
normalX: 0,
|
|
116
|
+
normalY: 0,
|
|
117
|
+
normalZ: 0
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function resetSample(result, status) {
|
|
121
|
+
result.status = status;
|
|
122
|
+
result.gradientStatus = status;
|
|
123
|
+
result.height = result.gradientX = result.gradientY = result.normalX = result.normalY = result.normalZ = 0;
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
function isTerrainArray(value2) {
|
|
127
|
+
return value2 instanceof Float32Array || value2 instanceof Float64Array;
|
|
128
|
+
}
|
|
129
|
+
function validateBatch(positions, output) {
|
|
130
|
+
if (!isTerrainArray(positions) || positions.length % 2 !== 0) {
|
|
131
|
+
throw new Error("Terrain batch positions must contain Float32/Float64 XY pairs");
|
|
132
|
+
}
|
|
133
|
+
const count = positions.length / 2;
|
|
134
|
+
const buffers = [positions];
|
|
135
|
+
for (const [key3, size] of [
|
|
136
|
+
["heights", 1],
|
|
137
|
+
["statuses", 1],
|
|
138
|
+
["gradients", 2],
|
|
139
|
+
["normals", 3],
|
|
140
|
+
["gradientStatuses", 1]
|
|
141
|
+
]) {
|
|
142
|
+
const buffer = output[key3];
|
|
143
|
+
if (buffer === void 0 && key3 !== "heights" && key3 !== "statuses")
|
|
144
|
+
continue;
|
|
145
|
+
const byte = key3 === "statuses" || key3 === "gradientStatuses";
|
|
146
|
+
if ((byte ? !(buffer instanceof Uint8Array) : !isTerrainArray(buffer)) || buffer.length < count * size) {
|
|
147
|
+
throw new Error(`Terrain batch ${key3} has an invalid type or insufficient length`);
|
|
148
|
+
}
|
|
149
|
+
for (const other of buffers) {
|
|
150
|
+
if (buffer.buffer === other.buffer && buffer.byteOffset < other.byteOffset + other.byteLength && other.byteOffset < buffer.byteOffset + buffer.byteLength) {
|
|
151
|
+
throw new Error("Terrain batch input and output buffers must not overlap");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
buffers.push(buffer);
|
|
155
|
+
}
|
|
156
|
+
if ((output.gradients || output.normals) && !output.gradientStatuses) {
|
|
157
|
+
throw new Error("Terrain batch derivatives require gradientStatuses");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
var HeightField;
|
|
161
|
+
var init_height_field = __esm({
|
|
162
|
+
"dist/terrain/height-field.js"() {
|
|
163
|
+
init_types();
|
|
164
|
+
HeightField = class {
|
|
165
|
+
constructor(props) {
|
|
166
|
+
this.batchSample = createSample();
|
|
167
|
+
const { width, height: height2, heights, validity, offset = 0, stride = width } = props;
|
|
168
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height2) || height2 < 2) {
|
|
169
|
+
throw new Error("HeightField width and height must be integers >= 2");
|
|
170
|
+
}
|
|
171
|
+
if (!isTerrainArray(heights) || validity !== void 0 && !(validity instanceof Uint8Array)) {
|
|
172
|
+
throw new Error("HeightField requires Float32/Float64 heights and an optional Uint8 validity mask");
|
|
173
|
+
}
|
|
174
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(stride) || stride < width) {
|
|
175
|
+
throw new Error("HeightField offset must be nonnegative and stride must be >= width");
|
|
176
|
+
}
|
|
177
|
+
const end = offset + (height2 - 1) * stride + width;
|
|
178
|
+
if (!Number.isSafeInteger(end) || end > heights.length || validity && end > validity.length) {
|
|
179
|
+
throw new Error("HeightField input buffers are too small");
|
|
180
|
+
}
|
|
181
|
+
this.width = width;
|
|
182
|
+
this.height = height2;
|
|
183
|
+
this.origin = copyVector(props.origin ?? [0, 0]);
|
|
184
|
+
this.columnStep = copyVector(props.columnStep ?? [1, 0]);
|
|
185
|
+
this.rowStep = copyVector(props.rowStep ?? [0, 1]);
|
|
186
|
+
this.registration = props.registration ?? "vertex";
|
|
187
|
+
this.diagonal = props.diagonal ?? "00-11";
|
|
188
|
+
this.heightReference = props.heightReference ?? "unknown";
|
|
189
|
+
if (this.registration !== "vertex" && this.registration !== "cell") {
|
|
190
|
+
throw new Error("HeightField registration must be vertex or cell");
|
|
191
|
+
}
|
|
192
|
+
if (this.diagonal !== "00-11" && this.diagonal !== "10-01") {
|
|
193
|
+
throw new Error("HeightField diagonal must be 00-11 or 10-01");
|
|
194
|
+
}
|
|
195
|
+
if (typeof this.heightReference !== "string") {
|
|
196
|
+
throw new Error("HeightField heightReference must be a string");
|
|
197
|
+
}
|
|
198
|
+
const [a, c] = this.columnStep;
|
|
199
|
+
const [b, d] = this.rowStep;
|
|
200
|
+
const determinant = a * d - b * c;
|
|
201
|
+
const scale3 = Math.hypot(a, c) * Math.hypot(b, d);
|
|
202
|
+
if (!Number.isFinite(determinant) || Math.abs(determinant) <= Number.EPSILON * scale3) {
|
|
203
|
+
throw new Error("HeightField grid transform must be finite and nonsingular");
|
|
204
|
+
}
|
|
205
|
+
this.inverse = [d / determinant, -b / determinant, -c / determinant, a / determinant];
|
|
206
|
+
if (!this.inverse.every(Number.isFinite)) {
|
|
207
|
+
throw new Error("HeightField inverse transform must be finite");
|
|
208
|
+
}
|
|
209
|
+
this.heights = heights instanceof Float64Array ? new Float64Array(width * height2) : new Float32Array(width * height2);
|
|
210
|
+
this.validity = new Uint8Array(width * height2);
|
|
211
|
+
let min2 = Infinity;
|
|
212
|
+
let max2 = -Infinity;
|
|
213
|
+
let validCount = 0;
|
|
214
|
+
for (let row = 0; row < height2; row++) {
|
|
215
|
+
for (let column = 0; column < width; column++) {
|
|
216
|
+
const input = offset + row * stride + column;
|
|
217
|
+
const output = row * width + column;
|
|
218
|
+
const value2 = heights[input];
|
|
219
|
+
if (Number.isFinite(value2) && (!validity || validity[input] !== 0)) {
|
|
220
|
+
this.heights[output] = value2;
|
|
221
|
+
this.validity[output] = 1;
|
|
222
|
+
min2 = Math.min(min2, value2);
|
|
223
|
+
max2 = Math.max(max2, value2);
|
|
224
|
+
validCount++;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
this.validCount = validCount;
|
|
229
|
+
this.heightRange = validCount ? Object.freeze([min2, max2]) : void 0;
|
|
230
|
+
}
|
|
231
|
+
/** Reads an original grid sample, independently of interpolation footprints. */
|
|
232
|
+
getHeight(column, row) {
|
|
233
|
+
if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= this.width || row >= this.height)
|
|
234
|
+
return void 0;
|
|
235
|
+
const index = row * this.width + column;
|
|
236
|
+
return this.validity[index] ? this.heights[index] : void 0;
|
|
237
|
+
}
|
|
238
|
+
/** Independent, tightly packed copies, suitable for worker transfer or GPU preparation. */
|
|
239
|
+
copyData() {
|
|
240
|
+
return { heights: this.heights.slice(), validity: this.validity.slice() };
|
|
241
|
+
}
|
|
242
|
+
/** Samples world XY in meters. Supply result to avoid allocating a result object. */
|
|
243
|
+
sample(x, y, options, result = createSample()) {
|
|
244
|
+
resetSample(result, TerrainSampleStatus.INVALID_INPUT);
|
|
245
|
+
const interpolation = (options == null ? void 0 : options.interpolation) ?? "bilinear";
|
|
246
|
+
if (interpolation !== "nearest" && interpolation !== "bilinear" && interpolation !== "triangle") {
|
|
247
|
+
throw new Error("Unknown terrain interpolation");
|
|
248
|
+
}
|
|
249
|
+
const domain = (options == null ? void 0 : options.domain) ?? "samples";
|
|
250
|
+
const noData = (options == null ? void 0 : options.noData) ?? "cell";
|
|
251
|
+
if (domain !== "samples" && domain !== "footprint")
|
|
252
|
+
throw new Error("Unknown terrain sample domain");
|
|
253
|
+
if (noData !== "cell" && noData !== "support")
|
|
254
|
+
throw new Error("Unknown terrain nodata policy");
|
|
255
|
+
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
256
|
+
return result;
|
|
257
|
+
const dx = x - this.origin[0];
|
|
258
|
+
const dy = y - this.origin[1];
|
|
259
|
+
const offset = this.registration === "cell" ? 0.5 : 0;
|
|
260
|
+
let u = this.inverse[0] * dx + this.inverse[1] * dy - offset;
|
|
261
|
+
let v = this.inverse[2] * dx + this.inverse[3] * dy - offset;
|
|
262
|
+
if (!Number.isFinite(u) || !Number.isFinite(v))
|
|
263
|
+
return resetSample(result, TerrainSampleStatus.NUMERIC_ERROR);
|
|
264
|
+
const tolerance = 8 * Number.EPSILON * Math.max(this.width, this.height);
|
|
265
|
+
const errorX = 4 * Number.EPSILON * Math.abs(x) + 4 * Number.EPSILON * Math.abs(this.origin[0]);
|
|
266
|
+
const errorY = 4 * Number.EPSILON * Math.abs(y) + 4 * Number.EPSILON * Math.abs(this.origin[1]);
|
|
267
|
+
const toleranceU = tolerance + Math.abs(this.inverse[0]) * errorX + Math.abs(this.inverse[1]) * errorY;
|
|
268
|
+
const toleranceV = tolerance + Math.abs(this.inverse[2]) * errorX + Math.abs(this.inverse[3]) * errorY;
|
|
269
|
+
const margin = domain === "footprint" && this.registration === "cell" ? 0.5 : 0;
|
|
270
|
+
if (u < -margin - toleranceU || v < -margin - toleranceV || u > this.width - 1 + margin + toleranceU || v > this.height - 1 + margin + toleranceV) {
|
|
271
|
+
return resetSample(result, TerrainSampleStatus.OUTSIDE_DOMAIN);
|
|
272
|
+
}
|
|
273
|
+
const edgeToleranceU = Math.min(1e-6, toleranceU);
|
|
274
|
+
const edgeToleranceV = Math.min(1e-6, toleranceV);
|
|
275
|
+
const clampedColumn = margin > 0 && (u < -edgeToleranceU || u > this.width - 1 + edgeToleranceU);
|
|
276
|
+
const clampedRow = margin > 0 && (v < -edgeToleranceV || v > this.height - 1 + edgeToleranceV);
|
|
277
|
+
u = Math.max(0, Math.min(this.width - 1, u));
|
|
278
|
+
v = Math.max(0, Math.min(this.height - 1, v));
|
|
279
|
+
if (noData === "support" && interpolation === "bilinear") {
|
|
280
|
+
const column2 = Math.round(u), row2 = Math.round(v);
|
|
281
|
+
if (Math.abs(u - column2) <= Math.min(1e-6, toleranceU))
|
|
282
|
+
u = column2;
|
|
283
|
+
if (Math.abs(v - row2) <= Math.min(1e-6, toleranceV))
|
|
284
|
+
v = row2;
|
|
285
|
+
}
|
|
286
|
+
if (interpolation === "nearest") {
|
|
287
|
+
const value2 = this.getHeight(Math.floor(u + 0.5), Math.floor(v + 0.5));
|
|
288
|
+
if (value2 === void 0)
|
|
289
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
290
|
+
result.status = TerrainSampleStatus.VALID;
|
|
291
|
+
result.height = value2;
|
|
292
|
+
result.gradientStatus = TerrainSampleStatus.UNAVAILABLE;
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
const column = Math.min(Math.floor(u), this.width - 2);
|
|
296
|
+
const row = Math.min(Math.floor(v), this.height - 2);
|
|
297
|
+
u -= column;
|
|
298
|
+
v -= row;
|
|
299
|
+
const a = row * this.width + column;
|
|
300
|
+
const b = a + 1;
|
|
301
|
+
const c = a + this.width;
|
|
302
|
+
const d = c + 1;
|
|
303
|
+
const za = this.heights[a];
|
|
304
|
+
const zb = this.heights[b];
|
|
305
|
+
const zc = this.heights[c];
|
|
306
|
+
const zd = this.heights[d];
|
|
307
|
+
let du;
|
|
308
|
+
let dv;
|
|
309
|
+
if (interpolation === "bilinear") {
|
|
310
|
+
if (!this.validity[a] || !this.validity[b] || !this.validity[c] || !this.validity[d]) {
|
|
311
|
+
if (noData === "cell")
|
|
312
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
313
|
+
const weightA = (1 - u) * (1 - v);
|
|
314
|
+
const weightB = u * (1 - v);
|
|
315
|
+
const weightC = (1 - u) * v;
|
|
316
|
+
const weightD = u * v;
|
|
317
|
+
if (weightA > 0 && !this.validity[a] || weightB > 0 && !this.validity[b] || weightC > 0 && !this.validity[c] || weightD > 0 && !this.validity[d])
|
|
318
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
319
|
+
const height2 = weightA * za + weightB * zb + weightC * zc + weightD * zd;
|
|
320
|
+
if (!Number.isFinite(height2))
|
|
321
|
+
return resetSample(result, TerrainSampleStatus.NUMERIC_ERROR);
|
|
322
|
+
result.status = TerrainSampleStatus.VALID;
|
|
323
|
+
result.height = height2;
|
|
324
|
+
result.gradientStatus = TerrainSampleStatus.NO_DATA;
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
result.height = (1 - v) * ((1 - u) * za + u * zb) + v * ((1 - u) * zc + u * zd);
|
|
328
|
+
du = (1 - v) * (zb - za) + v * (zd - zc);
|
|
329
|
+
dv = (1 - u) * (zc - za) + u * (zd - zb);
|
|
330
|
+
} else if (this.diagonal === "00-11" ? v <= u : u + v <= 1) {
|
|
331
|
+
const last = this.diagonal === "00-11" ? d : c;
|
|
332
|
+
if (!this.validity[a] || !this.validity[b] || !this.validity[last]) {
|
|
333
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
334
|
+
}
|
|
335
|
+
du = zb - za;
|
|
336
|
+
dv = this.diagonal === "00-11" ? zd - zb : zc - za;
|
|
337
|
+
result.height = this.diagonal === "00-11" ? (1 - u) * za + (u - v) * zb + v * zd : (1 - u - v) * za + u * zb + v * zc;
|
|
338
|
+
} else {
|
|
339
|
+
const first = this.diagonal === "00-11" ? a : b;
|
|
340
|
+
if (!this.validity[first] || !this.validity[c] || !this.validity[d]) {
|
|
341
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
342
|
+
}
|
|
343
|
+
du = zd - zc;
|
|
344
|
+
dv = this.diagonal === "00-11" ? zc - za : zd - zb;
|
|
345
|
+
result.height = this.diagonal === "00-11" ? (1 - v) * za + u * zd + (v - u) * zc : (1 - v) * zb + (1 - u) * zc + (u + v - 1) * zd;
|
|
346
|
+
}
|
|
347
|
+
if (!Number.isFinite(result.height))
|
|
348
|
+
return resetSample(result, TerrainSampleStatus.NUMERIC_ERROR);
|
|
349
|
+
result.status = TerrainSampleStatus.VALID;
|
|
350
|
+
if (clampedColumn)
|
|
351
|
+
du = 0;
|
|
352
|
+
if (clampedRow)
|
|
353
|
+
dv = 0;
|
|
354
|
+
const gx = du * this.inverse[0] + dv * this.inverse[2];
|
|
355
|
+
const gy = du * this.inverse[1] + dv * this.inverse[3];
|
|
356
|
+
if (!Number.isFinite(gx) || !Number.isFinite(gy)) {
|
|
357
|
+
result.gradientStatus = TerrainSampleStatus.NUMERIC_ERROR;
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
const normalScale = Math.max(Math.abs(gx), Math.abs(gy), 1);
|
|
361
|
+
const nx = -gx / normalScale;
|
|
362
|
+
const ny = -gy / normalScale;
|
|
363
|
+
const nz = 1 / normalScale;
|
|
364
|
+
const length = Math.hypot(nx, ny, nz);
|
|
365
|
+
result.gradientStatus = TerrainSampleStatus.VALID;
|
|
366
|
+
result.gradientX = gx;
|
|
367
|
+
result.gradientY = gy;
|
|
368
|
+
result.normalX = nx / length;
|
|
369
|
+
result.normalY = ny / length;
|
|
370
|
+
result.normalZ = nz / length;
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
/** Interleaved XY inputs and caller-owned outputs, with no per-sample allocation. */
|
|
374
|
+
sampleBatch(positions, output, options) {
|
|
375
|
+
validateBatch(positions, output);
|
|
376
|
+
for (let i = 0; i < positions.length / 2; i++) {
|
|
377
|
+
const sample2 = this.sample(positions[2 * i], positions[2 * i + 1], options, this.batchSample);
|
|
378
|
+
output.heights[i] = sample2.height;
|
|
379
|
+
if (!Number.isFinite(output.heights[i])) {
|
|
380
|
+
resetSample(sample2, TerrainSampleStatus.NUMERIC_ERROR);
|
|
381
|
+
output.heights[i] = 0;
|
|
382
|
+
}
|
|
383
|
+
if (output.gradients) {
|
|
384
|
+
output.gradients[2 * i] = sample2.gradientX;
|
|
385
|
+
output.gradients[2 * i + 1] = sample2.gradientY;
|
|
386
|
+
if (!Number.isFinite(output.gradients[2 * i]) || !Number.isFinite(output.gradients[2 * i + 1])) {
|
|
387
|
+
output.gradients[2 * i] = output.gradients[2 * i + 1] = 0;
|
|
388
|
+
sample2.gradientStatus = TerrainSampleStatus.NUMERIC_ERROR;
|
|
389
|
+
sample2.normalX = sample2.normalY = sample2.normalZ = 0;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (output.normals) {
|
|
393
|
+
output.normals[3 * i] = sample2.normalX;
|
|
394
|
+
output.normals[3 * i + 1] = sample2.normalY;
|
|
395
|
+
output.normals[3 * i + 2] = sample2.normalZ;
|
|
396
|
+
}
|
|
397
|
+
output.statuses[i] = sample2.status;
|
|
398
|
+
if (output.gradientStatuses)
|
|
399
|
+
output.gradientStatuses[i] = sample2.gradientStatus;
|
|
400
|
+
}
|
|
401
|
+
return output;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// dist/terrain/sample-triangle-height.js
|
|
408
|
+
function sampleTerrainTriangleHeight(field, x, y) {
|
|
409
|
+
if (Number.isInteger(x) && Number.isInteger(y))
|
|
410
|
+
return field.getHeight(x, y);
|
|
411
|
+
const column = Math.min(Math.floor(x), field.width - 2);
|
|
412
|
+
const row = Math.min(Math.floor(y), field.height - 2);
|
|
413
|
+
const u = x - column, v = y - row;
|
|
414
|
+
let a, b, c, d;
|
|
415
|
+
if (field.diagonal === "00-11") {
|
|
416
|
+
if (v <= u) {
|
|
417
|
+
a = 1 - u;
|
|
418
|
+
b = u - v;
|
|
419
|
+
c = 0;
|
|
420
|
+
d = v;
|
|
421
|
+
} else {
|
|
422
|
+
a = 1 - v;
|
|
423
|
+
b = 0;
|
|
424
|
+
c = v - u;
|
|
425
|
+
d = u;
|
|
426
|
+
}
|
|
427
|
+
} else if (u + v <= 1) {
|
|
428
|
+
a = 1 - u - v;
|
|
429
|
+
b = u;
|
|
430
|
+
c = v;
|
|
431
|
+
d = 0;
|
|
432
|
+
} else {
|
|
433
|
+
a = 0;
|
|
434
|
+
b = 1 - v;
|
|
435
|
+
c = 1 - u;
|
|
436
|
+
d = u + v - 1;
|
|
437
|
+
}
|
|
438
|
+
const za = a ? field.getHeight(column, row) : 0;
|
|
439
|
+
const zb = b ? field.getHeight(column + 1, row) : 0;
|
|
440
|
+
const zc = c ? field.getHeight(column, row + 1) : 0;
|
|
441
|
+
const zd = d ? field.getHeight(column + 1, row + 1) : 0;
|
|
442
|
+
if (za === void 0 || zb === void 0 || zc === void 0 || zd === void 0)
|
|
443
|
+
return void 0;
|
|
444
|
+
const height2 = a * za + b * zb + c * zc + d * zd;
|
|
445
|
+
if (!Number.isFinite(height2))
|
|
446
|
+
throw new Error("Terrain triangle numeric sampling failure");
|
|
447
|
+
return height2;
|
|
448
|
+
}
|
|
449
|
+
var init_sample_triangle_height = __esm({
|
|
450
|
+
"dist/terrain/sample-triangle-height.js"() {
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
// dist/terrain/mixed-vertex-halos.js
|
|
455
|
+
function buildMixedVertexTileHalos(tiles, options = {}, targets, preparation) {
|
|
456
|
+
const maxSamples = options.maxSamples ?? 4e6, maxTests = options.maxTileTests ?? 1e7;
|
|
457
|
+
if (![maxSamples, maxTests].every((v) => Number.isSafeInteger(v) && v >= 0))
|
|
458
|
+
throw new Error("Invalid mixed halo capacity");
|
|
459
|
+
let count = 0;
|
|
460
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
461
|
+
let frame;
|
|
462
|
+
const sources = [...tiles].sort((a, b) => a.spacing - b.spacing || a.column - b.column || a.row - b.row).map((tile) => {
|
|
463
|
+
if (![tile.column, tile.row, tile.spacing].every(Number.isSafeInteger) || tile.spacing < 1 || 2 ** Math.round(Math.log2(tile.spacing)) !== tile.spacing)
|
|
464
|
+
throw new Error("Invalid mixed halo lattice");
|
|
465
|
+
const key3 = `${tile.spacing}/${tile.column}/${tile.row}`;
|
|
466
|
+
if (addresses.has(key3))
|
|
467
|
+
throw new Error("Duplicate mixed halo tile");
|
|
468
|
+
addresses.add(key3);
|
|
469
|
+
count += (tile.field.width + 2) * (tile.field.height + 2);
|
|
470
|
+
if (!Number.isSafeInteger(count) || count > maxSamples)
|
|
471
|
+
throw new Error("Mixed halo sample capacity exceeded");
|
|
472
|
+
let field = preparation == null ? void 0 : preparation.fields.get(tile);
|
|
473
|
+
if (!field) {
|
|
474
|
+
field = new HeightField(tile.field);
|
|
475
|
+
preparation == null ? void 0 : preparation.fields.set(tile, field);
|
|
476
|
+
}
|
|
477
|
+
if (field.registration !== "vertex")
|
|
478
|
+
throw new Error("Mixed halos require vertex registration");
|
|
479
|
+
const column = field.columnStep.map((v) => v / tile.spacing);
|
|
480
|
+
const row = field.rowStep.map((v) => v / tile.spacing);
|
|
481
|
+
const origin = field.origin.map((v, axis) => v - tile.column * column[axis] - tile.row * row[axis]);
|
|
482
|
+
const scale3 = field.origin.map((v, i) => Math.max(1, Math.abs(v), Math.abs(tile.column * column[i]), Math.abs(tile.row * row[i])));
|
|
483
|
+
if (!origin.every(Number.isFinite))
|
|
484
|
+
throw new Error("Mixed halo coordinate overflow");
|
|
485
|
+
if (frame && (frame.reference !== field.heightReference || column.some((v, i) => v !== frame.column[i]) || row.some((v, i) => v !== frame.row[i]) || origin.some((v, i) => Math.abs(v - frame.origin[i]) > Math.min(16 * Number.EPSILON * Math.max(scale3[i], frame.scale[i]), 1e-9 * Math.max(Math.abs(column[i]), Math.abs(row[i]))))))
|
|
486
|
+
throw new Error("Mixed halo frames or height references differ");
|
|
487
|
+
frame ?? (frame = { origin, column, row, reference: field.heightReference, scale: scale3 });
|
|
488
|
+
return { ...tile, source: field };
|
|
489
|
+
});
|
|
490
|
+
for (const axis of ["column", "row"]) {
|
|
491
|
+
let min2 = Infinity, max2 = -Infinity;
|
|
492
|
+
for (const tile of sources) {
|
|
493
|
+
const size = axis === "column" ? tile.source.width : tile.source.height;
|
|
494
|
+
const low = tile[axis] - tile.spacing, high = tile[axis] + size * tile.spacing;
|
|
495
|
+
if (![low, high].every(Number.isSafeInteger))
|
|
496
|
+
throw new Error("Mixed halo lattice overflow");
|
|
497
|
+
min2 = Math.min(min2, low);
|
|
498
|
+
max2 = Math.max(max2, high);
|
|
499
|
+
}
|
|
500
|
+
if (sources.length && !Number.isSafeInteger(max2 - min2))
|
|
501
|
+
throw new Error("Mixed halo lattice span overflow");
|
|
502
|
+
}
|
|
503
|
+
if (targets && targets.size === 0)
|
|
504
|
+
return { tiles: [] };
|
|
505
|
+
let index;
|
|
506
|
+
if (sources.length > 8) {
|
|
507
|
+
const keys = preparation && sources.map((tile) => `${tile.spacing}/${tile.column}/${tile.row}/${tile.source.width}/${tile.source.height}`);
|
|
508
|
+
const cached = preparation == null ? void 0 : preparation.layout;
|
|
509
|
+
if (keys && cached && keys.length === cached.keys.length && keys.every((key3, i) => key3 === cached.keys[i])) {
|
|
510
|
+
index = cached.query;
|
|
511
|
+
} else {
|
|
512
|
+
index = createTerrainBoxIndex(sources.map((tile) => ({
|
|
513
|
+
minX: tile.column,
|
|
514
|
+
minY: tile.row,
|
|
515
|
+
maxX: tile.column + (tile.source.width - 1) * tile.spacing,
|
|
516
|
+
maxY: tile.row + (tile.source.height - 1) * tile.spacing
|
|
517
|
+
})));
|
|
518
|
+
if (preparation && keys)
|
|
519
|
+
preparation.layout = { keys, query: index };
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
let tests = 0;
|
|
523
|
+
const charge = () => {
|
|
524
|
+
if (++tests > maxTests)
|
|
525
|
+
throw new Error("Mixed halo tile-test budget exceeded");
|
|
526
|
+
};
|
|
527
|
+
return {
|
|
528
|
+
tiles: sources.filter((tile) => !targets || targets.has(`${tile.spacing}/${tile.column}/${tile.row}`)).map((tile) => {
|
|
529
|
+
const source = tile.source, width = source.width + 2, height2 = source.height + 2;
|
|
530
|
+
const heights = new Float64Array(width * height2), validity = new Uint8Array(heights.length), statuses = new Uint8Array(heights.length);
|
|
531
|
+
const candidates = (index == null ? void 0 : index({
|
|
532
|
+
minX: tile.column - tile.spacing,
|
|
533
|
+
minY: tile.row - tile.spacing,
|
|
534
|
+
maxX: tile.column + source.width * tile.spacing,
|
|
535
|
+
maxY: tile.row + source.height * tile.spacing
|
|
536
|
+
}, charge).map((id) => sources[id])) ?? sources;
|
|
537
|
+
for (let y = 0; y < height2; y++)
|
|
538
|
+
for (let x = 0; x < width; x++) {
|
|
539
|
+
const gx = tile.column + (x - 1) * tile.spacing, gy = tile.row + (y - 1) * tile.spacing;
|
|
540
|
+
if (![gx, gy].every(Number.isSafeInteger))
|
|
541
|
+
throw new Error("Mixed halo lattice overflow");
|
|
542
|
+
for (const candidate of candidates) {
|
|
543
|
+
charge();
|
|
544
|
+
const cx = (gx - candidate.column) / candidate.spacing, cy = (gy - candidate.row) / candidate.spacing;
|
|
545
|
+
const f = candidate.source;
|
|
546
|
+
if (cx < 0 || cy < 0 || cx > f.width - 1 || cy > f.height - 1)
|
|
547
|
+
continue;
|
|
548
|
+
const value2 = sampleTerrainTriangleHeight(f, cx, cy);
|
|
549
|
+
const i = y * width + x;
|
|
550
|
+
statuses[i] = value2 === void 0 ? 1 : 2;
|
|
551
|
+
if (value2 !== void 0) {
|
|
552
|
+
heights[i] = value2;
|
|
553
|
+
validity[i] = 1;
|
|
554
|
+
}
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
const origin = [
|
|
559
|
+
source.origin[0] - source.columnStep[0] - source.rowStep[0],
|
|
560
|
+
source.origin[1] - source.columnStep[1] - source.rowStep[1]
|
|
561
|
+
];
|
|
562
|
+
if (!origin.every(Number.isFinite))
|
|
563
|
+
throw new Error("Mixed halo coordinate overflow");
|
|
564
|
+
return {
|
|
565
|
+
column: tile.column,
|
|
566
|
+
row: tile.row,
|
|
567
|
+
spacing: tile.spacing,
|
|
568
|
+
statuses,
|
|
569
|
+
field: {
|
|
570
|
+
...tile.field,
|
|
571
|
+
width,
|
|
572
|
+
height: height2,
|
|
573
|
+
heights,
|
|
574
|
+
validity,
|
|
575
|
+
offset: 0,
|
|
576
|
+
stride: width,
|
|
577
|
+
origin,
|
|
578
|
+
columnStep: [...source.columnStep],
|
|
579
|
+
rowStep: [...source.rowStep]
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
})
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
var init_mixed_vertex_halos = __esm({
|
|
586
|
+
"dist/terrain/mixed-vertex-halos.js"() {
|
|
587
|
+
init_box_index();
|
|
588
|
+
init_height_field();
|
|
589
|
+
init_sample_triangle_height();
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// dist/terrain/mixed-halo-update.js
|
|
594
|
+
var mixed_halo_update_exports = {};
|
|
595
|
+
__export(mixed_halo_update_exports, {
|
|
596
|
+
updateTerrainMixedVertexTileHalos: () => updateTerrainMixedVertexTileHalos
|
|
597
|
+
});
|
|
598
|
+
function editedBounds(old, next) {
|
|
599
|
+
const a = old.field;
|
|
600
|
+
const b = next.field;
|
|
601
|
+
if (a.width !== b.width || a.height !== b.height || (a.diagonal ?? "00-11") !== (b.diagonal ?? "00-11"))
|
|
602
|
+
return bounds(next);
|
|
603
|
+
const sample2 = (field, x, y) => {
|
|
604
|
+
const i = (field.offset ?? 0) + y * (field.stride ?? field.width) + x;
|
|
605
|
+
const z = field.heights[i];
|
|
606
|
+
return Number.isFinite(z) && (field.validity === void 0 || field.validity[i] !== 0) ? z : void 0;
|
|
607
|
+
};
|
|
608
|
+
let left = b.width, right = -1, top = b.height, bottom = -1;
|
|
609
|
+
for (let y = 0; y < b.height; y++) {
|
|
610
|
+
for (let x = 0; x < b.width; x++) {
|
|
611
|
+
if (Object.is(sample2(a, x, y), sample2(b, x, y)))
|
|
612
|
+
continue;
|
|
613
|
+
left = Math.min(left, x);
|
|
614
|
+
right = Math.max(right, x);
|
|
615
|
+
top = Math.min(top, y);
|
|
616
|
+
bottom = Math.max(bottom, y);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (right < 0)
|
|
620
|
+
return null;
|
|
621
|
+
return {
|
|
622
|
+
minX: next.column + Math.max(0, left - 1) * next.spacing,
|
|
623
|
+
maxX: next.column + Math.min(b.width - 1, right + 1) * next.spacing,
|
|
624
|
+
minY: next.row + Math.max(0, top - 1) * next.spacing,
|
|
625
|
+
maxY: next.row + Math.min(b.height - 1, bottom + 1) * next.spacing
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function updateTerrainMixedVertexTileHalos(previous, resident, options = {}) {
|
|
629
|
+
const budget = options.maxDependencyTests ?? 1e7;
|
|
630
|
+
if (!Number.isSafeInteger(budget) || budget < 0)
|
|
631
|
+
throw new Error("Invalid mixed halo dependency budget");
|
|
632
|
+
const old = new Map(previous == null ? void 0 : previous.sources.map((t) => [key(t), t]));
|
|
633
|
+
const current = new Map(resident.map((t) => [key(t), t]));
|
|
634
|
+
const cached = new Map(previous == null ? void 0 : previous.tiles.map((t) => [key(t), t]));
|
|
635
|
+
const targets = /* @__PURE__ */ new Set();
|
|
636
|
+
const unchangedLayout = (previous == null ? void 0 : previous.sources.length) === resident.length && resident.every((tile, i) => {
|
|
637
|
+
const prior = previous.sources[i];
|
|
638
|
+
return key(prior) === key(tile) && prior.field.width === tile.field.width && prior.field.height === tile.field.height;
|
|
639
|
+
});
|
|
640
|
+
let index = unchangedLayout && previous ? targetIndexes.get(previous) : void 0;
|
|
641
|
+
let tests = 0;
|
|
642
|
+
const charge = () => {
|
|
643
|
+
if (++tests > budget)
|
|
644
|
+
throw new Error("Mixed halo dependency budget exceeded");
|
|
645
|
+
};
|
|
646
|
+
function invalidate(box) {
|
|
647
|
+
index ?? (index = createTerrainBoxIndex(resident.map((tile) => bounds(tile, tile.spacing))));
|
|
648
|
+
for (const id of index(box, charge))
|
|
649
|
+
targets.add(key(resident[id]));
|
|
650
|
+
}
|
|
651
|
+
for (const tile of resident) {
|
|
652
|
+
const address = key(tile);
|
|
653
|
+
const prior = old.get(address);
|
|
654
|
+
if (!cached.has(address) || prior !== tile)
|
|
655
|
+
targets.add(address);
|
|
656
|
+
if (prior === tile || !previous)
|
|
657
|
+
continue;
|
|
658
|
+
if (!prior) {
|
|
659
|
+
invalidate(bounds(tile));
|
|
660
|
+
} else if (prior.field.width !== tile.field.width || prior.field.height !== tile.field.height) {
|
|
661
|
+
invalidate(bounds(prior));
|
|
662
|
+
invalidate(bounds(tile));
|
|
663
|
+
} else {
|
|
664
|
+
const dirty = editedBounds(prior, tile);
|
|
665
|
+
if (dirty)
|
|
666
|
+
invalidate(dirty);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
for (const [address, tile] of old) {
|
|
670
|
+
if (!current.has(address) && resident.length)
|
|
671
|
+
invalidate(bounds(tile));
|
|
672
|
+
}
|
|
673
|
+
const priorPreparation = previous && preparations.get(previous);
|
|
674
|
+
const preparation = {
|
|
675
|
+
fields: (priorPreparation == null ? void 0 : priorPreparation.fields) ?? /* @__PURE__ */ new WeakMap(),
|
|
676
|
+
layout: priorPreparation == null ? void 0 : priorPreparation.layout
|
|
677
|
+
};
|
|
678
|
+
const built = buildMixedVertexTileHalos(resident, options, targets, preparation).tiles;
|
|
679
|
+
for (const tile of built)
|
|
680
|
+
cached.set(key(tile), tile);
|
|
681
|
+
const tiles = resident.map((t) => cached.get(key(t))).sort((a, b) => a.spacing - b.spacing || a.column - b.column || a.row - b.row);
|
|
682
|
+
const snapshot2 = {
|
|
683
|
+
sources: resident.slice(),
|
|
684
|
+
tiles,
|
|
685
|
+
rebuilt: built.map(key),
|
|
686
|
+
removed: [...old.keys()].filter((k2) => !current.has(k2)).sort()
|
|
687
|
+
};
|
|
688
|
+
preparations.set(snapshot2, preparation);
|
|
689
|
+
if (index)
|
|
690
|
+
targetIndexes.set(snapshot2, index);
|
|
691
|
+
return snapshot2;
|
|
692
|
+
}
|
|
693
|
+
var key, bounds, preparations, targetIndexes;
|
|
694
|
+
var init_mixed_halo_update = __esm({
|
|
695
|
+
"dist/terrain/mixed-halo-update.js"() {
|
|
696
|
+
init_box_index();
|
|
697
|
+
init_mixed_vertex_halos();
|
|
698
|
+
key = (t) => `${t.spacing}/${t.column}/${t.row}`;
|
|
699
|
+
bounds = (tile, padding = 0) => ({
|
|
700
|
+
minX: tile.column - padding,
|
|
701
|
+
minY: tile.row - padding,
|
|
702
|
+
maxX: tile.column + (tile.field.width - 1) * tile.spacing + padding,
|
|
703
|
+
maxY: tile.row + (tile.field.height - 1) * tile.spacing + padding
|
|
704
|
+
});
|
|
705
|
+
preparations = /* @__PURE__ */ new WeakMap();
|
|
706
|
+
targetIndexes = /* @__PURE__ */ new WeakMap();
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
// dist/terrain/mesh-coverage.js
|
|
711
|
+
var mesh_coverage_exports = {};
|
|
712
|
+
__export(mesh_coverage_exports, {
|
|
713
|
+
certifyTerrainMeshCoverage: () => certifyTerrainMeshCoverage
|
|
714
|
+
});
|
|
715
|
+
function gcd(a, b) {
|
|
716
|
+
if (a < 0n)
|
|
717
|
+
a = -a;
|
|
718
|
+
if (b < 0n)
|
|
719
|
+
b = -b;
|
|
720
|
+
while (b !== 0n)
|
|
721
|
+
[a, b] = [b, a % b];
|
|
722
|
+
return a;
|
|
723
|
+
}
|
|
724
|
+
function certifyTerrainMeshCoverage(field, mesh, options = {}) {
|
|
725
|
+
var _a3, _b2;
|
|
726
|
+
const { reference = "triangle", maxTriangles = 2e6 } = options;
|
|
727
|
+
const referenceMesh = typeof reference === "object" ? reference : null;
|
|
728
|
+
const validShape = (input) => input.indices.length % 3 === 0 && input.gridCoordinates.length % 2 === 0;
|
|
729
|
+
if (!Number.isSafeInteger(maxTriangles) || maxTriangles < 1 || !referenceMesh && reference !== "triangle" && reference !== "bilinear" || !validShape(mesh) || referenceMesh && !validShape(referenceMesh))
|
|
730
|
+
throw new Error("Invalid terrain coverage input");
|
|
731
|
+
const trianglesVisited = mesh.indices.length / 3 + (referenceMesh ? referenceMesh.indices.length / 3 : 2 * (field.width - 1) * (field.height - 1));
|
|
732
|
+
if (trianglesVisited > maxTriangles) {
|
|
733
|
+
return {
|
|
734
|
+
status: "budget-exhausted",
|
|
735
|
+
unmatchedSegments: 0,
|
|
736
|
+
witness: null,
|
|
737
|
+
trianglesVisited: 0,
|
|
738
|
+
residualEdges: 0
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
const bits = new DataView(new ArrayBuffer(8));
|
|
742
|
+
function exact(value2) {
|
|
743
|
+
bits.setFloat64(0, value2);
|
|
744
|
+
const raw = bits.getBigUint64(0);
|
|
745
|
+
const exponent = Number(raw >> 52n & 2047n);
|
|
746
|
+
const fraction = raw & (1n << 52n) - 1n;
|
|
747
|
+
const integer = exponent === 0 ? fraction : (1n << 52n | fraction) << BigInt(exponent - 1);
|
|
748
|
+
return value2 < 0 ? -integer : integer;
|
|
749
|
+
}
|
|
750
|
+
const vertices2 = [];
|
|
751
|
+
const vertexIds = /* @__PURE__ */ new Map();
|
|
752
|
+
const edges = /* @__PURE__ */ new Map();
|
|
753
|
+
function vertex(x, y) {
|
|
754
|
+
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
755
|
+
throw new Error("Nonfinite coverage coordinate");
|
|
756
|
+
const key3 = `${x},${y}`;
|
|
757
|
+
const previous = vertexIds.get(key3);
|
|
758
|
+
if (previous !== void 0)
|
|
759
|
+
return previous;
|
|
760
|
+
const id = vertices2.length;
|
|
761
|
+
vertices2.push([x, y]);
|
|
762
|
+
vertexIds.set(key3, id);
|
|
763
|
+
return id;
|
|
764
|
+
}
|
|
765
|
+
function edge2(a, b, weight) {
|
|
766
|
+
var _a4;
|
|
767
|
+
if (a > b) {
|
|
768
|
+
[a, b] = [b, a];
|
|
769
|
+
weight = -weight;
|
|
770
|
+
}
|
|
771
|
+
const key3 = b < 2 ** 26 ? a * 2 ** 26 + b : `${a},${b}`;
|
|
772
|
+
const sum = (((_a4 = edges.get(key3)) == null ? void 0 : _a4.weight) ?? 0) + weight;
|
|
773
|
+
if (sum === 0)
|
|
774
|
+
edges.delete(key3);
|
|
775
|
+
else
|
|
776
|
+
edges.set(key3, { a, b, weight: sum });
|
|
777
|
+
}
|
|
778
|
+
function triangle(a, b, c, weight) {
|
|
779
|
+
edge2(a, b, weight);
|
|
780
|
+
edge2(b, c, weight);
|
|
781
|
+
edge2(c, a, weight);
|
|
782
|
+
}
|
|
783
|
+
function addMesh({ indices, gridCoordinates }, weight) {
|
|
784
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
785
|
+
const ids = [indices[i], indices[i + 1], indices[i + 2]].map((id) => {
|
|
786
|
+
if (!Number.isSafeInteger(id) || id < 0 || id >= gridCoordinates.length / 2)
|
|
787
|
+
throw new Error("Invalid coverage vertex index");
|
|
788
|
+
return vertex(gridCoordinates[id * 2], gridCoordinates[id * 2 + 1]);
|
|
789
|
+
});
|
|
790
|
+
const [a, b, c] = ids.map((id) => vertices2[id]);
|
|
791
|
+
const left = (b[0] - a[0]) * (c[1] - a[1]);
|
|
792
|
+
const right = (b[1] - a[1]) * (c[0] - a[0]);
|
|
793
|
+
const det = left - right;
|
|
794
|
+
const limit = 8 * Number.EPSILON * (Math.abs(left) + Math.abs(right)) + 8 * Number.MIN_VALUE;
|
|
795
|
+
let sign5 = Math.sign(det);
|
|
796
|
+
if (!Number.isFinite(det) || Math.abs(det) <= limit) {
|
|
797
|
+
const [ax, ay] = a.map(exact), [bx, by] = b.map(exact), [cx, cy] = c.map(exact);
|
|
798
|
+
const determinant = (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
|
|
799
|
+
sign5 = determinant > 0n ? 1 : determinant < 0n ? -1 : 0;
|
|
800
|
+
}
|
|
801
|
+
if (!sign5)
|
|
802
|
+
throw new Error("Degenerate coverage triangle");
|
|
803
|
+
triangle(ids[0], ids[1], ids[2], weight * sign5);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
addMesh(mesh, 1);
|
|
807
|
+
if (referenceMesh)
|
|
808
|
+
addMesh(referenceMesh, -1);
|
|
809
|
+
else
|
|
810
|
+
for (let y = 0; y < field.height - 1; y++) {
|
|
811
|
+
for (let x = 0; x < field.width - 1; x++) {
|
|
812
|
+
const valid = [
|
|
813
|
+
field.getHeight(x, y),
|
|
814
|
+
field.getHeight(x + 1, y),
|
|
815
|
+
field.getHeight(x, y + 1),
|
|
816
|
+
field.getHeight(x + 1, y + 1)
|
|
817
|
+
].map((z) => z !== void 0);
|
|
818
|
+
if (reference === "bilinear" && !valid.every(Boolean))
|
|
819
|
+
continue;
|
|
820
|
+
const corners2 = [
|
|
821
|
+
[x, y],
|
|
822
|
+
[x + 1, y],
|
|
823
|
+
[x, y + 1],
|
|
824
|
+
[x + 1, y + 1]
|
|
825
|
+
];
|
|
826
|
+
const faces = field.diagonal === "00-11" ? [
|
|
827
|
+
[0, 1, 3],
|
|
828
|
+
[0, 3, 2]
|
|
829
|
+
] : [
|
|
830
|
+
[0, 1, 2],
|
|
831
|
+
[1, 3, 2]
|
|
832
|
+
];
|
|
833
|
+
for (const [a, b, c] of faces) {
|
|
834
|
+
if (!valid[a] || !valid[b] || !valid[c])
|
|
835
|
+
continue;
|
|
836
|
+
triangle(vertex(...corners2[a]), vertex(...corners2[b]), vertex(...corners2[c]), -1);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const lines = /* @__PURE__ */ new Map();
|
|
841
|
+
for (const { a, b, weight } of edges.values()) {
|
|
842
|
+
const p = vertices2[a], q = vertices2[b];
|
|
843
|
+
const [x, y] = p.map(exact), [u, v] = q.map(exact);
|
|
844
|
+
const divisor = gcd(u - x, v - y);
|
|
845
|
+
let dx = (u - x) / divisor, dy = (v - y) / divisor;
|
|
846
|
+
if (dx < 0n || dx === 0n && dy < 0n)
|
|
847
|
+
[dx, dy] = [-dx, -dy];
|
|
848
|
+
const key3 = `${dx},${dy},${dx * y - dy * x}`;
|
|
849
|
+
let events = lines.get(key3);
|
|
850
|
+
if (!events) {
|
|
851
|
+
events = /* @__PURE__ */ new Map();
|
|
852
|
+
lines.set(key3, events);
|
|
853
|
+
}
|
|
854
|
+
const axis = dx === 0n ? 1 : 0;
|
|
855
|
+
const delta = weight;
|
|
856
|
+
events.set(p[axis], { point: p, delta: (((_a3 = events.get(p[axis])) == null ? void 0 : _a3.delta) ?? 0) + delta });
|
|
857
|
+
events.set(q[axis], { point: q, delta: (((_b2 = events.get(q[axis])) == null ? void 0 : _b2.delta) ?? 0) - delta });
|
|
858
|
+
}
|
|
859
|
+
let unmatchedSegments = 0;
|
|
860
|
+
let witness = null;
|
|
861
|
+
for (const events of lines.values()) {
|
|
862
|
+
const sorted = [...events].sort(([a], [b]) => a - b);
|
|
863
|
+
let jump = 0;
|
|
864
|
+
for (let i = 0; i + 1 < sorted.length; i++) {
|
|
865
|
+
jump += sorted[i][1].delta;
|
|
866
|
+
if (!jump)
|
|
867
|
+
continue;
|
|
868
|
+
unmatchedSegments++;
|
|
869
|
+
witness ?? (witness = { start: sorted[i][1].point, end: sorted[i + 1][1].point, multiplicityJump: jump });
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return {
|
|
873
|
+
status: unmatchedSegments ? "mismatch" : "certified",
|
|
874
|
+
unmatchedSegments,
|
|
875
|
+
witness,
|
|
876
|
+
trianglesVisited,
|
|
877
|
+
residualEdges: edges.size
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
var init_mesh_coverage = __esm({
|
|
881
|
+
"dist/terrain/mesh-coverage.js"() {
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
|
|
37
885
|
// dist/maps/layout.js
|
|
38
886
|
function getMapLayout(map, options = {}) {
|
|
39
887
|
const regions2 = map.regions.map((region) => {
|
|
@@ -201,7 +1049,7 @@ function snapshot(value2) {
|
|
|
201
1049
|
if (Array.isArray(value2))
|
|
202
1050
|
return Object.freeze(value2.map(snapshot));
|
|
203
1051
|
if (typeof value2 === "object" && Object.getPrototypeOf(value2) === Object.prototype)
|
|
204
|
-
return Object.freeze(Object.fromEntries(Object.entries(value2).map(([
|
|
1052
|
+
return Object.freeze(Object.fromEntries(Object.entries(value2).map(([key3, item]) => [key3, snapshot(item)])));
|
|
205
1053
|
throw new Error("MapDescription must contain only finite JSON data; pass callbacks in MapEngineOptions");
|
|
206
1054
|
}
|
|
207
1055
|
var MapEngine;
|
|
@@ -286,9 +1134,9 @@ var init_map_engine = __esm({
|
|
|
286
1134
|
const first = groups.get(seam.regions[0]);
|
|
287
1135
|
for (const id of seam.regions.slice(1)) {
|
|
288
1136
|
const previous = groups.get(id);
|
|
289
|
-
for (const [
|
|
1137
|
+
for (const [key3, group] of groups)
|
|
290
1138
|
if (group === previous)
|
|
291
|
-
groups.set(
|
|
1139
|
+
groups.set(key3, first);
|
|
292
1140
|
}
|
|
293
1141
|
}
|
|
294
1142
|
this.capabilities = Object.freeze({
|
|
@@ -966,10 +1814,10 @@ var init_map_layout = __esm({
|
|
|
966
1814
|
}
|
|
967
1815
|
buildSeams() {
|
|
968
1816
|
const groups = /* @__PURE__ */ new Map();
|
|
969
|
-
const
|
|
1817
|
+
const key3 = (p) => p.map((v) => Math.round(v * 1e9)).join(",");
|
|
970
1818
|
for (const r of this.compiled)
|
|
971
1819
|
r.vertices.forEach((p, i) => {
|
|
972
|
-
const k2 = [
|
|
1820
|
+
const k2 = [key3(p), key3(r.vertices[(i + 1) % r.vertices.length])].sort().join("/");
|
|
973
1821
|
const group = groups.get(k2) || [];
|
|
974
1822
|
group.push({ r, i });
|
|
975
1823
|
groups.set(k2, group);
|
|
@@ -1777,15 +2625,15 @@ function tracePolygonConstraints(input, output, tolerance = 1e-10, priorities, a
|
|
|
1777
2625
|
Math.max(a[0], b[0]) + padding,
|
|
1778
2626
|
Math.max(a[1], b[1]) + padding
|
|
1779
2627
|
], ids = [];
|
|
1780
|
-
const
|
|
2628
|
+
const overlaps2 = (b2) => b2[0] <= box[2] && b2[2] >= box[0] && b2[1] <= box[3] && b2[3] >= box[1];
|
|
1781
2629
|
const visit = (node) => {
|
|
1782
2630
|
tick();
|
|
1783
|
-
if (!
|
|
2631
|
+
if (!overlaps2(node.box))
|
|
1784
2632
|
return;
|
|
1785
2633
|
if (node.ids) {
|
|
1786
2634
|
for (const id of node.ids) {
|
|
1787
2635
|
tick();
|
|
1788
|
-
if (
|
|
2636
|
+
if (overlaps2(boxes[id]))
|
|
1789
2637
|
ids.push(id);
|
|
1790
2638
|
}
|
|
1791
2639
|
} else {
|
|
@@ -4105,15 +4953,15 @@ function createWorldKernel(name, parameters = {}) {
|
|
|
4105
4953
|
}
|
|
4106
4954
|
};
|
|
4107
4955
|
const entry = table[name];
|
|
4108
|
-
for (const
|
|
4109
|
-
if (!(entry == null ? void 0 : entry.fields.some((f) => f[0] ===
|
|
4110
|
-
throw new Error(`Unsupported ${name} parameter: ${
|
|
4956
|
+
for (const key3 of Object.keys(parameters))
|
|
4957
|
+
if (!(entry == null ? void 0 : entry.fields.some((f) => f[0] === key3)))
|
|
4958
|
+
throw new Error(`Unsupported ${name} parameter: ${key3}`);
|
|
4111
4959
|
if (!entry || !Object.keys(parameters).length)
|
|
4112
4960
|
return worldKernels[name];
|
|
4113
|
-
const values = entry.fields.map(([
|
|
4114
|
-
const value2 = parameters[
|
|
4961
|
+
const values = entry.fields.map(([key3, fallback, low, high, degrees4]) => {
|
|
4962
|
+
const value2 = parameters[key3] ?? fallback;
|
|
4115
4963
|
if (!Number.isFinite(value2) || value2 < low || value2 > high)
|
|
4116
|
-
throw new Error(`Invalid ${name} ${
|
|
4964
|
+
throw new Error(`Invalid ${name} ${key3}; expected [${low}, ${high}]`);
|
|
4117
4965
|
return degrees4 ? value2 * Math.PI / 180 : value2;
|
|
4118
4966
|
});
|
|
4119
4967
|
if (name === "hammer" && values[0] === 1 || name === "lagrange" && values[0] === 1)
|
|
@@ -5198,13 +6046,13 @@ var init_map = __esm({
|
|
|
5198
6046
|
}
|
|
5199
6047
|
makeSeams() {
|
|
5200
6048
|
const groups = /* @__PURE__ */ new Map();
|
|
5201
|
-
const
|
|
6049
|
+
const key3 = (p) => [Math.abs(p[0]) === 180 ? -180 : p[0], p[1]].map((v) => Math.round(v * 1e7)).join(",");
|
|
5202
6050
|
for (const c of this.charts) {
|
|
5203
6051
|
let edge2 = 0;
|
|
5204
6052
|
for (const polygon of c.domain)
|
|
5205
6053
|
for (const ring of polygon)
|
|
5206
6054
|
for (let i = 1; i < ring.length; i++, edge2++) {
|
|
5207
|
-
const a = ring[i - 1], b = ring[i], k2 = [
|
|
6055
|
+
const a = ring[i - 1], b = ring[i], k2 = [key3(a), key3(b)].sort().join("/"), group = groups.get(k2) ?? [];
|
|
5208
6056
|
group.push({ c, a, b, edge: edge2 });
|
|
5209
6057
|
groups.set(k2, group);
|
|
5210
6058
|
}
|
|
@@ -6593,12 +7441,12 @@ function createRegionalMap(options) {
|
|
|
6593
7441
|
if (!Number.isFinite(radius2) || radius2 <= 0)
|
|
6594
7442
|
throw new Error("Expected positive finite radius");
|
|
6595
7443
|
if (projection === "hammer-retroazimuthal") {
|
|
6596
|
-
if (Object.keys(options).some((
|
|
7444
|
+
if (Object.keys(options).some((key3) => !["projection", "radius", "type", "parallel"].includes(key3)))
|
|
6597
7445
|
throw new Error("Unsupported Hammer retroazimuthal option");
|
|
6598
7446
|
return createHammerRetroazimuthalMap({ radius: radius2, parallel: options.parallel });
|
|
6599
7447
|
}
|
|
6600
7448
|
if (projection === "armadillo") {
|
|
6601
|
-
if (Object.keys(options).some((
|
|
7449
|
+
if (Object.keys(options).some((key3) => !["projection", "radius", "type", "parallel"].includes(key3)))
|
|
6602
7450
|
throw new Error("Unsupported Armadillo option");
|
|
6603
7451
|
const parallel = options.parallel ?? 20;
|
|
6604
7452
|
if (!Number.isFinite(parallel) || parallel <= 0 || parallel >= 90)
|
|
@@ -6627,13 +7475,13 @@ function createRegionalMap(options) {
|
|
|
6627
7475
|
"two-point-azimuthal": ["controlPoints"],
|
|
6628
7476
|
"two-point-equidistant": ["controlPoints"]
|
|
6629
7477
|
};
|
|
6630
|
-
for (const
|
|
6631
|
-
if (!["projection", "radius", "type"].includes(
|
|
6632
|
-
throw new Error(`Unsupported ${projection} option: ${
|
|
6633
|
-
const value2 = (
|
|
6634
|
-
const n = options[
|
|
7478
|
+
for (const key3 of Object.keys(options))
|
|
7479
|
+
if (!["projection", "radius", "type"].includes(key3) && !((_a3 = allowed[projection]) == null ? void 0 : _a3.includes(key3)))
|
|
7480
|
+
throw new Error(`Unsupported ${projection} option: ${key3}`);
|
|
7481
|
+
const value2 = (key3, fallback, low, high) => {
|
|
7482
|
+
const n = options[key3] ?? fallback;
|
|
6635
7483
|
if (!Number.isFinite(n) || n <= low || n >= high)
|
|
6636
|
-
throw new Error(`Invalid ${projection} ${
|
|
7484
|
+
throw new Error(`Invalid ${projection} ${key3}`);
|
|
6637
7485
|
return n;
|
|
6638
7486
|
};
|
|
6639
7487
|
let kernel2, clipAngle = 90, aspect = [0, 0], frame;
|
|
@@ -6657,7 +7505,7 @@ function createRegionalMap(options) {
|
|
|
6657
7505
|
kernel2 = satelliteRaw(distance3, tilt);
|
|
6658
7506
|
clipAngle = horizon / RAD - 1e-6;
|
|
6659
7507
|
} else if (projection.startsWith("modified-stereographic")) {
|
|
6660
|
-
const
|
|
7508
|
+
const key3 = projection.slice("modified-stereographic-".length);
|
|
6661
7509
|
const presets = {
|
|
6662
7510
|
alaska: { center: [-152, 64], clip: 30 },
|
|
6663
7511
|
gs48: { center: [-95, 38], clip: 55 },
|
|
@@ -6665,8 +7513,8 @@ function createRegionalMap(options) {
|
|
|
6665
7513
|
miller: { center: [20, 18], clip: 82 },
|
|
6666
7514
|
lee: { center: [-165, -10], clip: 130 }
|
|
6667
7515
|
};
|
|
6668
|
-
const preset2 = presets[
|
|
6669
|
-
const c = projection === "modified-stereographic" ? options.coefficients : coefficients[
|
|
7516
|
+
const preset2 = presets[key3];
|
|
7517
|
+
const c = projection === "modified-stereographic" ? options.coefficients : coefficients[key3];
|
|
6670
7518
|
if (!(c == null ? void 0 : c.length) || c.length > 32 || !c.every((p) => p.length === 2 && p.every(Number.isFinite)))
|
|
6671
7519
|
throw new Error("Expected finite complex coefficients");
|
|
6672
7520
|
if (preset2) {
|
|
@@ -7454,8 +8302,8 @@ function createAlbersUsaMap(options = {}) {
|
|
|
7454
8302
|
const radius2 = options.radius ?? 1;
|
|
7455
8303
|
if (!Number.isFinite(radius2) || radius2 <= 0)
|
|
7456
8304
|
throw new Error("Radius must be finite and positive");
|
|
7457
|
-
const region = (id,
|
|
7458
|
-
const [west, south, east, north] =
|
|
8305
|
+
const region = (id, bounds2, center3, parallels, size, offset, insetBounds) => {
|
|
8306
|
+
const [west, south, east, north] = bounds2;
|
|
7459
8307
|
const n = (Math.sin(parallels[0] * RAD) + Math.sin(parallels[1] * RAD)) / 2;
|
|
7460
8308
|
const c = Math.cos(parallels[0] * RAD) ** 2 + 2 * n * Math.sin(parallels[0] * RAD);
|
|
7461
8309
|
const rho = (latitude) => Math.sqrt(c - 2 * n * Math.sin(latitude)) / n;
|
|
@@ -7526,8 +8374,8 @@ function createAlbersUsaMap(options = {}) {
|
|
|
7526
8374
|
region("hawaii", [-179, 17, -153, 30], [-157, 21], [8, 18], 1, [-0.15, -0.2], [-0.215, -0.245, -0.1, -0.155])
|
|
7527
8375
|
];
|
|
7528
8376
|
if (options.includeTerritories) {
|
|
7529
|
-
const territory = (id,
|
|
7530
|
-
const result = region(id,
|
|
8377
|
+
const territory = (id, bounds2, center3, parallels, scale3, frame) => {
|
|
8378
|
+
const result = region(id, bounds2, center3, parallels, scale3, [
|
|
7531
8379
|
(frame[0] + frame[2]) / 2,
|
|
7532
8380
|
(frame[1] + frame[3]) / 2
|
|
7533
8381
|
]);
|
|
@@ -7642,10 +8490,10 @@ function createSolid(solid, subdivisions = 0) {
|
|
|
7642
8490
|
for (let level = 0; level < subdivisions; level++) {
|
|
7643
8491
|
const midpoints = /* @__PURE__ */ new Map();
|
|
7644
8492
|
const midpoint = (a, b) => {
|
|
7645
|
-
const
|
|
7646
|
-
if (!midpoints.has(
|
|
7647
|
-
midpoints.set(
|
|
7648
|
-
return midpoints.get(
|
|
8493
|
+
const key3 = edgeKey(a, b);
|
|
8494
|
+
if (!midpoints.has(key3))
|
|
8495
|
+
midpoints.set(key3, vertices2.push(normalize(center2([vertices2[a], vertices2[b]]))) - 1);
|
|
8496
|
+
return midpoints.get(key3);
|
|
7649
8497
|
};
|
|
7650
8498
|
faces = faces.flatMap(([a, b, c]) => {
|
|
7651
8499
|
const ab = midpoint(a, b), bc = midpoint(b, c), ca = midpoint(c, a);
|
|
@@ -7682,8 +8530,8 @@ function convexFaces(vertices2) {
|
|
|
7682
8530
|
distances = distances.map((x2) => -x2);
|
|
7683
8531
|
}
|
|
7684
8532
|
const ids = distances.flatMap((d, i) => Math.abs(d) < 1e-8 ? [i] : []);
|
|
7685
|
-
const
|
|
7686
|
-
if (found.has(
|
|
8533
|
+
const key3 = ids.join(":");
|
|
8534
|
+
if (found.has(key3))
|
|
7687
8535
|
continue;
|
|
7688
8536
|
const origin = center2(ids.map((i) => vertices2[i]));
|
|
7689
8537
|
const x = normalize(subtract3(vertices2[ids[0]], origin)), y = cross3(n, x);
|
|
@@ -7691,7 +8539,7 @@ function convexFaces(vertices2) {
|
|
|
7691
8539
|
const p = subtract3(vertices2[i], origin), q = subtract3(vertices2[j], origin);
|
|
7692
8540
|
return Math.atan2(dot2(p, y), dot2(p, x)) - Math.atan2(dot2(q, y), dot2(q, x));
|
|
7693
8541
|
});
|
|
7694
|
-
found.set(
|
|
8542
|
+
found.set(key3, ids);
|
|
7695
8543
|
}
|
|
7696
8544
|
return [...found.values()];
|
|
7697
8545
|
}
|
|
@@ -7750,10 +8598,10 @@ function createLayout(mesh, seed = 1, options = {}) {
|
|
|
7750
8598
|
const normals = mesh.faces.map((f) => faceNormal(mesh, f));
|
|
7751
8599
|
const map = /* @__PURE__ */ new Map();
|
|
7752
8600
|
mesh.faces.forEach((face, i) => face.forEach((a, j) => {
|
|
7753
|
-
const b = face[(j + 1) % face.length],
|
|
7754
|
-
if (!map.has(
|
|
7755
|
-
map.set(
|
|
7756
|
-
map.get(
|
|
8601
|
+
const b = face[(j + 1) % face.length], key3 = edgeKey(a, b);
|
|
8602
|
+
if (!map.has(key3))
|
|
8603
|
+
map.set(key3, { a: Math.min(a, b), b: Math.max(a, b), faces: [], weight: 0, hinge: false });
|
|
8604
|
+
map.get(key3).faces.push(i);
|
|
7757
8605
|
}));
|
|
7758
8606
|
const edges = [...map.values()];
|
|
7759
8607
|
for (const edge2 of edges) {
|
|
@@ -7849,7 +8697,7 @@ function restoreLayout(data) {
|
|
|
7849
8697
|
return { ...data, tree, rootTransform, evaluate: evaluate2 };
|
|
7850
8698
|
}
|
|
7851
8699
|
function countOverlaps(faces) {
|
|
7852
|
-
const
|
|
8700
|
+
const bounds2 = faces.map((points, i) => ({
|
|
7853
8701
|
i,
|
|
7854
8702
|
minX: Math.min(...points.map((p) => p[0])),
|
|
7855
8703
|
maxX: Math.max(...points.map((p) => p[0])),
|
|
@@ -7857,9 +8705,9 @@ function countOverlaps(faces) {
|
|
|
7857
8705
|
maxY: Math.max(...points.map((p) => p[1]))
|
|
7858
8706
|
})).sort((a, b) => a.minX - b.minX);
|
|
7859
8707
|
let count = 0;
|
|
7860
|
-
for (let i = 0; i <
|
|
7861
|
-
for (let j = i + 1; j <
|
|
7862
|
-
const a =
|
|
8708
|
+
for (let i = 0; i < bounds2.length; i++)
|
|
8709
|
+
for (let j = i + 1; j < bounds2.length && bounds2[j].minX < bounds2[i].maxX - 1e-8; j++) {
|
|
8710
|
+
const a = bounds2[i], b = bounds2[j];
|
|
7863
8711
|
if (b.minY >= a.maxY - 1e-8 || a.minY >= b.maxY - 1e-8)
|
|
7864
8712
|
continue;
|
|
7865
8713
|
const p = faces[a.i], q = faces[b.i];
|
|
@@ -7912,8 +8760,8 @@ function createMyriahedralLayout(options = {}) {
|
|
|
7912
8760
|
[mesh.faces[0], mesh.faces[root]] = [mesh.faces[root], mesh.faces[0]];
|
|
7913
8761
|
const samples = /* @__PURE__ */ new Map();
|
|
7914
8762
|
const data = (edge2) => {
|
|
7915
|
-
const
|
|
7916
|
-
let value2 = samples.get(
|
|
8763
|
+
const key3 = `${edge2.a}:${edge2.b}`;
|
|
8764
|
+
let value2 = samples.get(key3);
|
|
7917
8765
|
if (value2)
|
|
7918
8766
|
return value2;
|
|
7919
8767
|
const a = mesh.vertices[edge2.a], b = mesh.vertices[edge2.b];
|
|
@@ -7937,7 +8785,7 @@ function createMyriahedralLayout(options = {}) {
|
|
|
7937
8785
|
arcLength,
|
|
7938
8786
|
landFraction
|
|
7939
8787
|
});
|
|
7940
|
-
samples.set(
|
|
8788
|
+
samples.set(key3, value2);
|
|
7941
8789
|
return value2;
|
|
7942
8790
|
};
|
|
7943
8791
|
const weight = (edge2) => {
|
|
@@ -9117,8 +9965,8 @@ function fullCoverage(map) {
|
|
|
9117
9965
|
completeSections = false;
|
|
9118
9966
|
return valid.length ? import_polygon_clipping4.default.intersection(domain, valid) : [];
|
|
9119
9967
|
});
|
|
9120
|
-
const
|
|
9121
|
-
covered = completeSections && !
|
|
9968
|
+
const overlaps2 = domains.some((domain, i) => domains.slice(i + 1).some((other) => import_polygon_clipping4.default.intersection(domain, other).length > 0));
|
|
9969
|
+
covered = completeSections && !overlaps2 && import_polygon_clipping4.default.difference(world, ...domains).length === 0;
|
|
9122
9970
|
} else if (d.type === "world") {
|
|
9123
9971
|
covered = directWorldProjections.has(d.projection) && Object.keys(d.parameters ?? {}).length === 0;
|
|
9124
9972
|
}
|
|
@@ -9550,7 +10398,7 @@ function unsupportedStage(message) {
|
|
|
9550
10398
|
throw new TypeScriptCRSError("missing-transform-stage", message);
|
|
9551
10399
|
}
|
|
9552
10400
|
var _a, CRS_ERROR, TypeScriptCRSError;
|
|
9553
|
-
var
|
|
10401
|
+
var init_types2 = __esm({
|
|
9554
10402
|
"dist/projection/experimental/crs/types.js"() {
|
|
9555
10403
|
CRS_ERROR = /* @__PURE__ */ Symbol.for("@math.gl/projection/TypeScriptCRSError");
|
|
9556
10404
|
TypeScriptCRSError = class _TypeScriptCRSError extends Error {
|
|
@@ -9645,7 +10493,7 @@ function applySpatialReference(crs, reference) {
|
|
|
9645
10493
|
}
|
|
9646
10494
|
var init_spatial_reference2 = __esm({
|
|
9647
10495
|
"dist/projection/experimental/crs/spatial-reference.js"() {
|
|
9648
|
-
|
|
10496
|
+
init_types2();
|
|
9649
10497
|
}
|
|
9650
10498
|
});
|
|
9651
10499
|
|
|
@@ -9698,13 +10546,13 @@ function getDatumDefinitions(options) {
|
|
|
9698
10546
|
if (!catalog.name || !catalog.datums)
|
|
9699
10547
|
throw new Error("Invalid datum catalogue plugin");
|
|
9700
10548
|
for (const [name, definition] of Object.entries(catalog.datums)) {
|
|
9701
|
-
const
|
|
9702
|
-
if (!
|
|
10549
|
+
const key3 = datumNameKey(name);
|
|
10550
|
+
if (!key3 || key3 === "none" || !definition || ["ellipse", "towgs84", "nadgrids"].some((field) => definition[field] !== void 0 && typeof definition[field] !== "string"))
|
|
9703
10551
|
throw new Error("Invalid datum definition: " + name);
|
|
9704
|
-
const previous = names.get(
|
|
10552
|
+
const previous = names.get(key3);
|
|
9705
10553
|
if (previous && (previous.owner !== owner || previous.definition.ellipse !== definition.ellipse || previous.definition.towgs84 !== definition.towgs84 || previous.definition.nadgrids !== definition.nadgrids))
|
|
9706
10554
|
throw new Error("Conflicting datum registration: " + name);
|
|
9707
|
-
names.set(
|
|
10555
|
+
names.set(key3, { definition, owner });
|
|
9708
10556
|
definitions[name] = definition;
|
|
9709
10557
|
}
|
|
9710
10558
|
});
|
|
@@ -10015,7 +10863,7 @@ function getCRSSignature(crs) {
|
|
|
10015
10863
|
return JSON.stringify([
|
|
10016
10864
|
crs.coordinateFrame,
|
|
10017
10865
|
crs.projection,
|
|
10018
|
-
Object.keys(crs.parameters).sort().map((
|
|
10866
|
+
Object.keys(crs.parameters).sort().map((key3) => [key3, crs.parameters[key3]]),
|
|
10019
10867
|
[crs.ellipsoid.semiMajorAxis, crs.ellipsoid.semiMinorAxis],
|
|
10020
10868
|
crs.axis,
|
|
10021
10869
|
[crs.xUnit.name, crs.xUnit.metersPerUnit, crs.xUnit.degreesPerUnit],
|
|
@@ -10033,8 +10881,8 @@ var init_crs_metadata = __esm({
|
|
|
10033
10881
|
|
|
10034
10882
|
// dist/projection/experimental/crs/normalize.js
|
|
10035
10883
|
function lookup(table, name) {
|
|
10036
|
-
const
|
|
10037
|
-
return
|
|
10884
|
+
const key3 = Object.keys(table).find((key4) => keyOf(key4) === keyOf(name));
|
|
10885
|
+
return key3 === void 0 ? void 0 : table[key3];
|
|
10038
10886
|
}
|
|
10039
10887
|
function parseAngle(text) {
|
|
10040
10888
|
if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(text)) {
|
|
@@ -10240,7 +11088,7 @@ var init_normalize = __esm({
|
|
|
10240
11088
|
init_ellipsoid_table();
|
|
10241
11089
|
init_primemeridian_table();
|
|
10242
11090
|
init_crs_metadata();
|
|
10243
|
-
|
|
11091
|
+
init_types2();
|
|
10244
11092
|
ALIASES = {
|
|
10245
11093
|
WGS84: "+proj=longlat +datum=WGS84",
|
|
10246
11094
|
"EPSG:4326": "+proj=longlat +datum=WGS84",
|
|
@@ -10278,7 +11126,7 @@ var init_normalize = __esm({
|
|
|
10278
11126
|
"lon_wrap"
|
|
10279
11127
|
];
|
|
10280
11128
|
CORE_FLAGS = ["no_defs", "over"];
|
|
10281
|
-
own = (object2,
|
|
11129
|
+
own = (object2, key3) => Object.prototype.hasOwnProperty.call(object2, key3);
|
|
10282
11130
|
keyOf = (value2) => value2.toLowerCase().replace(/[\s_-]/g, "");
|
|
10283
11131
|
}
|
|
10284
11132
|
});
|
|
@@ -10473,7 +11321,7 @@ async function resolveCRSDescriptor(engine, definition, normalization, options =
|
|
|
10473
11321
|
if (!profile)
|
|
10474
11322
|
throw new Error("Projection must define a rendering profile for CRS retrieval");
|
|
10475
11323
|
const center3 = (projection.targetLongitudeOrigin + crs.primeMeridian) * 180 / Math.PI;
|
|
10476
|
-
const
|
|
11324
|
+
const bounds2 = adaptBounds(profile, crs, axis);
|
|
10477
11325
|
const normalizeWGS84 = createNormalization(profile.normalize);
|
|
10478
11326
|
const renderingScale = createRenderingScale(crs, projection, axis, center3);
|
|
10479
11327
|
const sources = [.../* @__PURE__ */ new Set(["WGS84", ...conventions.converters || []])];
|
|
@@ -10512,7 +11360,7 @@ async function resolveCRSDescriptor(engine, definition, normalization, options =
|
|
|
10512
11360
|
// Exact caller identity is sufficient under default execution conventions.
|
|
10513
11361
|
// Additional source converters do not change the target CRS.
|
|
10514
11362
|
signature: useDefinitionSignature && typeof input === "string" && !conventions.enforceAxis && !crs.lossy ? input : getCRSSignature(metadata),
|
|
10515
|
-
renderingBounds:
|
|
11363
|
+
renderingBounds: bounds2,
|
|
10516
11364
|
renderingScale,
|
|
10517
11365
|
getRenderingScale: (coordinate) => typeof renderingScale === "function" ? renderingScale(coordinate) : renderingScale,
|
|
10518
11366
|
converter
|
|
@@ -10565,11 +11413,11 @@ function adaptBounds(profile, crs, axis) {
|
|
|
10565
11413
|
horizontalUnit,
|
|
10566
11414
|
crs.kind === "geocentric" ? crs.toMeter : crs.verticalUnit
|
|
10567
11415
|
];
|
|
10568
|
-
const
|
|
11416
|
+
const bounds2 = profile.bounds;
|
|
10569
11417
|
const limits = [...axis].map((direction) => {
|
|
10570
11418
|
const index = /[ew]/.test(direction) ? 0 : /[ns]/.test(direction) ? 1 : 2;
|
|
10571
|
-
const minimum =
|
|
10572
|
-
const maximum =
|
|
11419
|
+
const minimum = bounds2[0][index] / units2[index];
|
|
11420
|
+
const maximum = bounds2[1][index] / units2[index];
|
|
10573
11421
|
return /[wsd]/.test(direction) ? [-maximum, -minimum] : [minimum, maximum];
|
|
10574
11422
|
});
|
|
10575
11423
|
return [
|
|
@@ -10697,19 +11545,19 @@ function createGeographicBounds(west, south, east, north) {
|
|
|
10697
11545
|
north
|
|
10698
11546
|
];
|
|
10699
11547
|
}
|
|
10700
|
-
function getLongitudeSpan(
|
|
10701
|
-
const span =
|
|
11548
|
+
function getLongitudeSpan(bounds2) {
|
|
11549
|
+
const span = bounds2[2] - bounds2[0];
|
|
10702
11550
|
return span < 0 ? span + 360 : span;
|
|
10703
11551
|
}
|
|
10704
|
-
function splitGeographicBounds(
|
|
10705
|
-
const [west, south, east, north] =
|
|
10706
|
-
return west <= east ? [
|
|
11552
|
+
function splitGeographicBounds(bounds2) {
|
|
11553
|
+
const [west, south, east, north] = bounds2;
|
|
11554
|
+
return west <= east ? [bounds2] : [
|
|
10707
11555
|
[west, south, 180, north],
|
|
10708
11556
|
[-180, south, east, north]
|
|
10709
11557
|
];
|
|
10710
11558
|
}
|
|
10711
|
-
function containsGeographicPoint(
|
|
10712
|
-
const [west, south, east, north] =
|
|
11559
|
+
function containsGeographicPoint(bounds2, point) {
|
|
11560
|
+
const [west, south, east, north] = bounds2;
|
|
10713
11561
|
const longitude3 = normalizeLongitude(point[0]);
|
|
10714
11562
|
return point[1] >= south && point[1] <= north && (west <= east ? longitude3 >= west && longitude3 <= east || longitude3 === -180 && east === 180 : longitude3 >= west || longitude3 <= east);
|
|
10715
11563
|
}
|
|
@@ -10744,32 +11592,32 @@ function intersectGeographicBounds(a, b) {
|
|
|
10744
11592
|
}
|
|
10745
11593
|
return merged.map(([west, east]) => [west, south, east, north]);
|
|
10746
11594
|
}
|
|
10747
|
-
function clampGeographicPoint(
|
|
11595
|
+
function clampGeographicPoint(bounds2, point) {
|
|
10748
11596
|
let longitude3 = normalizeLongitude(point[0]);
|
|
10749
|
-
const latitude = Math.max(
|
|
10750
|
-
if (!containsGeographicPoint(
|
|
10751
|
-
const westDistance = Math.abs(normalizeLongitude(longitude3 -
|
|
10752
|
-
const eastDistance = Math.abs(normalizeLongitude(longitude3 -
|
|
10753
|
-
longitude3 = westDistance <= eastDistance ?
|
|
11597
|
+
const latitude = Math.max(bounds2[1], Math.min(bounds2[3], point[1]));
|
|
11598
|
+
if (!containsGeographicPoint(bounds2, [longitude3, latitude])) {
|
|
11599
|
+
const westDistance = Math.abs(normalizeLongitude(longitude3 - bounds2[0]));
|
|
11600
|
+
const eastDistance = Math.abs(normalizeLongitude(longitude3 - bounds2[2]));
|
|
11601
|
+
longitude3 = westDistance <= eastDistance ? bounds2[0] : bounds2[2];
|
|
10754
11602
|
}
|
|
10755
11603
|
return [longitude3, latitude];
|
|
10756
11604
|
}
|
|
10757
|
-
function getAngularRanges(
|
|
10758
|
-
const width = getLongitudeSpan(
|
|
10759
|
-
const west =
|
|
11605
|
+
function getAngularRanges(bounds2, primeMeridian2 = 0, origin = 0) {
|
|
11606
|
+
const width = getLongitudeSpan(bounds2);
|
|
11607
|
+
const west = bounds2[0] * RADIANS2 - primeMeridian2;
|
|
10760
11608
|
const middle = west + width * RADIANS2 / 2;
|
|
10761
11609
|
const shift = Math.round((origin - middle) / (2 * Math.PI)) * 2 * Math.PI;
|
|
10762
|
-
return createAngularRanges(width === 360 ? origin - Math.PI : west + shift,
|
|
11610
|
+
return createAngularRanges(width === 360 ? origin - Math.PI : west + shift, bounds2[1] * RADIANS2, width === 360 ? origin + Math.PI : west + shift + width * RADIANS2, bounds2[3] * RADIANS2);
|
|
10763
11611
|
}
|
|
10764
11612
|
function getGeographicBounds(ranges, primeMeridian2 = 0) {
|
|
10765
11613
|
return createGeographicBounds((ranges[0][0] + primeMeridian2) / RADIANS2, ranges[0][1] / RADIANS2, (ranges[1][0] + primeMeridian2) / RADIANS2, ranges[1][1] / RADIANS2);
|
|
10766
11614
|
}
|
|
10767
|
-
function unionRenderingBounds(
|
|
10768
|
-
if (!
|
|
11615
|
+
function unionRenderingBounds(bounds2) {
|
|
11616
|
+
if (!bounds2.length)
|
|
10769
11617
|
throw new Error("CRS coverage does not intersect the rendering target");
|
|
10770
11618
|
return [
|
|
10771
|
-
[0, 1, 2].map((axis) => Math.min(...
|
|
10772
|
-
[0, 1, 2].map((axis) => Math.max(...
|
|
11619
|
+
[0, 1, 2].map((axis) => Math.min(...bounds2.map((pair2) => pair2[0][axis]))),
|
|
11620
|
+
[0, 1, 2].map((axis) => Math.max(...bounds2.map((pair2) => pair2[1][axis])))
|
|
10773
11621
|
];
|
|
10774
11622
|
}
|
|
10775
11623
|
var RADIANS2;
|
|
@@ -10793,10 +11641,10 @@ function resolveRenderingProfile(getRenderingProfile, coverage) {
|
|
|
10793
11641
|
}
|
|
10794
11642
|
function resolveBounds(profile) {
|
|
10795
11643
|
var _a3;
|
|
10796
|
-
const
|
|
10797
|
-
if (
|
|
11644
|
+
const bounds2 = profile.bounds;
|
|
11645
|
+
if (bounds2.some((corner) => corner.some((value2) => !Number.isFinite(value2))))
|
|
10798
11646
|
throw new Error("Projection rendering bounds must be finite");
|
|
10799
|
-
return { bounds, normalize: (_a3 = profile.normalize) == null ? void 0 : _a3.bind(profile) };
|
|
11647
|
+
return { bounds: bounds2, normalize: (_a3 = profile.normalize) == null ? void 0 : _a3.bind(profile) };
|
|
10800
11648
|
}
|
|
10801
11649
|
function createAngularNormalization(normalize2, primeMeridian2 = 0) {
|
|
10802
11650
|
return (point) => {
|
|
@@ -10883,9 +11731,9 @@ function preloadProjection(projection) {
|
|
|
10883
11731
|
return Promise.resolve(state.implementation);
|
|
10884
11732
|
const entry = state;
|
|
10885
11733
|
entry.pending || (entry.pending = Promise.resolve().then(entry.load).then((plugin) => {
|
|
10886
|
-
const
|
|
10887
|
-
const supported = new Set([plugin.name, ...plugin.aliases || []].map(
|
|
10888
|
-
if (typeof plugin.create !== "function" || ![projection.name, ...projection.aliases || []].every((name) => supported.has(
|
|
11734
|
+
const key3 = (value2) => value2.toLowerCase().replace(/[\s_-]/g, "");
|
|
11735
|
+
const supported = new Set([plugin.name, ...plugin.aliases || []].map(key3));
|
|
11736
|
+
if (typeof plugin.create !== "function" || ![projection.name, ...projection.aliases || []].every((name) => supported.has(key3(name))))
|
|
10889
11737
|
throw new Error("Loaded projection does not match descriptor: " + projection.name);
|
|
10890
11738
|
entry.implementation = plugin;
|
|
10891
11739
|
return plugin;
|
|
@@ -11180,8 +12028,8 @@ function withRectangleRenderingProfile(implementation, parameters, resolveBounds
|
|
|
11180
12028
|
};
|
|
11181
12029
|
try {
|
|
11182
12030
|
const profile = createRectangleRenderingProfile(resolveBounds2, coverage, origin, primeMeridian2, over);
|
|
11183
|
-
const
|
|
11184
|
-
return { bounds, normalize: profile.normalize };
|
|
12031
|
+
const bounds2 = profile.bounds;
|
|
12032
|
+
return { bounds: bounds2, normalize: profile.normalize };
|
|
11185
12033
|
} catch {
|
|
11186
12034
|
return createRegionsRenderingProfile(resolveBounds2, intersectGeographicBounds(coverage, defaults), origin, primeMeridian2, over);
|
|
11187
12035
|
}
|
|
@@ -11349,7 +12197,7 @@ function compileVerticalGrid(names, grids = {}) {
|
|
|
11349
12197
|
}
|
|
11350
12198
|
var init_vertical_datum = __esm({
|
|
11351
12199
|
"dist/projection/experimental/vertical-datum.js"() {
|
|
11352
|
-
|
|
12200
|
+
init_types2();
|
|
11353
12201
|
}
|
|
11354
12202
|
});
|
|
11355
12203
|
|
|
@@ -11439,14 +12287,14 @@ function compileCRS(definition, plugins, options) {
|
|
|
11439
12287
|
if (!["geographic", "identity"].includes(crs.kind) && !plugin)
|
|
11440
12288
|
throw new TypeScriptCRSError("missing-plugin", "Projection plugin is not registered: " + crs.projection);
|
|
11441
12289
|
const allowed = /* @__PURE__ */ new Set([...CORE_PARAMETERS, ...(plugin == null ? void 0 : plugin.parameters) || []]);
|
|
11442
|
-
for (const
|
|
11443
|
-
if (!allowed.has(
|
|
11444
|
-
throw new TypeScriptCRSError("missing-transform-stage", "Unsupported PROJ parameter: +" +
|
|
11445
|
-
const flag = CORE_FLAGS.includes(
|
|
11446
|
-
if (flag && crs.parameters[
|
|
11447
|
-
throw new Error("Expected a flag without a value: +" +
|
|
11448
|
-
if (!flag && !crs.parameters[
|
|
11449
|
-
throw new Error("PROJ parameter requires a value: +" +
|
|
12290
|
+
for (const key3 of Object.keys(crs.parameters)) {
|
|
12291
|
+
if (!allowed.has(key3))
|
|
12292
|
+
throw new TypeScriptCRSError("missing-transform-stage", "Unsupported PROJ parameter: +" + key3);
|
|
12293
|
+
const flag = CORE_FLAGS.includes(key3) || ((_a3 = plugin == null ? void 0 : plugin.flags) == null ? void 0 : _a3.includes(key3));
|
|
12294
|
+
if (flag && crs.parameters[key3] !== void 0)
|
|
12295
|
+
throw new Error("Expected a flag without a value: +" + key3);
|
|
12296
|
+
if (!flag && !crs.parameters[key3])
|
|
12297
|
+
throw new Error("PROJ parameter requires a value: +" + key3);
|
|
11450
12298
|
}
|
|
11451
12299
|
if (crs.parameters["type"] && crs.parameters["type"] !== "crs")
|
|
11452
12300
|
throw new Error("Only +type=crs is supported");
|
|
@@ -11674,7 +12522,7 @@ var init_typescript_projection = __esm({
|
|
|
11674
12522
|
init_projection_scratch();
|
|
11675
12523
|
init_scalar_output();
|
|
11676
12524
|
init_normalize();
|
|
11677
|
-
|
|
12525
|
+
init_types2();
|
|
11678
12526
|
init_datum();
|
|
11679
12527
|
init_parameters();
|
|
11680
12528
|
init_geographic_rendering_profile();
|
|
@@ -13214,8 +14062,8 @@ var init_datum_table = __esm({
|
|
|
13214
14062
|
towgs84: "0,0,0"
|
|
13215
14063
|
}
|
|
13216
14064
|
};
|
|
13217
|
-
for (const
|
|
13218
|
-
const datum = datums[
|
|
14065
|
+
for (const key3 in datums) {
|
|
14066
|
+
const datum = datums[key3];
|
|
13219
14067
|
if (!datum.datumName) {
|
|
13220
14068
|
continue;
|
|
13221
14069
|
}
|
|
@@ -13344,14 +14192,14 @@ var init_mercator = __esm({
|
|
|
13344
14192
|
getRenderingProfile(coverage) {
|
|
13345
14193
|
if (coverage) {
|
|
13346
14194
|
const clipped = coverage[1] <= -90 || coverage[3] >= 90;
|
|
13347
|
-
const
|
|
14195
|
+
const bounds2 = [
|
|
13348
14196
|
coverage[0],
|
|
13349
14197
|
clipped ? Math.max(-maxLatitude * 180 / Math.PI, Math.min(maxLatitude * 180 / Math.PI, coverage[1])) : coverage[1],
|
|
13350
14198
|
coverage[2],
|
|
13351
14199
|
clipped ? Math.max(-maxLatitude * 180 / Math.PI, Math.min(maxLatitude * 180 / Math.PI, coverage[3])) : coverage[3]
|
|
13352
14200
|
];
|
|
13353
14201
|
const northing = (latitude) => y0 + radius2 * (Math.asinh(Math.tan(latitude)) - e * Math.atanh(e * Math.sin(latitude)));
|
|
13354
|
-
return createRectangleRenderingProfile((region) => envelope(add2([x0, x0], scale2(longitudeRange(region, longitudeOrigin, over), radius2)), [northing(region[0][1]), northing(region[1][1])]),
|
|
14202
|
+
return createRectangleRenderingProfile((region) => envelope(add2([x0, x0], scale2(longitudeRange(region, longitudeOrigin, over), radius2)), [northing(region[0][1]), northing(region[1][1])]), bounds2, longitudeOrigin, primeMeridian2, over);
|
|
13355
14203
|
}
|
|
13356
14204
|
const defaultBounds = [
|
|
13357
14205
|
[x0 - width, y0 - height2, 0],
|
|
@@ -20900,13 +21748,13 @@ function obliqueTransformation(wrapped) {
|
|
|
20900
21748
|
}, context.primeMeridian ?? 0);
|
|
20901
21749
|
return {
|
|
20902
21750
|
get bounds() {
|
|
20903
|
-
const
|
|
21751
|
+
const bounds2 = child2.bounds;
|
|
20904
21752
|
const degrees4 = (corner) => [
|
|
20905
21753
|
corner[0] * 180 / Math.PI,
|
|
20906
21754
|
corner[1] * 180 / Math.PI,
|
|
20907
21755
|
corner[2]
|
|
20908
21756
|
];
|
|
20909
|
-
return geographic2 ? [degrees4(
|
|
21757
|
+
return geographic2 ? [degrees4(bounds2[0]), degrees4(bounds2[1])] : bounds2;
|
|
20910
21758
|
},
|
|
20911
21759
|
normalize(point) {
|
|
20912
21760
|
source == null ? void 0 : source.normalize(point);
|
|
@@ -20939,7 +21787,7 @@ var init_ob_tran = __esm({
|
|
|
20939
21787
|
init_geographic_rendering_profile();
|
|
20940
21788
|
init_parameters();
|
|
20941
21789
|
init_rendering_profile();
|
|
20942
|
-
|
|
21790
|
+
init_types2();
|
|
20943
21791
|
init_rectangular_rendering_profile();
|
|
20944
21792
|
init_geographic_bounds();
|
|
20945
21793
|
init_spherical_rendering_domain();
|
|
@@ -21477,7 +22325,7 @@ function object(value2) {
|
|
|
21477
22325
|
function array(value2) {
|
|
21478
22326
|
return Array.isArray(value2) ? value2 : [];
|
|
21479
22327
|
}
|
|
21480
|
-
function
|
|
22328
|
+
function key2(value2) {
|
|
21481
22329
|
return String(value2 || "").toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
21482
22330
|
}
|
|
21483
22331
|
function finite2(value2) {
|
|
@@ -21508,7 +22356,7 @@ function unit2(value2, fallback) {
|
|
|
21508
22356
|
partspermillion: 1e-6,
|
|
21509
22357
|
unity: 1
|
|
21510
22358
|
};
|
|
21511
|
-
const factor = factors2[
|
|
22359
|
+
const factor = factors2[key2(value2)];
|
|
21512
22360
|
if (!factor)
|
|
21513
22361
|
unsupportedStage("Unsupported CRS unit: " + String(value2));
|
|
21514
22362
|
return factor;
|
|
@@ -21532,7 +22380,7 @@ function readStructuredCRS(crs, options) {
|
|
|
21532
22380
|
if (target.parameters["datum"] !== "WGS84" || !["longlat", "geocent"].includes(target.parameters["proj"]) || Number(target.parameters["pm"] || 0) !== 0 || target.parameters["towgs84"] || Number(target.parameters["a"]) !== 6378137 || !(Math.abs(Number(target.parameters["rf"]) - 298.257223563) <= 1e-9 || Math.abs(Number(target.parameters["b"]) - 6356752314245179e-9) <= 1e-6))
|
|
21533
22381
|
unsupportedStage("BoundCRS requires a WGS84 target");
|
|
21534
22382
|
const operation2 = object(crs["transformation"]);
|
|
21535
|
-
const method =
|
|
22383
|
+
const method = key2(object(operation2["method"])["name"]);
|
|
21536
22384
|
const translation = method === "geocentrictranslations" || /^geocentrictranslationsgeog[23]ddomain$/.test(method);
|
|
21537
22385
|
const position2 = /^positionvector(?:transformation)?(?:geog[23]ddomain|geocentricdomain)?$/.test(method);
|
|
21538
22386
|
const frame = /^coordinateframe(?:rotation)?(?:geog[23]ddomain|geocentricdomain)?$/.test(method);
|
|
@@ -21549,7 +22397,7 @@ function readStructuredCRS(crs, options) {
|
|
|
21549
22397
|
];
|
|
21550
22398
|
const values = new Array(translation ? 3 : 7).fill(void 0);
|
|
21551
22399
|
for (const entry of array(operation2["parameters"])) {
|
|
21552
|
-
const parameter = object(entry), index = names2.indexOf(
|
|
22400
|
+
const parameter = object(entry), index = names2.indexOf(key2(parameter["name"]));
|
|
21553
22401
|
if (index < 0 || index >= values.length || values[index] !== void 0)
|
|
21554
22402
|
unsupportedStage("Unsupported or duplicate Helmert parameter: " + String(parameter["name"]));
|
|
21555
22403
|
const base2 = index < 3 ? 1 : index < 6 ? DEGREES_TO_RADIANS / 3600 : 1e-6;
|
|
@@ -21586,10 +22434,10 @@ function readStructuredCRS(crs, options) {
|
|
|
21586
22434
|
throw new Error("Ellipsoid requires inverse flattening or semi-minor axis");
|
|
21587
22435
|
const datums2 = getDatumDefinitions(options);
|
|
21588
22436
|
const rawDatumName = String(datum["name"] || "");
|
|
21589
|
-
const datumName =
|
|
22437
|
+
const datumName = key2(rawDatumName);
|
|
21590
22438
|
const names = Object.keys(datums2);
|
|
21591
22439
|
const exactDatum = names.find((name) => datumNameKey(name) === datumNameKey(rawDatumName));
|
|
21592
|
-
const matches = exactDatum ? [exactDatum] : names.filter((name) =>
|
|
22440
|
+
const matches = exactDatum ? [exactDatum] : names.filter((name) => key2(name) === datumName || key2(name) === datumName.replace(/^d/, ""));
|
|
21593
22441
|
const namedDatum = matches[0];
|
|
21594
22442
|
const first = datums2[namedDatum];
|
|
21595
22443
|
if (first && matches.some((name) => {
|
|
@@ -21636,8 +22484,8 @@ function readStructuredCRS(crs, options) {
|
|
|
21636
22484
|
}
|
|
21637
22485
|
const cs = crs["coordinate_system"] ? object(crs["coordinate_system"]) : {};
|
|
21638
22486
|
const axes = array(cs["axis"]).map(object);
|
|
21639
|
-
const geocentric2 =
|
|
21640
|
-
if (type !== "ProjectedCRS" && !geocentric2 && cs["subtype"] &&
|
|
22487
|
+
const geocentric2 = key2(cs["subtype"]) === "cartesian" && type === "GeodeticCRS";
|
|
22488
|
+
if (type !== "ProjectedCRS" && !geocentric2 && cs["subtype"] && key2(cs["subtype"]) !== "ellipsoidal")
|
|
21641
22489
|
unsupportedStage("Unsupported coordinate system subtype");
|
|
21642
22490
|
if (geocentric2)
|
|
21643
22491
|
parameters["proj"] = "geocent";
|
|
@@ -21653,19 +22501,19 @@ function readStructuredCRS(crs, options) {
|
|
|
21653
22501
|
parameters["pm"] = String(finite2(meridian["longitude"]) * unit2(meridian["unit"], angularUnit) / DEGREES_TO_RADIANS);
|
|
21654
22502
|
}
|
|
21655
22503
|
if (type === "ProjectedCRS") {
|
|
21656
|
-
const conversion = object(crs["conversion"]), method =
|
|
22504
|
+
const conversion = object(crs["conversion"]), method = key2(object(conversion["method"])["name"]);
|
|
21657
22505
|
const conversionParameters = array(conversion["parameters"]).map(object);
|
|
21658
|
-
const polarTrueScale = method === "stereographicnorthpole" && !conversionParameters.some((parameter) =>
|
|
22506
|
+
const polarTrueScale = method === "stereographicnorthpole" && !conversionParameters.some((parameter) => key2(parameter["name"]).startsWith("scalefactor"));
|
|
21659
22507
|
const projection = polarTrueScale ? "stere" : METHODS[method];
|
|
21660
|
-
const esriKrovak = conversionParameters.filter((parameter) => ["xscale", "yscale", "xyplanerotation"].includes(
|
|
22508
|
+
const esriKrovak = conversionParameters.filter((parameter) => ["xscale", "yscale", "xyplanerotation"].includes(key2(parameter["name"])));
|
|
21661
22509
|
if (esriKrovak.length) {
|
|
21662
22510
|
const expected = {
|
|
21663
22511
|
xscale: -1,
|
|
21664
22512
|
yscale: 1,
|
|
21665
22513
|
xyplanerotation: 90
|
|
21666
22514
|
};
|
|
21667
|
-
if (projection !== "krovak" || esriKrovak.length !== 3 || new Set(esriKrovak.map((parameter) =>
|
|
21668
|
-
const name =
|
|
22515
|
+
if (projection !== "krovak" || esriKrovak.length !== 3 || new Set(esriKrovak.map((parameter) => key2(parameter["name"]))).size !== 3 || esriKrovak.some((parameter) => {
|
|
22516
|
+
const name = key2(parameter["name"]);
|
|
21669
22517
|
const factor2 = name === "xyplanerotation" ? unit2(parameter["unit"], angularUnit) / DEGREES_TO_RADIANS : unit2(parameter["unit"], 1);
|
|
21670
22518
|
return Math.abs(finite2(parameter["value"]) * factor2 - expected[name]) > 1e-10;
|
|
21671
22519
|
}))
|
|
@@ -21676,7 +22524,7 @@ function readStructuredCRS(crs, options) {
|
|
|
21676
22524
|
parameters["proj"] = projection === "webmerc" ? "merc" : projection;
|
|
21677
22525
|
let hasSemiMinor = false;
|
|
21678
22526
|
for (const parameter of conversionParameters) {
|
|
21679
|
-
const parameterName =
|
|
22527
|
+
const parameterName = key2(parameter["name"]);
|
|
21680
22528
|
if (esriKrovak.includes(parameter))
|
|
21681
22529
|
continue;
|
|
21682
22530
|
if (parameterName === "auxiliaryspheretype" && projection === "webmerc" && parameter["value"] === 0)
|
|
@@ -21781,7 +22629,7 @@ function readAxisDirection(entry, parameters, projected) {
|
|
|
21781
22629
|
if (meridian !== void 0) {
|
|
21782
22630
|
const latitude = Number(parameters["lat_0"]);
|
|
21783
22631
|
const north = latitude === 90;
|
|
21784
|
-
if (!projected || parameters["proj"] !== "stere" || Math.abs(latitude) !== 90 ||
|
|
22632
|
+
if (!projected || parameters["proj"] !== "stere" || Math.abs(latitude) !== 90 || key2(direction) !== (north ? "south" : "north"))
|
|
21785
22633
|
unsupportedStage("Axis meridians require an outward-facing polar stereographic axis");
|
|
21786
22634
|
const longitude3 = object(meridian)["longitude"];
|
|
21787
22635
|
const degrees4 = typeof longitude3 === "number" ? finite2(longitude3) : finite2(object(longitude3)["value"]) * unit2(object(longitude3)["unit"], DEGREES_TO_RADIANS) / DEGREES_TO_RADIANS;
|
|
@@ -21791,7 +22639,7 @@ function readAxisDirection(entry, parameters, projected) {
|
|
|
21791
22639
|
const quadrant = (Math.round(quarterTurns) % 4 + 4) % 4;
|
|
21792
22640
|
return (north ? "senw" : "nesw")[quadrant];
|
|
21793
22641
|
}
|
|
21794
|
-
const result = DIRECTIONS[
|
|
22642
|
+
const result = DIRECTIONS[key2(direction)];
|
|
21795
22643
|
if (!result)
|
|
21796
22644
|
unsupportedStage("Unsupported axis direction: " + direction);
|
|
21797
22645
|
return result;
|
|
@@ -21801,7 +22649,7 @@ var init_structured = __esm({
|
|
|
21801
22649
|
"dist/projection/experimental/crs/structured.js"() {
|
|
21802
22650
|
init_datum_catalog();
|
|
21803
22651
|
init_parameters();
|
|
21804
|
-
|
|
22652
|
+
init_types2();
|
|
21805
22653
|
METHODS = {
|
|
21806
22654
|
hotineobliquemercator: "omerc",
|
|
21807
22655
|
hotineobliquemercatorvarianta: "omerc",
|
|
@@ -22091,7 +22939,7 @@ var init_wkt = __esm({
|
|
|
22091
22939
|
"dist/projection/experimental/crs/wkt.js"() {
|
|
22092
22940
|
init_spatial_reference();
|
|
22093
22941
|
init_wkt_crs();
|
|
22094
|
-
|
|
22942
|
+
init_types2();
|
|
22095
22943
|
init_structured();
|
|
22096
22944
|
wktCRSParser = {
|
|
22097
22945
|
name: "wkt",
|
|
@@ -22192,8 +23040,8 @@ function compatibilityParser(parser) {
|
|
|
22192
23040
|
parse(definition, options) {
|
|
22193
23041
|
const parsed = parser.parse(definition, options);
|
|
22194
23042
|
const datum = parsed.parameters["datum"];
|
|
22195
|
-
const
|
|
22196
|
-
if (datum && !Object.keys(getDatumDefinitions(options)).some((name) =>
|
|
23043
|
+
const key3 = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
|
|
23044
|
+
if (datum && !Object.keys(getDatumDefinitions(options)).some((name) => key3(name) === key3(datum))) {
|
|
22197
23045
|
const parameters = { ...parsed.parameters };
|
|
22198
23046
|
delete parameters["datum"];
|
|
22199
23047
|
return { ...parsed, parameters };
|
|
@@ -22242,7 +23090,7 @@ function defaultProjections() {
|
|
|
22242
23090
|
tiltedPerspective,
|
|
22243
23091
|
vanDerGrinten
|
|
22244
23092
|
];
|
|
22245
|
-
const
|
|
23093
|
+
const key3 = (name) => name.toLowerCase().replace(/[\s_-]/g, "");
|
|
22246
23094
|
const geographic2 = obliqueTransformation("longlat");
|
|
22247
23095
|
const oblique = {
|
|
22248
23096
|
name: geographic2.name,
|
|
@@ -22253,7 +23101,7 @@ function defaultProjections() {
|
|
|
22253
23101
|
const requested = context.parameters["o_proj"];
|
|
22254
23102
|
if (!requested)
|
|
22255
23103
|
throw new Error("Oblique transformation requires +o_proj");
|
|
22256
|
-
const child2 = ["longlat", "latlong", "latlon", "lonlat", "identity"].includes(
|
|
23104
|
+
const child2 = ["longlat", "latlong", "latlon", "lonlat", "identity"].includes(key3(requested)) ? "longlat" : projections.find((p) => [p.name, ...p.aliases || []].some((name) => key3(name) === key3(requested)));
|
|
22257
23105
|
if (!child2)
|
|
22258
23106
|
throw new Error("Unknown oblique transformation projection: " + requested);
|
|
22259
23107
|
const plugin = obliqueTransformation(child2);
|
|
@@ -22346,11 +23194,138 @@ var init_operations = __esm({
|
|
|
22346
23194
|
// dist/tasks/index.js
|
|
22347
23195
|
var index_exports = {};
|
|
22348
23196
|
__export(index_exports, {
|
|
23197
|
+
CertifyTerrainCoverageTask: () => CertifyTerrainCoverageTask2,
|
|
22349
23198
|
PrepareMapTask: () => PrepareMapTask2,
|
|
22350
|
-
ProjectCoordinatesTask: () => ProjectCoordinatesTask2
|
|
23199
|
+
ProjectCoordinatesTask: () => ProjectCoordinatesTask2,
|
|
23200
|
+
TerrainResidencyTask: () => TerrainResidencyTask2
|
|
22351
23201
|
});
|
|
22352
23202
|
module.exports = __toCommonJS(index_exports);
|
|
22353
23203
|
|
|
23204
|
+
// dist/tasks/terrain-residency.js
|
|
23205
|
+
var addressKey = ({ spacing, column, row }) => `${spacing}/${column}/${row}`;
|
|
23206
|
+
function sameArray(a, b) {
|
|
23207
|
+
if (a.length !== b.length)
|
|
23208
|
+
return false;
|
|
23209
|
+
for (let i = 0; i < a.length; i++)
|
|
23210
|
+
if (!Object.is(a[i], b[i]))
|
|
23211
|
+
return false;
|
|
23212
|
+
return true;
|
|
23213
|
+
}
|
|
23214
|
+
function sameHalo(a, b) {
|
|
23215
|
+
if (a === b)
|
|
23216
|
+
return true;
|
|
23217
|
+
const af = a.field;
|
|
23218
|
+
const bf = b.field;
|
|
23219
|
+
const keys = Object.keys(af);
|
|
23220
|
+
return keys.length === Object.keys(bf).length && keys.every((key3) => {
|
|
23221
|
+
const left = af[key3];
|
|
23222
|
+
const right = bf[key3];
|
|
23223
|
+
if (typeof left === "object" && typeof right === "object")
|
|
23224
|
+
return sameArray(left, right);
|
|
23225
|
+
return Object.prototype.hasOwnProperty.call(bf, key3) && Object.is(left, right);
|
|
23226
|
+
}) && sameArray(a.statuses, b.statuses);
|
|
23227
|
+
}
|
|
23228
|
+
var TerrainResidencyTask = {
|
|
23229
|
+
id: "terrain-residency",
|
|
23230
|
+
initialize(limits) {
|
|
23231
|
+
return { limits: { ...limits }, snapshot: null, revision: 0 };
|
|
23232
|
+
},
|
|
23233
|
+
async process(input, _options, context) {
|
|
23234
|
+
var _a3, _b2, _c;
|
|
23235
|
+
const state = context.state;
|
|
23236
|
+
if ("type" in input) {
|
|
23237
|
+
if (input.type !== "snapshot")
|
|
23238
|
+
throw new Error("Unknown terrain residency request");
|
|
23239
|
+
return {
|
|
23240
|
+
revision: state.revision,
|
|
23241
|
+
tiles: structuredClone(((_a3 = state.snapshot) == null ? void 0 : _a3.tiles) ?? []),
|
|
23242
|
+
removed: []
|
|
23243
|
+
};
|
|
23244
|
+
}
|
|
23245
|
+
try {
|
|
23246
|
+
if (input.revision !== state.revision)
|
|
23247
|
+
throw new Error("Stale terrain residency revision");
|
|
23248
|
+
const [{ updateTerrainMixedVertexTileHalos: updateTerrainMixedVertexTileHalos2 }, { HeightField: HeightField2 }] = await Promise.all([
|
|
23249
|
+
Promise.resolve().then(() => (init_mixed_halo_update(), mixed_halo_update_exports)),
|
|
23250
|
+
Promise.resolve().then(() => (init_height_field(), height_field_exports))
|
|
23251
|
+
]);
|
|
23252
|
+
context.throwIfAborted();
|
|
23253
|
+
const sources = new Map((_b2 = state.snapshot) == null ? void 0 : _b2.sources.map((tile) => [addressKey(tile), tile]));
|
|
23254
|
+
const writable = /* @__PURE__ */ new Map();
|
|
23255
|
+
for (const edit of input.edits) {
|
|
23256
|
+
if (edit.type === "upsert") {
|
|
23257
|
+
const key4 = addressKey(edit.tile);
|
|
23258
|
+
sources.set(key4, structuredClone(edit.tile));
|
|
23259
|
+
writable.delete(key4);
|
|
23260
|
+
continue;
|
|
23261
|
+
}
|
|
23262
|
+
const key3 = addressKey(edit.address);
|
|
23263
|
+
if (edit.type === "remove") {
|
|
23264
|
+
sources.delete(key3);
|
|
23265
|
+
writable.delete(key3);
|
|
23266
|
+
continue;
|
|
23267
|
+
}
|
|
23268
|
+
if (edit.type !== "samples")
|
|
23269
|
+
throw new Error("Unknown terrain residency edit");
|
|
23270
|
+
const source = sources.get(key3);
|
|
23271
|
+
if (!source)
|
|
23272
|
+
throw new Error("Terrain sample edit requires a resident tile");
|
|
23273
|
+
if (!edit.samples.length)
|
|
23274
|
+
continue;
|
|
23275
|
+
let data = writable.get(key3);
|
|
23276
|
+
if (!data) {
|
|
23277
|
+
const copied = new HeightField2(source.field).copyData();
|
|
23278
|
+
data = { heights: copied.heights, validity: copied.validity };
|
|
23279
|
+
writable.set(key3, data);
|
|
23280
|
+
sources.set(key3, {
|
|
23281
|
+
...source,
|
|
23282
|
+
field: { ...source.field, ...data, offset: 0, stride: source.field.width }
|
|
23283
|
+
});
|
|
23284
|
+
}
|
|
23285
|
+
for (const { index, height: height2 } of edit.samples) {
|
|
23286
|
+
if (!Number.isSafeInteger(index) || index < 0 || index >= data.heights.length || height2 !== null && !Number.isFinite(height2)) {
|
|
23287
|
+
throw new Error("Invalid terrain sample edit");
|
|
23288
|
+
}
|
|
23289
|
+
data.heights[index] = height2 ?? 0;
|
|
23290
|
+
if (!Number.isFinite(data.heights[index]))
|
|
23291
|
+
throw new Error("Terrain sample edit overflow");
|
|
23292
|
+
data.validity[index] = height2 === null ? 0 : 1;
|
|
23293
|
+
}
|
|
23294
|
+
}
|
|
23295
|
+
const next = updateTerrainMixedVertexTileHalos2(state.snapshot, [...sources.values()], state.limits);
|
|
23296
|
+
const old = new Map((_c = state.snapshot) == null ? void 0 : _c.tiles.map((tile) => [addressKey(tile), tile]));
|
|
23297
|
+
const tiles = structuredClone(next.tiles.filter((tile) => {
|
|
23298
|
+
const prior = old.get(addressKey(tile));
|
|
23299
|
+
return !prior || !sameHalo(prior, tile);
|
|
23300
|
+
}));
|
|
23301
|
+
context.throwIfAborted();
|
|
23302
|
+
state.snapshot = next;
|
|
23303
|
+
state.revision++;
|
|
23304
|
+
return { revision: state.revision, tiles, removed: next.removed };
|
|
23305
|
+
} catch (error) {
|
|
23306
|
+
context.throwIfAborted();
|
|
23307
|
+
return {
|
|
23308
|
+
revision: state.revision,
|
|
23309
|
+
tiles: [],
|
|
23310
|
+
removed: [],
|
|
23311
|
+
error: error instanceof Error ? error.message : String(error)
|
|
23312
|
+
};
|
|
23313
|
+
}
|
|
23314
|
+
}
|
|
23315
|
+
};
|
|
23316
|
+
|
|
23317
|
+
// dist/tasks/terrain-coverage.js
|
|
23318
|
+
var CertifyTerrainCoverageTask = {
|
|
23319
|
+
id: "certify-terrain-coverage",
|
|
23320
|
+
async process({ field, mesh }, options) {
|
|
23321
|
+
const [{ HeightField: HeightField2 }, { certifyTerrainMeshCoverage: certifyTerrainMeshCoverage2 }] = await Promise.all([
|
|
23322
|
+
Promise.resolve().then(() => (init_height_field(), height_field_exports)),
|
|
23323
|
+
Promise.resolve().then(() => (init_mesh_coverage(), mesh_coverage_exports))
|
|
23324
|
+
]);
|
|
23325
|
+
return certifyTerrainMeshCoverage2(new HeightField2(field), mesh, options);
|
|
23326
|
+
}
|
|
23327
|
+
};
|
|
23328
|
+
|
|
22354
23329
|
// dist/tasks/definitions.js
|
|
22355
23330
|
var processCoordinates = async (input, options, context) => {
|
|
22356
23331
|
const projection = input.projection ?? context.state.defaultOptions;
|
|
@@ -22395,12 +23370,12 @@ var PrepareMapTask = {
|
|
|
22395
23370
|
}
|
|
22396
23371
|
};
|
|
22397
23372
|
async function prepareProjection(state, options) {
|
|
22398
|
-
const
|
|
22399
|
-
if (!state.projection || state.key !==
|
|
23373
|
+
const key3 = JSON.stringify(options);
|
|
23374
|
+
if (!state.projection || state.key !== key3) {
|
|
22400
23375
|
const { FullProjectionEngine: FullProjectionEngine2 } = await Promise.resolve().then(() => (init_projection(), projection_exports));
|
|
22401
23376
|
const projection = new FullProjectionEngine2().createProjection(options);
|
|
22402
23377
|
state.projection = projection;
|
|
22403
|
-
state.key =
|
|
23378
|
+
state.key = key3;
|
|
22404
23379
|
}
|
|
22405
23380
|
}
|
|
22406
23381
|
|
|
@@ -22426,4 +23401,22 @@ var PrepareMapTask2 = {
|
|
|
22426
23401
|
capabilities: { atomic: true, streaming: false }
|
|
22427
23402
|
}
|
|
22428
23403
|
};
|
|
23404
|
+
var CertifyTerrainCoverageTask2 = {
|
|
23405
|
+
...CertifyTerrainCoverageTask,
|
|
23406
|
+
worker: {
|
|
23407
|
+
...!isBrowser ? { url: /* @__PURE__ */ (() => new URL("./terrain-coverage-worker.js", moduleUrl).href)() } : {
|
|
23408
|
+
create: () => new Worker(new URL("./terrain-coverage-worker.js", import_meta.url), { type: "module" })
|
|
23409
|
+
},
|
|
23410
|
+
capabilities: { atomic: true, streaming: false }
|
|
23411
|
+
}
|
|
23412
|
+
};
|
|
23413
|
+
var TerrainResidencyTask2 = {
|
|
23414
|
+
...TerrainResidencyTask,
|
|
23415
|
+
worker: {
|
|
23416
|
+
...!isBrowser ? { url: /* @__PURE__ */ (() => new URL("./terrain-residency-worker.js", moduleUrl).href)() } : {
|
|
23417
|
+
create: () => new Worker(new URL("./terrain-residency-worker.js", import_meta.url), { type: "module" })
|
|
23418
|
+
},
|
|
23419
|
+
capabilities: { atomic: true, streaming: false }
|
|
23420
|
+
}
|
|
23421
|
+
};
|
|
22429
23422
|
//# sourceMappingURL=index.cjs.map
|