@math.gl/geospatial 5.0.0-beta.3 → 5.0.0-beta.4
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 +244 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/terrain/contour-boundary-diagnostics.d.ts +23 -0
- package/dist/terrain/contour-boundary-diagnostics.d.ts.map +1 -0
- package/dist/terrain/contour-boundary-diagnostics.js +62 -0
- package/dist/terrain/contour-boundary-diagnostics.js.map +1 -0
- package/dist/terrain/contour-tile-paths.d.ts +7 -0
- package/dist/terrain/contour-tile-paths.d.ts.map +1 -0
- package/dist/terrain/contour-tile-paths.js +12 -0
- package/dist/terrain/contour-tile-paths.js.map +1 -0
- package/dist/terrain/contour-tile-weld.d.ts +24 -0
- package/dist/terrain/contour-tile-weld.d.ts.map +1 -0
- package/dist/terrain/contour-tile-weld.js +147 -0
- package/dist/terrain/contour-tile-weld.js.map +1 -0
- package/dist/terrain/gradient-pyramid.d.ts +29 -0
- package/dist/terrain/gradient-pyramid.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid.js +94 -0
- package/dist/terrain/gradient-pyramid.js.map +1 -0
- package/dist/terrain/index.cjs +245 -1
- package/dist/terrain/index.cjs.map +2 -2
- package/dist/terrain/index.d.ts +7 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +4 -0
- package/dist/terrain/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +10 -0
- package/src/terrain/contour-boundary-diagnostics.ts +90 -0
- package/src/terrain/contour-tile-paths.ts +20 -0
- package/src/terrain/contour-tile-weld.ts +182 -0
- package/src/terrain/gradient-pyramid.ts +129 -0
- package/src/terrain/index.ts +10 -0
package/dist/index.cjs
CHANGED
|
@@ -71,6 +71,7 @@ __export(index_exports, {
|
|
|
71
71
|
RhumbPath: () => RhumbPath,
|
|
72
72
|
RhumbPolygon: () => RhumbPolygon,
|
|
73
73
|
TERRAIN_BUFFER_VERSION: () => TERRAIN_BUFFER_VERSION,
|
|
74
|
+
TerrainContourBoundaryAxis: () => TerrainContourBoundaryAxis,
|
|
74
75
|
TerrainProfileViewStatus: () => TerrainProfileViewStatus,
|
|
75
76
|
TerrainSampleStatus: () => TerrainSampleStatus,
|
|
76
77
|
TerrainSurface: () => TerrainSurface,
|
|
@@ -103,6 +104,7 @@ __export(index_exports, {
|
|
|
103
104
|
createTerrainContours: () => createTerrainContours,
|
|
104
105
|
createTerrainFilteredPyramid: () => createTerrainFilteredPyramid,
|
|
105
106
|
createTerrainGradientGrid: () => createTerrainGradientGrid,
|
|
107
|
+
createTerrainGradientPyramid: () => createTerrainGradientPyramid,
|
|
106
108
|
createTerrainMesh: () => createTerrainMesh,
|
|
107
109
|
createTerrainSkirt: () => createTerrainSkirt,
|
|
108
110
|
createTerrainSlopeAspectGrid: () => createTerrainSlopeAspectGrid,
|
|
@@ -110,6 +112,7 @@ __export(index_exports, {
|
|
|
110
112
|
createTerrainVertexTileHalos: () => createTerrainVertexTileHalos,
|
|
111
113
|
decodeGeoArrowWKB: () => decodeGeoArrowWKB,
|
|
112
114
|
decodeGeoArrowWKT: () => decodeGeoArrowWKT,
|
|
115
|
+
diagnoseTerrainContourBoundaries: () => diagnoseTerrainContourBoundaries,
|
|
113
116
|
eastNorthUpToFixedFrame: () => eastNorthUpToFixedFrame,
|
|
114
117
|
encodeGeoArrowWKB: () => encodeGeoArrowWKB,
|
|
115
118
|
encodeGeoArrowWKT: () => encodeGeoArrowWKT,
|
|
@@ -209,6 +212,7 @@ __export(index_exports, {
|
|
|
209
212
|
splitGeographicPolyline: () => splitGeographicPolyline,
|
|
210
213
|
splitGlobeBounds: () => splitGlobeBounds,
|
|
211
214
|
standardGridZone: () => standardGridZone,
|
|
215
|
+
stitchTerrainContourTiles: () => stitchTerrainContourTiles,
|
|
212
216
|
stitchTerrainContours: () => stitchTerrainContours,
|
|
213
217
|
stitchTerrainMeshEdges: () => stitchTerrainMeshEdges,
|
|
214
218
|
streamGeoArrow: () => streamGeoArrow,
|
|
@@ -230,6 +234,7 @@ __export(index_exports, {
|
|
|
230
234
|
validateWKTCRS: () => validateWKTCRS,
|
|
231
235
|
visitGeoArrowCoordinates: () => visitGeoArrowCoordinates,
|
|
232
236
|
visitWKB: () => visitWKB,
|
|
237
|
+
weldTerrainContourTiles: () => weldTerrainContourTiles,
|
|
233
238
|
worldToLngLat: () => web_mercator_exports.worldToLngLat,
|
|
234
239
|
worldToPixels: () => web_mercator_exports.worldToPixels,
|
|
235
240
|
writeWKB: () => writeWKB,
|
|
@@ -17492,6 +17497,245 @@ function stitchTerrainContours(contours, options = {}) {
|
|
|
17492
17497
|
};
|
|
17493
17498
|
}
|
|
17494
17499
|
|
|
17500
|
+
// dist/terrain/contour-tile-weld.js
|
|
17501
|
+
function weldTerrainContourTiles(tiles, options) {
|
|
17502
|
+
const { width, height } = options;
|
|
17503
|
+
const limits = contourPathLimits(options);
|
|
17504
|
+
const tolerance = options.maxPositionDifference ?? 0;
|
|
17505
|
+
const maxTiles = options.maxTiles ?? 4096;
|
|
17506
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height) || height < 2 || !Number.isFinite(tolerance) || tolerance < 0 || !Number.isSafeInteger(maxTiles) || maxTiles < 1 || tiles.length > maxTiles || !tiles.length)
|
|
17507
|
+
throw new Error("Invalid terrain contour tile dimensions or tolerance");
|
|
17508
|
+
const sorted = [...tiles].sort((a, b) => a.column - b.column || a.row - b.row);
|
|
17509
|
+
const first = sorted[0].contours;
|
|
17510
|
+
const origin = [...first.origin];
|
|
17511
|
+
const levels = first.levels.slice();
|
|
17512
|
+
const positions = [], grid = [], segments = [], levelIndices = [];
|
|
17513
|
+
const vertices = /* @__PURE__ */ new Map();
|
|
17514
|
+
const edges = /* @__PURE__ */ new Map();
|
|
17515
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
17516
|
+
let inputVertices = 0;
|
|
17517
|
+
let inputSegments = 0;
|
|
17518
|
+
for (let tileIndex = 0; tileIndex < sorted.length; tileIndex++) {
|
|
17519
|
+
const tile = sorted[tileIndex], data = tile.contours;
|
|
17520
|
+
const id = `${tile.column},${tile.row}`;
|
|
17521
|
+
if (!Number.isSafeInteger(tile.column) || !Number.isSafeInteger(tile.row) || addresses.has(id))
|
|
17522
|
+
throw new Error("Invalid or duplicate terrain contour tile address");
|
|
17523
|
+
addresses.add(id);
|
|
17524
|
+
const x0 = tile.column * (width - 1), y0 = tile.row * (height - 1);
|
|
17525
|
+
if (![x0, y0, x0 + width - 1, y0 + height - 1].every(Number.isSafeInteger))
|
|
17526
|
+
throw new Error("Terrain contour tile lattice overflow");
|
|
17527
|
+
const count = validateContourData(data, limits);
|
|
17528
|
+
inputVertices += count;
|
|
17529
|
+
if (inputVertices > limits.maxVertices)
|
|
17530
|
+
throw new Error("Terrain contour input vertex capacity exceeded");
|
|
17531
|
+
if (data.heightReference !== first.heightReference || data.levels.length !== levels.length || !data.levels.every((level, i) => level === levels[i]))
|
|
17532
|
+
throw new Error("Terrain contour tile levels or height reference differ");
|
|
17533
|
+
if (!(data.segments instanceof Uint32Array) || data.segments.length % 2 || !(data.levelIndices instanceof Uint32Array) || data.levelIndices.length !== data.segments.length / 2 || data.levelIndices.length > limits.maxSegments)
|
|
17534
|
+
throw new Error("Invalid terrain contour tile segments");
|
|
17535
|
+
inputSegments += data.levelIndices.length;
|
|
17536
|
+
if (inputSegments > limits.maxSegments)
|
|
17537
|
+
throw new Error("Terrain contour input segment capacity exceeded");
|
|
17538
|
+
const assigned = new Uint32Array(count).fill(4294967295);
|
|
17539
|
+
const remap = new Uint32Array(count).fill(4294967295);
|
|
17540
|
+
const localBoundary = /* @__PURE__ */ new Set();
|
|
17541
|
+
const mapVertex = (source, level) => {
|
|
17542
|
+
validateContourVertex(data, source, level, assigned);
|
|
17543
|
+
if (remap[source] !== 4294967295)
|
|
17544
|
+
return remap[source];
|
|
17545
|
+
const x = data.gridCoordinates[2 * source], y = data.gridCoordinates[2 * source + 1];
|
|
17546
|
+
if (x < 0 || x > width - 1 || y < 0 || y > height - 1)
|
|
17547
|
+
throw new Error("Terrain contour vertex outside tile lattice");
|
|
17548
|
+
const gx = x0 + x, gy = y0 + y;
|
|
17549
|
+
if (!Number.isFinite(gx) || !Number.isFinite(gy) || x % 1 !== 0 && Number.isInteger(gx) || y % 1 !== 0 && Number.isInteger(gy))
|
|
17550
|
+
throw new Error("Terrain contour tile lattice loses precision");
|
|
17551
|
+
const px = data.positions[3 * source] + (data.origin[0] - origin[0]);
|
|
17552
|
+
const py = data.positions[3 * source + 1] + (data.origin[1] - origin[1]);
|
|
17553
|
+
if (!Number.isFinite(px) || !Number.isFinite(py))
|
|
17554
|
+
throw new Error("Terrain contour frame overflow");
|
|
17555
|
+
const boundary = x === 0 || y === 0 || x === width - 1 || y === height - 1;
|
|
17556
|
+
const xi = Math.floor(x), yi = Math.floor(y);
|
|
17557
|
+
const vertexKey = `${level}/${x0 + xi}/${x - xi}/${y0 + yi}/${y - yi}`;
|
|
17558
|
+
if (boundary) {
|
|
17559
|
+
if (localBoundary.has(vertexKey))
|
|
17560
|
+
throw new Error("Duplicate terrain contour boundary vertex");
|
|
17561
|
+
localBoundary.add(vertexKey);
|
|
17562
|
+
}
|
|
17563
|
+
const found = boundary ? vertices.get(vertexKey) : void 0;
|
|
17564
|
+
if (found) {
|
|
17565
|
+
if (found.tile === tileIndex)
|
|
17566
|
+
throw new Error("Duplicate terrain contour boundary vertex");
|
|
17567
|
+
const delta = Math.hypot(px - positions[3 * found.id], py - positions[3 * found.id + 1]);
|
|
17568
|
+
if (!Number.isFinite(delta) || delta > tolerance)
|
|
17569
|
+
throw new Error("Terrain contour boundary positions disagree");
|
|
17570
|
+
remap[source] = found.id;
|
|
17571
|
+
return found.id;
|
|
17572
|
+
}
|
|
17573
|
+
if (positions.length / 3 >= limits.maxVertices)
|
|
17574
|
+
throw new Error("Terrain contour vertex capacity exceeded");
|
|
17575
|
+
const output2 = positions.length / 3;
|
|
17576
|
+
const pz = levels[level] - origin[2];
|
|
17577
|
+
if (!Number.isFinite(pz))
|
|
17578
|
+
throw new Error("Terrain contour frame overflow");
|
|
17579
|
+
positions.push(px, py, pz);
|
|
17580
|
+
grid.push(gx, gy);
|
|
17581
|
+
if (boundary)
|
|
17582
|
+
vertices.set(vertexKey, { id: output2, tile: tileIndex });
|
|
17583
|
+
remap[source] = output2;
|
|
17584
|
+
return output2;
|
|
17585
|
+
};
|
|
17586
|
+
for (let i = 0; i < data.levelIndices.length; i++) {
|
|
17587
|
+
const level = data.levelIndices[i], a = mapVertex(data.segments[2 * i], level), b = mapVertex(data.segments[2 * i + 1], level);
|
|
17588
|
+
if (a === b || positions[3 * a] === positions[3 * b] && positions[3 * a + 1] === positions[3 * b + 1])
|
|
17589
|
+
throw new Error("Degenerate terrain contour segment after rebasing");
|
|
17590
|
+
const edge = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
17591
|
+
const previous = edges.get(edge);
|
|
17592
|
+
if (previous !== void 0) {
|
|
17593
|
+
if (previous === tileIndex)
|
|
17594
|
+
throw new Error("Duplicate terrain contour segment");
|
|
17595
|
+
continue;
|
|
17596
|
+
}
|
|
17597
|
+
if (levelIndices.length >= limits.maxSegments)
|
|
17598
|
+
throw new Error("Terrain contour segment capacity exceeded");
|
|
17599
|
+
edges.set(edge, tileIndex);
|
|
17600
|
+
segments.push(a, b);
|
|
17601
|
+
levelIndices.push(level);
|
|
17602
|
+
}
|
|
17603
|
+
}
|
|
17604
|
+
return {
|
|
17605
|
+
positions: Float64Array.from(positions),
|
|
17606
|
+
gridCoordinates: Float64Array.from(grid),
|
|
17607
|
+
segments: Uint32Array.from(segments),
|
|
17608
|
+
levelIndices: Uint32Array.from(levelIndices),
|
|
17609
|
+
levels,
|
|
17610
|
+
origin,
|
|
17611
|
+
heightReference: first.heightReference
|
|
17612
|
+
};
|
|
17613
|
+
}
|
|
17614
|
+
|
|
17615
|
+
// dist/terrain/contour-boundary-diagnostics.js
|
|
17616
|
+
var TerrainContourBoundaryAxis = { COLUMN: 1, ROW: 2 };
|
|
17617
|
+
function diagnoseTerrainContourBoundaries(contours, options) {
|
|
17618
|
+
const { width, height } = options;
|
|
17619
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height) || height < 2)
|
|
17620
|
+
throw new Error("Invalid terrain contour boundary tile dimensions");
|
|
17621
|
+
const limits = contourPathLimits(options);
|
|
17622
|
+
const count = validateContourData(contours, limits);
|
|
17623
|
+
if (!(contours.segments instanceof Uint32Array) || contours.segments.length % 2 || !(contours.levelIndices instanceof Uint32Array) || contours.levelIndices.length !== contours.segments.length / 2 || contours.levelIndices.length > limits.maxSegments)
|
|
17624
|
+
throw new Error("Invalid terrain contour boundary segments or capacity");
|
|
17625
|
+
const degrees2 = new Uint32Array(count), assignments = new Uint32Array(count).fill(4294967295);
|
|
17626
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17627
|
+
for (let i = 0; i < contours.levelIndices.length; i++) {
|
|
17628
|
+
const a = contours.segments[2 * i], b = contours.segments[2 * i + 1], level = contours.levelIndices[i];
|
|
17629
|
+
validateContourVertex(contours, a, level, assignments);
|
|
17630
|
+
validateContourVertex(contours, b, level, assignments);
|
|
17631
|
+
if (a === b || contours.positions[3 * a] === contours.positions[3 * b] && contours.positions[3 * a + 1] === contours.positions[3 * b + 1])
|
|
17632
|
+
throw new Error("Degenerate terrain contour segment");
|
|
17633
|
+
const key2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
17634
|
+
if (seen.has(key2))
|
|
17635
|
+
throw new Error("Duplicate terrain contour segment");
|
|
17636
|
+
seen.add(key2);
|
|
17637
|
+
degrees2[a]++;
|
|
17638
|
+
degrees2[b]++;
|
|
17639
|
+
}
|
|
17640
|
+
const vertices = [], resultDegrees = [], levels = [], axes = [];
|
|
17641
|
+
for (let i = 0; i < count; i++) {
|
|
17642
|
+
if (degrees2[i] !== 1 && degrees2[i] <= 2)
|
|
17643
|
+
continue;
|
|
17644
|
+
const x = contours.gridCoordinates[2 * i], y = contours.gridCoordinates[2 * i + 1];
|
|
17645
|
+
if (Math.abs(x) > Number.MAX_SAFE_INTEGER || Math.abs(y) > Number.MAX_SAFE_INTEGER)
|
|
17646
|
+
throw new Error("Terrain contour boundary lattice exceeds safe integer range");
|
|
17647
|
+
const axis = (Number.isSafeInteger(x) && x % (width - 1) === 0 ? TerrainContourBoundaryAxis.COLUMN : 0) | (Number.isSafeInteger(y) && y % (height - 1) === 0 ? TerrainContourBoundaryAxis.ROW : 0);
|
|
17648
|
+
if (!axis)
|
|
17649
|
+
continue;
|
|
17650
|
+
vertices.push(i);
|
|
17651
|
+
resultDegrees.push(degrees2[i]);
|
|
17652
|
+
levels.push(assignments[i]);
|
|
17653
|
+
axes.push(axis);
|
|
17654
|
+
}
|
|
17655
|
+
return {
|
|
17656
|
+
vertexIndices: Uint32Array.from(vertices),
|
|
17657
|
+
degrees: Uint32Array.from(resultDegrees),
|
|
17658
|
+
levelIndices: Uint32Array.from(levels),
|
|
17659
|
+
boundaryAxes: Uint8Array.from(axes)
|
|
17660
|
+
};
|
|
17661
|
+
}
|
|
17662
|
+
|
|
17663
|
+
// dist/terrain/contour-tile-paths.js
|
|
17664
|
+
function stitchTerrainContourTiles(tiles, options) {
|
|
17665
|
+
return stitchTerrainContours(weldTerrainContourTiles(tiles, options), options);
|
|
17666
|
+
}
|
|
17667
|
+
|
|
17668
|
+
// dist/terrain/gradient-pyramid.js
|
|
17669
|
+
function createTerrainGradientPyramid(grid, options = {}) {
|
|
17670
|
+
const { width, height, gradients, statuses } = grid;
|
|
17671
|
+
const count = width * height, limit = options.maxSamples ?? 4e6;
|
|
17672
|
+
if (!Number.isSafeInteger(width) || width < 1 || !Number.isSafeInteger(height) || height < 1 || !Number.isSafeInteger(count) || count > 4294967295 || !Number.isSafeInteger(limit) || limit < count || !(gradients instanceof Float64Array) || gradients.length !== 2 * count || !(statuses instanceof Uint8Array) || statuses.length !== count || grid.method !== "horn" && grid.method !== "zevenbergen-thorne" || grid.registration !== "cell" && grid.registration !== "vertex" || typeof grid.heightReference !== "string" || ![grid.origin, grid.columnStep, grid.rowStep].every((v) => v.length === 2 && v.every(Number.isFinite)))
|
|
17673
|
+
throw new Error("Invalid terrain gradient pyramid input or capacity");
|
|
17674
|
+
const base = {
|
|
17675
|
+
width,
|
|
17676
|
+
height,
|
|
17677
|
+
blockSize: 1,
|
|
17678
|
+
gradients: new Float64Array(2 * count),
|
|
17679
|
+
validCounts: new Uint32Array(count),
|
|
17680
|
+
sampleCounts: new Uint32Array(count).fill(1)
|
|
17681
|
+
};
|
|
17682
|
+
for (let i = 0; i < count; i++) {
|
|
17683
|
+
if (statuses[i] > TerrainSampleStatus.NOT_RESIDENT)
|
|
17684
|
+
throw new Error("Invalid terrain gradient status");
|
|
17685
|
+
if (statuses[i] === TerrainSampleStatus.VALID) {
|
|
17686
|
+
if (!Number.isFinite(gradients[2 * i]) || !Number.isFinite(gradients[2 * i + 1]))
|
|
17687
|
+
throw new Error("Invalid terrain gradient value");
|
|
17688
|
+
base.gradients[2 * i] = gradients[2 * i];
|
|
17689
|
+
base.gradients[2 * i + 1] = gradients[2 * i + 1];
|
|
17690
|
+
base.validCounts[i] = 1;
|
|
17691
|
+
}
|
|
17692
|
+
}
|
|
17693
|
+
const levels = [base];
|
|
17694
|
+
let source = base;
|
|
17695
|
+
while (source.width > 1 || source.height > 1) {
|
|
17696
|
+
const w = Math.ceil(source.width / 2), h = Math.ceil(source.height / 2);
|
|
17697
|
+
const next = {
|
|
17698
|
+
width: w,
|
|
17699
|
+
height: h,
|
|
17700
|
+
blockSize: source.blockSize * 2,
|
|
17701
|
+
gradients: new Float64Array(2 * w * h),
|
|
17702
|
+
validCounts: new Uint32Array(w * h),
|
|
17703
|
+
sampleCounts: new Uint32Array(w * h)
|
|
17704
|
+
};
|
|
17705
|
+
for (let y = 0; y < h; y++)
|
|
17706
|
+
for (let x = 0; x < w; x++) {
|
|
17707
|
+
const out = y * w + x;
|
|
17708
|
+
for (let dy = 0; dy < 2; dy++)
|
|
17709
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
17710
|
+
const sx = 2 * x + dx, sy = 2 * y + dy;
|
|
17711
|
+
if (sx >= source.width || sy >= source.height)
|
|
17712
|
+
continue;
|
|
17713
|
+
const index = sy * source.width + sx, n = source.validCounts[index], old = next.validCounts[out];
|
|
17714
|
+
next.sampleCounts[out] += source.sampleCounts[index];
|
|
17715
|
+
if (n) {
|
|
17716
|
+
const total = old + n;
|
|
17717
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
17718
|
+
const a = next.gradients[2 * out + axis], b = source.gradients[2 * index + axis];
|
|
17719
|
+
next.gradients[2 * out + axis] = old ? a * (old / total) + b * (n / total) : b;
|
|
17720
|
+
}
|
|
17721
|
+
next.validCounts[out] = total;
|
|
17722
|
+
}
|
|
17723
|
+
}
|
|
17724
|
+
}
|
|
17725
|
+
levels.push(next);
|
|
17726
|
+
source = next;
|
|
17727
|
+
}
|
|
17728
|
+
return {
|
|
17729
|
+
levels,
|
|
17730
|
+
method: grid.method,
|
|
17731
|
+
origin: [...grid.origin],
|
|
17732
|
+
columnStep: [...grid.columnStep],
|
|
17733
|
+
rowStep: [...grid.rowStep],
|
|
17734
|
+
registration: grid.registration,
|
|
17735
|
+
heightReference: grid.heightReference
|
|
17736
|
+
};
|
|
17737
|
+
}
|
|
17738
|
+
|
|
17495
17739
|
// dist/terrain/contour-simplify.js
|
|
17496
17740
|
function simplifyTerrainContourPaths(paths, options) {
|
|
17497
17741
|
const limits = contourPathLimits(options), count = validateContourData(paths, limits);
|