@math.gl/geospatial 5.0.0-beta.2 → 5.0.0-beta.3

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.
Files changed (99) hide show
  1. package/dist/index.cjs +374 -0
  2. package/dist/index.cjs.map +3 -3
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +7 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/tasks/definitions.d.ts +90 -0
  8. package/dist/tasks/definitions.d.ts.map +1 -0
  9. package/dist/tasks/definitions.js +54 -0
  10. package/dist/tasks/definitions.js.map +1 -0
  11. package/dist/{workers → tasks}/index.cjs +158 -122
  12. package/dist/tasks/index.cjs.map +6 -0
  13. package/dist/tasks/index.d.ts +12 -0
  14. package/dist/tasks/index.d.ts.map +1 -0
  15. package/dist/tasks/index.js +30 -0
  16. package/dist/tasks/index.js.map +1 -0
  17. package/dist/{workers → tasks}/map-worker.d.ts.map +1 -1
  18. package/dist/tasks/map-worker.js +7 -0
  19. package/dist/tasks/map-worker.js.map +1 -0
  20. package/dist/{workers → tasks}/operations.d.ts +6 -4
  21. package/dist/tasks/operations.d.ts.map +1 -0
  22. package/dist/{workers → tasks}/operations.js +3 -5
  23. package/dist/tasks/operations.js.map +1 -0
  24. package/dist/tasks/projection-worker.d.ts.map +1 -0
  25. package/dist/tasks/projection-worker.js +7 -0
  26. package/dist/tasks/projection-worker.js.map +1 -0
  27. package/dist/terrain/filtered-pyramid.d.ts +22 -0
  28. package/dist/terrain/filtered-pyramid.d.ts.map +1 -0
  29. package/dist/terrain/filtered-pyramid.js +71 -0
  30. package/dist/terrain/filtered-pyramid.js.map +1 -0
  31. package/dist/terrain/index.cjs +375 -1
  32. package/dist/terrain/index.cjs.map +2 -2
  33. package/dist/terrain/index.d.ts +12 -0
  34. package/dist/terrain/index.d.ts.map +1 -1
  35. package/dist/terrain/index.js +7 -0
  36. package/dist/terrain/index.js.map +1 -1
  37. package/dist/terrain/profile-horizon.d.ts +20 -0
  38. package/dist/terrain/profile-horizon.d.ts.map +1 -0
  39. package/dist/terrain/profile-horizon.js +69 -0
  40. package/dist/terrain/profile-horizon.js.map +1 -0
  41. package/dist/terrain/profile-slope.d.ts +3 -0
  42. package/dist/terrain/profile-slope.d.ts.map +1 -0
  43. package/dist/terrain/profile-slope.js +35 -0
  44. package/dist/terrain/profile-slope.js.map +1 -0
  45. package/dist/terrain/profile-viewshed.d.ts +17 -0
  46. package/dist/terrain/profile-viewshed.d.ts.map +1 -0
  47. package/dist/terrain/profile-viewshed.js +51 -0
  48. package/dist/terrain/profile-viewshed.js.map +1 -0
  49. package/dist/terrain/profile-visibility.d.ts +21 -0
  50. package/dist/terrain/profile-visibility.d.ts.map +1 -0
  51. package/dist/terrain/profile-visibility.js +61 -0
  52. package/dist/terrain/profile-visibility.js.map +1 -0
  53. package/dist/terrain/vertex-halo-invalidation.d.ts +16 -0
  54. package/dist/terrain/vertex-halo-invalidation.d.ts.map +1 -0
  55. package/dist/terrain/vertex-halo-invalidation.js +50 -0
  56. package/dist/terrain/vertex-halo-invalidation.js.map +1 -0
  57. package/dist/terrain/vertex-halo-update.d.ts +18 -0
  58. package/dist/terrain/vertex-halo-update.d.ts.map +1 -0
  59. package/dist/terrain/vertex-halo-update.js +76 -0
  60. package/dist/terrain/vertex-halo-update.js.map +1 -0
  61. package/dist/terrain/vertex-halos.d.ts +26 -0
  62. package/dist/terrain/vertex-halos.d.ts.map +1 -0
  63. package/dist/terrain/vertex-halos.js +80 -0
  64. package/dist/terrain/vertex-halos.js.map +1 -0
  65. package/package.json +10 -15
  66. package/src/index.ts +12 -0
  67. package/src/tasks/definitions.ts +89 -0
  68. package/src/tasks/index.ts +39 -0
  69. package/src/tasks/map-worker.ts +6 -0
  70. package/src/{workers → tasks}/operations.ts +11 -7
  71. package/src/tasks/projection-worker.ts +6 -0
  72. package/src/terrain/filtered-pyramid.ts +95 -0
  73. package/src/terrain/index.ts +12 -0
  74. package/src/terrain/profile-horizon.ts +86 -0
  75. package/src/terrain/profile-slope.ts +32 -0
  76. package/src/terrain/profile-viewshed.ts +57 -0
  77. package/src/terrain/profile-visibility.ts +81 -0
  78. package/src/terrain/vertex-halo-invalidation.ts +57 -0
  79. package/src/terrain/vertex-halo-update.ts +91 -0
  80. package/src/terrain/vertex-halos.ts +101 -0
  81. package/dist/workers/index.cjs.map +0 -6
  82. package/dist/workers/index.d.ts +0 -12
  83. package/dist/workers/index.d.ts.map +0 -1
  84. package/dist/workers/index.js +0 -41
  85. package/dist/workers/index.js.map +0 -1
  86. package/dist/workers/map-worker.js +0 -7
  87. package/dist/workers/map-worker.js.map +0 -1
  88. package/dist/workers/operations.cjs +0 -21008
  89. package/dist/workers/operations.cjs.map +0 -6
  90. package/dist/workers/operations.d.ts.map +0 -1
  91. package/dist/workers/operations.js.map +0 -1
  92. package/dist/workers/projection-worker.d.ts.map +0 -1
  93. package/dist/workers/projection-worker.js +0 -7
  94. package/dist/workers/projection-worker.js.map +0 -1
  95. package/src/workers/index.ts +0 -59
  96. package/src/workers/map-worker.ts +0 -7
  97. package/src/workers/projection-worker.ts +0 -7
  98. /package/dist/{workers → tasks}/map-worker.d.ts +0 -0
  99. /package/dist/{workers → tasks}/projection-worker.d.ts +0 -0
