mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
a8970c1f18
commit
f612fc2180
5 files changed
+107
-26
No files matched your search
@@ -123,6 +123,30 @@ export function lookAtPoint(camera) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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. `terrain` is a heights service
|
||||
* (`getHeights`); null when it is missing or cannot say.
|
||||
*/
|
||||
export async function groundedLookAt(camera, terrain, signal) {
|
||||
if (typeof terrain?.getHeights !== 'function') return null;
|
||||
if (!Number.isFinite(camera?.altitude_m) || !(camera.pitch_deg > -89))
|
||||
return null;
|
||||
let heights;
|
||||
try {
|
||||
heights = await 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 });
|
||||
}
|
||||
|
||||
/** Annotation kinds the app draws, as in its annotate_map action. */
|
||||
export const VIEW_ANNOTATION_TYPES = Object.freeze([
|
||||
'pin',
|
||||
|
||||
Reference in new issue
Block a user