fix(voice): skip the outline lookup for a sized area around a landmark

A radius the user gives always draws a buffer, but the enclosing outline
was still looked up first (up to 6 s and a guarded Nominatim request) and
then thrown away. It is no longer requested. The slow-outline test now
checks the default 250 m fallback it was meant to cover.
This commit is contained in:
Manjunath committed 2026-11-03 17:55:44 +05:30
1 parent 670e952c29
commit 03e9db07c1
2 files changed
+34 -7

No files matched your search

+10 -5
View File
@@ -603,6 +603,12 @@ export function createVoiceAreas({
return { ok: false, code: 'BAD_AREA', error: 'Name a landmark.' };
const budget = AbortSignal.timeout(AROUND_BUDGET_MS);
const combined = signal ? AbortSignal.any([signal, budget]) : budget;
// A radius the user gave always draws a buffer, so the enclosing outline
// (and its Nominatim request) is never looked up for it.
const explicitRadius =
args.radiusM !== undefined &&
args.radiusM !== null &&
Number.isFinite(Number(args.radiusM));
let resolved;
let outline = null;
try {
@@ -618,7 +624,10 @@ export function createVoiceAreas({
allowDistant: true,
signal: combined,
});
outline = resolved ? await awaitOutline(resolved, aroundOutlineMs) : null;
outline =
resolved && !explicitRadius
? await awaitOutline(resolved, aroundOutlineMs)
: null;
} catch {
resolved = null;
}
@@ -636,10 +645,6 @@ export function createVoiceAreas({
error: `Could not find ${target}.`,
};
}
const explicitRadius =
args.radiusM !== undefined &&
args.radiusM !== null &&
Number.isFinite(Number(args.radiusM));
const radiusM = Math.max(
50,
Math.min(