mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
fix(geocode): match the nearby whole-name fallback exactly
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
734c74c325
commit
2c16dd6601
2 files changed
+34
-1
No files matched your search
@@ -417,7 +417,13 @@ export async function geocodeKeylessWithOutcome(
|
|||||||
if (biased === null) everyAskAnswered = false;
|
if (biased === null) everyAskAnswered = false;
|
||||||
else if (queryRegion(trimmed)) {
|
else if (queryRegion(trimmed)) {
|
||||||
feature = selectQualifiedFeature(biased, trimmed);
|
feature = selectQualifiedFeature(biased, trimmed);
|
||||||
nearbyNameMatch = selectPhotonFeature(biased, normalizeToponym(trimmed));
|
// Exactly the whole query: "Springfield IL Auto" only starts with it.
|
||||||
|
const whole = normalizeToponym(trimmed);
|
||||||
|
nearbyNameMatch =
|
||||||
|
biased.find(
|
||||||
|
(candidate) =>
|
||||||
|
normalizeToponym(candidate?.properties?.name) === whole,
|
||||||
|
) ?? null;
|
||||||
} else {
|
} else {
|
||||||
feature = selectPhotonFeature(biased, normalizeToponym(trimmed));
|
feature = selectPhotonFeature(biased, normalizeToponym(trimmed));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,3 +594,30 @@ test('wrapped view bias stays near the antimeridian and malformed coordinates ar
|
|||||||
assert.equal(new URL(photonSearchUrl('island', { bias })).searchParams.has('lon'), false);
|
assert.equal(new URL(photonSearchUrl('island', { bias })).searchParams.has('lon'), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('the nearby whole-name fallback takes an exact name, not one that only starts with the query', async () => {
|
||||||
|
const place = (name, lon, lat, props) => ({
|
||||||
|
geometry: { type: 'Point', coordinates: [lon, lat] },
|
||||||
|
properties: { osm_key: 'place', name, ...props },
|
||||||
|
});
|
||||||
|
const nearby = [
|
||||||
|
place('Springfield IL Auto', -89.6, 39.8, {
|
||||||
|
osm_key: 'shop',
|
||||||
|
city: 'Springfield',
|
||||||
|
state: 'Illinois',
|
||||||
|
countrycode: 'US',
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
const anywhere = [
|
||||||
|
place('Springfield', -89.65, 39.78, { state: 'Illinois', countrycode: 'US' }),
|
||||||
|
];
|
||||||
|
const fetchImpl = photonPair(nearby, anywhere);
|
||||||
|
|
||||||
|
const result = await geocodeKeyless('Springfield, IL', {
|
||||||
|
bias: '39.70,-89.70|39.90,-89.50',
|
||||||
|
fetchImpl,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.doesNotMatch(result.label, /Auto/);
|
||||||
|
assert.match(result.label, /^Springfield/);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user