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

+51 -51
View File
@@ -1,3 +1,4 @@
import { createReticleFootprint } from './footprint.js';
import * as Cesium from 'cesium';
import {
deriveFetchCenter,
@@ -13,6 +14,7 @@ import {
} from './policy.js';
export function createViewport({ state: layerState, services, parts, source }) {
const reticleFootprint = createReticleFootprint();
// ─── Camera Monitoring ─────────────────────────────────────
/**
@@ -164,32 +166,16 @@ export function createViewport({ state: layerState, services, parts, source }) {
*/
function clampBounds(bounds) {
return clampBoundsAroundCenter(bounds, getBoundsCenter(bounds));
return bounds.coverage
? bounds
: clampBoundsAroundCenter(bounds, getBoundsCenter(bounds));
}
/**
* Camera-change handler — the main entry point for viewport-driven road loading.
*
* Gating logic:
* 1. If the camera is above ACTIVATION_ALTITUDE, clear all dots and bail.
* 2. Clamp the view bounds and compute the viewport center.
* 3. Skip the fetch if the new viewport significantly overlaps the last-fetched
* bounds AND the center has shifted less than MIN_CENTER_SHIFT_KM. This
* prevents redundant fetches during small pans.
* 4. Otherwise, debounce and schedule `loadRoadsForBounds`.
*/
function onCameraChanged() {
/** Debounce camera events and sample the actual settled view, including final flight steps. */
function onCameraChanged(options) {
if (!layerState._enabled) return;
const alt = getCameraAltitude();
// Above activation altitude — remove all traffic and stop.
// Also null the last-fetch gate: otherwise zooming back down to the SAME
// viewport hits the overlap/center-shift skip in step 3 and the dots
// (cleared here) never reload (H5). Clearing the gate forces a fresh fetch.
if (alt > ACTIVATION_ALTITUDE) {
clearTimeout(layerState._fetchTimeout);
clearTimeout(layerState._fetchTimeout);
if (getCameraAltitude() > ACTIVATION_ALTITUDE) {
clearTimeout(layerState._retryTimer);
layerState._retryTimer = null;
parts.ingestion.cancelActiveFetch();
@@ -202,38 +188,52 @@ export function createViewport({ state: layerState, services, parts, source }) {
layerState._lastViewCenter = null;
return;
}
const bounds = getViewBounds();
if (!bounds) return;
// C4 fix: center the fetch box on the camera's look-at ground point (with
// nadir fallback + 12 km horizon-gaze pull-back), NOT the view rectangle's
// midpoint — at oblique pitch that midpoint drifts toward the horizon.
const fetchCenter = getFetchCenter();
const clamped = fetchCenter
? clampBoundsAroundCenter(bounds, fetchCenter)
: clampBounds(bounds);
const center = getBoundsCenter(clamped);
// Skip re-fetch when viewport overlap is high and center shift is negligible
if (
layerState._lastBounds &&
layerState._lastViewCenter &&
boundsOverlap(clamped, layerState._lastBounds, OVERLAP_THRESHOLD) &&
distanceKm(center, layerState._lastViewCenter) < MIN_CENTER_SHIFT_KM
) {
return;
}
// Debounce: wait for camera to settle before triggering a fetch. In debug
// captures the final changed event that arms this exact timeout is its
// causal anchor; Cesium's later moveEnd notification is diagnostic only.
const interactionAnchor = TRAFFIC_TIMING_ENABLED
? parts.timing.markTrafficTimingCameraChange()
: null;
clearTimeout(layerState._fetchTimeout);
layerState._fetchTimeout = setTimeout(
() => layerState._loadRoadsForBounds(clamped, alt, interactionAnchor),
FETCH_DEBOUNCE,
() => {
if (!layerState._enabled) return;
const alt = getCameraAltitude();
if (alt > ACTIVATION_ALTITUDE) return onCameraChanged();
const footprint = reticleFootprint(layerState._viewer, alt);
const bounds = footprint || getViewBounds();
if (!bounds) return;
const center = footprint ? null : getFetchCenter();
const clamped =
footprint ||
(center
? clampBoundsAroundCenter(bounds, center)
: clampBounds(bounds));
const previous = layerState._lastBounds;
const sameCoverage = clamped.coverage
? previous?.coverage?.key === clamped.coverage.key &&
previous.coverage.viewKey === clamped.coverage.viewKey
: previous &&
layerState._lastViewCenter &&
boundsOverlap(clamped, previous, OVERLAP_THRESHOLD) &&
distanceKm(getBoundsCenter(clamped), layerState._lastViewCenter) <
MIN_CENTER_SHIFT_KM;
if (
sameCoverage &&
!layerState._roadPartial &&
!layerState._detailError &&
!layerState._roadError
) {
if (
Math.abs(alt - layerState._lastRenderAltitude) > 100 &&
layerState._roads.length
)
parts.rendering.renderRoadsForAltitude(
layerState._roads,
alt,
'Cached zoom',
);
return;
}
return layerState._loadRoadsForBounds(clamped, alt, interactionAnchor);
},
options?.immediate === true ? 0 : FETCH_DEBOUNCE,
);
}
return {