Street Level: a posted view without a photo point grounds its look-at too

show_in_gods_eye_view measured a view's altitude from the terrain before
taking the point the camera looks at; a view posted straight into the
embedded app used the ellipsoid altitude, so a camera over high ground
opened photos kilometres ahead. groundedLookAt moves to the view module,
and the embedded app uses it with the app's terrain heights for a posted
street_level that names no point.
This commit is contained in:
German Khokhlov committed 2026-11-11 13:46:10 +04:00
1 parent a8970c1f18
commit f612fc2180
5 files changed
+107 -26

No files matched your search

+2 -26
View File
@@ -3,7 +3,7 @@
import {
VIEW_PROPERTIES,
createView,
lookAtPoint,
groundedLookAt,
viewUrl,
} from '../../view/index.js';
import { defineTool, ToolError } from '../catalog.js';
@@ -41,30 +41,6 @@ async function followedAircraftPosition(follow, tools) {
}
}
/**
* Where a tilted camera looks, measured from the ground under it: a view's
* altitude is above the ellipsoid, and a city a mile up would otherwise put
* the point kilometres too far ahead. Null when the terrain cannot say.
*/
async function groundedLookAt(camera, services, signal) {
if (typeof services?.terrain?.getHeights !== 'function') return null;
if (!Number.isFinite(camera.altitude_m) || !(camera.pitch_deg > -89))
return null;
let heights;
try {
heights = await services.terrain.getHeights(
[{ lat: camera.lat, lon: camera.lon }],
{ signal },
);
} catch (error) {
if (signal?.aborted) throw error;
return null;
}
const ground = Number(heights?.[0]?.ellipsoid);
if (!Number.isFinite(ground)) return null;
return lookAtPoint({ ...camera, altitude_m: camera.altitude_m - ground });
}
/**
* The view described by tool arguments. An area frames the camera straight
* down over it; camera fields given alongside it override the framing. A
@@ -131,7 +107,7 @@ export async function resolveViewArguments(args, { services, signal, tools }) {
streetLevel.lat === undefined &&
streetLevel.lon === undefined
) {
const point = await groundedLookAt(camera, services, signal);
const point = await groundedLookAt(camera, services?.terrain, signal);
if (point) streetLevel = { ...streetLevel, ...point };
}
let view;