mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Merge main through #1495 into the renderer seam
Brings in radio country coverage (#1206), the restored format scope (#1527), the zoom-out guard (#1522), voice geometry and OSM places (#846) and paired traffic flow density (#1495). What main added that reached Cesium or the viewer now goes through the renderer: - The zoom-out guard reads the Cesium camera controller's own input, so it moves into the adapter (src/render/cesium/zoomOutGuard.js). The application installs it through the scene's viewer hooks, and a scene whose renderer gives no guard starts without one. - OSM places draws its points as a draw set, clamped to the ground. - The voice area actions read the view box and the view centre from the camera port. - The voice workflow harness is test support, named as such where the recent-imagery doubles are.
This commit is contained in:
commit
fd42fc0afd
136 files changed
+17399
-1120
No files matched your search
@@ -1,10 +1,19 @@
|
||||
/**
|
||||
* The action runner wired to fakes that behave like the real services:
|
||||
* aircraft records, an annotation board, the referent registry and a turn
|
||||
* pointer. Shared by the cross-feature voice contract tests.
|
||||
* The action runner with every cross-feature workflow wired to fakes that
|
||||
* behave like the real services: aircraft records, an annotation board, OSM
|
||||
* places, the real Recent Imagery layer over a manual catalog, the outline
|
||||
* ladder with Kathmandu and an ambiguous "Punjab", the referent registry and
|
||||
* a turn pointer. Shared by the cross-feature voice contract tests.
|
||||
*/
|
||||
import { createGevActionRunner } from './gevActions.js';
|
||||
import { createReferentRegistry } from './referents.js';
|
||||
import { createRecentImageryLayer } from '../layers/recentImagery/index.js';
|
||||
import {
|
||||
fakeCatalog,
|
||||
fakeRenderer,
|
||||
fakeThumbnails,
|
||||
} from '../layers/recentImagery/testDoubles.mjs';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
globalThis.window = globalThis.window || {
|
||||
clearTimeout,
|
||||
@@ -12,6 +21,55 @@ globalThis.window = globalThis.window || {
|
||||
requestIdleCallback: null,
|
||||
};
|
||||
|
||||
const square = (w, s, e, n) => [
|
||||
[w, s],
|
||||
[e, s],
|
||||
[e, n],
|
||||
[w, n],
|
||||
[w, s],
|
||||
];
|
||||
|
||||
const punjab = (country, box) => ({
|
||||
kind: 'state',
|
||||
name: 'Punjab',
|
||||
country,
|
||||
source: 'natural-earth',
|
||||
polygons: [[square(...box)]],
|
||||
});
|
||||
|
||||
/** Bundled units sharing a name, as data/adminBoundaries.js lists them. */
|
||||
const PUNJABS = [
|
||||
punjab('India', [73.9, 29.5, 76.9, 32.5]),
|
||||
punjab('Pakistan', [69.3, 27.7, 73.8, 34.0]),
|
||||
];
|
||||
|
||||
/**
|
||||
* The annotation outline ladder: Kathmandu comes back from the guarded
|
||||
* Nominatim route; any other name anchors with no outline.
|
||||
*/
|
||||
async function resolveAnnotationTarget({ target }) {
|
||||
if (/kathmandu/i.test(target || ''))
|
||||
return {
|
||||
lat: 27.7,
|
||||
lon: 85.3,
|
||||
label: 'Kathmandu', // i18n-ignore: harness fixture place name
|
||||
ring: null,
|
||||
resolveOutline: async () => ({
|
||||
ring: square(85.2, 27.6, 85.4, 27.8),
|
||||
polygons: [[square(85.2, 27.6, 85.4, 27.8)]],
|
||||
synthesized: false,
|
||||
outlineSource: 'nominatim',
|
||||
}),
|
||||
};
|
||||
return { lat: 37.795, lon: -122.393, ring: null };
|
||||
}
|
||||
|
||||
const HOSPITALS = [
|
||||
{ id: 'node/1', lat: 27.7, lon: 85.31, tags: { name: 'Bir Hospital' } },
|
||||
{ id: 'node/2', lat: 27.71, lon: 85.33, tags: { name: 'Military Hospital' } },
|
||||
{ id: 'node/3', lat: 27.72, lon: 85.35, tags: {} },
|
||||
];
|
||||
|
||||
/** An annotation board that marks every spec it is given. */
|
||||
function fakeAnnotations() {
|
||||
const marks = [];
|
||||
@@ -22,8 +80,11 @@ function fakeAnnotations() {
|
||||
const results = specs.map((spec) => {
|
||||
const mark = {
|
||||
id: `anno-${(seq += 1)}`,
|
||||
ring: spec.ring,
|
||||
label: spec.label,
|
||||
target: spec.target,
|
||||
areaId: spec.areaId || null,
|
||||
origin: spec.manual ? spec.origin || 'drawn' : 'voice',
|
||||
createdAt: seq,
|
||||
};
|
||||
marks.push(mark);
|
||||
@@ -32,15 +93,47 @@ function fakeAnnotations() {
|
||||
return { drawn: results.length, failed: 0, results };
|
||||
},
|
||||
list: () => marks,
|
||||
generation: () => 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** The runner with aircraft, annotations, referents and a turn pointer wired. */
|
||||
function osmPlacesModule() {
|
||||
let records = [];
|
||||
return {
|
||||
setResults(next) {
|
||||
records = next.slice();
|
||||
},
|
||||
getAnalystRecords: (max = 2000) => records.slice(0, max),
|
||||
getStats: () => ({ count: records.length, lastUpdate: Date.now() }),
|
||||
};
|
||||
}
|
||||
|
||||
function realImageryLayer() {
|
||||
const catalog = fakeCatalog();
|
||||
const layer = createRecentImageryLayer({
|
||||
catalog,
|
||||
renderer: fakeRenderer(),
|
||||
thumbnails: fakeThumbnails(),
|
||||
host: () => ({ collection: {}, kind: 'globe' }),
|
||||
now: () => new Date('2026-09-23T12:00:00Z'),
|
||||
});
|
||||
layer.init({ camera: {} });
|
||||
layer.enable();
|
||||
return { layer, catalog };
|
||||
}
|
||||
|
||||
/**
|
||||
* The runner with every workflow wired: aircraft, annotations, OSM places,
|
||||
* imagery, areas, the referent registry and a turn pointer.
|
||||
*/
|
||||
export function harness({
|
||||
flights = null,
|
||||
pointer = null,
|
||||
on = ['flights'],
|
||||
osmHits = HOSPITALS,
|
||||
osmSearch = null,
|
||||
on = ['flights', 'recent-imagery'],
|
||||
} = {}) {
|
||||
const imagery = realImageryLayer();
|
||||
const modules = {
|
||||
flights: flights || {
|
||||
getStats: () => ({ count: 3, lastUpdate: Date.now() }),
|
||||
@@ -50,6 +143,8 @@ export function harness({
|
||||
{ id: 'SWA3', icao24: 'a3', callsign: 'SWA3', lat: 30.2, lon: -97 },
|
||||
],
|
||||
},
|
||||
'osm-places': osmPlacesModule(),
|
||||
'recent-imagery': imagery.layer,
|
||||
};
|
||||
const enabled = new Set(on);
|
||||
const viewer = {
|
||||
@@ -58,6 +153,13 @@ export function harness({
|
||||
scene: { canvas: { addEventListener() {}, removeEventListener() {} } },
|
||||
camera: {
|
||||
moveEnd: { addEventListener() {} },
|
||||
// The view: a box over Kathmandu, in radians.
|
||||
computeViewRectangle: () => ({
|
||||
west: (85.2 * Math.PI) / 180,
|
||||
south: (27.6 * Math.PI) / 180,
|
||||
east: (85.4 * Math.PI) / 180,
|
||||
north: (27.8 * Math.PI) / 180,
|
||||
}),
|
||||
positionCartographic: {
|
||||
height: 300_000,
|
||||
latitude: 0.52,
|
||||
@@ -65,16 +167,29 @@ export function harness({
|
||||
},
|
||||
},
|
||||
};
|
||||
// The actions read the view through the camera port.
|
||||
bindFakeCesiumCamera(viewer);
|
||||
const referents = createReferentRegistry();
|
||||
let snapshot = pointer;
|
||||
const osmCalls = [];
|
||||
const runner = createGevActionRunner({
|
||||
viewer,
|
||||
styleManager: {},
|
||||
annotations: fakeAnnotations(),
|
||||
annotationResolver: {
|
||||
resolveRegionRingForQuery: async () => null,
|
||||
resolveAnnotationTarget: async () => ({ lat: 37.795, lon: -122.393 }),
|
||||
resolveAnnotationTarget,
|
||||
},
|
||||
areaOptions: {
|
||||
findRegion: async () => null,
|
||||
findAdminCandidates: async (q) => (/^punjab$/i.test(q) ? PUNJABS : []),
|
||||
},
|
||||
osmSearch:
|
||||
osmSearch ||
|
||||
(async (request) => {
|
||||
osmCalls.push(request);
|
||||
return { ok: true, features: osmHits, truncated: false };
|
||||
}),
|
||||
deixis: {
|
||||
pointer: { activeSnapshot: () => snapshot },
|
||||
referents,
|
||||
@@ -102,6 +217,8 @@ export function harness({
|
||||
return {
|
||||
runner,
|
||||
referents,
|
||||
imagery,
|
||||
osmCalls,
|
||||
setPointer: (next) => (snapshot = next),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user