diff --git a/src/voice/areaActions.js b/src/voice/areaActions.js index 2032adcd4..d8785a84d 100644 --- a/src/voice/areaActions.js +++ b/src/voice/areaActions.js @@ -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( diff --git a/src/voice/areaActions.test.mjs b/src/voice/areaActions.test.mjs index 4894a2296..e99107e27 100644 --- a/src/voice/areaActions.test.mjs +++ b/src/voice/areaActions.test.mjs @@ -588,11 +588,33 @@ test('an area around a landmark uses its enclosing outline, else a labelled buff const buffered = await slow.areas.resolveAreaAction({ query: 'Ferry Building', around: true, - radiusM: 400, }); assert.ok(Date.now() - started < 1000); assert.equal(buffered.approximate, true); - assert.equal(buffered.display.basis, '400 m around the landmark'); + assert.equal(buffered.display.basis, '250 m around the landmark'); + + // A radius the user gave never needs the outline, so it is never looked up. + let outlineLookups = 0; + const radius = makeAreas({ + annotationResolver: { + resolveAnnotationTarget: async () => ({ + lat: 37.7955, + lon: -122.3937, + ring: null, + resolveOutline: async () => { + outlineLookups += 1; + return null; + }, + }), + }, + }); + const sizedBuffer = await radius.areas.resolveAreaAction({ + query: 'Ferry Building', + around: true, + radiusM: 400, + }); + assert.equal(sizedBuffer.display.basis, '400 m around the landmark'); + assert.equal(outlineLookups, 0, 'no outline request for a sized buffer'); const missing = makeAreas({ annotationResolver: { resolveAnnotationTarget: async () => null },