@math.gl/geospatial 5.0.0-beta.2 → 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 +618 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/tasks/definitions.d.ts +90 -0
- package/dist/tasks/definitions.d.ts.map +1 -0
- package/dist/tasks/definitions.js +54 -0
- package/dist/tasks/definitions.js.map +1 -0
- package/dist/{workers → tasks}/index.cjs +158 -122
- package/dist/tasks/index.cjs.map +6 -0
- package/dist/tasks/index.d.ts +12 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +30 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/{workers → tasks}/map-worker.d.ts.map +1 -1
- package/dist/tasks/map-worker.js +7 -0
- package/dist/tasks/map-worker.js.map +1 -0
- package/dist/{workers → tasks}/operations.d.ts +6 -4
- package/dist/tasks/operations.d.ts.map +1 -0
- package/dist/{workers → tasks}/operations.js +3 -5
- package/dist/tasks/operations.js.map +1 -0
- package/dist/tasks/projection-worker.d.ts.map +1 -0
- package/dist/tasks/projection-worker.js +7 -0
- package/dist/tasks/projection-worker.js.map +1 -0
- 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/filtered-pyramid.d.ts +22 -0
- package/dist/terrain/filtered-pyramid.d.ts.map +1 -0
- package/dist/terrain/filtered-pyramid.js +71 -0
- package/dist/terrain/filtered-pyramid.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 +619 -1
- package/dist/terrain/index.cjs.map +2 -2
- package/dist/terrain/index.d.ts +19 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +11 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/profile-horizon.d.ts +20 -0
- package/dist/terrain/profile-horizon.d.ts.map +1 -0
- package/dist/terrain/profile-horizon.js +69 -0
- package/dist/terrain/profile-horizon.js.map +1 -0
- package/dist/terrain/profile-slope.d.ts +3 -0
- package/dist/terrain/profile-slope.d.ts.map +1 -0
- package/dist/terrain/profile-slope.js +35 -0
- package/dist/terrain/profile-slope.js.map +1 -0
- package/dist/terrain/profile-viewshed.d.ts +17 -0
- package/dist/terrain/profile-viewshed.d.ts.map +1 -0
- package/dist/terrain/profile-viewshed.js +51 -0
- package/dist/terrain/profile-viewshed.js.map +1 -0
- package/dist/terrain/profile-visibility.d.ts +21 -0
- package/dist/terrain/profile-visibility.d.ts.map +1 -0
- package/dist/terrain/profile-visibility.js +61 -0
- package/dist/terrain/profile-visibility.js.map +1 -0
- package/dist/terrain/vertex-halo-invalidation.d.ts +16 -0
- package/dist/terrain/vertex-halo-invalidation.d.ts.map +1 -0
- package/dist/terrain/vertex-halo-invalidation.js +50 -0
- package/dist/terrain/vertex-halo-invalidation.js.map +1 -0
- package/dist/terrain/vertex-halo-update.d.ts +18 -0
- package/dist/terrain/vertex-halo-update.d.ts.map +1 -0
- package/dist/terrain/vertex-halo-update.js +76 -0
- package/dist/terrain/vertex-halo-update.js.map +1 -0
- package/dist/terrain/vertex-halos.d.ts +26 -0
- package/dist/terrain/vertex-halos.d.ts.map +1 -0
- package/dist/terrain/vertex-halos.js +80 -0
- package/dist/terrain/vertex-halos.js.map +1 -0
- package/package.json +10 -15
- package/src/index.ts +22 -0
- package/src/tasks/definitions.ts +89 -0
- package/src/tasks/index.ts +39 -0
- package/src/tasks/map-worker.ts +6 -0
- package/src/{workers → tasks}/operations.ts +11 -7
- package/src/tasks/projection-worker.ts +6 -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/filtered-pyramid.ts +95 -0
- package/src/terrain/gradient-pyramid.ts +129 -0
- package/src/terrain/index.ts +22 -0
- package/src/terrain/profile-horizon.ts +86 -0
- package/src/terrain/profile-slope.ts +32 -0
- package/src/terrain/profile-viewshed.ts +57 -0
- package/src/terrain/profile-visibility.ts +81 -0
- package/src/terrain/vertex-halo-invalidation.ts +57 -0
- package/src/terrain/vertex-halo-update.ts +91 -0
- package/src/terrain/vertex-halos.ts +101 -0
- package/dist/workers/index.cjs.map +0 -6
- package/dist/workers/index.d.ts +0 -12
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -41
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/map-worker.js +0 -7
- package/dist/workers/map-worker.js.map +0 -1
- package/dist/workers/operations.cjs +0 -21008
- package/dist/workers/operations.cjs.map +0 -6
- package/dist/workers/operations.d.ts.map +0 -1
- package/dist/workers/operations.js.map +0 -1
- package/dist/workers/projection-worker.d.ts.map +0 -1
- package/dist/workers/projection-worker.js +0 -7
- package/dist/workers/projection-worker.js.map +0 -1
- package/src/workers/index.ts +0 -59
- package/src/workers/map-worker.ts +0 -7
- package/src/workers/projection-worker.ts +0 -7
- /package/dist/{workers → tasks}/map-worker.d.ts +0 -0
- /package/dist/{workers → tasks}/projection-worker.d.ts +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { reconcileTerrainVertexTiles } from "./vertex-tiles.js";
|
|
5
|
+
/** Residency and validity of each padded lattice point. */
|
|
6
|
+
export const TerrainVertexHaloStatus = { NOT_RESIDENT: 0, NO_DATA: 1, VALID: 2 };
|
|
7
|
+
/** Reconcile and pad same-level vertex tiles with the actual adjacent lattice samples.
|
|
8
|
+
* Missing neighbors are NOT_RESIDENT; resident invalid samples are NO_DATA. No values
|
|
9
|
+
* are extrapolated. Recompute from a new tile snapshot after arrivals or evictions.
|
|
10
|
+
*/
|
|
11
|
+
export function createTerrainVertexTileHalos(tiles, options) {
|
|
12
|
+
const { width, height } = options;
|
|
13
|
+
const paddedWidth = width + 2, paddedHeight = height + 2;
|
|
14
|
+
const paddedCount = paddedWidth * paddedHeight * tiles.length;
|
|
15
|
+
if (!Number.isSafeInteger(paddedCount) || paddedCount > (options.maxSamples ?? 4000000))
|
|
16
|
+
throw new Error('Vertex tile halo sample capacity exceeded');
|
|
17
|
+
const reconciled = reconcileTerrainVertexTiles(tiles, options);
|
|
18
|
+
const lattice = new Map();
|
|
19
|
+
for (const tile of reconciled.tiles) {
|
|
20
|
+
const x = tile.column * (width - 1), y = tile.row * (height - 1);
|
|
21
|
+
if (![x - 1, y - 1, x + width, y + height].every(Number.isSafeInteger))
|
|
22
|
+
throw new Error('Vertex tile halo lattice overflow');
|
|
23
|
+
for (let row = 0; row < height; row++) {
|
|
24
|
+
for (let col = 0; col < width; col++) {
|
|
25
|
+
const index = row * width + col;
|
|
26
|
+
lattice.set(`${x + col},${y + row}`, {
|
|
27
|
+
height: tile.field.heights[index],
|
|
28
|
+
valid: tile.field.validity[index] !== 0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const result = reconciled.tiles.map(tile => {
|
|
34
|
+
const x = tile.column * (width - 1), y = tile.row * (height - 1);
|
|
35
|
+
const heights = new Float64Array(paddedWidth * paddedHeight);
|
|
36
|
+
const validity = new Uint8Array(heights.length);
|
|
37
|
+
const statuses = new Uint8Array(heights.length);
|
|
38
|
+
for (let row = 0; row < paddedHeight; row++) {
|
|
39
|
+
for (let col = 0; col < paddedWidth; col++) {
|
|
40
|
+
const index = row * paddedWidth + col;
|
|
41
|
+
const value = lattice.get(`${x + col - 1},${y + row - 1}`);
|
|
42
|
+
if (value) {
|
|
43
|
+
statuses[index] = value.valid
|
|
44
|
+
? TerrainVertexHaloStatus.VALID
|
|
45
|
+
: TerrainVertexHaloStatus.NO_DATA;
|
|
46
|
+
if (value.valid) {
|
|
47
|
+
heights[index] = value.height;
|
|
48
|
+
validity[index] = 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const origin = tile.field.origin, columnStep = tile.field.columnStep, rowStep = tile.field.rowStep;
|
|
54
|
+
const paddedOrigin = [
|
|
55
|
+
origin[0] - columnStep[0] - rowStep[0],
|
|
56
|
+
origin[1] - columnStep[1] - rowStep[1]
|
|
57
|
+
];
|
|
58
|
+
if (!paddedOrigin.every(Number.isFinite))
|
|
59
|
+
throw new Error('Vertex tile halo coordinate overflow');
|
|
60
|
+
return {
|
|
61
|
+
column: tile.column,
|
|
62
|
+
row: tile.row,
|
|
63
|
+
statuses,
|
|
64
|
+
field: {
|
|
65
|
+
...tile.field,
|
|
66
|
+
width: paddedWidth,
|
|
67
|
+
height: paddedHeight,
|
|
68
|
+
heights,
|
|
69
|
+
validity,
|
|
70
|
+
origin: paddedOrigin
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
tiles: result,
|
|
76
|
+
sharedVertices: reconciled.sharedVertices,
|
|
77
|
+
maxHeightDifference: reconciled.maxHeightDifference
|
|
78
|
+
};
|
|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,IAAI,CAAC,GAAG;YACb,QAAQ;YACR,KAAK,EAAE;gBACL,GAAG,IAAI,CAAC,KAAK;gBACb,KAAK,EAAE,WAAW;gBAClB,MAAM,EAAE,YAAY;gBACpB,OAAO;gBACP,QAAQ;gBACR,MAAM,EAAE,YAAY;aACrB;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO;QACL,KAAK,EAAE,MAAM;QACb,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;KACpD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"version": "5.0.0-beta.
|
|
9
|
+
"version": "5.0.0-beta.4",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"webgl",
|
|
12
12
|
"javascript",
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"import": "./dist/index.js",
|
|
34
34
|
"require": "./dist/index.cjs"
|
|
35
35
|
},
|
|
36
|
+
"./tasks": {
|
|
37
|
+
"types": "./dist/tasks/index.d.ts",
|
|
38
|
+
"import": "./dist/tasks/index.js",
|
|
39
|
+
"require": "./dist/tasks/index.cjs"
|
|
40
|
+
},
|
|
36
41
|
"./crs": {
|
|
37
42
|
"types": "./dist/crs/index.d.ts",
|
|
38
43
|
"import": "./dist/crs/index.js",
|
|
@@ -1015,16 +1020,6 @@
|
|
|
1015
1020
|
"import": "./dist/terrain/index.js",
|
|
1016
1021
|
"require": "./dist/terrain/index.cjs"
|
|
1017
1022
|
},
|
|
1018
|
-
"./workers": {
|
|
1019
|
-
"types": "./dist/workers/index.d.ts",
|
|
1020
|
-
"import": "./dist/workers/index.js",
|
|
1021
|
-
"require": "./dist/workers/index.cjs"
|
|
1022
|
-
},
|
|
1023
|
-
"./workers/operations": {
|
|
1024
|
-
"types": "./dist/workers/operations.d.ts",
|
|
1025
|
-
"import": "./dist/workers/operations.js",
|
|
1026
|
-
"require": "./dist/workers/operations.cjs"
|
|
1027
|
-
},
|
|
1028
1023
|
"./turf": {
|
|
1029
1024
|
"types": "./dist/turf.d.ts",
|
|
1030
1025
|
"import": "./dist/turf.js",
|
|
@@ -1046,9 +1041,9 @@
|
|
|
1046
1041
|
],
|
|
1047
1042
|
"dependencies": {
|
|
1048
1043
|
"@mapbox/martini": "0.2.0",
|
|
1049
|
-
"@math.gl/core": "5.0.0-beta.
|
|
1050
|
-
"@math.gl/geometry": "5.0.0-beta.
|
|
1051
|
-
"@math.gl/web-mercator": "5.0.0-beta.
|
|
1044
|
+
"@math.gl/core": "5.0.0-beta.4",
|
|
1045
|
+
"@math.gl/geometry": "5.0.0-beta.4",
|
|
1046
|
+
"@math.gl/web-mercator": "5.0.0-beta.4",
|
|
1052
1047
|
"polygon-clipping": "0.15.7"
|
|
1053
1048
|
},
|
|
1054
1049
|
"devDependencies": {
|
|
@@ -1060,5 +1055,5 @@
|
|
|
1060
1055
|
"proj4": "2.22.0"
|
|
1061
1056
|
},
|
|
1062
1057
|
"sideEffects": false,
|
|
1063
|
-
"gitHead": "
|
|
1058
|
+
"gitHead": "61847e2c9615be580088d54804fbb21c537b3850"
|
|
1064
1059
|
}
|
package/src/index.ts
CHANGED
|
@@ -373,12 +373,34 @@ export type {TerrainProfileSampler, TerrainProfile} from './terrain/profile';
|
|
|
373
373
|
export {createTerrainContours} from './terrain/contours';
|
|
374
374
|
export type {TerrainContours, TerrainContourOptions} from './terrain/contours';
|
|
375
375
|
export {stitchTerrainContours} from './terrain/contour-paths';
|
|
376
|
+
export {weldTerrainContourTiles} from './terrain/contour-tile-weld';
|
|
377
|
+
export {
|
|
378
|
+
diagnoseTerrainContourBoundaries,
|
|
379
|
+
TerrainContourBoundaryAxis
|
|
380
|
+
} from './terrain/contour-boundary-diagnostics';
|
|
381
|
+
export type {TerrainContourBoundaryDiagnostics} from './terrain/contour-boundary-diagnostics';
|
|
382
|
+
export {stitchTerrainContourTiles} from './terrain/contour-tile-paths';
|
|
383
|
+
export {createTerrainGradientPyramid} from './terrain/gradient-pyramid';
|
|
384
|
+
export type {TerrainGradientPyramid, TerrainGradientPyramidLevel} from './terrain/gradient-pyramid';
|
|
385
|
+
export type {TerrainContourTile, TerrainContourTileWeldOptions} from './terrain/contour-tile-weld';
|
|
376
386
|
export type {TerrainContourPaths, TerrainContourPathLimits} from './terrain/contour-paths';
|
|
377
387
|
export {simplifyTerrainContourPaths} from './terrain/contour-simplify';
|
|
378
388
|
export type {TerrainSimplifiedContourPaths} from './terrain/contour-simplify';
|
|
379
389
|
export {measureTerrainProfile} from './terrain/profile-measure';
|
|
390
|
+
export {getTerrainProfileVisibility} from './terrain/profile-visibility';
|
|
391
|
+
export type {TerrainProfileVisibility} from './terrain/profile-visibility';
|
|
392
|
+
export {getTerrainProfileHorizon} from './terrain/profile-horizon';
|
|
393
|
+
export type {TerrainProfileHorizon, TerrainProfileHorizonOptions} from './terrain/profile-horizon';
|
|
394
|
+
export {getTerrainProfileViewshed, TerrainProfileViewStatus} from './terrain/profile-viewshed';
|
|
380
395
|
export type {TerrainProfileMeasurements} from './terrain/profile-measure';
|
|
381
396
|
export {reconcileTerrainVertexTiles} from './terrain/vertex-tiles';
|
|
397
|
+
export {createTerrainVertexTileHalos, TerrainVertexHaloStatus} from './terrain/vertex-halos';
|
|
398
|
+
export type {TerrainVertexHaloTile} from './terrain/vertex-halos';
|
|
399
|
+
export {getTerrainVertexHaloAffectedTiles} from './terrain/vertex-halo-invalidation';
|
|
400
|
+
export type {TerrainVertexTileAddress} from './terrain/vertex-halo-invalidation';
|
|
401
|
+
export {updateTerrainVertexTileHalos} from './terrain/vertex-halo-update';
|
|
402
|
+
export {createTerrainFilteredPyramid} from './terrain/filtered-pyramid';
|
|
403
|
+
export type {TerrainFilteredLevel} from './terrain/filtered-pyramid';
|
|
382
404
|
export type {
|
|
383
405
|
TerrainVertexTile,
|
|
384
406
|
TerrainVertexTileOptions,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import type {Task} from '@math.gl/core/tasks';
|
|
5
|
+
import type {CreateProjectionOptions, Projection, ProjectionArray} from '../projection/types';
|
|
6
|
+
import type {MapDescription, PreparedMap} from '../discontinuous/map-engine';
|
|
7
|
+
export type ProjectCoordinatesTypes = {
|
|
8
|
+
initialization: {projection?: CreateProjectionOptions};
|
|
9
|
+
state: {projection?: Projection; key?: string; defaultOptions?: CreateProjectionOptions};
|
|
10
|
+
input: {
|
|
11
|
+
projection?: CreateProjectionOptions;
|
|
12
|
+
coordinates: ProjectionArray;
|
|
13
|
+
dimension?: number;
|
|
14
|
+
inverse?: boolean;
|
|
15
|
+
};
|
|
16
|
+
output: {coordinates: ProjectionArray};
|
|
17
|
+
options: {chunkSize?: number};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const processCoordinates: NonNullable<Task<ProjectCoordinatesTypes>['process']> = async (
|
|
21
|
+
input,
|
|
22
|
+
options,
|
|
23
|
+
context
|
|
24
|
+
) => {
|
|
25
|
+
const projection = input.projection ?? context.state.defaultOptions;
|
|
26
|
+
if (!projection) throw new Error('Provide projection in the input or initializeTask');
|
|
27
|
+
await prepareProjection(context.state, projection);
|
|
28
|
+
const {projectBulk} = await import('./operations');
|
|
29
|
+
const coordinates = await projectBulk(
|
|
30
|
+
{...input, projection, chunkSize: options.chunkSize},
|
|
31
|
+
context,
|
|
32
|
+
context.state.projection
|
|
33
|
+
);
|
|
34
|
+
return {coordinates};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Reproject packed coordinates, retaining the prepared projection for each task lifetime. */
|
|
38
|
+
export const ProjectCoordinatesTask = {
|
|
39
|
+
id: 'project-coordinates',
|
|
40
|
+
async preload() {
|
|
41
|
+
await Promise.all([import('./operations'), import('../projection/lib/projection')]);
|
|
42
|
+
},
|
|
43
|
+
async initialize({projection}) {
|
|
44
|
+
const state: ProjectCoordinatesTypes['state'] = {defaultOptions: projection};
|
|
45
|
+
if (projection) await prepareProjection(state, projection);
|
|
46
|
+
return state;
|
|
47
|
+
},
|
|
48
|
+
destroy(state) {
|
|
49
|
+
state.projection = undefined;
|
|
50
|
+
state.defaultOptions = undefined;
|
|
51
|
+
state.key = undefined;
|
|
52
|
+
},
|
|
53
|
+
process: processCoordinates,
|
|
54
|
+
async *processInBatches(inputs, options, context) {
|
|
55
|
+
for await (const input of inputs) {
|
|
56
|
+
yield await processCoordinates(input, options, context);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} satisfies Task<ProjectCoordinatesTypes>;
|
|
60
|
+
|
|
61
|
+
export type PrepareMapTypes = {
|
|
62
|
+
input: {description: MapDescription};
|
|
63
|
+
output: {map: PreparedMap};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Build a portable map snapshot for MapEngine.fromPrepared without blocking the UI. */
|
|
67
|
+
export const PrepareMapTask = {
|
|
68
|
+
id: 'prepare-map',
|
|
69
|
+
async preload() {
|
|
70
|
+
await import('./operations');
|
|
71
|
+
},
|
|
72
|
+
async process({description}, _options, context) {
|
|
73
|
+
const {setupMap} = await import('./operations');
|
|
74
|
+
return {map: setupMap(description, context).toPrepared()};
|
|
75
|
+
}
|
|
76
|
+
} satisfies Task<PrepareMapTypes>;
|
|
77
|
+
|
|
78
|
+
async function prepareProjection(
|
|
79
|
+
state: ProjectCoordinatesTypes['state'],
|
|
80
|
+
options: CreateProjectionOptions
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
const key = JSON.stringify(options);
|
|
83
|
+
if (!state.projection || state.key !== key) {
|
|
84
|
+
const {FullProjectionEngine} = await import('../projection/lib/projection');
|
|
85
|
+
const projection = new FullProjectionEngine().createProjection(options);
|
|
86
|
+
state.projection = projection;
|
|
87
|
+
state.key = key;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import type {TaskWorker} from '@math.gl/core/tasks';
|
|
5
|
+
import {ProjectCoordinatesTask as projectionTask, PrepareMapTask as mapTask} from './definitions';
|
|
6
|
+
export type {ProjectCoordinatesTypes, PrepareMapTypes} from './definitions';
|
|
7
|
+
declare const __filename: string;
|
|
8
|
+
|
|
9
|
+
// Resolve compiled worker modules in both ESM and CommonJS package entries.
|
|
10
|
+
const isBrowser = !(globalThis as {process?: {versions?: {node?: string}}}).process?.versions?.node;
|
|
11
|
+
const path = typeof __filename === 'string' ? __filename.replace(/\\/g, '/') : '';
|
|
12
|
+
const moduleUrl = path
|
|
13
|
+
? `file://${path.startsWith('/') ? '' : '/'}${encodeURI(path).replace(/#/g, '%23').replace(/\?/g, '%3F')}`
|
|
14
|
+
: import.meta.url;
|
|
15
|
+
|
|
16
|
+
/** Reproject coordinates with an automatic or explicitly retained worker. */
|
|
17
|
+
export const ProjectCoordinatesTask: typeof projectionTask & {worker: TaskWorker} = {
|
|
18
|
+
...projectionTask,
|
|
19
|
+
worker: {
|
|
20
|
+
...(!isBrowser
|
|
21
|
+
? {url: /* @__PURE__ */ (() => new URL('./projection-worker.js', moduleUrl).href)()}
|
|
22
|
+
: {
|
|
23
|
+
create: () =>
|
|
24
|
+
new Worker(new URL('./projection-worker.js', import.meta.url), {type: 'module'})
|
|
25
|
+
}),
|
|
26
|
+
capabilities: {atomic: true, streaming: true}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Prepare a portable map snapshot in a worker. */
|
|
31
|
+
export const PrepareMapTask: typeof mapTask & {worker: TaskWorker} = {
|
|
32
|
+
...mapTask,
|
|
33
|
+
worker: {
|
|
34
|
+
...(!isBrowser
|
|
35
|
+
? {url: /* @__PURE__ */ (() => new URL('./map-worker.js', moduleUrl).href)()}
|
|
36
|
+
: {create: () => new Worker(new URL('./map-worker.js', import.meta.url), {type: 'module'})}),
|
|
37
|
+
capabilities: {atomic: true, streaming: false}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
import {MapEngine, type MapDescription, type MapEngineOptions} from '../discontinuous/map-engine';
|
|
5
|
-
import type {CreateProjectionOptions, ProjectionArray} from '../projection/types';
|
|
6
|
-
import type {
|
|
5
|
+
import type {CreateProjectionOptions, ProjectionArray, Projection} from '../projection/types';
|
|
6
|
+
import type {TaskContext} from '@math.gl/core/tasks';
|
|
7
|
+
type OperationContext = Partial<Omit<TaskContext<unknown>, 'state'>>;
|
|
7
8
|
|
|
8
9
|
export type BulkProjectionTask = {
|
|
9
10
|
projection: CreateProjectionOptions;
|
|
@@ -16,7 +17,7 @@ export type BulkProjectionTask = {
|
|
|
16
17
|
/** Setup callbacks belong in the worker and cannot be sent in a request. */
|
|
17
18
|
export function setupMap(
|
|
18
19
|
description: MapDescription,
|
|
19
|
-
context:
|
|
20
|
+
context: OperationContext,
|
|
20
21
|
options?: MapEngineOptions
|
|
21
22
|
): MapEngine {
|
|
22
23
|
context.reportProgress?.({phase: 'map-setup', completed: 0, total: 1, unit: 'tasks'});
|
|
@@ -29,7 +30,8 @@ export function setupMap(
|
|
|
29
30
|
/** Process worker-owned storage in chunks. Failed jobs return no partial result. */
|
|
30
31
|
export async function projectBulk(
|
|
31
32
|
input: BulkProjectionTask,
|
|
32
|
-
context:
|
|
33
|
+
context: OperationContext,
|
|
34
|
+
preparedProjection?: Projection
|
|
33
35
|
): Promise<ProjectionArray> {
|
|
34
36
|
const {coordinates, dimension = 2, chunkSize = 4096} = input;
|
|
35
37
|
if (
|
|
@@ -45,8 +47,11 @@ export async function projectBulk(
|
|
|
45
47
|
'Expected ordinary floating-point buffers, complete records and positive chunk size'
|
|
46
48
|
);
|
|
47
49
|
context.reportProgress?.({phase: 'projection-setup', completed: 0, total: 1, unit: 'tasks'});
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
+
const projection =
|
|
51
|
+
preparedProjection ??
|
|
52
|
+
new (await import('../projection/lib/projection')).FullProjectionEngine().createProjection(
|
|
53
|
+
input.projection
|
|
54
|
+
);
|
|
50
55
|
context.reportProgress?.({phase: 'projection-setup', completed: 1, total: 1, unit: 'tasks'});
|
|
51
56
|
const total = coordinates.length / dimension;
|
|
52
57
|
context.reportProgress?.({phase: 'bulk-projection', completed: 0, total, unit: 'records'});
|
|
@@ -57,7 +62,6 @@ export async function projectBulk(
|
|
|
57
62
|
const chunk = coordinates.subarray(start * dimension, end * dimension);
|
|
58
63
|
if (input.inverse) projection.unprojectFlatSync(chunk, dimension);
|
|
59
64
|
else projection.projectFlatSync(chunk, dimension);
|
|
60
|
-
if (total <= 0x7fffffff) context.sharedState?.setProgress(end, total);
|
|
61
65
|
context.reportProgress?.({phase: 'bulk-projection', completed: end, total, unit: 'records'});
|
|
62
66
|
await new Promise(resolve => setTimeout(resolve, 0));
|
|
63
67
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import {initializeTaskWorker} from '@math.gl/core/tasks';
|
|
5
|
+
import {ProjectCoordinatesTask} from './definitions';
|
|
6
|
+
void initializeTaskWorker(ProjectCoordinatesTask);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {TerrainContours} from './contours';
|
|
6
|
+
import {
|
|
7
|
+
contourPathLimits,
|
|
8
|
+
validateContourData,
|
|
9
|
+
validateContourVertex,
|
|
10
|
+
type TerrainContourPathLimits
|
|
11
|
+
} from './contour-path-data';
|
|
12
|
+
|
|
13
|
+
export const TerrainContourBoundaryAxis = {COLUMN: 1, ROW: 2} as const;
|
|
14
|
+
export type TerrainContourBoundaryDiagnostics = {
|
|
15
|
+
/** Boundary vertices with degree one (open) or greater than two (junction). */
|
|
16
|
+
vertexIndices: Uint32Array;
|
|
17
|
+
degrees: Uint32Array;
|
|
18
|
+
levelIndices: Uint32Array;
|
|
19
|
+
/** Bitmask of TerrainContourBoundaryAxis values; corners have both bits. */
|
|
20
|
+
boundaryAxes: Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Inspect a welded contour graph at same-level tile lattice lines. An open
|
|
24
|
+
* endpoint can indicate a dataset edge, missing tile, nodata or another break;
|
|
25
|
+
* this function does not infer the cause or alter the graph.
|
|
26
|
+
*/
|
|
27
|
+
export function diagnoseTerrainContourBoundaries(
|
|
28
|
+
contours: TerrainContours,
|
|
29
|
+
options: TerrainContourPathLimits & {width: number; height: number}
|
|
30
|
+
): TerrainContourBoundaryDiagnostics {
|
|
31
|
+
const {width, height} = options;
|
|
32
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height) || height < 2)
|
|
33
|
+
throw new Error('Invalid terrain contour boundary tile dimensions');
|
|
34
|
+
const limits = contourPathLimits(options);
|
|
35
|
+
const count = validateContourData(contours, limits);
|
|
36
|
+
if (
|
|
37
|
+
!(contours.segments instanceof Uint32Array) ||
|
|
38
|
+
contours.segments.length % 2 ||
|
|
39
|
+
!(contours.levelIndices instanceof Uint32Array) ||
|
|
40
|
+
contours.levelIndices.length !== contours.segments.length / 2 ||
|
|
41
|
+
contours.levelIndices.length > limits.maxSegments
|
|
42
|
+
)
|
|
43
|
+
throw new Error('Invalid terrain contour boundary segments or capacity');
|
|
44
|
+
const degrees = new Uint32Array(count),
|
|
45
|
+
assignments = new Uint32Array(count).fill(0xffffffff);
|
|
46
|
+
const seen = new Set<string>();
|
|
47
|
+
for (let i = 0; i < contours.levelIndices.length; i++) {
|
|
48
|
+
const a = contours.segments[2 * i],
|
|
49
|
+
b = contours.segments[2 * i + 1],
|
|
50
|
+
level = contours.levelIndices[i];
|
|
51
|
+
validateContourVertex(contours, a, level, assignments);
|
|
52
|
+
validateContourVertex(contours, b, level, assignments);
|
|
53
|
+
if (
|
|
54
|
+
a === b ||
|
|
55
|
+
(contours.positions[3 * a] === contours.positions[3 * b] &&
|
|
56
|
+
contours.positions[3 * a + 1] === contours.positions[3 * b + 1])
|
|
57
|
+
)
|
|
58
|
+
throw new Error('Degenerate terrain contour segment');
|
|
59
|
+
const key = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
60
|
+
if (seen.has(key)) throw new Error('Duplicate terrain contour segment');
|
|
61
|
+
seen.add(key);
|
|
62
|
+
degrees[a]++;
|
|
63
|
+
degrees[b]++;
|
|
64
|
+
}
|
|
65
|
+
const vertices: number[] = [],
|
|
66
|
+
resultDegrees: number[] = [],
|
|
67
|
+
levels: number[] = [],
|
|
68
|
+
axes: number[] = [];
|
|
69
|
+
for (let i = 0; i < count; i++) {
|
|
70
|
+
if (degrees[i] !== 1 && degrees[i] <= 2) continue;
|
|
71
|
+
const x = contours.gridCoordinates[2 * i],
|
|
72
|
+
y = contours.gridCoordinates[2 * i + 1];
|
|
73
|
+
if (Math.abs(x) > Number.MAX_SAFE_INTEGER || Math.abs(y) > Number.MAX_SAFE_INTEGER)
|
|
74
|
+
throw new Error('Terrain contour boundary lattice exceeds safe integer range');
|
|
75
|
+
const axis =
|
|
76
|
+
(Number.isSafeInteger(x) && x % (width - 1) === 0 ? TerrainContourBoundaryAxis.COLUMN : 0) |
|
|
77
|
+
(Number.isSafeInteger(y) && y % (height - 1) === 0 ? TerrainContourBoundaryAxis.ROW : 0);
|
|
78
|
+
if (!axis) continue;
|
|
79
|
+
vertices.push(i);
|
|
80
|
+
resultDegrees.push(degrees[i]);
|
|
81
|
+
levels.push(assignments[i]);
|
|
82
|
+
axes.push(axis);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
vertexIndices: Uint32Array.from(vertices),
|
|
86
|
+
degrees: Uint32Array.from(resultDegrees),
|
|
87
|
+
levelIndices: Uint32Array.from(levels),
|
|
88
|
+
boundaryAxes: Uint8Array.from(axes)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
weldTerrainContourTiles,
|
|
7
|
+
type TerrainContourTile,
|
|
8
|
+
type TerrainContourTileWeldOptions
|
|
9
|
+
} from './contour-tile-weld';
|
|
10
|
+
import {stitchTerrainContours, type TerrainContourPaths} from './contour-paths';
|
|
11
|
+
|
|
12
|
+
/** Weld a same-level tile snapshot and trace its maximal contour paths.
|
|
13
|
+
* Missing tiles and source gaps remain open. This does not simplify paths.
|
|
14
|
+
*/
|
|
15
|
+
export function stitchTerrainContourTiles(
|
|
16
|
+
tiles: readonly TerrainContourTile[],
|
|
17
|
+
options: TerrainContourTileWeldOptions
|
|
18
|
+
): TerrainContourPaths {
|
|
19
|
+
return stitchTerrainContours(weldTerrainContourTiles(tiles, options), options);
|
|
20
|
+
}
|