mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
keep bent streets, enclosed landmarks and same-name outlines honest
A street ribbon that holds neither its ring mean nor the anchor is centred on the street's nearest point when the street runs within 100 m. Nominatim outline selection ranks an exact name, then one holding every asked word, then an overlap, and refuses an overlap whose name lacks the ask's last word unless that word is in the result's address or type, so "Central Park Zoo" is no longer Central Park. The server caches every accepted outline and answers each ask with the one holding its resolved anchor (sent as alat/alon), read across the antimeridian. A duplicate mark that fails to clean up no longer tears down the new outline it duplicates.
This commit is contained in:
1 parent
d9a460658d
commit
a38a065c5c
16 files changed
+516
-133
No files matched your search
@@ -120,3 +120,45 @@ test('the engine resolves a bare street highlight with its footprint', async (t)
|
||||
assert.equal(seen[0].footprint, true);
|
||||
assert.equal(seen[0].entityKind, 'street');
|
||||
});
|
||||
|
||||
test('a duplicate that fails to clean up never costs the new outline', async (t) => {
|
||||
installAnimationFrameStubs(t);
|
||||
const polygons = [[outer]];
|
||||
const outline = { ring: outer, polygons, footprintKind: 'area' };
|
||||
const point = { lon: 0.005, lat: 0.005, height: 0, source: 'fake' };
|
||||
// "Old" draws at once; "New" resolves the same polygon later.
|
||||
const resolveTarget = async ({ target }) =>
|
||||
target === 'old'
|
||||
? { ...point, label: target, ...outline }
|
||||
: {
|
||||
...point,
|
||||
label: target,
|
||||
resolveOutline: async () => ({ ...point, ...outline }),
|
||||
};
|
||||
const stuck = new Set();
|
||||
const outcomes = [];
|
||||
const engine = createAnnotationEngine({
|
||||
viewer: {},
|
||||
renderer: {
|
||||
...renderer,
|
||||
add(anno) {
|
||||
if (anno.label === 'Old') stuck.add(anno);
|
||||
},
|
||||
remove(anno) {
|
||||
if (stuck.has(anno)) throw new Error('renderer refused');
|
||||
},
|
||||
},
|
||||
resolveTarget,
|
||||
});
|
||||
engine.onOutlineEvent((event) => outcomes.push(event));
|
||||
await engine.annotate({ type: 'area', target: 'old', label: 'Old' });
|
||||
await engine.annotate({ type: 'area', target: 'new', label: 'New' });
|
||||
for (let i = 0; i < 10; i++) await new Promise((r) => setTimeout(r, 0));
|
||||
const fresh = engine.list().find((mark) => mark.label === 'New');
|
||||
assert.equal(fresh?.footprintKind, 'area', 'the new mark keeps its outline');
|
||||
assert.notEqual(fresh.outlineUnavailable, true);
|
||||
assert.deepEqual(
|
||||
outcomes.filter((event) => event.label === 'New').map((e) => e.status),
|
||||
['resolved'],
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user