mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(geocode): keep a nearby whole-name match as the last choice, and document the region rule
A query with a comma counted as "place, region", so a nearby place whose
own name has a comma ("Bed, Bath & Beyond") no longer won the nearby pass
and the unbiased pass could fly to a namesake far away. Its whole-name
match is now kept as the last choice, after the region checks of both
passes. CURRENT-STATE describes the place-region rule.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
7775f6007d
commit
91769d74b8
3 files changed
+41
-6
No files matched your search
@@ -560,3 +560,26 @@ test('"UK" names the United Kingdom', () => {
|
||||
};
|
||||
assert.equal(selectQualifiedFeature([ontario, london], 'London, UK'), london);
|
||||
});
|
||||
|
||||
test('a nearby place whose own name has a comma still wins when nothing matches as place and region', async () => {
|
||||
const store = (lon, lat, city) => ({
|
||||
geometry: { type: 'Point', coordinates: [lon, lat] },
|
||||
properties: {
|
||||
osm_key: 'shop',
|
||||
osm_value: 'houseware',
|
||||
name: 'Bed, Bath & Beyond',
|
||||
city,
|
||||
countrycode: 'US',
|
||||
},
|
||||
});
|
||||
const nearby = store(-104.94, 39.66, 'Denver');
|
||||
const fetchImpl = photonPair([nearby], [store(-73.99, 40.74, 'New York')]);
|
||||
|
||||
const result = await geocodeKeyless('Bed, Bath & Beyond', {
|
||||
bias: '39.60,-105.00|39.70,-104.90',
|
||||
fetchImpl,
|
||||
});
|
||||
|
||||
assert.match(result.label, /Denver/);
|
||||
assert.equal(fetchImpl.urls.length, 2, 'the region checks ran first');
|
||||
});
|
||||
Reference in new issue
Block a user