feat(mapillary): street-level layer core — coverage, sequences, viewer bridge, query engine

Camera-driven Mapillary coverage (z0–5 overview points from orbit, z11–14
ground-clamped sequence lines below 60 km), per-sequence image cones, an
embedded MapillaryJS viewer bridge with a camera-follow mode, sprite icons
for map features, and a query engine that turns a plan into a streamed
z14 tile fan-out. Registers an on-globe CC BY-SA 4.0 credit while enabled.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
Said TurkseverandClaude Fable 5.1 committed 2026-09-23 15:44:32 +01:00
1 parent 0d41b6be54
commit fa5710bcf2
46 files changed
+9935 -32

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
bboxFromGeocode,
enforceMinimumSpan,
fitBboxToTileBudget,
summarizeResults,
} from './query.js';
import { countTilesForBbox } from './tileMath.js';
test('bboxFromGeocode prefers bounds and falls back to a point box', () => {
const withBounds = bboxFromGeocode({
geometry: {
location: { lat: 38.58, lng: -121.49 },
bounds: {
southwest: { lat: 38.44, lng: -121.56 },
northeast: { lat: 38.69, lng: -121.36 },
},
},
formatted_address: 'Sacramento, California',
});
assert.deepEqual(withBounds.bbox, [-121.56, 38.44, -121.36, 38.69]);
assert.equal(withBounds.label, 'Sacramento, California');
const point = bboxFromGeocode({
geometry: { location: { lat: 42.33, lng: -83.05 } },
});
assert.ok(point.bbox[0] < -83.05 && point.bbox[2] > -83.05);
assert.equal(bboxFromGeocode(null), null);
});
test('fitBboxToTileBudget shrinks an oversized box around its centre', () => {
const california = [-125, 32, -114, 42];
const fitted = fitBboxToTileBudget(california, 600);
assert.ok(countTilesForBbox(fitted, 14) <= 600);
const cx = (fitted[0] + fitted[2]) / 2;
assert.ok(Math.abs(cx - -119.5) < 1e-6);
const small = [-121.5, 38.5, -121.4, 38.6];
assert.deepEqual(fitBboxToTileBudget(small, 600), small);
});
test('summarizeResults reports totals, top classes and the sighting window', () => {
const text = summarizeResults({
total: 1234,
counts: new Map([
['object--fire-hydrant', 1000],
['object--bench', 200],
['object--mailbox', 20],
['object--trash-can', 14],
]),
earliest: Date.UTC(2019, 0, 1),
latest: Date.UTC(2026, 5, 1),
truncated: true,
failed: 2,
});
assert.match(
text,
/^1,234 features: 1,000 fire hydrant, 200 bench, 20 mailbox and 1 more classes/,
);
assert.match(text, /seen 2019–2026 · capped · 2 tiles failed$/);
assert.equal(
summarizeResults({ total: 0, counts: new Map() }),
'No matching features in this area.',
);
});
test('node-sized geocode bounds are grown to a queryable neighbourhood box', () => {
const tiny = bboxFromGeocode({
geometry: {
location: { lat: 42.3292, lng: -83.0527 },
bounds: {
southwest: { lat: 42.329, lng: -83.053 },
northeast: { lat: 42.3294, lng: -83.0524 },
},
},
});
assert.ok(tiny.bbox[2] - tiny.bbox[0] >= 0.01 - 1e-9);
assert.ok(tiny.bbox[3] - tiny.bbox[1] >= 0.01 - 1e-9);
assert.deepEqual(enforceMinimumSpan([0, 0, 1, 1], 0.5), [0, 0, 1, 1]);
});