@@ -0,0 +1,69 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { TerrainSampleStatus } from "./types.js";
5
+ import { compareTerrainSlopes } from "./profile-slope.js";
6
+ /** Calculate the maximum elevation angle in radians of a straight, sampled profile.
7
+ * The observer is at station zero, and its absolute height must be above known terrain
8
+ * there. Values describe a local Cartesian piecewise-linear profile, not unsampled
9
+ * terrain, curvature, refraction or a geographic path. Missing samples leave the
10
+ * maximum of known samples as a lower bound rather than a complete horizon.
11
+ */
12
+ export function getTerrainProfileHorizon(profile, options) {
13
+ const { distances, heights, statuses, length } = profile;
14
+ const count = distances.length;
15
+ const limit = options.maxSamples ?? 1000000;
16
+ if (!(distances instanceof Float64Array) ||
17
+ !(heights instanceof Float64Array) ||
18
+ !(statuses instanceof Uint8Array) ||
19
+ count < 2 ||
20
+ heights.length !== count ||
21
+ statuses.length !== count ||
22
+ !Number.isSafeInteger(limit) ||
23
+ limit < count ||
24
+ !Number.isFinite(options.observerHeight) ||
25
+ !Number.isFinite(length) ||
26
+ length <= 0 ||
27
+ distances[0] !== 0 ||
28
+ distances[count - 1] !== length)
29
+ throw new Error('Invalid terrain horizon profile or options');
30
+ let winningRise = 0;
31
+ let winningDistance = 1;
32
+ let sampleIndex;
33
+ let missingSampleCount = 0;
34
+ for (let i = 0; i < count; i++) {
35
+ const distance = distances[i];
36
+ const status = statuses[i];
37
+ if (!Number.isFinite(distance) || (i > 0 && distance <= distances[i - 1]))
38
+ throw new Error('Invalid terrain horizon stationing');
39
+ if (status > TerrainSampleStatus.NOT_RESIDENT)
40
+ throw new Error('Invalid terrain horizon status');
41
+ if (status !== TerrainSampleStatus.VALID) {
42
+ missingSampleCount++;
43
+ continue;
44
+ }
45
+ if (!Number.isFinite(heights[i]))
46
+ throw new Error('Invalid terrain horizon height');
47
+ if (i === 0) {
48
+ if (options.observerHeight <= heights[i])
49
+ throw new Error('Terrain horizon observer must be above ground');
50
+ continue;
51
+ }
52
+ const delta = heights[i] - options.observerHeight;
53
+ if (!Number.isFinite(delta))
54
+ throw new Error('Terrain horizon arithmetic overflow');
55
+ if (sampleIndex === undefined ||
56
+ compareTerrainSlopes(delta, distance, winningRise, winningDistance) > 0) {
57
+ winningRise = delta;
58
+ winningDistance = distance;
59
+ sampleIndex = i;
60
+ }
61
+ }
62
+ return {
63
+ angle: sampleIndex === undefined ? undefined : Math.atan2(winningRise, winningDistance),
64
+ sampleIndex,
65
+ missingSampleCount,
66
+ complete: missingSampleCount === 0
67
+ };
68
+ }
69
+ //# sourceMappingURL=profile-horizon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-horizon.js","s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AClB,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC;QACvF,WAAW;QACX,kBAAkB;QAClB,QAAQ,EAAE,kBAAkB,KAAK,CAAC;KACnC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Compare finite rises divided by positive distances, including overflow and rounded ties. */
2
+ export declare function compareTerrainSlopes(a: number, ad: number, b: number, bd: number): number;
3
+ //# sourceMappingURL=profile-slope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-slope.d.ts","sourceRoot":"","sources":["../../src/terrain/profile-slope.ts"],"names":[],"mappings":"AAIA,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA0BzF"}
@@ -0,0 +1,35 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ /** Compare finite rises divided by positive distances, including overflow and rounded ties. */
5
+ export function compareTerrainSlopes(a, ad, b, bd) {
6
+ const as = a / ad;
7
+ const bs = b / bd;
8
+ if (as < bs)
9
+ return -1;
10
+ if (as > bs)
11
+ return 1;
12
+ if (a === 0 || b === 0 || Math.sign(a) !== Math.sign(b))
13
+ return Math.sign(a) - Math.sign(b);
14
+ // Division can round distinct ratios to the same value, zero or infinity.
15
+ // Compare the exact products of their binary64 significands only on that path.
16
+ const bytes = new DataView(new ArrayBuffer(8));
17
+ const parts = (value) => {
18
+ bytes.setFloat64(0, Math.abs(value));
19
+ const bits = bytes.getBigUint64(0);
20
+ const exponent = Number((bits >> 52n) & 0x7ffn);
21
+ const fraction = bits & 0xfffffffffffffn;
22
+ return exponent ? [fraction | 0x10000000000000n, exponent - 1075] : [fraction, -1074];
23
+ };
24
+ const [am, ae] = parts(a), [bdm, bde] = parts(bd);
25
+ const [bm, be] = parts(b), [adm, ade] = parts(ad);
26
+ let left = am * bdm;
27
+ let right = bm * adm;
28
+ const shift = ae + bde - be - ade;
29
+ if (shift > 0)
30
+ left <<= BigInt(shift);
31
+ else if (shift < 0)
32
+ right <<= BigInt(-shift);
33
+ return (left < right ? -1 : left > right ? 1 : 0) * Math.sign(a);
34
+ }
35
+ //# sourceMappingURL=profile-slope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-slope.js","sourceRoot":"","sources":["../../src/terrain/profile-slope.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,+FAA+F;AAC/F,MAAM,UAAU,oBAAoB,CAAC,CAAS,EAAE,EAAU,EAAE,CAAS,EAAE,EAAU;IAC/E,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IAClB,IAAI,EAAE,GAAG,EAAE;QAAE,OAAO,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,GAAG,EAAE;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5F,0EAA0E;IAC1E,+EAA+E;IAC/E,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,CAAC,KAAa,EAAoB,EAAE;QAChD,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,GAA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AC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { TerrainProfile } from "./profile.js";
2
+ import { type TerrainProfileHorizonOptions } from "./profile-horizon.js";
3
+ /** Sample classification for a single radial profile; station zero is the observer. */
4
+ export declare const TerrainProfileViewStatus: {
5
+ readonly OBSERVER: 0;
6
+ readonly VISIBLE: 1;
7
+ readonly BLOCKED: 2;
8
+ readonly UNKNOWN: 3;
9
+ readonly MISSING: 4;
10
+ };
11
+ /** Classify each terrain sample against earlier samples on a straight radial profile.
12
+ * A previous sample on the ray blocks it. Missing earlier samples make otherwise
13
+ * visible targets unknown, but cannot undo a known obstruction. This is a sampled
14
+ * local profile, not an area viewshed or a guarantee about unsampled terrain.
15
+ */
16
+ export declare function getTerrainProfileViewshed(profile: TerrainProfile, options: TerrainProfileHorizonOptions): Uint8Array;
17
+ //# sourceMappingURL=profile-viewshed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-viewshed.d.ts","sourceRoot":"","sources":["../../src/terrain/profile-viewshed.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAC,qBAAkB;AAE9C,OAAO,EAA2B,KAAK,4BAA4B,EAAC,6BAA0B;AAG9F,uFAAuF;AACvF,eAAO,MAAM,wBAAwB;;;;;;CAM3B,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,4BAA4B,GACpC,UAAU,CA8BZ"}
@@ -0,0 +1,51 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { TerrainSampleStatus } from "./types.js";
5
+ import { getTerrainProfileHorizon } from "./profile-horizon.js";
6
+ import { compareTerrainSlopes } from "./profile-slope.js";
7
+ /** Sample classification for a single radial profile; station zero is the observer. */
8
+ export const TerrainProfileViewStatus = {
9
+ OBSERVER: 0,
10
+ VISIBLE: 1,
11
+ BLOCKED: 2,
12
+ UNKNOWN: 3,
13
+ MISSING: 4
14
+ };
15
+ /** Classify each terrain sample against earlier samples on a straight radial profile.
16
+ * A previous sample on the ray blocks it. Missing earlier samples make otherwise
17
+ * visible targets unknown, but cannot undo a known obstruction. This is a sampled
18
+ * local profile, not an area viewshed or a guarantee about unsampled terrain.
19
+ */
20
+ export function getTerrainProfileViewshed(profile, options) {
21
+ // Validate the whole profile before writing any output.
22
+ getTerrainProfileHorizon(profile, options);
23
+ const result = new Uint8Array(profile.distances.length);
24
+ let maxRise = 0;
25
+ let maxDistance = 1;
26
+ let hasHorizon = false;
27
+ let missingBefore = profile.statuses[0] !== TerrainSampleStatus.VALID;
28
+ for (let i = 1; i < result.length; i++) {
29
+ if (profile.statuses[i] !== TerrainSampleStatus.VALID) {
30
+ result[i] = TerrainProfileViewStatus.MISSING;
31
+ missingBefore = true;
32
+ continue;
33
+ }
34
+ const rise = profile.heights[i] - options.observerHeight;
35
+ const distance = profile.distances[i];
36
+ const comparison = hasHorizon ? compareTerrainSlopes(rise, distance, maxRise, maxDistance) : 1;
37
+ result[i] =
38
+ comparison <= 0
39
+ ? TerrainProfileViewStatus.BLOCKED
40
+ : missingBefore
41
+ ? TerrainProfileViewStatus.UNKNOWN
42
+ : TerrainProfileViewStatus.VISIBLE;
43
+ if (comparison > 0) {
44
+ maxRise = rise;
45
+ maxDistance = distance;
46
+ hasHorizon = true;
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+ //# sourceMappingURL=profile-viewshed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-viewshed.js","sourceRoot":"","sources":["../../src/terrain/profile-viewshed.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,mBAAmB,EAAC,mBAAgB;AAC5C,OAAO,EAAC,wBAAwB,EAAoC,6BAA0B;AAC9F,OAAO,EAAC,oBAAoB,EAAC,2BAAwB;AAErD,uFAAuF;AACvF,MAAM,C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gBACb,CAAC,CAAC,wBAAwB,CAAC,OAAO;gBAClC,CAAC,CAAC,aAAa;oBACb,CAAC,CAAC,wBAAwB,CAAC,OAAO;oBAClC,CAAC,CAAC,wBAAwB,CAAC,OAAO,CAAC;QACzC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,OAAO,GAAG,IAAI,CAAC;YACf,WAAW,GAAG,QAAQ,CAAC;YACvB,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { TerrainProfile } from "./profile.js";
2
+ export type TerrainProfileVisibility = {
3
+ /** A sample blocks the line, all samples are clear, or coverage is incomplete. */
4
+ status: 'blocked' | 'clear' | 'unknown';
5
+ /** First observed blocking sample; missing samples can hide an earlier obstruction. */
6
+ firstBlockingSample: number | undefined;
7
+ missingSampleCount: number;
8
+ /** Smallest sampled vertical clearance, including endpoints. */
9
+ minimumClearance: number | undefined;
10
+ };
11
+ /** Compare absolute observer and target heights against a sampled, straight horizontal profile.
12
+ * A touching sample blocks the line. A clear result applies only to the sampled
13
+ * piecewise-linear profile; it does not certify unsampled terrain, Earth curvature,
14
+ * refraction, or a geographic/geodesic path. Heights and distances must use compatible units.
15
+ */
16
+ export declare function getTerrainProfileVisibility(profile: TerrainProfile, options: {
17
+ observerHeight: number;
18
+ targetHeight: number;
19
+ maxSamples?: number;
20
+ }): TerrainProfileVisibility;
21
+ //# sourceMappingURL=profile-visibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-visibility.d.ts","sourceRoot":"","sources":["../../src/terrain/profile-visibility.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAC,qBAAkB;AAG9C,MAAM,MAAM,wBAAwB,GAAG;IACrC,kFAAkF;IAClF,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACxC,uFAAuF;IACvF,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE;IACP,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,wBAAwB,CAmD1B"}
@@ -0,0 +1,61 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { TerrainSampleStatus } from "./types.js";
5
+ /** Compare absolute observer and target heights against a sampled, straight horizontal profile.
6
+ * A touching sample blocks the line. A clear result applies only to the sampled
7
+ * piecewise-linear profile; it does not certify unsampled terrain, Earth curvature,
8
+ * refraction, or a geographic/geodesic path. Heights and distances must use compatible units.
9
+ */
10
+ export function getTerrainProfileVisibility(profile, options) {
11
+ const { observerHeight, targetHeight } = options;
12
+ const limit = options.maxSamples ?? 1000000;
13
+ const { distances, heights, statuses, length } = profile;
14
+ const count = distances.length;
15
+ if (!(distances instanceof Float64Array) ||
16
+ !(heights instanceof Float64Array) ||
17
+ !(statuses instanceof Uint8Array) ||
18
+ count < 2 ||
19
+ heights.length !== count ||
20
+ statuses.length !== count ||
21
+ !Number.isSafeInteger(limit) ||
22
+ limit < count ||
23
+ !Number.isFinite(observerHeight) ||
24
+ !Number.isFinite(targetHeight) ||
25
+ !Number.isFinite(length) ||
26
+ length <= 0 ||
27
+ distances[0] !== 0 ||
28
+ distances[count - 1] !== length)
29
+ throw new Error('Invalid terrain visibility profile or options');
30
+ let missingSampleCount = 0;
31
+ let firstBlockingSample;
32
+ let minimumClearance = Infinity;
33
+ for (let i = 0; i < count; i++) {
34
+ const distance = distances[i], status = statuses[i];
35
+ if (!Number.isFinite(distance) || (i > 0 && distance <= distances[i - 1]))
36
+ throw new Error('Invalid terrain visibility stationing');
37
+ if (status > TerrainSampleStatus.NOT_RESIDENT)
38
+ throw new Error('Invalid terrain visibility status');
39
+ if (status !== TerrainSampleStatus.VALID) {
40
+ missingSampleCount++;
41
+ continue;
42
+ }
43
+ if (!Number.isFinite(heights[i]))
44
+ throw new Error('Invalid terrain visibility height');
45
+ const fraction = distance / length;
46
+ const lineHeight = observerHeight * (1 - fraction) + targetHeight * fraction;
47
+ const clearance = lineHeight - heights[i];
48
+ if (!Number.isFinite(clearance))
49
+ throw new Error('Terrain visibility arithmetic overflow');
50
+ minimumClearance = Math.min(minimumClearance, clearance);
51
+ if (clearance <= 0 && firstBlockingSample === undefined)
52
+ firstBlockingSample = i;
53
+ }
54
+ return {
55
+ status: firstBlockingSample !== undefined ? 'blocked' : missingSampleCount ? 'unknown' : 'clear',
56
+ firstBlockingSample,
57
+ missingSampleCount,
58
+ minimumClearance: minimumClearance === Infinity ? undefined : minimumClearance
59
+ };
60
+ }
61
+ //# sourceMappingURL=profile-visibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-visibility.js","sourceRoot":"","sources":["../../src/terrain/profile-visibility.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,mBAAmB,EAAC,mBAAgB;AAY5C;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAuB,EACvB,OAIC;IAED,MAAM,EAAC,cAAc,EAAE,YAAY,EAAC,GAAG,OAAO,CAAC;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,IAAI,OAAS,CAAC;IAC9C,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC;IACvD,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC;IAC/B,IACE,CAAC,CAAC,SAAS,YAAY,YAAY,CAAC;QACpC,CAAC,CAAC,OAAO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B,SAAS;QACX,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvF,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;QACnC,MAAM,UAAU,GAAG,cAAc,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,YAAY,GAAG,QAAQ,CAAC;QAC7E,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC3F,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;QACzD,IAAI,SAAS,IAAI,CAAC,IAAI,mBAAmB,KAAK,SAAS;YAAE,mBAAmB,GAAG,CAAC,CAAC;IACnF,CAAC;IACD,OAAO;QACL,MAAM,EACJ,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;QAC1F,mBAAmB;QACnB,kBAAkB;QAClB,gBAAgB,EAAE,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB;KAC/E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ export type TerrainVertexTileAddress = {
2
+ column: number;
3
+ row: number;
4
+ };
5
+ /** Identify resident tiles whose one-vertex halo may change after tile updates.
6
+ * Updates include arrivals, replacements and evictions; resident addresses describe
7
+ * the snapshot after applying them. The result is deduplicated and sorted by column,
8
+ * then row. A two-vertex tile can depend on tiles two addresses away because a
9
+ * halo point is itself shared with the next tile. The result is conservative.
10
+ */
11
+ export declare function getTerrainVertexHaloAffectedTiles(resident: readonly TerrainVertexTileAddress[], changed: readonly TerrainVertexTileAddress[], options: {
12
+ width: number;
13
+ height: number;
14
+ maxTiles?: number;
15
+ }): TerrainVertexTileAddress[];
16
+ //# sourceMappingURL=vertex-halo-invalidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-halo-invalidation.d.ts","sourceRoot":"","sources":["../../src/terrain/vertex-halo-invalidation.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,wBAAwB,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,OAAO,EAAE,SAAS,wBAAwB,EAAE,EAC5C,OAAO,EAAE;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,GAC1D,wBAAwB,EAAE,CAwC5B"}
@@ -0,0 +1,50 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ /** Identify resident tiles whose one-vertex halo may change after tile updates.
5
+ * Updates include arrivals, replacements and evictions; resident addresses describe
6
+ * the snapshot after applying them. The result is deduplicated and sorted by column,
7
+ * then row. A two-vertex tile can depend on tiles two addresses away because a
8
+ * halo point is itself shared with the next tile. The result is conservative.
9
+ */
10
+ export function getTerrainVertexHaloAffectedTiles(resident, changed, options) {
11
+ const limit = options.maxTiles ?? 4096;
12
+ if (!Number.isSafeInteger(limit) ||
13
+ limit < 0 ||
14
+ resident.length > limit ||
15
+ changed.length > limit ||
16
+ !Number.isSafeInteger(options.width) ||
17
+ options.width < 2 ||
18
+ !Number.isSafeInteger(options.height) ||
19
+ options.height < 2)
20
+ throw new Error('Invalid vertex halo tile capacity');
21
+ const addresses = new Map();
22
+ const key = (tile) => {
23
+ if (!Number.isSafeInteger(tile.column) || !Number.isSafeInteger(tile.row))
24
+ throw new Error('Invalid vertex tile address');
25
+ return `${tile.column},${tile.row}`;
26
+ };
27
+ for (const tile of resident) {
28
+ const id = key(tile);
29
+ if (addresses.has(id))
30
+ throw new Error('Duplicate resident vertex tile address');
31
+ addresses.set(id, { column: tile.column, row: tile.row });
32
+ }
33
+ const affected = new Map();
34
+ for (const tile of changed) {
35
+ key(tile);
36
+ const rx = options.width === 2 ? 2 : 1, ry = options.height === 2 ? 2 : 1;
37
+ for (let x = -rx; x <= rx; x++)
38
+ for (let y = -ry; y <= ry; y++) {
39
+ const column = tile.column + x, row = tile.row + y;
40
+ if (!Number.isSafeInteger(column) || !Number.isSafeInteger(row))
41
+ continue;
42
+ const id = `${column},${row}`;
43
+ const target = addresses.get(id);
44
+ if (target)
45
+ affected.set(id, target);
46
+ }
47
+ }
48
+ return [...affected.values()].sort((a, b) => a.column - b.column || a.row - b.row);
49
+ }
50
+ //# sourceMappingURL=vertex-halo-invalidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-halo-invalidation.js","sourceRoot":"","sources":["../../src/terrain/vertex-halo-invalidation.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAI5D;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,QAA6C,EAC7C,OAA4C,EAC5C,OAA2D;IAE3D,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;IACvC,IACE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;QAC5B,KAAK,GAAG,CAAC;QACT,QAAQ,CAAC,MAAM,GAAG,KAAK;QACvB,OAAO,CAAC,MAAM,GAAG,KAAK;QACtB,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC;QACpC,OAAO,CAAC,KAAK,GAAG,CAAC;QACjB,CAAC,MAAM,CAAC,aAAa,CAAC,O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AE,CAAC,EAAE;YAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAC5B,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBACrB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC;oBAAE,SAAS;gBAC1E,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;gBAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACjC,IAAI,MAAM;oBAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACvC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type TerrainVertexHaloTile } from "./vertex-halos.js";
2
+ import { type TerrainVertexTileAddress } from "./vertex-halo-invalidation.js";
3
+ import type { TerrainVertexTile, TerrainVertexTileOptions } from "./vertex-tiles.js";
4
+ /** Update selected halo tiles using a complete post-update resident tile snapshot.
5
+ * The caller must enumerate every arrival, replacement and eviction in `changed`.
6
+ * Unaffected halo objects are shared with the previous snapshot and must be treated
7
+ * as immutable. This function does not retain source buffers or mutate inputs.
8
+ * Pass the options used for the previous snapshot; changes to its grid transform,
9
+ * dimensions, height reference or reconciliation tolerance require a full rebuild.
10
+ */
11
+ export declare function updateTerrainVertexTileHalos(previous: readonly TerrainVertexHaloTile[], resident: readonly TerrainVertexTile[], changed: readonly TerrainVertexTileAddress[], options: TerrainVertexTileOptions & {
12
+ previousOptions: TerrainVertexTileOptions;
13
+ }): {
14
+ tiles: TerrainVertexHaloTile[];
15
+ rebuilt: TerrainVertexTileAddress[];
16
+ removed: TerrainVertexTileAddress[];
17
+ };
18
+ //# sourceMappingURL=vertex-halo-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-halo-update.d.ts","sourceRoot":"","sources":["../../src/terrain/vertex-halo-update.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+B,KAAK,qBAAqB,EAAC,0BAAuB;AACxF,OAAO,EAEL,KAAK,wBAAwB,EAC9B,sCAAmC;AACpC,OAAO,KAAK,EAAC,iBAAiB,EAAE,wBAAwB,EAAC,0BAAuB;AAEhF;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,SAAS,qBAAqB,EAAE,EAC1C,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,OAAO,EAAE,SAAS,wBAAwB,EAAE,EAC5C,OAAO,EAAE,wBAAwB,GAAG;IAAC,eAAe,EAAE,wBAAwB,CAAA;CAAC,GAC9E;IACD,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACpC,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,CA+DA"}
@@ -0,0 +1,76 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { createTerrainVertexTileHalos } from "./vertex-halos.js";
5
+ import { getTerrainVertexHaloAffectedTiles } from "./vertex-halo-invalidation.js";
6
+ /** Update selected halo tiles using a complete post-update resident tile snapshot.
7
+ * The caller must enumerate every arrival, replacement and eviction in `changed`.
8
+ * Unaffected halo objects are shared with the previous snapshot and must be treated
9
+ * as immutable. This function does not retain source buffers or mutate inputs.
10
+ * Pass the options used for the previous snapshot; changes to its grid transform,
11
+ * dimensions, height reference or reconciliation tolerance require a full rebuild.
12
+ */
13
+ export function updateTerrainVertexTileHalos(previous, resident, changed, options) {
14
+ const prior = options.previousOptions;
15
+ if (!prior)
16
+ throw new Error('Previous vertex tile options are required');
17
+ const paddedCount = (options.width + 2) * (options.height + 2) * resident.length;
18
+ if (!Number.isSafeInteger(paddedCount) || paddedCount > (options.maxSamples ?? 4000000))
19
+ throw new Error('Vertex tile halo sample capacity exceeded');
20
+ const equalPair = (a, b) => a[0] === b[0] && a[1] === b[1];
21
+ if (prior.width !== options.width ||
22
+ prior.height !== options.height ||
23
+ !equalPair(prior.origin ?? [0, 0], options.origin ?? [0, 0]) ||
24
+ !equalPair(prior.columnStep ?? [1, 0], options.columnStep ?? [1, 0]) ||
25
+ !equalPair(prior.rowStep ?? [0, 1], options.rowStep ?? [0, 1]) ||
26
+ (prior.heightReference ?? 'unknown') !== (options.heightReference ?? 'unknown') ||
27
+ (prior.maxHeightDifference ?? 0) !== (options.maxHeightDifference ?? 0))
28
+ throw new Error('Vertex tile options changed; rebuild the full snapshot');
29
+ const key = (t) => `${t.column},${t.row}`;
30
+ const affected = getTerrainVertexHaloAffectedTiles(resident, changed, options);
31
+ // Validate previous addresses and obtain an ordered, duplicate-free snapshot.
32
+ getTerrainVertexHaloAffectedTiles(previous, [], options);
33
+ const previousMap = new Map(previous.map(tile => [key(tile), tile]));
34
+ const currentKeys = new Set(resident.map(key));
35
+ const changedKeys = new Set(changed.map(key));
36
+ for (const tile of resident) {
37
+ if (!previousMap.has(key(tile)) && !changedKeys.has(key(tile)))
38
+ throw new Error('Unreported vertex tile arrival');
39
+ }
40
+ const removed = [];
41
+ for (const tile of previous) {
42
+ if (!currentKeys.has(key(tile))) {
43
+ if (!changedKeys.has(key(tile)))
44
+ throw new Error('Unreported vertex tile eviction');
45
+ removed.push({ column: tile.column, row: tile.row });
46
+ }
47
+ }
48
+ removed.sort((a, b) => a.column - b.column || a.row - b.row);
49
+ const affectedKeys = new Set(affected.map(key));
50
+ const rx = options.width === 2 ? 2 : 1;
51
+ const ry = options.height === 2 ? 2 : 1;
52
+ const needed = new Set();
53
+ for (const tile of affected)
54
+ for (let x = -rx; x <= rx; x++)
55
+ for (let y = -ry; y <= ry; y++) {
56
+ const column = tile.column + x, row = tile.row + y;
57
+ if (Number.isSafeInteger(column) && Number.isSafeInteger(row))
58
+ needed.add(`${column},${row}`);
59
+ }
60
+ const source = resident.filter(tile => needed.has(key(tile)));
61
+ const rebuilt = createTerrainVertexTileHalos(source, options).tiles;
62
+ const results = new Map(previous
63
+ .filter(tile => currentKeys.has(key(tile)) && !affectedKeys.has(key(tile)))
64
+ .map(tile => [key(tile), tile]));
65
+ for (const tile of rebuilt)
66
+ if (affectedKeys.has(key(tile)))
67
+ results.set(key(tile), tile);
68
+ if (results.size !== resident.length)
69
+ throw new Error('Incomplete vertex halo update');
70
+ return {
71
+ tiles: [...results.values()].sort((a, b) => a.column - b.column || a.row - b.row),
72
+ rebuilt: affected,
73
+ removed
74
+ };
75
+ }
76
+ //# sourceMappingURL=vertex-halo-update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-halo-update.js","sourceRoot":"","sources":["../../src/terrain/vertex-halo-update.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,4BAA4B,EAA6B,0BAAuB;AACxF,OAAO,EACL,iCAAiC,EAElC,sCAAmC;AAGpC;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAA0C,EAC1C,QAAsC,EACtC,OAA4C,EAC5C,OAA+E;IAM/E,MAAM,KAAK,GAAG,OAAO,CAAC,eAAe,CAAC;IACtC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACzE,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC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C9D,MAAM,OAAO,GAAG,4BAA4B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;IACpE,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,QAAQ;SACL,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1E,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAClC,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,OAAO;QAAE,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1F,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACvF,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;QACjF,OAAO,EAAE,QAAQ;QACjB,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { TerrainVertexTile, TerrainVertexTileOptions } from "./vertex-tiles.js";
2
+ import type { HeightFieldProps } from "./types.js";
3
+ /** Residency and validity of each padded lattice point. */
4
+ export declare const TerrainVertexHaloStatus: {
5
+ readonly NOT_RESIDENT: 0;
6
+ readonly NO_DATA: 1;
7
+ readonly VALID: 2;
8
+ };
9
+ export type TerrainVertexHaloTile = {
10
+ column: number;
11
+ row: number;
12
+ /** One-sample border around the tile, suitable for a vertex-registered HeightField. */
13
+ field: HeightFieldProps;
14
+ /** Matches field buffers, including interior: NOT_RESIDENT, NO_DATA or VALID. */
15
+ statuses: Uint8Array;
16
+ };
17
+ /** Reconcile and pad same-level vertex tiles with the actual adjacent lattice samples.
18
+ * Missing neighbors are NOT_RESIDENT; resident invalid samples are NO_DATA. No values
19
+ * are extrapolated. Recompute from a new tile snapshot after arrivals or evictions.
20
+ */
21
+ export declare function createTerrainVertexTileHalos(tiles: readonly TerrainVertexTile[], options: TerrainVertexTileOptions): {
22
+ tiles: TerrainVertexHaloTile[];
23
+ sharedVertices: number;
24
+ maxHeightDifference: number;
25
+ };
26
+ //# sourceMappingURL=vertex-halos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-halos.d.ts","sourceRoot":"","sources":["../../src/terrain/vertex-halos.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,iBAAiB,EAAE,wBAAwB,EAAC,0BAAuB;AAChF,OAAO,KAAK,EAAC,gBAAgB,EAAC,mBAAgB;AAE9C,2DAA2D;AAC3D,eAAO,MAAM,uBAAuB;;;;CAAmD,CAAC;AAExF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,uFAAuF;IACvF,KAAK,EAAE,gBAAgB,CAAC;IACxB,iFAAiF;IACjF,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,OAAO,EAAE,wBAAwB,GAChC;IAAC,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAC,CAyEvF"}
@@ -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
+ };
79
+ }
80
+ //# sourceMappingURL=vertex-halos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-halos.js","sourceRoot":"","sources":["../../src/terrain/vertex-halos.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,2BAA2B,EAAC,0BAAuB;AAI3D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAU,CAAC;AAWxF;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAAmC,EACnC,OAAiC;IAEjC,MAAM,EAAC,KAAK,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,GAAG,CAAC,EAC3B,YAAY,GAAG,MAAM,GAAG,CAAC,CAAC;IAC5B,MAAM,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,KAAK,CAAC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