mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(voice): treat a Zone as retired only in Nepal
Every name ending in "Zone" was kept without a level and refused as a retired administrative identity. That is right for Nepal, which replaced its zones in 2015, but zones are current units elsewhere: Ethiopia's "Gamo Zone" was refused. The selector now keeps the verified level unless display_name places the zone in Nepal or names no country, and the client no longer reads "Zone" as a retired level when the source verified one.
This commit is contained in:
1 parent
682427ef1d
commit
451be8e3b7
4 files changed
+73
-2
No files matched your search
@@ -270,6 +270,12 @@ export function createVoiceAreas({
|
||||
const sourceAdmin = administrativeIdentity(sourceIdentity);
|
||||
const primaryAdmin = administrativeIdentity(primaryLabel);
|
||||
const requestedAdmin = administrativeIdentity(requestedLabel);
|
||||
// The server leaves a Zone without a level only where zones were retired
|
||||
// (Nepal). A verified level means a current zone, so "Zone" claims no level.
|
||||
if (sourceLevel && sourceAdmin.level === 'retired') {
|
||||
for (const admin of [sourceAdmin, primaryAdmin, requestedAdmin])
|
||||
if (admin.level === 'retired') admin.level = null;
|
||||
}
|
||||
const sourceClaimsAdministrative = Boolean(
|
||||
administrativeRequest ||
|
||||
administrativeLabel ||
|
||||
|
||||
@@ -30,12 +30,13 @@ function fakeLadder({
|
||||
calls = [],
|
||||
delay = null,
|
||||
label = 'Bagmati Province',
|
||||
match = /bagmati/i,
|
||||
} = {}) {
|
||||
return {
|
||||
calls,
|
||||
async resolveAnnotationTarget(request) {
|
||||
calls.push(request);
|
||||
if (!/bagmati/i.test(request.target)) return null;
|
||||
if (!match.test(request.target)) return null;
|
||||
return {
|
||||
lat: 27.7,
|
||||
lon: 85.3,
|
||||
@@ -391,6 +392,26 @@ test('a verified province accepts a bare query with a separate level', async ()
|
||||
assert.equal(retired.areas.store.size, 0);
|
||||
});
|
||||
|
||||
test('a current Zone the source verified is not refused as retired', async () => {
|
||||
const gamo = makeAreas({
|
||||
annotationResolver: fakeLadder({
|
||||
label: 'Gamo Zone',
|
||||
match: /gamo/i,
|
||||
outline: {
|
||||
ring: BAGMATI_POLYGONS[0][0],
|
||||
polygons: BAGMATI_POLYGONS,
|
||||
adminArea: 'Gamo Zone',
|
||||
adminLevel: 'admin2',
|
||||
synthesized: false,
|
||||
outlineSource: 'nominatim',
|
||||
},
|
||||
}),
|
||||
});
|
||||
const result = await gamo.areas.resolveAreaAction({ query: 'Gamo Zone' });
|
||||
assert.equal(result.ok, true, result.error);
|
||||
assert.equal(gamo.areas.store.size, 1);
|
||||
});
|
||||
|
||||
test('a place no outline source can trace is refused, not guessed', async () => {
|
||||
const miss = makeAreas({
|
||||
annotationResolver: fakeLadder({ outline: null }),
|
||||
|
||||
Reference in new issue
Block a user