mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
feat: return the view that shows each answer
Tool answers with something to show now include data.view: the view with the matching layers on, the area framed from above or a single aircraft or satellite followed, and the link that opens it. Area framing moves to src/tools/views.js so links and answers frame alike.
This commit is contained in:
1 parent
96a8a9addb
commit
d6473b6049
20 files changed
+393
-34
No files matched your search
@@ -2,12 +2,8 @@
|
||||
|
||||
import { VIEW_PROPERTIES, createView, viewUrl } from '../../view/index.js';
|
||||
import { defineTool, ToolError } from '../catalog.js';
|
||||
import { AREA_SCHEMA, areaCenter, areaRadiusKm, resolveArea } from '../area.js';
|
||||
|
||||
const MIN_ALTITUDE_M = 500;
|
||||
const MAX_ALTITUDE_M = 15_000_000;
|
||||
// A top-down view sees roughly this many meters of ground per meter of altitude.
|
||||
const GROUND_PER_ALTITUDE = 0.55;
|
||||
import { AREA_SCHEMA, resolveArea } from '../area.js';
|
||||
import { cameraForArea } from '../views.js';
|
||||
|
||||
/** Tool arguments that describe a view: an area to frame, or a camera. */
|
||||
export const VIEW_ARGUMENTS = Object.freeze({
|
||||
@@ -24,20 +20,8 @@ export async function resolveViewArguments(args, { services, signal }) {
|
||||
let label = null;
|
||||
if (args.area) {
|
||||
const area = await resolveArea(args.area, { services, signal });
|
||||
const center = areaCenter(area);
|
||||
label = area.label;
|
||||
camera = {
|
||||
lat: center.lat,
|
||||
lon: center.lon,
|
||||
altitude_m: Math.min(
|
||||
MAX_ALTITUDE_M,
|
||||
Math.max(
|
||||
MIN_ALTITUDE_M,
|
||||
(areaRadiusKm(area) * 1000) / GROUND_PER_ALTITUDE,
|
||||
),
|
||||
),
|
||||
...camera,
|
||||
};
|
||||
camera = { ...cameraForArea(area), ...camera };
|
||||
}
|
||||
if (!Number.isFinite(camera.lat) || !Number.isFinite(camera.lon))
|
||||
throw new ToolError(
|
||||
|
||||
Reference in new issue
Block a user