fix(osm): stop using public Overpass by default (#648) (#742)

Traffic roads come from OpenFreeMap vector tiles, or TomTom flow tiles with a
key (Hybrid by default). Military areas use OpenFreeMap polygons with a bundled
worldwide name index; wide views show named points. ALPR reads an hourly
OpenStreetMap extract. Cockpit place context and country, state and US county
outlines use bundled Natural Earth and US Census data. Overpass is used only
when an operator configures their own endpoint.

Also: camera arrivals no longer land below ground, keyless terrain retries on
429, bounded relation geometry for configured Overpass, one shared
OpenStreetMap credit, and separate tile and API transports for embedders.

Co-authored-by: theGaryLarson <[email protected]>
Co-authored-by: Milan Khanal <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-09-28 19:07:57 -05:00
1 parent 81eb44340d
commit f4fcf267c6
200 files changed
+26665 -1977

No files matched your search

+180 -2
View File
@@ -1,8 +1,43 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createInstallationSource } from './source.js';
import { readFileSync } from 'node:fs';
import { tilesForBounds } from '../../data/tomtomTiles.js';
import { installationFeedback } from '../../data/installationFeedback.js';
import {
createInstallationSource,
installationAnchorBox,
installationTileZoom,
MILITARY_TILE_MAX,
MILITARY_TILE_MIN_ZOOM,
} from './source.js';
import {
decodeOpenFreeMapMilitaryTile,
decodeOpenFreeMapTile,
} from '../../sources/openFreeMap.js';
const box = { south: 30.1, west: -97.9, north: 30.3, east: -97.6 };
test('a wide-view pack failure names the unavailable data without an API fallback', async () => {
const source = createInstallationSource({
fetchImpl: async () => assert.fail('no API request for bundled names'),
loadNames: async () => {
throw new Error('asset unavailable');
},
});
await assert.rejects(
source.getMappedSites({ south: 20, west: -130, north: 60, east: -60 }),
(error) => {
assert.equal(error.failureReason, 'names_unavailable');
assert.equal(
installationFeedback({
status: 'unavailable',
failureReason: error.failureReason,
}),
'Mapped names temporarily unavailable',
);
return true;
},
);
});
test('mapped-site sources validate viewport bounds and preserve the exact retry key', async () => {
const calls = [];
const source = createInstallationSource({
@@ -14,7 +49,7 @@ test('mapped-site sources validate viewport bounds and preserve the exact retry
for (const invalid of [
null,
{ ...box, east: Infinity },
{ ...box, north: 90 },
{ ...box, north: 91 },
{ ...box, south: 31 },
])
await assert.rejects(
@@ -84,3 +119,146 @@ test('mapped-site sources normalize records and derive saturation from legacy ca
assert.equal(payload.status, 'stale');
assert.equal('elements' in payload, false);
});
test('installation tiles never drop below z9, where military areas exist', () => {
// OpenMapTiles omits landuse=military below z9; a z6-z8 view used to read as
// an empty, "Mapped sites loaded" area in Cockpit and wide follow views.
assert.equal(
installationTileZoom({
south: 30.3,
west: -97.8,
north: 30.33,
east: -97.74,
}),
12,
);
assert.equal(
installationTileZoom({ south: 30, west: -98, north: 31, east: -97 }),
10,
);
assert.equal(
installationTileZoom({ south: 30, west: -98.2, north: 31.4, east: -96.8 }),
9,
);
assert.equal(
installationTileZoom({ south: 28, west: -100, north: 32, east: -96 }),
null,
);
});
test('a Contacts window fits the tile cap at z9 from the tropics to the Arctic', () => {
for (const latitude of [0, 30.3125, 51.5, 60, 70]) {
const box = installationAnchorBox({ latitude, longitude: -97.765 });
assert.ok(box, `window at ${latitude}`);
assert.ok(
tilesForBounds(box, MILITARY_TILE_MIN_ZOOM, { maxTiles: 64 }).length <=
MILITARY_TILE_MAX,
);
assert.ok(box.south < latitude && box.north > latitude);
}
assert.equal(
installationAnchorBox({ latitude: 30.3125, longitude: -97.765 }).radiusM,
100_000,
);
assert.ok(
installationAnchorBox({ latitude: 60, longitude: 10 }).radiusM < 100_000,
);
assert.equal(
installationAnchorBox({ latitude: Number.NaN, longitude: 0 }),
null,
);
});
test('too-wide tile views use bundled named points without requesting tiles', async () => {
const fetched = [];
const source = createInstallationSource({
fetchImpl: async () =>
Response.json({ code: 'OVERPASS_NOT_CONFIGURED', retryable: false }),
mapTiles: {
clear() {},
async fetchBounds(box, { zoom }) {
fetched.push(zoom);
return { tiles: [], partial: false };
},
},
});
const wide = await source.getMappedSites({
south: 28,
west: -100,
north: 32,
east: -96,
});
assert.equal(wide.wide, true);
assert.equal(wide.status, 'ready');
assert.ok(wide.records.some((r) => r.name === 'Fort Hood'));
assert.ok(wide.records.every((r) => r.namedArea));
assert.deepEqual(
fetched,
[],
'no tile request for a view the tiles cannot answer',
);
await source.getMappedSites({
south: 30,
west: -98.2,
north: 31.4,
east: -96.8,
});
assert.deepEqual(fetched, [9]);
});
test('the military-only decoder keeps Camp Mabry and skips road geometry', () => {
const bytes = readFileSync(
new URL(
'../../data/fixtures/ofm-camp-mabry-12-935-1685.pbf',
import.meta.url,
),
);
const full = decodeOpenFreeMapTile(bytes, 12, 935, 1685);
const military = decodeOpenFreeMapMilitaryTile(bytes, 12, 935, 1685);
assert.ok(full.roads.length > 0);
assert.equal(military.roads.length, 0);
assert.deepEqual(
military.military.map((record) => record.id),
full.military.map((record) => record.id),
);
});
test('installation API transports never receive vector-tile URLs', async (t) => {
const calls = [];
const tileFetch = async (url) => {
calls.push(url);
return url.endsWith('/planet')
? Response.json({
tiles: ['https://tiles.openfreemap.org/test/{z}/{x}/{y}.pbf'],
})
: new Response(
readFileSync(
new URL(
'../../data/fixtures/ofm-camp-mabry-12-935-1685.pbf',
import.meta.url,
),
),
);
};
t.mock.method(globalThis, 'fetch', tileFetch);
for (const tileFetchImpl of [undefined, tileFetch]) {
const source = createInstallationSource({
tileFetchImpl,
fetchImpl: async (url) => {
assert.ok(url.startsWith('/api/'));
return Response.json({
code: 'OVERPASS_NOT_CONFIGURED',
retryable: false,
});
},
});
const data = await source.getMappedSites({
south: 30.3,
west: -97.77,
north: 30.32,
east: -97.75,
});
assert.ok(data.records.length);
}
assert.ok(calls.length >= 4);
});