tighten the remaining voice outline review items

- One place-name key for server and tiles, so "St. Paul" and "Saint Paul"
  agree in Nominatim name checks.
- Tile street names: a lone letter is a direction only beside another name
  word ("E Street" is not "East Street"), and a trailing quadrant ("E St NW")
  may go unsaid in the ask.
- A building cut at the tile edge that is nearer the point than any whole
  one leaves the point instead of a farther neighbour standing in; an edge
  without a tile buffer counts as a cut, so a cut area never answers grounds.
- A batch building install re-judges only results that installed; a late
  timeout during caption conversion keeps the pending point drawn; a failed
  plain recaption keeps the old mark addressable.
- An interrupted Nominatim dispatch is reclaimed by the next lock owner ten
  minutes after the start its marker names; node:sqlite loads on first use
  without its experimental warning.
- PHOTON_URL accepts only https, which the page's connect-src allows.
- Shared OpenFreeMap tiles decode each layer when a consumer first selects
  it; outline selection reuses the shared ring area and simplification, and
  ground probes the shared ring centroid; the grounds word list lives once.
This commit is contained in:
Sameh Khamis committed 2026-11-02 08:50:05 -08:00
1 parent a38a065c5c
commit a61d0f4c2a
24 files changed
+422 -128

No files matched your search

