mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Keep each mesh floor reading at its point and answer from the nearest one
Keeping a cell's lowest reading let a street probe pull a vehicle on a viaduct or bridge in the same cell down to street level. Readings now stay at the point they were taken (up to eight per cell, about 17 m apart), a read answers from the reading nearest the vehicle, and two readings within about 5 m keep the lower.
This commit is contained in:
1 parent
18a9e0470d
commit
76b5d99e24
4 files changed
+100
-54
No files matched your search
+12
-10
@@ -1136,15 +1136,17 @@ On the photoreal stack the shared floor (`cachedGroundFloor`) answers from a
|
|||||||
rendered-mesh reading per coarse cell (0.001°, about 110 × 80 m), sampled by
|
rendered-mesh reading per coarse cell (0.001°, about 110 × 80 m), sampled by
|
||||||
`src/services/meshFloorSampler.js` and gated against the DEM by
|
`src/services/meshFloorSampler.js` and gated against the DEM by
|
||||||
`reportValidatedMeshFloorCell` in `src/services/groundFloor.js`. The probe goes
|
`reportValidatedMeshFloorCell` in `src/services/groundFloor.js`. The probe goes
|
||||||
where the caller's point is (a vehicle or contact), not to the cell's centre,
|
where the caller's point is (a vehicle or contact), not to the cell's centre;
|
||||||
and a cell is read up to four times at points about 17 m or more apart; the
|
a cell is read up to eight times, at points about 17 m or more apart, and each
|
||||||
lowest reading that passes the gate is kept. Before this, one probe at the
|
reading that passes the gate is kept at its point. A read answers from the
|
||||||
cell's centre latched for the session, so a centre on a roof lifted everything
|
cell's reading nearest the asked point, so a viaduct and the street beside it
|
||||||
in the cell (a Haymarket bus drew 23.5 m above the street, on the garage roof)
|
in one cell keep their own heights; two readings within about 5 m of each other
|
||||||
and a centre in the river put Red Line trains on the Longfellow Bridge 6–9 m
|
keep the lower. Before this, one probe at the cell's centre latched for the
|
||||||
under the deck. Accepted limit: a cell holds one floor, so a vehicle on a
|
session, so a centre on a roof lifted everything in the cell (a Haymarket bus
|
||||||
bridge or viaduct whose cell also gets a street-level probe beneath it is drawn
|
drew 23.5 m above the street, on the garage roof) and a centre in the river put
|
||||||
at that lower level.
|
Red Line trains on the Longfellow Bridge 6–9 m under the deck. Residual: the
|
||||||
|
probe is vertical, so a vehicle directly under a deck or a roof overhang reads
|
||||||
|
the structure above it.
|
||||||
|
|
||||||
## Vessel components and sources
|
## Vessel components and sources
|
||||||
|
|
||||||
@@ -2558,7 +2560,7 @@ This is the current runtime/source-of-truth snapshot for the project.
|
|||||||
> `HELD_SNAP_CONTRADICTION_M` (5 m) ABOVE the held value drops the hold and the
|
> `HELD_SNAP_CONTRADICTION_M` (5 m) ABOVE the held value drops the hold and the
|
||||||
> contact is COLD again, back to the floored 2D billboard. The rule is
|
> contact is COLD again, back to the floored 2D billboard. The rule is
|
||||||
> ONE-SIDED on purpose — it targets BURIAL. A cell reading BELOW a real sample
|
> ONE-SIDED on purpose — it targets BURIAL. A cell reading BELOW a real sample
|
||||||
> is the floor chain's expected under-read (lowest of up to four probes over ~111 m,
|
> is the floor chain's expected under-read (a few point readings over ~111 m,
|
||||||
> neighbours lean lowest, `displayFloorHeightM` only ever raises), not evidence
|
> neighbours lean lowest, `displayFloorHeightM` only ever raises), not evidence
|
||||||
> of anything, and a two-sided cut was disproved on the track rig by a planted
|
> of anything, and a two-sided cut was disproved on the track rig by a planted
|
||||||
> cell 66.7 m below a real sample at the same spot. Accepted residual, stated
|
> cell 66.7 m below a real sample at the same spot. Accepted residual, stated
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import { bindRenderer } from '../render/rendererOf.js';
|
|||||||
import { resolveEllipsoidalGround } from './terrainHeights.js';
|
import { resolveEllipsoidalGround } from './terrainHeights.js';
|
||||||
import {
|
import {
|
||||||
cachedGroundFloor, cachedMeshFloor, setMeshFloorPreferred,
|
cachedGroundFloor, cachedMeshFloor, setMeshFloorPreferred,
|
||||||
_clearMeshFloorCellsForTest,
|
_clearMeshFloorCellsForTest, reportValidatedMeshFloorCell,
|
||||||
} from './groundFloor.js';
|
} from './groundFloor.js';
|
||||||
|
|
||||||
/** Distinct site per test — terrainHeights' cache is module-global and warm
|
/** Distinct site per test — terrainHeights' cache is module-global and warm
|
||||||
@@ -199,27 +199,39 @@ test('sampler: the probe goes where the point is, not to the cell centre', async
|
|||||||
assert.ok(Math.abs(asked[0] - point.lon) < 1e-9, `probed at ${asked[0]}, not ${point.lon}`);
|
assert.ok(Math.abs(asked[0] - point.lon) < 1e-9, `probed at ${asked[0]}, not ${point.lon}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sampler: a rooftop reading gives way to a lower one from another point in the cell', async () => {
|
test('sampler: a viaduct and the street beside it in one cell keep their own heights', async () => {
|
||||||
reset();
|
reset();
|
||||||
const cell = nextSite();
|
const cell = nextSite();
|
||||||
await seedDem(cell, 120.0);
|
await seedDem(cell, 120.0);
|
||||||
// A roof 22 m up at the first point, the street at the others.
|
// A viaduct deck 9 m up along one line of the cell, the street elsewhere.
|
||||||
const roofLon = cell.lon + 0.0004;
|
const deckLat = cell.lat + 0.0003;
|
||||||
let calls = 0;
|
let calls = 0;
|
||||||
const scene = fakeScene((carto) => {
|
const scene = fakeScene((carto) => {
|
||||||
calls += 1;
|
calls += 1;
|
||||||
return Math.abs(Cesium.Math.toDegrees(carto.longitude) - roofLon) < 1e-7 ? 143.0 : 121.0;
|
return Math.abs(Cesium.Math.toDegrees(carto.latitude) - deckLat) < 1e-7 ? 129.0 : 121.0;
|
||||||
});
|
});
|
||||||
const opts = { viewerLat: cell.lat, viewerLon: cell.lon };
|
const opts = { viewerLat: cell.lat, viewerLon: cell.lon };
|
||||||
sampleMeshFloorCells(scene, [{ lat: cell.lat, lon: roofLon }], opts);
|
const onDeck = { lat: deckLat, lon: cell.lon };
|
||||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), 143.0, 'the roof passes the +80 m window');
|
const street = { lat: cell.lat - 0.0003, lon: cell.lon };
|
||||||
sampleMeshFloorCells(scene, [{ lat: cell.lat, lon: roofLon + 0.00001 }], opts);
|
sampleMeshFloorCells(scene, [onDeck], opts);
|
||||||
assert.equal(calls, 1, 'a point next to one already probed is not probed again');
|
sampleMeshFloorCells(scene, [street], opts);
|
||||||
sampleMeshFloorCells(scene, [{ lat: cell.lat, lon: cell.lon - 0.0003 }], opts);
|
assert.equal(calls, 2);
|
||||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), 121.0, 'the street reading replaces it');
|
assert.equal(cachedMeshFloor(onDeck.lat, onDeck.lon + 0.0001), 129.0, 'the train stays on the deck');
|
||||||
assert.equal(cachedGroundFloor(cell.lat, cell.lon), 121.0);
|
assert.equal(cachedMeshFloor(street.lat, street.lon - 0.0001), 121.0, 'the bus stays on the street');
|
||||||
sampleMeshFloorCells(scene, [{ lat: cell.lat + 0.0003, lon: cell.lon + 0.0001 }], opts);
|
assert.equal(cachedGroundFloor(street.lat, street.lon), 121.0);
|
||||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), 121.0, 'a higher reading never raises it');
|
sampleMeshFloorCells(scene, [{ lat: deckLat, lon: cell.lon + 0.00001 }], opts);
|
||||||
|
assert.equal(calls, 2, 'a point next to one already probed is not probed again');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sampler: a second reading at the same spot keeps the lower one', async () => {
|
||||||
|
reset();
|
||||||
|
const cell = nextSite();
|
||||||
|
await seedDem(cell, 120.0);
|
||||||
|
assert.equal(reportValidatedMeshFloorCell(cell.lat, cell.lon, 131.0), true);
|
||||||
|
assert.equal(reportValidatedMeshFloorCell(cell.lat + 0.00002, cell.lon, 122.0), true);
|
||||||
|
assert.equal(cachedMeshFloor(cell.lat, cell.lon), 122.0);
|
||||||
|
assert.equal(reportValidatedMeshFloorCell(cell.lat, cell.lon + 0.00002, 140.0), true);
|
||||||
|
assert.equal(cachedMeshFloor(cell.lat, cell.lon), 122.0, 'a higher one never raises it');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sampler: a latched cell is read a few times at most', async () => {
|
test('sampler: a latched cell is read a few times at most', async () => {
|
||||||
@@ -229,11 +241,14 @@ test('sampler: a latched cell is read a few times at most', async () => {
|
|||||||
let calls = 0;
|
let calls = 0;
|
||||||
const scene = fakeScene(() => {
|
const scene = fakeScene(() => {
|
||||||
calls += 1;
|
calls += 1;
|
||||||
return 125.0 - calls;
|
return 121.0;
|
||||||
});
|
});
|
||||||
const opts = { viewerLat: cell.lat, viewerLon: cell.lon };
|
const opts = { viewerLat: cell.lat, viewerLon: cell.lon };
|
||||||
for (let i = 0; i < 10; i++)
|
for (let i = 0; i < 20; i++)
|
||||||
sampleMeshFloorCells(scene, [{ lat: cell.lat - 0.0004 + i * 0.0001, lon: cell.lon }], opts);
|
sampleMeshFloorCells(
|
||||||
assert.equal(calls, 4);
|
scene,
|
||||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), 121.0);
|
[{ lat: cell.lat - 0.0004 + (i % 5) * 0.0002, lon: cell.lon - 0.00045 + Math.floor(i / 5) * 0.0003 }],
|
||||||
|
opts,
|
||||||
|
);
|
||||||
|
assert.equal(calls, 8);
|
||||||
});
|
});
|
||||||
+44
-16
@@ -418,14 +418,21 @@ export function createGroundFloor({ terrain, signal }) {
|
|||||||
// is the photogrammetric MESH, which sits above it (measured ~17 m at the
|
// is the photogrammetric MESH, which sits above it (measured ~17 m at the
|
||||||
// Austin airport apron). DEM-flooring therefore still buried sprites/trails
|
// Austin airport apron). DEM-flooring therefore still buried sprites/trails
|
||||||
// inside the mesh. These cells hold the RENDERED surface height, sampled
|
// inside the mesh. These cells hold the RENDERED surface height, sampled
|
||||||
// a few probes per coarse cell near the viewer, lowest passing reading kept
|
// at the callers' points, a few per coarse cell near the viewer, each kept
|
||||||
// (a probe can land on a roof) (scene.sampleHeight — the same
|
// where it was taken and read back from the nearest (scene.sampleHeight — the same
|
||||||
// source groundSnap uses, which is why 3D models always looked right) and
|
// source groundSnap uses, which is why 3D models always looked right) and
|
||||||
// reported here by meshFloorSampler.js. Design principle (owner): NEVER
|
// reported here by meshFloorSampler.js. Design principle (owner): NEVER
|
||||||
// below the visible surface; slightly above is always fine. The DEM stays
|
// below the visible surface; slightly above is always fine. The DEM stays
|
||||||
// the instant global prior/fallback and the sanity gate for samples.
|
// the instant global prior/fallback and the sanity gate for samples.
|
||||||
/** @type {Map<string, number>} coarse cell key -> rendered-surface height (m, ellipsoidal). */
|
/** @type {Map<string, Array<{lat: number, lon: number, h: number}>>}
|
||||||
|
* coarse cell key -> rendered-surface readings (m, ellipsoidal), each kept
|
||||||
|
* at the point it was probed. A read answers from the reading nearest the
|
||||||
|
* asked point, so a viaduct and the street beside it in one cell keep their
|
||||||
|
* own heights. */
|
||||||
const _meshCells = new Map();
|
const _meshCells = new Map();
|
||||||
|
/** @constant {number} Readings closer than this (degrees, about 5 m) are
|
||||||
|
* one spot: the lower one is kept there. */
|
||||||
|
const MESH_READING_SAME_SPOT_DEG = 0.00005;
|
||||||
/** @type {boolean} Whether mesh cells apply — true only in the google-3d
|
/** @type {boolean} Whether mesh cells apply — true only in the google-3d
|
||||||
* regime (photoreal stack). On globe stacks the rendered surface IS the
|
* regime (photoreal stack). On globe stacks the rendered surface IS the
|
||||||
* terrain provider (Re:Earth on keyless), so the DEM is already correct
|
* terrain provider (Re:Earth on keyless), so the DEM is already correct
|
||||||
@@ -445,8 +452,8 @@ export function createGroundFloor({ terrain, signal }) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Records a sampled rendered-surface height for the cell containing the
|
* Records a sampled rendered-surface height for the cell containing the
|
||||||
* coordinate, unchecked; the first record wins. The sampler goes through
|
* coordinate, unchecked, when the cell has no reading yet. The sampler goes
|
||||||
* `reportValidatedMeshFloorCell`, which keeps the lowest passing reading.
|
* through `reportValidatedMeshFloorCell`, which keeps a reading per point.
|
||||||
* @param {number} lat @param {number} lon @param {number} heightM
|
* @param {number} lat @param {number} lon @param {number} heightM
|
||||||
*/
|
*/
|
||||||
function reportMeshFloorCell(lat, lon, heightM) {
|
function reportMeshFloorCell(lat, lon, heightM) {
|
||||||
@@ -458,7 +465,7 @@ export function createGroundFloor({ terrain, signal }) {
|
|||||||
return;
|
return;
|
||||||
const c = coarseFloorCoord(lat, lon);
|
const c = coarseFloorCoord(lat, lon);
|
||||||
const key = `${c.lat},${c.lon}`;
|
const key = `${c.lat},${c.lon}`;
|
||||||
if (!_meshCells.has(key)) _meshCells.set(key, heightM);
|
if (!_meshCells.has(key)) _meshCells.set(key, [{ lat, lon, h: heightM }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return whether a rendered-mesh sample is plausible against a real DEM prior. */
|
/** Return whether a rendered-mesh sample is plausible against a real DEM prior. */
|
||||||
@@ -475,8 +482,8 @@ export function createGroundFloor({ terrain, signal }) {
|
|||||||
* Validate and record a rendered-mesh floor through the single shared gate.
|
* Validate and record a rendered-mesh floor through the single shared gate.
|
||||||
* Callers must not bypass this with raw `reportMeshFloorCell`: a coarse-LOD
|
* Callers must not bypass this with raw `reportMeshFloorCell`: a coarse-LOD
|
||||||
* or aircraft hit would otherwise poison every floor consumer in the cell.
|
* or aircraft hit would otherwise poison every floor consumer in the cell.
|
||||||
* The lowest passing reading is kept, so a rooftop hit within the window
|
* The reading is kept at the point it was taken; a second reading at the
|
||||||
* gives way to a later probe that reached the street.
|
* same spot (within about 5 m) keeps the lower of the two.
|
||||||
* @returns {boolean} Whether the sample passed and was reported.
|
* @returns {boolean} Whether the sample passed and was reported.
|
||||||
*/
|
*/
|
||||||
function reportValidatedMeshFloorCell(lat, lon, heightM) {
|
function reportValidatedMeshFloorCell(lat, lon, heightM) {
|
||||||
@@ -484,17 +491,26 @@ export function createGroundFloor({ terrain, signal }) {
|
|||||||
const cell = coarseFloorCoord(lat, lon);
|
const cell = coarseFloorCoord(lat, lon);
|
||||||
const prior = cachedRealEllipsoidalGround(cell.lat, cell.lon);
|
const prior = cachedRealEllipsoidalGround(cell.lat, cell.lon);
|
||||||
if (!meshFloorSampleWithinPrior(heightM, prior)) return false;
|
if (!meshFloorSampleWithinPrior(heightM, prior)) return false;
|
||||||
// The lowest passing reading wins: a probe that hit a roof is replaced
|
|
||||||
// by a later one that reached the street.
|
|
||||||
const key = `${cell.lat},${cell.lon}`;
|
const key = `${cell.lat},${cell.lon}`;
|
||||||
const held = _meshCells.get(key);
|
const readings = _meshCells.get(key);
|
||||||
if (held == null || heightM < held) _meshCells.set(key, heightM);
|
if (!readings) {
|
||||||
|
_meshCells.set(key, [{ lat, lon, h: heightM }]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const same = readings.find(
|
||||||
|
(r) =>
|
||||||
|
Math.abs(r.lat - lat) < MESH_READING_SAME_SPOT_DEG &&
|
||||||
|
Math.abs(r.lon - lon) < MESH_READING_SAME_SPOT_DEG,
|
||||||
|
);
|
||||||
|
if (!same) readings.push({ lat, lon, h: heightM });
|
||||||
|
else if (heightM < same.h) same.h = heightM;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronous mesh-cell read — null when the cell is unsampled OR the
|
* Synchronous mesh-cell read — the cell's reading nearest the point, or
|
||||||
* google-3d regime is inactive (globe stacks must floor on the DEM).
|
* null when the cell is unsampled OR the google-3d regime is inactive (globe
|
||||||
|
* stacks must floor on the DEM).
|
||||||
* @param {number} lat @param {number} lon
|
* @param {number} lat @param {number} lon
|
||||||
* @returns {number|null}
|
* @returns {number|null}
|
||||||
*/
|
*/
|
||||||
@@ -502,8 +518,20 @@ export function createGroundFloor({ terrain, signal }) {
|
|||||||
if (!_meshPreferred) return null;
|
if (!_meshPreferred) return null;
|
||||||
if (!Number.isFinite(lat) || !Number.isFinite(lon)) return null;
|
if (!Number.isFinite(lat) || !Number.isFinite(lon)) return null;
|
||||||
const c = coarseFloorCoord(lat, lon);
|
const c = coarseFloorCoord(lat, lon);
|
||||||
const h = _meshCells.get(`${c.lat},${c.lon}`);
|
const readings = _meshCells.get(`${c.lat},${c.lon}`);
|
||||||
return h != null ? h : null;
|
if (!readings) return null;
|
||||||
|
if (readings.length === 1) return readings[0].h;
|
||||||
|
const k = Math.cos((lat * Math.PI) / 180) ** 2;
|
||||||
|
let best = readings[0],
|
||||||
|
bestD = Infinity;
|
||||||
|
for (const r of readings) {
|
||||||
|
const d = (r.lat - lat) ** 2 + k * (r.lon - lon) ** 2;
|
||||||
|
if (d < bestD) {
|
||||||
|
bestD = d;
|
||||||
|
best = r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test hook: clears mesh cells (never called at runtime — cells are valid all session). */
|
/** Test hook: clears mesh cells (never called at runtime — cells are valid all session). */
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ export function createMeshFloorSampler({
|
|||||||
// airport apron) — so DEM-floored sprites/trails still buried themselves in
|
// airport apron) — so DEM-floored sprites/trails still buried themselves in
|
||||||
// the mesh while 3D models (which groundSnap against the mesh) looked right.
|
// the mesh while 3D models (which groundSnap against the mesh) looked right.
|
||||||
// This module samples the mesh height at the callers' points, a few probes
|
// This module samples the mesh height at the callers' points, a few probes
|
||||||
// per coarse cell, and reports them to groundFloor.js, which keeps the
|
// per coarse cell, and reports them to groundFloor.js, which keeps each
|
||||||
// lowest that passes its gate; cachedGroundFloor() then answers mesh-first.
|
// reading that passes its gate at its own point; cachedGroundFloor() then
|
||||||
|
// answers mesh-first, from the reading nearest the asked point.
|
||||||
//
|
//
|
||||||
// Rationing (the CCTV loading-jitter lesson): scene.sampleHeight forces
|
// Rationing (the CCTV loading-jitter lesson): scene.sampleHeight forces
|
||||||
// tile-load prioritization at the probe point, so sampling is (a) gated to
|
// tile-load prioritization at the probe point, so sampling is (a) gated to
|
||||||
@@ -53,10 +54,10 @@ export function createMeshFloorSampler({
|
|||||||
* streamed LOD under a high camera is coarse everywhere, so every probe
|
* streamed LOD under a high camera is coarse everywhere, so every probe
|
||||||
* would latch junk. */
|
* would latch junk. */
|
||||||
const MAX_CAMERA_HEIGHT_M = 25_000;
|
const MAX_CAMERA_HEIGHT_M = 25_000;
|
||||||
/** @constant {number} Readings kept per cell: a cell is probed at most
|
/** @constant {number} Readings per cell: a cell is probed at most this
|
||||||
* this many times, each at a different point, and the lowest reading
|
* many times, each at a point apart from the others, and groundFloor keeps
|
||||||
* that passes the DEM gate is the cell's floor. */
|
* each reading at its point (a read answers from the nearest one). */
|
||||||
const MAX_PROBES_PER_CELL = 4;
|
const MAX_PROBES_PER_CELL = 8;
|
||||||
/** @constant {number} How far apart (degrees, about 17 m) a new probe must
|
/** @constant {number} How far apart (degrees, about 17 m) a new probe must
|
||||||
* be from the cell's earlier ones to be worth taking. */
|
* be from the cell's earlier ones to be worth taking. */
|
||||||
const PROBE_APART_DEG = 0.00015;
|
const PROBE_APART_DEG = 0.00015;
|
||||||
@@ -149,8 +150,8 @@ export function createMeshFloorSampler({
|
|||||||
const key = `${cell.lat},${cell.lon}`;
|
const key = `${cell.lat},${cell.lon}`;
|
||||||
if (attempted.has(key)) continue;
|
if (attempted.has(key)) continue;
|
||||||
// A latched cell is probed again only at a point well apart from the
|
// A latched cell is probed again only at a point well apart from the
|
||||||
// ones already probed, a few times at most: a later, lower reading
|
// ones already probed, a few times at most, so the cell's readings
|
||||||
// replaces a rooftop the first probe may have hit.
|
// follow where its vehicles actually are.
|
||||||
const probes = _probedPoints.get(key);
|
const probes = _probedPoints.get(key);
|
||||||
if (
|
if (
|
||||||
cachedMeshFloor(cell.lat, cell.lon) != null &&
|
cachedMeshFloor(cell.lat, cell.lon) != null &&
|
||||||
@@ -211,7 +212,7 @@ export function createMeshFloorSampler({
|
|||||||
// feasible and deliberately deferred — see the P2 in
|
// feasible and deliberately deferred — see the P2 in
|
||||||
// the project roadmap, which bundles it with the fly_route probe so
|
// the project roadmap, which bundles it with the fly_route probe so
|
||||||
// one post-launch pass settles rendered-mesh sampling everywhere.
|
// one post-launch pass settles rendered-mesh sampling everywhere.
|
||||||
reportValidatedMeshFloorCell(cell.lat, cell.lon, height);
|
reportValidatedMeshFloorCell(p.lat, p.lon, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user