mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(street-level): "show me X on Street View" action, street_level view field and sl= links
show_street_level (voice and typed) flies to a place and opens its nearest street-level photo from Google Street View, Mapillary, KartaView or Panoramax; Street View switches to Google 3D first. The view model gains a street_level field, share links carry sl=<source>,<lat>,<lon>, and show_in_gods_eye_view can open a photo. A plain sl=google link only arms the point and waits for OPEN, so it never bills a key without a click. Embed pages show an open photo in an overlay that Esc closes. On-screen strings are translated into es, ru, zh-CN and zh-Hant. Covered by unit tests and three new steps in the Street Level browser suite.
This commit is contained in:
1 parent
f3adccd01a
commit
98de41c94a
64 files changed
+4147
-66
No files matched your search
@@ -47,10 +47,26 @@ export async function resolveViewArguments(args, { services, signal, tools }) {
|
||||
? { ...args.camera }
|
||||
: { ...base.camera, ...args.camera };
|
||||
let label = null;
|
||||
// Street-level photos open at the area's centre unless a point is given;
|
||||
// a new area moves a passed-through view's photos with it.
|
||||
let streetLevel =
|
||||
args.street_level && typeof args.street_level === 'object'
|
||||
? { ...args.street_level }
|
||||
: base.street_level && typeof base.street_level === 'object'
|
||||
? args.area
|
||||
? { provider: base.street_level.provider }
|
||||
: { ...base.street_level }
|
||||
: null;
|
||||
if (args.area) {
|
||||
const area = await resolveArea(args.area, { services, signal });
|
||||
label = area.label;
|
||||
const framed = cameraForArea(area);
|
||||
if (
|
||||
streetLevel &&
|
||||
streetLevel.lat === undefined &&
|
||||
streetLevel.lon === undefined
|
||||
)
|
||||
streetLevel = { ...streetLevel, lat: framed.lat, lon: framed.lon };
|
||||
// A tilted view of an area looks at its center from behind, unless the
|
||||
// caller placed the camera itself.
|
||||
camera =
|
||||
@@ -84,6 +100,7 @@ export async function resolveViewArguments(args, { services, signal, tools }) {
|
||||
map: args.map ?? base.map ?? null,
|
||||
follow,
|
||||
annotations: args.annotations ?? base.annotations ?? [],
|
||||
street_level: streetLevel,
|
||||
});
|
||||
} catch (error) {
|
||||
// A view passed through can hold anything; report it as bad arguments.
|
||||
@@ -113,7 +130,9 @@ export const showInGodsEyeView = defineTool({
|
||||
'it. Pass the view another answer returned, or describe one: an area ' +
|
||||
'framed from above or a camera position, with chosen data layers, visual ' +
|
||||
'style and map, optionally following an aircraft (or riding in its ' +
|
||||
'cockpit view) or a satellite, and with marks drawn on the map.',
|
||||
'cockpit view) or a satellite, with marks drawn on the map, or opening ' +
|
||||
'street-level photos (Google Street View, Mapillary, KartaView or ' +
|
||||
'Panoramax) at a place.',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: VIEW_ARGUMENTS,
|
||||
|
||||
@@ -113,3 +113,104 @@ test('links carry a camera, style, map and an entity to follow', async () => {
|
||||
/Give a view, an area, or a camera with lat and lon/,
|
||||
);
|
||||
});
|
||||
|
||||
test('links can open street-level photos at the area, on the map the source needs', async () => {
|
||||
const { viewFromParams } = await import('../../view/index.js');
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { app: { baseUrl: 'http://localhost:4173/' } },
|
||||
});
|
||||
const result = await catalog.call('show_in_gods_eye_view', {
|
||||
area: { lat: 38.5799, lon: -121.4937, radius_km: 1 },
|
||||
street_level: { provider: 'google' },
|
||||
});
|
||||
const { view } = result.data;
|
||||
assert.equal(view.map, 'photoreal');
|
||||
assert.deepEqual(view.layers, ['street-level']);
|
||||
assert.deepEqual(view.street_level, {
|
||||
provider: 'google',
|
||||
lat: 38.5799,
|
||||
lon: -121.4937,
|
||||
});
|
||||
const params = new URLSearchParams(new URL(result.data.url).hash.slice(1));
|
||||
assert.equal(params.get('sl'), 'google,38.57990,-121.49370');
|
||||
assert.equal(params.get('map'), 'photoreal');
|
||||
assert.deepEqual(viewFromParams(params), view);
|
||||
|
||||
const point = await catalog.call('show_in_gods_eye_view', {
|
||||
view,
|
||||
street_level: { provider: 'mapillary', lat: 38.58, lon: -121.49 },
|
||||
});
|
||||
assert.deepEqual(point.data.view.street_level, {
|
||||
provider: 'mapillary',
|
||||
lat: 38.58,
|
||||
lon: -121.49,
|
||||
});
|
||||
await assert.rejects(
|
||||
catalog.call('show_in_gods_eye_view', {
|
||||
area: { lat: 0, lon: 0, radius_km: 1 },
|
||||
map: 'osm',
|
||||
street_level: { provider: 'google' },
|
||||
}),
|
||||
/photoreal/,
|
||||
);
|
||||
});
|
||||
|
||||
test('a new area moves a passed-through view’s photos, and a tilted area still opens them at its centre', async () => {
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { app: { baseUrl: 'http://localhost:4173/' } },
|
||||
});
|
||||
const first = await catalog.call('show_in_gods_eye_view', {
|
||||
area: { lat: 38.5799, lon: -121.4937, radius_km: 1 },
|
||||
street_level: { provider: 'google' },
|
||||
});
|
||||
const second = await catalog.call('show_in_gods_eye_view', {
|
||||
view: first.data.view,
|
||||
area: { lat: 42.3314, lon: -83.0458, radius_km: 1 },
|
||||
});
|
||||
assert.deepEqual(second.data.view.street_level, {
|
||||
provider: 'google',
|
||||
lat: 42.3314,
|
||||
lon: -83.0458,
|
||||
});
|
||||
const tilted = await catalog.call('show_in_gods_eye_view', {
|
||||
area: { lat: 48.8584, lon: 2.2945, radius_km: 1 },
|
||||
camera: { pitch_deg: -30 },
|
||||
street_level: { provider: 'mapillary' },
|
||||
});
|
||||
assert.notEqual(
|
||||
tilted.data.view.camera.lat,
|
||||
48.8584,
|
||||
'the camera sits behind the target',
|
||||
);
|
||||
assert.deepEqual(tilted.data.view.street_level, {
|
||||
provider: 'mapillary',
|
||||
lat: 48.8584,
|
||||
lon: 2.2945,
|
||||
});
|
||||
await assert.rejects(
|
||||
catalog.call('show_in_gods_eye_view', {
|
||||
area: { lat: 0, lon: 0, radius_km: 1 },
|
||||
follow: { kind: 'aircraft', id: 'AE1234' },
|
||||
street_level: {},
|
||||
}),
|
||||
/cannot both follow/,
|
||||
);
|
||||
});
|
||||
|
||||
test('a view passed through alone keeps its street-level photos', async () => {
|
||||
const catalog = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { app: { baseUrl: 'http://localhost:4173/' } },
|
||||
});
|
||||
const first = await catalog.call('show_in_gods_eye_view', {
|
||||
area: { lat: 38.5799, lon: -121.4937, radius_km: 1 },
|
||||
street_level: { provider: 'mapillary' },
|
||||
});
|
||||
const again = await catalog.call('show_in_gods_eye_view', {
|
||||
view: first.data.view,
|
||||
});
|
||||
assert.deepEqual(again.data.view.street_level, first.data.view.street_level);
|
||||
assert.deepEqual(again.data.view, first.data.view);
|
||||
});
|
||||
Reference in new issue
Block a user