mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge upstream main (voice geometry: resolve_area, find_imagery, osm_query) into pr/street-level-show-action
This commit is contained in:
commit
34f694c6f2
138 files changed
+17718
-1136
No files matched your search
+70
-2
@@ -22,7 +22,7 @@
|
||||
* the model; the card shows them through the shown* helpers.
|
||||
*/
|
||||
|
||||
import { analystHeadline } from './resultDisplay.js';
|
||||
import { voiceLayer } from './layerManifest.js';
|
||||
import {
|
||||
formatDate,
|
||||
formatNumber,
|
||||
@@ -44,10 +44,40 @@ import { formatQuantity } from '../ui/unitLabels.js';
|
||||
const LAYER_NOUNS = Object.freeze({
|
||||
flights: 'aircraft',
|
||||
military: 'military aircraft',
|
||||
'local-adsb': 'aircraft',
|
||||
'ais-live-vessels': 'ships',
|
||||
satellites: 'satellites',
|
||||
'rocket-launches': 'launches',
|
||||
earthquakes: 'earthquakes',
|
||||
'local-firms': 'fires',
|
||||
'osm-places': 'places',
|
||||
});
|
||||
|
||||
const AIRCRAFT_LAYERS = new Set(['flights', 'military', 'local-adsb']);
|
||||
const MAX_ANALYST_HEADLINE = 64;
|
||||
|
||||
export function analystNounFor(layerKeys) {
|
||||
const keys = [...new Set((layerKeys || []).filter(Boolean))];
|
||||
if (keys.length > 1 && keys.every((key) => AIRCRAFT_LAYERS.has(key)))
|
||||
return 'aircraft';
|
||||
if (keys.length !== 1) return 'results';
|
||||
const key = keys[0];
|
||||
return LAYER_NOUNS[key] || voiceLayer(key)?.aliases?.[0] || 'results';
|
||||
}
|
||||
|
||||
/** The count/scope headline shared by the analyst card and spoken answer. */
|
||||
export function analystHeadline(result) {
|
||||
const keys = (result?.coverage?.layersQueried || []).map(
|
||||
(layer) => layer.layerKey,
|
||||
);
|
||||
const count = Number(result?.count) || 0;
|
||||
const floor = result?.complete === false ? 'At least ' : '';
|
||||
return spokenLabel(
|
||||
`${floor}${count.toLocaleString('en-US')} ${analystNounFor(keys)} ${result?.scopeLabel || ''}`,
|
||||
MAX_ANALYST_HEADLINE,
|
||||
);
|
||||
}
|
||||
|
||||
/** Feed states that change what a spoken answer means. */
|
||||
const MATERIAL_FEED_TAGS = Object.freeze({
|
||||
stale: 'stale',
|
||||
@@ -825,7 +855,7 @@ function annotateMap(result) {
|
||||
|
||||
function analystQuery(result) {
|
||||
if (!result?.ok || result.cancelled) return null;
|
||||
const headline = spokenLabel(analystHeadline(result), 96);
|
||||
const headline = analystHeadline(result);
|
||||
const state =
|
||||
result.feedState ||
|
||||
result.feedProvenance?.overall ||
|
||||
@@ -1018,6 +1048,24 @@ export function planStepLabel(name, args = {}) {
|
||||
return t('Check view state');
|
||||
case 'frame_overhead':
|
||||
return frameStepLabel(spokenLabel(args.target || 'flights', 24));
|
||||
case 'resolve_area': {
|
||||
const place = args.query
|
||||
? shownPlace(args.query, args.around ? 32 : 36)
|
||||
: '';
|
||||
if (args.around)
|
||||
return place
|
||||
? t('Area around {place}', { place })
|
||||
: t('Area around landmark');
|
||||
if (args.draw)
|
||||
return place ? t('Outline {place}', { place }) : t('Outline area');
|
||||
return place ? t('Find {place}', { place }) : t('Find area');
|
||||
}
|
||||
case 'find_imagery':
|
||||
return t('Find recent imagery');
|
||||
case 'osm_query':
|
||||
return args.what
|
||||
? t('Find {what}', { what: spokenLabel(args.what, 32) })
|
||||
: t('Find places');
|
||||
default:
|
||||
// A tool with no label: its name in English, "Action" elsewhere.
|
||||
return getLocale() === 'en'
|
||||
@@ -1046,6 +1094,12 @@ export function narrationLabel(name, args = {}) {
|
||||
);
|
||||
case 'show_street_level':
|
||||
return shownPlace(args.query || '', 32);
|
||||
case 'resolve_area':
|
||||
return displayName(args.query || '', 32);
|
||||
case 'find_imagery':
|
||||
return 'the imagery';
|
||||
case 'osm_query':
|
||||
return spokenLabel(args.what || '', 32);
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@@ -1062,6 +1116,10 @@ const STEP_LABELS = Object.freeze({
|
||||
nearest: msg('Picking nearest'),
|
||||
map: msg('Switching map'),
|
||||
imagery: msg('Opening imagery'),
|
||||
draw: msg('Drawing outline'),
|
||||
catalog: msg('Searching imagery catalog'),
|
||||
drape: msg('Loading imagery'),
|
||||
osm: msg('Searching OpenStreetMap'),
|
||||
});
|
||||
|
||||
/** On-screen label for a progress step. */
|
||||
@@ -1088,6 +1146,16 @@ export function progressLine(step, label) {
|
||||
return place ? `Finding ${place} on the map.` : 'Finding those places.';
|
||||
case 'search':
|
||||
return place ? `Looking up ${place}.` : null;
|
||||
case 'draw':
|
||||
return place ? `Outlining ${place}.` : null;
|
||||
case 'catalog':
|
||||
return 'Searching the imagery catalog.';
|
||||
case 'drape':
|
||||
return 'Loading the image.';
|
||||
case 'osm':
|
||||
return place
|
||||
? `Searching OpenStreetMap for ${place}.`
|
||||
: 'Searching OpenStreetMap.';
|
||||
case 'fly':
|
||||
return place ? `Heading to ${place}.` : null;
|
||||
case 'layer':
|
||||
|
||||
Reference in new issue
Block a user