mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(voice): add reusable geometry actions
- turn named places and mapped landmarks into reusable bounded areas - count loaded records inside resolved, drawn and annotated geometry - find recent imagery for an area, the view or the pointer snapshot - keep osm place search behind an operator-configured overpass endpoint - preserve cancellation, ownership and follow-up memory across every action - cover geometry, provider lifecycle, cache isolation and voice routing
This commit is contained in:
1 parent
01979bba1e
commit
b234d7b427
84 files changed
+14262
-1681
No files matched your search
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Observe an explicit request to turn a layer off while a feature action is
|
||||
* pending. The visibility-request stream is synchronous, so an OFF owns the
|
||||
* action even before the layer's queued lifecycle work settles.
|
||||
*
|
||||
* @module voice/layerActionOwnership
|
||||
*/
|
||||
|
||||
const EXPLICIT_OFF_ORIGINS = new Set(['user', 'voice', 'tool']);
|
||||
|
||||
export function watchExplicitLayerOff(dataManager, layerId, { onOff } = {}) {
|
||||
let requested = false;
|
||||
const observe = (change) => {
|
||||
if (
|
||||
change?.layerId === layerId &&
|
||||
change.enabled === false &&
|
||||
EXPLICIT_OFF_ORIGINS.has(change.origin)
|
||||
) {
|
||||
requested = true;
|
||||
onOff?.(change);
|
||||
}
|
||||
};
|
||||
const stopRequest =
|
||||
dataManager?.subscribeVisibilityRequests?.(observe) || (() => {});
|
||||
// Lightweight managers sometimes expose only the settled change stream.
|
||||
const stopSettled = dataManager?.subscribe?.(observe) || (() => {});
|
||||
return {
|
||||
requested: () => requested,
|
||||
stop() {
|
||||
stopRequest();
|
||||
stopSettled();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function displacedLayerResult(dataManager, layerId, action, error) {
|
||||
const state = dataManager?.getLayerLifecycleState?.(layerId);
|
||||
return {
|
||||
ok: false,
|
||||
action,
|
||||
code: 'DISPLACED',
|
||||
cancelled: true,
|
||||
layerId,
|
||||
requestedEnabled: false,
|
||||
error,
|
||||
enabled:
|
||||
typeof state?.enabled === 'boolean'
|
||||
? state.enabled
|
||||
: Boolean(dataManager?.isEnabled?.(layerId)),
|
||||
...(state?.lifecycleState ? { lifecycleState: state.lifecycleState } : {}),
|
||||
...(typeof state?.uncertain === 'boolean'
|
||||
? { lifecycleUncertain: state.uncertain }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user