mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(atlas): replace fuzzy region matching with exact name_en check
Bidirectional substring matching in isVisitedFeature caused unrelated regions to be highlighted as visited (e.g. selecting Nordrhein-Westfalen also marked Nord France due to "nord" being a substring match). Replace the fuzzy loop with an additional exact check against the Natural Earth name_en property to cover English-vs-native name mismatches. Also fix Nominatim field priority to prefer state over county so reverse-geocoded places resolve to the correct admin-1 level. Adds integration tests ATLAS-009 through ATLAS-011 covering mark/unmark region endpoints and user isolation. Fixes #446
This commit is contained in:
@@ -421,7 +421,7 @@ async function reverseGeocodeRegion(lat: number, lng: number): Promise<RegionInf
|
||||
if (regionCode && /^[A-Z]{2}-\d+[A-Z]$/i.test(regionCode)) {
|
||||
regionCode = regionCode.replace(/[A-Z]$/i, '');
|
||||
}
|
||||
const regionName = data.address?.county || data.address?.state || data.address?.province || data.address?.region || data.address?.city || null;
|
||||
const regionName = data.address?.state || data.address?.province || data.address?.region || data.address?.county || data.address?.city || null;
|
||||
if (!countryCode || !regionName) { regionCache.set(key, null); return null; }
|
||||
const info: RegionInfo = {
|
||||
country_code: countryCode,
|
||||
|
||||
Reference in New Issue
Block a user