mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
fix(street-level): camera height over Google 3D, cast only when it helps, gate token
From the code review of #768: - view.js measured the camera's height above ground with globe.getHeight, but Google 3D hides the globe, so coverage picked its zoom from the ellipsoidal height. Over a high city (Denver, ~1,600 m) a camera 500 m up read 2,100 m: coverage stayed at z12/z13, whose tiles are too big to cast, and lines stayed draped on the roofs. With the globe hidden, the bare-earth height from the ground caster now answers; coverage re-picks its zoom when the surface mode changes. Verified in Denver: terrain mode, z14, cast lines. The core's surface check uses the same helper (and no longer subtracts the 2 m lift from the camera height). - castTile rebuilt a tile even when no line could be cast (terrain proxy down, tile too big); it now leaves such tiles as they are. - The feature gate read Street Level's share token as a literal `0`; it now takes it from LAYER_STATE_REGISTRY, since a rebase can reassign it. New view.test.mjs covers the shown-globe, hidden-globe and no-sample cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e01ffb3cad
commit
abbf69a512
6 files changed
+96
-22
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { cameraHeightAboveGround } from './view.js';
|
||||
|
||||
const RAD = Math.PI / 180;
|
||||
/** A viewer 300 m above a street 1,600 m up (Denver-like). */
|
||||
function viewer({ globeShown, globeHeight }) {
|
||||
return {
|
||||
camera: {
|
||||
positionCartographic: {
|
||||
longitude: -104.99 * RAD,
|
||||
latitude: 39.74 * RAD,
|
||||
height: 1900,
|
||||
},
|
||||
},
|
||||
scene: { globe: { show: globeShown, getHeight: () => globeHeight } },
|
||||
};
|
||||
}
|
||||
|
||||
test('a shown globe answers the ground under the camera', () => {
|
||||
assert.equal(
|
||||
cameraHeightAboveGround(viewer({ globeShown: true, globeHeight: 1600 })),
|
||||
300,
|
||||
);
|
||||
});
|
||||
|
||||
test('a hidden globe (Google 3D) falls back to the bare-earth height', () => {
|
||||
const calls = [];
|
||||
const groundAt = (lon, lat) => {
|
||||
calls.push([+lon.toFixed(2), +lat.toFixed(2)]);
|
||||
return 1600;
|
||||
};
|
||||
// A hidden globe's getHeight is ignored even when it returns a number.
|
||||
const hidden = viewer({ globeShown: false, globeHeight: 0 });
|
||||
assert.equal(cameraHeightAboveGround(hidden, { groundAt }), 300);
|
||||
assert.deepEqual(calls, [[-104.99, 39.74]]);
|
||||
});
|
||||
|
||||
test('with no ground sample the ellipsoidal height is used', () => {
|
||||
const hidden = viewer({ globeShown: false, globeHeight: 0 });
|
||||
assert.equal(cameraHeightAboveGround(hidden), 1900);
|
||||
assert.equal(cameraHeightAboveGround(hidden, { groundAt: () => null }), 1900);
|
||||
assert.equal(cameraHeightAboveGround({}), null);
|
||||
});
|
||||
Reference in new issue
Block a user