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.

test: show a capped overview no longer holds repeat tiles

Sameh Khamis84714030c86c
diff --git a/src/layers/streetLevel/street-level-unique-tiles.test.mjs b/src/layers/streetLevel/street-level-unique-tiles.test.mjs
index 224de523b..52e7b6aea 100644
--- a/src/layers/streetLevel/street-level-unique-tiles.test.mjs
+++ b/src/layers/streetLevel/street-level-unique-tiles.test.mjs
@@ -20,3 +20,12 @@ test('reachable polar dateline coverage ranks 24 distinct tiles before overview
);
assert.equal(overview.truncated, true);
});
+
+test('a limit that fits every distinct tile is not spent on repeats', () => {
+ // Before de-duplication this box yielded 27 entries for 24 tiles, so a
+ // 24-slot overview held repeats and still reported itself truncated.
+ const result = tilesForBbox([-10, 60, -20, 85], 3, { limit: 24 });
+ const keys = result.tiles.map((tile) => `${tile.x}/${tile.y}/${tile.z}`);
+ assert.equal(new Set(keys).size, 24);
+ assert.equal(result.truncated, false);
+});
diff --git a/src/layers/streetLevel/tileMath.js b/src/layers/streetLevel/tileMath.js
index ca7b09cd5..350188200 100644
--- a/src/layers/streetLevel/tileMath.js
+++ b/src/layers/streetLevel/tileMath.js
@@ -146,7 +146,10 @@ export function tilesForBbox(bbox, z, { limit = Infinity, focus = null } = {}) {
const dx = Math.abs(tile.x - centre.x);
return Math.min(dx, n - dx) ** 2 + (tile.y - centre.y) ** 2;
};
- // Each tile's distance is computed once; ties keep their row order.
+ // The date-line halves share a column when the gap between east and west is
+ // narrower than a tile; count that column once so a capped overview does not
+ // spend its slots on repeats. Each tile's distance is computed once; ties keep
+ // their row order.
const unique = [
...new Map(
tiles.map((tile) => [`${tile.x}/${tile.y}/${tile.z}`, tile]),