mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
200 files changed
+26665
-1977
No files matched your search
@@ -1,7 +1,27 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { MAX_VIEWPORT_DEGREES, REQUEST_DEBOUNCE_MS } from './policy.js';
|
||||
import { REQUEST_DEBOUNCE_MS } from './policy.js';
|
||||
import { installationAnchorBox } from './source.js';
|
||||
|
||||
export function createViewport({ state: layerState, services, parts, source }) {
|
||||
/**
|
||||
* The area this load describes: the window around a Contacts subject while
|
||||
* one is set (a follow or Cockpit camera never settles and often looks at the
|
||||
* horizon), otherwise the settled camera viewport.
|
||||
* @param {object} viewer Cesium viewer.
|
||||
* @returns {{box: object|null, coverage: object}} Query box and its coverage.
|
||||
*/
|
||||
function loadArea(viewer) {
|
||||
const anchor = layerState.contextAnchor;
|
||||
if (anchor) {
|
||||
const box = installationAnchorBox(anchor);
|
||||
if (box) {
|
||||
const { radiusM, ...bounds } = box;
|
||||
return { box: bounds, coverage: { kind: 'subject', radiusM } };
|
||||
}
|
||||
}
|
||||
return { box: viewportBox(viewer), coverage: { kind: 'viewport' } };
|
||||
}
|
||||
|
||||
function viewportBox(viewer) {
|
||||
const rectangle = viewer?.camera?.computeViewRectangle(
|
||||
viewer.scene.globe.ellipsoid,
|
||||
@@ -11,12 +31,11 @@ export function createViewport({ state: layerState, services, parts, source }) {
|
||||
const north = Cesium.Math.toDegrees(rectangle.north);
|
||||
const west = Cesium.Math.toDegrees(rectangle.west);
|
||||
const east = Cesium.Math.toDegrees(rectangle.east);
|
||||
// Cross-dateline/global views require a zoom before a bounded request.
|
||||
// Wide and dateline views use the bundled point index.
|
||||
if (
|
||||
!Number.isFinite(south + north + west + east) ||
|
||||
east <= west ||
|
||||
north - south > MAX_VIEWPORT_DEGREES ||
|
||||
east - west > MAX_VIEWPORT_DEGREES
|
||||
east === west ||
|
||||
north <= south
|
||||
)
|
||||
return null;
|
||||
return { south, west, north, east };
|
||||
@@ -44,10 +63,13 @@ export function createViewport({ state: layerState, services, parts, source }) {
|
||||
* zoom-out, or disable cancels it.
|
||||
*/
|
||||
|
||||
function scheduleUnavailableRetry() {
|
||||
function scheduleUnavailableRetry(retryAfterMs = 0) {
|
||||
if (!layerState.enabled) return;
|
||||
clearTimeout(layerState.retryTimer);
|
||||
layerState.retryDelayMs = installationRetryDelayMs(layerState.retryDelayMs);
|
||||
layerState.retryDelayMs = Math.max(
|
||||
retryAfterMs,
|
||||
installationRetryDelayMs(layerState.retryDelayMs),
|
||||
);
|
||||
layerState.retryAt = Date.now() + layerState.retryDelayMs;
|
||||
layerState.retryTimer = setTimeout(() => {
|
||||
layerState.retryTimer = null;
|
||||
@@ -66,15 +88,36 @@ export function createViewport({ state: layerState, services, parts, source }) {
|
||||
|
||||
function scheduleLoad() {
|
||||
if (!layerState.enabled) return;
|
||||
const { box, coverage } = loadArea(layerState.viewer);
|
||||
const camera = layerState.viewer.camera;
|
||||
const widePose =
|
||||
coverage.kind === 'viewport' &&
|
||||
box &&
|
||||
(box.east < box.west ||
|
||||
box.east - box.west > 10 ||
|
||||
box.north - box.south > 10)
|
||||
? [camera.positionWC, camera.directionWC]
|
||||
.map((v) =>
|
||||
v ? [v.x, v.y, v.z].map((n) => n.toFixed(4)).join(',') : '',
|
||||
)
|
||||
.join(':')
|
||||
: '';
|
||||
const key = `${coverage.kind}:${box ? [box.south, box.west, box.north, box.east].map((v) => v.toFixed(6)).join(',') : 'wide'}:${widePose}`;
|
||||
if (layerState.cameraLoadKey === key && !layerState.error) return;
|
||||
layerState.cameraLoadKey = key;
|
||||
layerState.cameraLoadOwner = {};
|
||||
layerState.abort?.abort();
|
||||
// A user-driven load supersedes any pending retry; the load reschedules on
|
||||
// failure, so the backoff step is kept rather than reset.
|
||||
clearUnavailableRetry({ resetBackoff: false });
|
||||
clearTimeout(layerState.timer);
|
||||
layerState.timer = setTimeout(() => {
|
||||
layerState.timer = null;
|
||||
parts.ingestion.loadInstallations();
|
||||
}, REQUEST_DEBOUNCE_MS);
|
||||
}
|
||||
return {
|
||||
loadArea,
|
||||
viewportBox,
|
||||
installationRetryDelayMs,
|
||||
scheduleUnavailableRetry,
|
||||
|
||||
Reference in new issue
Block a user