Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix(street-level): deduplicate overlapping dateline tile halves

Rudy Celekliba58a5ec5028
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7acdedf6b..0814f7e7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,8 @@
the five borough cores load and `CCTV_NYC_MAX_SOURCES` changes the cap. The catalog-wide ceiling is
unchanged; extra cameras share it round-robin with the other packs.
+- Street Level requests count each tile once when dateline bounds overlap at coarse zoom levels.
+
- Treat explicitly current, complete empty vessel coverage as a successful update,
clearing obsolete contacts while retaining stale or incomplete snapshots.
diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md
index c77d1d8e3..d0014227f 100644
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@ -5310,3 +5310,8 @@ datacenters, dams and the Nepal locator retain that shared credit while displaye
Military fragments stitch by source identity. Different mapped parcels merge only
when their footprints touch or contain one another, never across a seam tolerance gap.
+
+
+### fix(street-level): deduplicate overlapping dateline tile halves
+
+Deduplicate tile addresses before ranking, truncating and reporting total coverage. Dateline ordering and the existing focus policy remain in control.
diff --git a/src/layers/streetLevel/street-level-unique-tiles.test.mjs b/src/layers/streetLevel/street-level-unique-tiles.test.mjs
new file mode 100644
index 000000000..f96f0b892
--- /dev/null
+++ b/src/layers/streetLevel/street-level-unique-tiles.test.mjs
@@ -0,0 +1,15 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { tilesForBbox } from './tileMath.js';
+test('coarse dateline coverage counts each tile exactly once', () => {
+ for (const z of [0, 1, 2]) {
+ const result = tilesForBbox([170, -1, -170, 1], z);
+ const keys = result.tiles.map((t) => `${t.x}/${t.y}/${t.z}`);
+ assert.equal(new Set(keys).size, keys.length);
+ assert.equal(result.total, keys.length);
+ const limited = tilesForBbox([170, -1, -170, 1], z, { limit: 1 });
+ assert.equal(limited.total, keys.length);
+ assert.equal(limited.truncated, keys.length > 1);
+ assert.equal(limited.tiles.length, 1);
+ }
+});
diff --git a/src/layers/streetLevel/tileMath.js b/src/layers/streetLevel/tileMath.js
index fe3c3ec18..ca7b09cd5 100644
--- a/src/layers/streetLevel/tileMath.js
+++ b/src/layers/streetLevel/tileMath.js
@@ -147,7 +147,12 @@ export function tilesForBbox(bbox, z, { limit = Infinity, focus = null } = {}) {
return Math.min(dx, n - dx) ** 2 + (tile.y - centre.y) ** 2;
};
// Each tile's distance is computed once; ties keep their row order.
- const ranked = tiles
+ const unique = [
+ ...new Map(
+ tiles.map((tile) => [`${tile.x}/${tile.y}/${tile.z}`, tile]),
+ ).values(),
+ ];
+ const ranked = unique
.map((tile) => ({ tile, d: distance2(tile) }))
.sort((a, b) => a.d - b.d)
.map(({ tile }) => tile);