@math.gl/geospatial 5.0.0 → 5.0.2
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/coverage-simplification.d.ts +9 -0
- package/dist/coverage-simplification.d.ts.map +1 -0
- package/dist/coverage-simplification.js +167 -0
- package/dist/coverage-simplification.js.map +1 -0
- package/dist/line-network/build-line-network.d.ts +100 -0
- package/dist/line-network/build-line-network.d.ts.map +1 -0
- package/dist/line-network/build-line-network.js +766 -0
- package/dist/line-network/build-line-network.js.map +1 -0
- package/dist/line-network/line-network-routes.d.ts +53 -0
- package/dist/line-network/line-network-routes.d.ts.map +1 -0
- package/dist/line-network/line-network-routes.js +146 -0
- package/dist/line-network/line-network-routes.js.map +1 -0
- package/dist/line-network/line-network-weights.d.ts +11 -0
- package/dist/line-network/line-network-weights.d.ts.map +1 -0
- package/dist/line-network/line-network-weights.js +25 -0
- package/dist/line-network/line-network-weights.js.map +1 -0
- package/dist/line-network.cjs +850 -0
- package/dist/line-network.cjs.map +6 -0
- package/dist/line-network.d.ts +7 -0
- package/dist/line-network.d.ts.map +1 -0
- package/dist/line-network.js +7 -0
- package/dist/line-network.js.map +1 -0
- package/dist/line-simplification.d.ts +7 -0
- package/dist/line-simplification.d.ts.map +1 -1
- package/dist/line-simplification.js +4 -13
- package/dist/line-simplification.js.map +1 -1
- package/dist/linear-referencing.d.ts +3 -1
- package/dist/linear-referencing.d.ts.map +1 -1
- package/dist/linear-referencing.js +21 -33
- package/dist/linear-referencing.js.map +1 -1
- package/dist/measure-referencing.d.ts +16 -0
- package/dist/measure-referencing.d.ts.map +1 -0
- package/dist/measure-referencing.js +143 -0
- package/dist/measure-referencing.js.map +1 -0
- package/dist/polygon-simplification.d.ts +6 -0
- package/dist/polygon-simplification.d.ts.map +1 -0
- package/dist/polygon-simplification.js +111 -0
- package/dist/polygon-simplification.js.map +1 -0
- package/dist/route-editing.d.ts +10 -0
- package/dist/route-editing.d.ts.map +1 -0
- package/dist/route-editing.js +58 -0
- package/dist/route-editing.js.map +1 -0
- package/dist/spatial-box-clipping.d.ts +9 -0
- package/dist/spatial-box-clipping.d.ts.map +1 -0
- package/dist/spatial-box-clipping.js +123 -0
- package/dist/spatial-box-clipping.js.map +1 -0
- package/dist/spatial-dwithin.d.ts +19 -0
- package/dist/spatial-dwithin.d.ts.map +1 -0
- package/dist/spatial-dwithin.js +107 -0
- package/dist/spatial-dwithin.js.map +1 -0
- package/dist/spatial-hulls.d.ts +6 -0
- package/dist/spatial-hulls.d.ts.map +1 -0
- package/dist/spatial-hulls.js +176 -0
- package/dist/spatial-hulls.js.map +1 -0
- package/dist/spatial-line-intersection-result.d.ts +4 -0
- package/dist/spatial-line-intersection-result.d.ts.map +1 -0
- package/dist/spatial-line-intersection-result.js +79 -0
- package/dist/spatial-line-intersection-result.js.map +1 -0
- package/dist/spatial-line-polygon-intersection.d.ts +4 -0
- package/dist/spatial-line-polygon-intersection.d.ts.map +1 -0
- package/dist/spatial-line-polygon-intersection.js +130 -0
- package/dist/spatial-line-polygon-intersection.js.map +1 -0
- package/dist/spatial-planar-intersects.d.ts +1 -0
- package/dist/spatial-planar-intersects.d.ts.map +1 -1
- package/dist/spatial-planar-intersects.js +5 -37
- package/dist/spatial-planar-intersects.js.map +1 -1
- package/dist/spatial-planar.d.ts +9 -0
- package/dist/spatial-planar.d.ts.map +1 -1
- package/dist/spatial-planar.js +13 -1
- package/dist/spatial-planar.js.map +1 -1
- package/dist/spatial-polygon-overlay.d.ts +5 -0
- package/dist/spatial-polygon-overlay.d.ts.map +1 -0
- package/dist/spatial-polygon-overlay.js +23 -0
- package/dist/spatial-polygon-overlay.js.map +1 -0
- package/dist/spatial-sql.d.ts +15 -2
- package/dist/spatial-sql.d.ts.map +1 -1
- package/dist/spatial-sql.js +65 -13
- package/dist/spatial-sql.js.map +1 -1
- package/dist/spatial-subdivision.d.ts +9 -0
- package/dist/spatial-subdivision.d.ts.map +1 -0
- package/dist/spatial-subdivision.js +61 -0
- package/dist/spatial-subdivision.js.map +1 -0
- package/dist/spatial-touches.d.ts +11 -0
- package/dist/spatial-touches.d.ts.map +1 -0
- package/dist/spatial-touches.js +178 -0
- package/dist/spatial-touches.js.map +1 -0
- package/dist/st-coverage-functions.d.ts +11 -0
- package/dist/st-coverage-functions.d.ts.map +1 -0
- package/dist/st-coverage-functions.js +57 -0
- package/dist/st-coverage-functions.js.map +1 -0
- package/dist/st-functions.cjs +3279 -554
- package/dist/st-functions.cjs.map +3 -3
- package/dist/st-functions.d.ts +100 -2
- package/dist/st-functions.d.ts.map +1 -1
- package/dist/st-functions.js +239 -22
- package/dist/st-functions.js.map +1 -1
- package/dist/st-geodesic-functions.d.ts +41 -0
- package/dist/st-geodesic-functions.d.ts.map +1 -0
- package/dist/st-geodesic-functions.js +238 -0
- package/dist/st-geodesic-functions.js.map +1 -0
- package/dist/st-hull-functions.cjs +386 -0
- package/dist/st-hull-functions.cjs.map +6 -0
- package/dist/st-hull-functions.d.ts +17 -0
- package/dist/st-hull-functions.d.ts.map +1 -0
- package/dist/st-hull-functions.js +14 -0
- package/dist/st-hull-functions.js.map +1 -0
- package/dist/st-overlay-functions.cjs +668 -0
- package/dist/st-overlay-functions.cjs.map +6 -0
- package/dist/st-overlay-functions.d.ts +46 -0
- package/dist/st-overlay-functions.d.ts.map +1 -0
- package/dist/st-overlay-functions.js +248 -0
- package/dist/st-overlay-functions.js.map +1 -0
- package/dist/st-viewport-functions.cjs +481 -0
- package/dist/st-viewport-functions.cjs.map +6 -0
- package/dist/st-viewport-functions.d.ts +13 -0
- package/dist/st-viewport-functions.d.ts.map +1 -0
- package/dist/st-viewport-functions.js +81 -0
- package/dist/st-viewport-functions.js.map +1 -0
- package/dist/terrain/index.cjs +93 -20
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +1 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +1 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/regional-watersheds.d.ts +44 -0
- package/dist/terrain/regional-watersheds.d.ts.map +1 -0
- package/dist/terrain/regional-watersheds.js +108 -0
- package/dist/terrain/regional-watersheds.js.map +1 -0
- package/dist/terrain/tile-cutout-update.d.ts.map +1 -1
- package/dist/terrain/tile-cutout-update.js +28 -22
- package/dist/terrain/tile-cutout-update.js.map +1 -1
- package/dist/turf-functions.cjs +16 -9
- package/dist/turf-functions.cjs.map +1 -1
- package/package.json +27 -6
- package/src/coverage-simplification.ts +215 -0
- package/src/line-network/build-line-network.ts +990 -0
- package/src/line-network/line-network-routes.ts +213 -0
- package/src/line-network/line-network-weights.ts +40 -0
- package/src/line-network.ts +29 -0
- package/src/line-simplification.ts +4 -16
- package/src/linear-referencing.ts +27 -40
- package/src/measure-referencing.ts +165 -0
- package/src/polygon-simplification.ts +146 -0
- package/src/route-editing.ts +107 -0
- package/src/spatial-box-clipping.ts +140 -0
- package/src/spatial-dwithin.ts +135 -0
- package/src/spatial-hulls.ts +203 -0
- package/src/spatial-line-intersection-result.ts +93 -0
- package/src/spatial-line-polygon-intersection.ts +152 -0
- package/src/spatial-planar-intersects.ts +10 -51
- package/src/spatial-planar.ts +20 -1
- package/src/spatial-polygon-overlay.ts +30 -0
- package/src/spatial-sql.ts +97 -13
- package/src/spatial-subdivision.ts +75 -0
- package/src/spatial-touches.ts +204 -0
- package/src/st-coverage-functions.ts +88 -0
- package/src/st-functions.ts +345 -26
- package/src/st-geodesic-functions.ts +313 -0
- package/src/st-hull-functions.ts +25 -0
- package/src/st-overlay-functions.ts +313 -0
- package/src/st-viewport-functions.ts +98 -0
- package/src/terrain/index.ts +7 -0
- package/src/terrain/regional-watersheds.ts +153 -0
- package/src/terrain/tile-cutout-update.ts +32 -26
package/dist/terrain/index.cjs
CHANGED
|
@@ -63,6 +63,7 @@ __export(index_exports, {
|
|
|
63
63
|
createTerrainMixedIsobands: () => createTerrainMixedIsobands,
|
|
64
64
|
createTerrainMixedVertexTileHalos: () => createTerrainMixedVertexTileHalos,
|
|
65
65
|
createTerrainRegionalViewshed: () => createTerrainRegionalViewshed,
|
|
66
|
+
createTerrainRegionalWatersheds: () => createTerrainRegionalWatersheds,
|
|
66
67
|
createTerrainSkirt: () => createTerrainSkirt,
|
|
67
68
|
createTerrainSlopeAspectGrid: () => createTerrainSlopeAspectGrid,
|
|
68
69
|
createTerrainSurface: () => createTerrainSurface,
|
|
@@ -8032,6 +8033,7 @@ function updateTerrainTileCutouts(residents, polygon2, previous, options = {}) {
|
|
|
8032
8033
|
splitTerrainMesh({ positions: new Float64Array(), indices: new Uint32Array() }, polygon2, limits);
|
|
8033
8034
|
const entries = /* @__PURE__ */ new Map();
|
|
8034
8035
|
const rebuilt = [];
|
|
8036
|
+
const dirty = /* @__PURE__ */ new Map();
|
|
8035
8037
|
let boundaryCount = 0;
|
|
8036
8038
|
for (const resident of residents) {
|
|
8037
8039
|
if (!resident.id || typeof resident.id !== "string" || entries.has(resident.id) || !Number.isSafeInteger(resident.revision) || resident.revision < 0)
|
|
@@ -8053,6 +8055,7 @@ function updateTerrainTileCutouts(residents, polygon2, previous, options = {}) {
|
|
|
8053
8055
|
}
|
|
8054
8056
|
entry = { resident: { ...resident }, split, displayed: split, bounds: bounds2, edges: edges2 };
|
|
8055
8057
|
rebuilt.push(resident.id);
|
|
8058
|
+
dirty.set(entry, entries.size);
|
|
8056
8059
|
}
|
|
8057
8060
|
boundaryCount += entry.edges.length;
|
|
8058
8061
|
if (boundaryCount > limits.maxBoundaryEdges)
|
|
@@ -8060,45 +8063,42 @@ function updateTerrainTileCutouts(residents, polygon2, previous, options = {}) {
|
|
|
8060
8063
|
entries.set(resident.id, entry);
|
|
8061
8064
|
}
|
|
8062
8065
|
const values = [...entries.values()];
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
if (a.bounds[2] < b.bounds[0] || b.bounds[2] < a.bounds[0] || a.bounds[3] < b.bounds[1] || b.bounds[3] < a.bounds[1])
|
|
8066
|
+
const pairCount = values.length * (values.length - 1) / 2;
|
|
8067
|
+
if (pairCount > limits.maxPairChecks)
|
|
8068
|
+
throw new RangeError("Terrain cutout pair budget exceeded");
|
|
8069
|
+
for (const [a, index] of dirty)
|
|
8070
|
+
for (const b of values) {
|
|
8071
|
+
if (a === b || (dirty.get(b) ?? Infinity) < index)
|
|
8070
8072
|
continue;
|
|
8071
|
-
if (
|
|
8073
|
+
if (a.bounds[2] < b.bounds[0] || b.bounds[2] < a.bounds[0] || a.bounds[3] < b.bounds[1] || b.bounds[3] < a.bounds[1])
|
|
8072
8074
|
continue;
|
|
8073
8075
|
const combined = assembleTerrainCutoutTiles([a.resident.mesh, b.resident.mesh], limits);
|
|
8074
8076
|
validateTerrainCutoutTopology(combined.mesh, combined.remainingWork);
|
|
8075
8077
|
}
|
|
8076
8078
|
const boundaries = /* @__PURE__ */ new Map();
|
|
8077
|
-
const cutKeys = /* @__PURE__ */ new Map();
|
|
8078
8079
|
for (let tile = 0; tile < values.length; tile++)
|
|
8079
8080
|
for (const edge2 of values[tile].edges) {
|
|
8080
8081
|
const other = boundaries.get(edge2.key);
|
|
8081
|
-
if (
|
|
8082
|
-
boundaries.set(edge2.key,
|
|
8082
|
+
if (other === void 0) {
|
|
8083
|
+
boundaries.set(edge2.key, edge2);
|
|
8083
8084
|
continue;
|
|
8084
8085
|
}
|
|
8085
|
-
if (other
|
|
8086
|
+
if (typeof other !== "object" || other === null || other.start !== edge2.end || other.end !== edge2.start)
|
|
8086
8087
|
throw new RangeError("Nonconforming terrain cutout tile boundary");
|
|
8087
|
-
other.
|
|
8088
|
-
if (other.edge.side !== edge2.side) {
|
|
8089
|
-
cutKeys.set(edge2.key, edge2.side === 0 ? edge2.polygon : other.edge.polygon);
|
|
8090
|
-
}
|
|
8088
|
+
boundaries.set(edge2.key, other.side === edge2.side ? null : edge2.side === 0 ? edge2.polygon : other.polygon);
|
|
8091
8089
|
}
|
|
8092
8090
|
const tiles = /* @__PURE__ */ new Map();
|
|
8093
8091
|
const changed = [];
|
|
8092
|
+
const cuts = [[], []];
|
|
8093
|
+
const polygons = [[], []];
|
|
8094
8094
|
for (let i = 0; i < values.length; i++) {
|
|
8095
8095
|
const entry = values[i];
|
|
8096
8096
|
const old = prior == null ? void 0 : prior.entries.get(entry.resident.id);
|
|
8097
|
-
|
|
8098
|
-
|
|
8097
|
+
cuts[0].length = cuts[1].length = 0;
|
|
8098
|
+
polygons[0].length = polygons[1].length = 0;
|
|
8099
8099
|
for (const edge2 of entry.edges) {
|
|
8100
|
-
const polygonIndex =
|
|
8101
|
-
if (polygonIndex
|
|
8100
|
+
const polygonIndex = boundaries.get(edge2.key);
|
|
8101
|
+
if (typeof polygonIndex === "number") {
|
|
8102
8102
|
cuts[edge2.side].push(edge2.a, edge2.b);
|
|
8103
8103
|
polygons[edge2.side].push(polygonIndex);
|
|
8104
8104
|
}
|
|
@@ -8374,4 +8374,77 @@ function contains(ring, p, charge) {
|
|
|
8374
8374
|
}
|
|
8375
8375
|
return winding === 0 ? -1 : 1;
|
|
8376
8376
|
}
|
|
8377
|
+
|
|
8378
|
+
// dist/terrain/regional-watersheds.js
|
|
8379
|
+
function createTerrainRegionalWatersheds(tiles, { width, height, origin, outlets, maxCells = 4194304 }) {
|
|
8380
|
+
const count = width * height;
|
|
8381
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height) || height < 2 || !Number.isSafeInteger(maxCells) || maxCells < 0 || origin.length !== 2 || !origin.every(Number.isFinite) || count > maxCells || count > 2147483647 || !tiles.length)
|
|
8382
|
+
throw new RangeError("Invalid regional watershed window or cell budget");
|
|
8383
|
+
const { columnStep, rowStep, heightReference, diagonal } = tiles[0].field;
|
|
8384
|
+
const heights = new Float64Array(count);
|
|
8385
|
+
const validity = new Uint8Array(count);
|
|
8386
|
+
const coverage = new Uint8Array(count);
|
|
8387
|
+
for (const { column, row, field: field2 } of tiles) {
|
|
8388
|
+
if (!Number.isSafeInteger(column) || !Number.isSafeInteger(row) || column < 0 || row < 0 || column + field2.width > width || row + field2.height > height || field2.registration !== "cell" || field2.heightReference !== heightReference || field2.diagonal !== diagonal || !origin.every((value, axis) => field2.origin[axis] === value + column * columnStep[axis] + row * rowStep[axis] && field2.columnStep[axis] === columnStep[axis] && field2.rowStep[axis] === rowStep[axis]))
|
|
8389
|
+
throw new RangeError("Regional watershed tiles must align to the shared cell grid");
|
|
8390
|
+
for (let y = 0; y < field2.height; y++) {
|
|
8391
|
+
for (let x = 0; x < field2.width; x++) {
|
|
8392
|
+
const index = (row + y) * width + column + x;
|
|
8393
|
+
if (coverage[index])
|
|
8394
|
+
throw new RangeError("Regional watershed tiles overlap");
|
|
8395
|
+
const value = field2.getHeight(x, y);
|
|
8396
|
+
coverage[index] = value === void 0 ? 1 : 2;
|
|
8397
|
+
if (value !== void 0) {
|
|
8398
|
+
heights[index] = value;
|
|
8399
|
+
validity[index] = 1;
|
|
8400
|
+
}
|
|
8401
|
+
}
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
const mosaic = new HeightField({
|
|
8405
|
+
width,
|
|
8406
|
+
height,
|
|
8407
|
+
origin,
|
|
8408
|
+
columnStep,
|
|
8409
|
+
rowStep,
|
|
8410
|
+
heightReference,
|
|
8411
|
+
diagonal,
|
|
8412
|
+
registration: "cell",
|
|
8413
|
+
heights,
|
|
8414
|
+
validity
|
|
8415
|
+
});
|
|
8416
|
+
const { field, receiver } = fillTerrainDepressions(mosaic, { outlets, maxCells });
|
|
8417
|
+
const touchesUnknown = new Uint8Array(count);
|
|
8418
|
+
const queue = new Int32Array(count);
|
|
8419
|
+
let end = 0;
|
|
8420
|
+
function mark(index) {
|
|
8421
|
+
if (coverage[index] !== 2 || touchesUnknown[index])
|
|
8422
|
+
return;
|
|
8423
|
+
touchesUnknown[index] = 1;
|
|
8424
|
+
queue[end++] = index;
|
|
8425
|
+
}
|
|
8426
|
+
function markNeighbors(index) {
|
|
8427
|
+
const x = index % width;
|
|
8428
|
+
if (x > 0)
|
|
8429
|
+
mark(index - 1);
|
|
8430
|
+
if (x + 1 < width)
|
|
8431
|
+
mark(index + 1);
|
|
8432
|
+
if (index >= width)
|
|
8433
|
+
mark(index - width);
|
|
8434
|
+
if (index < count - width)
|
|
8435
|
+
mark(index + width);
|
|
8436
|
+
}
|
|
8437
|
+
for (let i = 0; i < count; i++)
|
|
8438
|
+
if (coverage[i] === 0)
|
|
8439
|
+
markNeighbors(i);
|
|
8440
|
+
for (let i = 0; i < end; i++)
|
|
8441
|
+
markNeighbors(queue[i]);
|
|
8442
|
+
return {
|
|
8443
|
+
field,
|
|
8444
|
+
receiver,
|
|
8445
|
+
coverage,
|
|
8446
|
+
touchesUnknown,
|
|
8447
|
+
...accumulateTerrainWatersheds(receiver, { maxCells })
|
|
8448
|
+
};
|
|
8449
|
+
}
|
|
8377
8450
|
//# sourceMappingURL=index.cjs.map
|