mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
fix(area): accept "State of Texas" and "USA" as the units they name
resolve_area compared the spoken name with the unit's name literally, so "State of Texas" (admin1) and "USA" or "UK" (country) were refused with AREA_IDENTITY_MISMATCH although the bundled matcher found exactly those units. Both identity checks, the bundled one and the outline ladder's, now also accept the prefix forms and same-unit country aliases the matcher reads, at the level they imply, so the level check still applies. "Great Britain", "Britain", "America" and "Korea" still need their own names, and the natural-region check stays literal.
This commit is contained in:
1 parent
540629a0fc
commit
68667e2e3c
5 files changed
+128
-6
No files matched your search
@@ -21,7 +21,10 @@ import { createAreaStore, summarizeArea } from '../data/areaStore.js';
|
||||
import { createAreaResolver, foldLatinMarks } from '../data/areaResolver.js';
|
||||
import { circleRing, displayParts } from '../data/areaGeometry.js';
|
||||
import { findNaturalRegion } from '../data/naturalEarthRegions.js';
|
||||
import { findAdminCandidates as findBundledAdminCandidates } from '../data/adminBoundaries.js';
|
||||
import {
|
||||
adminQueryIdentity,
|
||||
findAdminCandidates as findBundledAdminCandidates,
|
||||
} from '../data/adminBoundaries.js';
|
||||
import {
|
||||
NATURAL_EARTH_CREDIT,
|
||||
US_CENSUS_CREDIT,
|
||||
@@ -87,6 +90,16 @@ function administrativeIdentity(value) {
|
||||
.toLocaleLowerCase()
|
||||
.replace(/[^\p{L}\p{M}\p{N}]+/gu, ' ')
|
||||
.trim();
|
||||
// Forms the administrative matcher reads as one unit's name: "State of
|
||||
// Texas" is Texas at admin level 1, "USA" is United States of America.
|
||||
const named = adminQueryIdentity(value);
|
||||
if (named?.level === 'admin1')
|
||||
return {
|
||||
name: foldLatinMarks(normalized.replace(/^(?:the )?.+? of /, '')),
|
||||
level: 'admin1',
|
||||
};
|
||||
if (named?.level === 'country')
|
||||
return { name: foldLatinMarks(named.name), level: 'country' };
|
||||
const match = normalized.match(
|
||||
/\b(country|nation|province|state|region|zone|oblast|prefecture|canton|governorate|county|district|department)$/,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user