+8 -2
View File
@@ -411,6 +411,8 @@ export function createAnnotationEngine({
const results = [];
const ids = [];
const installations = [];
// Result slots an installation settles; only these are re-validated after the await.
const installed = new Set();
const trackBuildingInstall = (
anno,
resolved,
@@ -423,6 +425,7 @@ export function createAnnotationEngine({
ensureTicking();
const index = results.length;
results.push(null);
installed.add(index);
const record = beginBuildingInstall(anno);
installations.push(
Promise.resolve(completion)
@@ -589,6 +592,7 @@ export function createAnnotationEngine({
}
const index = results.length;
results.push(null);
installed.add(index);
anno.pendingOutline = true;
installations.push(
Promise.resolve(completion)
@@ -642,11 +646,12 @@ export function createAnnotationEngine({
);
continue;
}
// Remove before delete: a failed cleanup stays addressable through the old slot.
removeRendered(dup);
annotations.delete(dup.id);
annotations.set(anno.id, anno);
syncAnnotationHold();
try {
removeRendered(dup);
renderer.add(anno);
} catch (swapError) {
// Same contract as the fresh path: a renderer/WebGL throw must
@@ -690,6 +695,7 @@ export function createAnnotationEngine({
if (record) {
const index = results.length;
results.push(null);
installed.add(index);
installations.push(
(async () => {
do {
@@ -788,7 +794,7 @@ export function createAnnotationEngine({
await Promise.all(installations);
for (let index = 0; index < results.length; index += 1) {
const result = results[index];
if (!result?.ok) continue;
if (!result?.ok || !installed.has(index)) continue;
const current = annotations.get(result.id);
if (
!current ||
+53
View File
@@ -1249,3 +1249,56 @@ test('recaption inherits outline credit from borrowed geometry rather than its n
assert.equal(engine.list()[0].ring, ring);
engine.clear();
});
test('a building install in the batch does not re-judge marks that never installed', async (t) => {
installAnimationFrameStubs(t);
const h = controlledBuildingRenderer();
const engine = createAnnotationEngine({
viewer: {},
renderer: h.renderer,
resolveTarget: async ({ target }) =>
target === 'Tower' ? { ...BUILDING_FP, lon: -97.7 } : { ...FIXED_POINT },
});
// The recolour replaces the first point within the same batch; without the
// building that point's result stays ok, so the building must not change it.
const batch = engine.annotate([
{ type: 'point', target: 'Capitol', label: 'Capitol' },
{ type: 'area', target: 'Tower', label: 'Tower' },
{ type: 'point', target: 'Capitol', label: 'Capitol', color: 'amber' },
]);
await flushMicrotasks();
h.pending[0].finish();
const completed = await batch;
assert.deepEqual(completed.results.map((result) => result.ok), [true, true, true]);
assert.equal(completed.drawn, 3);
});
test('plain recaption keeps the old mark addressable when its removal throws', async (t) => {
installAnimationFrameStubs(t);
const { renderer } = fakeRenderer();
const engine = createAnnotationEngine({
viewer: {}, renderer, resolveTarget: async () => ({ ...FIXED_POINT }),
});
await engine.annotate([{ type: 'point', target: 'Capitol', label: 'Capitol' }]);
const old = engine.list()[0];
const removals = [];
let fail = true;
renderer.remove = (anno) => {
removals.push(anno.id);
if (anno.id === old.id && fail) throw new Error('old route removal failed');
};
const swap = await engine.annotate([
{ type: 'point', target: 'Capitol', label: 'Capitol', color: 'amber' },
]);
assert.equal(swap.drawn, 0);
assert.deepEqual(engine.list().map((anno) => anno.id), [old.id], 'failed cleanup remains reachable');
assert.equal(engine.list()[0].cleanupPending, true);
fail = false;
const attempts = removals.filter((id) => id === old.id).length;
engine.clear();
assert.ok(
removals.filter((id) => id === old.id).length > attempts,
'the old route is retried on the next clear',
);
assert.equal(engine.count(), 0);
});
+3 -1
View File
@@ -186,12 +186,14 @@ export function createHybridAnnotationRenderer(
if (entry.screenProxy) screen.remove(entry.screenProxy);
entry.screenProxy = null;
} else {
// The caption conversion already reshaped the group; redraw the pending point.
const pending = liveProxy(anno, {
ring: null,
pendingOutline: true,
});
screen.update(pending);
if (entry.screenProxy) screen.remove(entry.screenProxy);
entry.screenProxy = pending;
screen.add(pending);
}
if (workTrace) workTrace.rendererStatus = 'timeout';
return { ...result, status: 'timeout' };
@@ -757,3 +757,30 @@ test('an asynchronous caption-conversion throw rolls back multipart world geomet
renderer.remove(anno);
renderer.destroy();
});
test('a deadline passed during caption conversion leaves a drawn pending point', async (t) => {
installBrowserGlobals(t);
let now = 0;
t.mock.method(globalThis.performance, 'now', () => now);
const { viewer, frames } = fakeViewer(-99, 31);
const { store, renderer } = hybridWithBoard(viewer);
// Unlabeled: the conversion empties the screen group rather than relabelling it.
const anno = { ...buildingAnnotation('late-timeout'), ring: null };
renderer.add(anno);
anno.ring = buildingAnnotation('geometry').ring;
const completion = renderer.update(anno);
for (let frame = 0; frame < 8; frame += 1) frames.emit();
// The clock passes the deadline while the conversion presents the board.
const publish = store.publish;
store.publish = (board) => {
now = 1e9;
return publish(board);
};
assert.equal((await completion).status, 'timeout');
store.publish = publish;
const live = annotationGroups(store).filter((mark) => !mark.className?.includes('gev-out'));
assert.equal(live.length, 1);
assert.ok(childrenWithClass(live[0], 'gev-anno-ring').length > 0, 'the pending point still draws');
renderer.remove(anno);
renderer.destroy();
});
+1 -4
View File
@@ -8,6 +8,7 @@ import { containsAnchor } from '../data/adminBoundaries.js';
import { lonLatToTile } from '../data/tomtomTiles.js';
import {
BUILDING_MAX_DISTANCE_M,
GROUNDS_WORDS_RE,
OUTLINE_TILE_ZOOM,
STREET_RADIUS_M,
boxAround,
@@ -48,10 +49,6 @@ const GROUNDS_MIN_AREA_M2 = 20_000;
const DEICTIC_RE =
/^(?:(?:this|that|the|my)\s+)?(?:building|house|structure|tower|place|one|thing|spot|here|there|it)$/i;
/** Words that describe grounds rather than belong to the name searched. */
const GROUNDS_WORDS_RE =
/\b(?:grounds|compound|campus|premises|property|site|area|complex)\b/gi;
/** Whether the ask names a thing (vs. "this building" at a pointer). */
export function isNamedAsk(target) {
const text = String(target || '').trim();
+2 -8
View File
@@ -1,4 +1,5 @@
import { recordWorkSlice } from '../sources/phaseTiming.js';
import { ringCentroid } from '../sources/featureGeometry.js';
import * as Cesium from 'cesium';
import { showOsmCredit, hideOsmCredit } from '../data/dataCredits.js';
@@ -741,14 +742,7 @@ function decimateRing(ring, n) {
* while scheduling the expensive scene picks across rendered frames.
*/
function groundProbePositions(ring) {
let clon = 0;
let clat = 0;
for (const [lon, lat] of ring) {
clon += lon;
clat += lat;
}
clon /= ring.length;
clat /= ring.length;
const { lon: clon, lat: clat } = ringCentroid(ring);
const latS = 111320;
const lonS = latS * Math.cos(Cesium.Math.toRadians(clat));
let maxR = 0;