mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
Merge origin/main: Google Street View, KartaView and Panoramax on the slim Street Level
Main gained three imagery providers (Google Street View, KartaView,
Panoramax), shared line-coverage, cone and photo-viewer modules, one source
lit at a time and the translated interface. Their shared modules still
carried what this branch removes, so the merge ports them onto it:
- lineCoverage.js is this branch's coverage.js made provider-neutral
(draped lines near the ground only, the selection drawn over them, key
and rate-limit blocking); sequenceCones.js is sequences.js the same way.
Mapillary, KartaView and Panoramax all build on them; Mapillary moves
back to providers/mapillary/ beside the others.
- No ground casting, mesh sampling, surface modes, FOLLOW, legend, prewarm,
orbit overview points (Panoramax's density dots included), stale-tile
swaps or water-filled point budget come back.
- Kept from main because the new providers need them: requiresMapStack and
attachMapStackController (Street View on Google 3D only), ground clicks,
openNearest with an optional provider nearestImage, openImage {frame},
reportError, the view-cone marker (now an SVG glyph), filters /
coverageLabel / sinceBasis, OPEN STREET VIEW, keyAlternatives and i18n.
- photoViewer.js treats the viewer as expanded when its wrap is full screen
or the iPhone popover, as EXPAND now is.
- The fixture browser gate keeps its 8 steps and adds one each for
KartaView and Panoramax; catalogs, docs, boundaries and format scope
follow.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
6390a3346f
809 files changed
+81825
-6035
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApplicationRequestServices } from './requests.js';
|
||||
test('unknown capability replies recover after backoff', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['Date'], now: 100_000 });
|
||||
for (const first of [
|
||||
() => Response.json({ wrong: true }),
|
||||
() => new Response('bad', { status: 503 }),
|
||||
]) {
|
||||
let probes = 0;
|
||||
let queries = 0;
|
||||
const services = createApplicationRequestServices({
|
||||
boundaryProbe: { timeoutMs: 1000, retryMs: 1000 },
|
||||
fetchImpl: async (url) => {
|
||||
if (url.endsWith('/status'))
|
||||
return ++probes === 1
|
||||
? first()
|
||||
: Response.json({ configured: false });
|
||||
queries++;
|
||||
return Response.json({ elements: [] });
|
||||
},
|
||||
});
|
||||
assert.deepEqual(await services.boundaries.query('fixture'), []);
|
||||
assert.deepEqual(await services.boundaries.query('fixture'), []);
|
||||
assert.equal(probes, 1, 'unknown reply is not re-probed inside backoff');
|
||||
t.mock.timers.tick(1000);
|
||||
assert.equal(
|
||||
(await services.boundaries.query('fixture')).code,
|
||||
'OVERPASS_NOT_CONFIGURED',
|
||||
);
|
||||
assert.equal(
|
||||
(await services.boundaries.query('fixture')).code,
|
||||
'OVERPASS_NOT_CONFIGURED',
|
||||
);
|
||||
assert.equal(probes, 2);
|
||||
assert.equal(queries, 2);
|
||||
}
|
||||
});
|
||||
+18
-11
@@ -204,12 +204,16 @@ export function createGroundFloor({ terrain, signal }) {
|
||||
* @returns {{lat: number, lon: number}} The cell to read.
|
||||
*/
|
||||
function stickyFloorCell(lat, lon, previousCell) {
|
||||
if (
|
||||
previousCell &&
|
||||
Math.abs(lat - previousCell.lat) <= 0.0005 + CELL_HYSTERESIS_DEG &&
|
||||
Math.abs(lon - previousCell.lon) <= 0.0005 + CELL_HYSTERESIS_DEG
|
||||
) {
|
||||
return previousCell;
|
||||
if (previousCell) {
|
||||
// The short way round, so a contact on the 180° seam keeps its cell.
|
||||
let dLon = lon - previousCell.lon;
|
||||
dLon -= 360 * Math.round(dLon / 360);
|
||||
if (
|
||||
Math.abs(lat - previousCell.lat) <= 0.0005 + CELL_HYSTERESIS_DEG &&
|
||||
Math.abs(dLon) <= 0.0005 + CELL_HYSTERESIS_DEG
|
||||
) {
|
||||
return previousCell;
|
||||
}
|
||||
}
|
||||
return coarseFloorCoord(lat, lon);
|
||||
}
|
||||
@@ -269,17 +273,20 @@ export function createGroundFloor({ terrain, signal }) {
|
||||
const a = points[s];
|
||||
const b = points[s + 1];
|
||||
if (![a?.lat, a?.lon, b?.lat, b?.lon].every(Number.isFinite)) continue;
|
||||
// The short way round, so a segment across 180° walks across it.
|
||||
let dLon = b.lon - a.lon;
|
||||
dLon -= 360 * Math.round(dLon / 360);
|
||||
const steps = Math.ceil(
|
||||
Math.max(Math.abs(b.lat - a.lat), Math.abs(b.lon - a.lon)) /
|
||||
Math.max(Math.abs(b.lat - a.lat), Math.abs(dLon)) /
|
||||
CORRIDOR_WALK_STEP_DEG,
|
||||
);
|
||||
for (let i = 1; i <= steps; i++) {
|
||||
if (out.length >= prefixLimit) break walk;
|
||||
const t = i / steps;
|
||||
const cell = coarseFloorCoord(
|
||||
a.lat + (b.lat - a.lat) * t,
|
||||
a.lon + (b.lon - a.lon) * t,
|
||||
);
|
||||
let lon = a.lon + dLon * t;
|
||||
if (lon > 180) lon -= 360;
|
||||
else if (lon < -180) lon += 360;
|
||||
const cell = coarseFloorCoord(a.lat + (b.lat - a.lat) * t, lon);
|
||||
const key = `${cell.lat},${cell.lon}`;
|
||||
if (seen.has(key) || key === destKey) continue;
|
||||
seen.add(key);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { approxDistanceKm } from '../data/approxDistance.js';
|
||||
|
||||
/** Construct an instance-owned meshFloorSampler service with explicit dependencies. */
|
||||
export function createMeshFloorSampler({
|
||||
@@ -79,16 +80,6 @@ export function createMeshFloorSampler({
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equirectangular distance (km) — same approximation the flights clamp uses.
|
||||
*/
|
||||
function _approxKm(lat1, lon1, lat2, lon2) {
|
||||
const dLat = (lat2 - lat1) * 111.32;
|
||||
const dLon =
|
||||
(lon2 - lon1) * 111.32 * Math.cos((((lat1 + lat2) / 2) * Math.PI) / 180);
|
||||
return Math.hypot(dLat, dLon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Samples the rendered mesh height for the coarse cells containing `points`,
|
||||
* one-shot per cell, budget-capped, viewer-proximity-gated. Call ONCE per
|
||||
@@ -133,7 +124,8 @@ export function createMeshFloorSampler({
|
||||
if (
|
||||
Number.isFinite(viewerLat) &&
|
||||
Number.isFinite(viewerLon) &&
|
||||
_approxKm(viewerLat, viewerLon, cell.lat, cell.lon) > MAX_SAMPLE_DIST_KM
|
||||
approxDistanceKm(viewerLat, viewerLon, cell.lat, cell.lon) >
|
||||
MAX_SAMPLE_DIST_KM
|
||||
) {
|
||||
continue; // too far: tiles not streamed there, probe would be a guaranteed miss
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ export function createApplicationRequestServices({
|
||||
throw new Error(`${label} unavailable (${response.status})`);
|
||||
return response.data;
|
||||
}
|
||||
// Learn once per page whether the server has an Overpass instance, so an
|
||||
// Remember valid capability decisions for the page, so an
|
||||
// unconfigured server is never asked (and never answers with an error).
|
||||
// Discovery is bounded; a failed or timed-out probe is forgotten and not
|
||||
// Discovery is bounded; failed, malformed or timed-out probes are forgotten and not
|
||||
// retried for a short backoff, during which queries go to the server as
|
||||
// they would against an older server without the probe.
|
||||
let boundaryCapability = null;
|
||||
@@ -79,10 +79,13 @@ export function createApplicationRequestServices({
|
||||
boundaryCapability = request(`${urls.boundaries}/status`, {
|
||||
signal: AbortSignal.timeout(boundaryProbe.timeoutMs),
|
||||
}).then(
|
||||
(response) =>
|
||||
response.ok && typeof response.data?.configured === 'boolean'
|
||||
? response.data.configured
|
||||
: null, // an older server: fall back to asking per query
|
||||
(response) => {
|
||||
if (response.ok && typeof response.data?.configured === 'boolean')
|
||||
return response.data.configured;
|
||||
boundaryCapability = null;
|
||||
boundaryProbeRetryAt = Date.now() + boundaryProbe.retryMs;
|
||||
return null; // capability unknown: let this query ask the server
|
||||
},
|
||||
(error) => {
|
||||
boundaryCapability = null;
|
||||
if (lifetime?.aborted) throw error;
|
||||
|
||||
@@ -272,28 +272,26 @@ export function createTerrainHeights({
|
||||
const uncached = [];
|
||||
const seenKeys = new Set();
|
||||
const now = Date.now();
|
||||
// What this call resolved or found warm, so the assembly below can report a
|
||||
// point even if a later chunk's writes pushed it past CACHE_MAX_ENTRIES.
|
||||
// Without it a batch big enough to evict its own entries would report
|
||||
// points as unresolved that it had in fact resolved.
|
||||
const resolvedThisCall = new Map();
|
||||
for (const item of work) {
|
||||
const entry = cache.get(item.key);
|
||||
const entry = cacheTouch(item.key);
|
||||
const fallbackCooling =
|
||||
entry?.source === 'geoid-fallback' &&
|
||||
Number.isFinite(entry.retryAt) &&
|
||||
now < entry.retryAt;
|
||||
if (
|
||||
(entry && entry.source === 'reearth') ||
|
||||
fallbackCooling ||
|
||||
seenKeys.has(item.key)
|
||||
)
|
||||
if ((entry && entry.source === 'reearth') || fallbackCooling) {
|
||||
resolvedThisCall.set(item.key, entry);
|
||||
continue;
|
||||
}
|
||||
if (seenKeys.has(item.key)) continue;
|
||||
seenKeys.add(item.key);
|
||||
uncached.push(item);
|
||||
}
|
||||
|
||||
// What this call resolved, so the assembly below can report a point even
|
||||
// if a later chunk's writes pushed it past CACHE_MAX_ENTRIES. Without it a
|
||||
// batch big enough to evict its own earlier chunks would report points as
|
||||
// unresolved that it had in fact just resolved.
|
||||
const resolvedThisCall = new Map();
|
||||
|
||||
// Resolve the network path in sequential <=CHUNK_SIZE chunks. Each chunk's
|
||||
// failure is isolated to that chunk's points (geoid fallback), so a single
|
||||
// bad chunk doesn't lose results for the rest of a large batch.
|
||||
|
||||
@@ -114,6 +114,47 @@ test('a batch larger than the cache bound still reports every point it resolved'
|
||||
assert.equal(warm.length, 4);
|
||||
});
|
||||
|
||||
test('warm batch consumers retain their terrain cells ahead of unused cells', async () => {
|
||||
let calls = 0;
|
||||
const terrain = createTerrainHeights({
|
||||
maxCacheEntries: 2,
|
||||
source: {
|
||||
async getHeights(points) {
|
||||
calls++;
|
||||
return points.map((p) => ({ ellipsoid: 100 + p.lon }));
|
||||
},
|
||||
},
|
||||
});
|
||||
const p = (lon) => ({ lat: 0, lon });
|
||||
await terrain.resolveEllipsoidalGround([p(1)]);
|
||||
await terrain.resolveEllipsoidalGround([p(2)]);
|
||||
await terrain.resolveEllipsoidalGround([p(1)]);
|
||||
assert.equal(calls, 2);
|
||||
await terrain.resolveEllipsoidalGround([p(3)]);
|
||||
assert.equal(terrain.cachedEllipsoidalGround(0, 1), 101);
|
||||
assert.equal(terrain.cachedEllipsoidalGround(0, 2), null);
|
||||
assert.equal(calls, 3);
|
||||
});
|
||||
|
||||
test('a batch still reports its warm points after its own fetches evict them', async () => {
|
||||
const terrain = createTerrainHeights({
|
||||
source: stubSource(),
|
||||
maxCacheEntries: 2,
|
||||
});
|
||||
await terrain.resolveEllipsoidalGround([pointAt(0)]);
|
||||
|
||||
const results = await terrain.resolveEllipsoidalGround([
|
||||
pointAt(0),
|
||||
pointAt(1),
|
||||
pointAt(2),
|
||||
]);
|
||||
|
||||
results.forEach((result, i) => {
|
||||
assert.equal(result.source, 'reearth', `point ${i} reported resolved`);
|
||||
assert.equal(result.ellipsoid, heightAt(lonAt(i)));
|
||||
});
|
||||
});
|
||||
|
||||
test('an out-of-range cache bound falls back to the default instead of disabling the cache', async () => {
|
||||
for (const maxCacheEntries of [0, -1, Number.NaN, undefined]) {
|
||||
const terrain = createTerrainHeights({
|
||||
|
||||
Reference in new issue
Block a user