fix: improve mapped installations and map-source guidance (#183)

Improve mapped installation recovery, deselection, retry feedback, and visual-style and map-source guidance.
This commit is contained in:
Bilawal Sidhu authored and GitHub committed 2026-09-05 03:30:55 -05:00
1 parent 3b6b3f1007
commit 759652207f
25 files changed
+479 -41

No files matched your search

@@ -74,3 +74,79 @@ test('accepts only small non-dateline request bboxes', () => {
assert.equal(isValidInstallationBoundingBox({ south: -1, west: 179, north: 1, east: -179 }), false);
assert.equal(isValidInstallationBoundingBox({ south: -20, west: 0, north: 20, east: 1 }), false);
});
test('a way with only bounds is kept, at the midpoint of that box', () => {
// The proxy asks for `out center tags geom` and Overpass honours only the
// LAST geometry mode, so `center` is never emitted and every way/relation
// arrives carrying `bounds` instead. Dropping those rendered nodes and
// nothing else — an empty screen over mapped installations.
const result = normalizeMilitaryInstallations({ elements: [
{ type: 'way', id: 92701457, bounds: { minlat: 51.94, minlon: 7.98, maxlat: 51.96, maxlon: 8.02 },
tags: { military: 'barracks', name: 'Sportschule der Bundeswehr' } },
] }, '2026-08-28T00:00:00.000Z');
assert.equal(result.records.length, 1);
assert.equal(result.droppedCount, 0);
assert.equal(result.records[0].latitude, 51.95);
assert.equal(result.records[0].longitude, 8.00);
});
test('a relation with only bounds is kept — it carries no geometry at all', () => {
const result = normalizeMilitaryInstallations({ elements: [
{ type: 'relation', id: 5, bounds: { minlat: -1, minlon: -2, maxlat: 1, maxlon: 2 },
tags: { landuse: 'military' } },
] });
assert.equal(result.records.length, 1);
assert.equal(result.records[0].latitude, 0);
assert.equal(result.records[0].longitude, 0);
});
test('an explicit centre still wins over bounds', () => {
const result = normalizeMilitaryInstallations({ elements: [
{ type: 'way', id: 6, center: { lat: 30.2, lon: -97.7 },
bounds: { minlat: 0, minlon: 0, maxlat: 60, maxlon: 60 },
tags: { military: 'airfield' } },
] });
assert.equal(result.records[0].latitude, 30.2);
assert.equal(result.records[0].longitude, -97.7);
});
test('an out-of-range or incomplete bounds box is dropped, not averaged', () => {
const result = normalizeMilitaryInstallations({ elements: [
// latitude past the pole
{ type: 'way', id: 1, bounds: { minlat: 80, minlon: 0, maxlat: 95, maxlon: 1 }, tags: { military: 'range' } },
// longitude past the antimeridian
{ type: 'way', id: 2, bounds: { minlat: 0, minlon: 170, maxlat: 1, maxlon: 181 }, tags: { military: 'range' } },
// a half-filled box would average to a plausible-looking lie
{ type: 'way', id: 3, bounds: { minlat: 10, maxlat: 12 }, tags: { military: 'range' } },
{ type: 'way', id: 4, bounds: {}, tags: { military: 'range' } },
{ type: 'way', id: 5, tags: { military: 'range' } },
] });
assert.deepEqual(result.records, []);
assert.equal(result.droppedCount, 5);
});
test('non-numeric bounds never coerce into a mapped site at zero', () => {
for (const value of [null, false, '', '0']) {
const result = normalizeMilitaryInstallations({ elements: [{
type: 'way', id: 90, tags: { military: 'barracks' },
bounds: { minlat: value, minlon: value, maxlat: value, maxlon: value },
}] });
assert.equal(result.records.length, 0);
assert.equal(result.droppedCount, 1);
}
});
test('an inverted or dateline-spanning bounds box is dropped rather than midpointed', () => {
const result = normalizeMilitaryInstallations({ elements: [
// south above north
{ type: 'way', id: 6, bounds: { minlat: 10, minlon: 0, maxlat: 8, maxlon: 1 }, tags: { military: 'range' } },
// west east of east: a dateline-spanning box would midpoint to longitude 0
{ type: 'way', id: 7, bounds: { minlat: 5, minlon: 179, maxlat: 6, maxlon: -179 }, tags: { military: 'range' } },
// ascending but implausibly wide: Overpass reports an antimeridian feature
// as minlon -179 / maxlon 179, which also midpoints to longitude 0
{ type: 'way', id: 8, bounds: { minlat: 5, minlon: -179, maxlat: 6, maxlon: 179 }, tags: { military: 'range' } },
] });
assert.deepEqual(result.records, []);
assert.equal(result.droppedCount, 3);
});