fix(voice): resolve areas per view, without accents and per natural place

From review:
- An answer the view picked ("Springfield" over Illinois) is reused or
  shared only within the same ~2° view cell, so asking again elsewhere no
  longer gets the first state's area.
- Admin names compare with accents folded on Latin letters only: "Quebec"
  matches "Québec" and "Cordoba" asks between Argentina and Spain, while a
  Thai or Devanagari mark still tells names apart.
- A Natural Earth name used by several features is one place with every
  part when they touch (the Great Rift Valley, the Lau Group across 180°)
  and a question when they are far apart (Flores); natural places can now
  be candidates.
- The AREAS rule and the area tool descriptions are tighter, leaving a
  ~270-character margin under the 55,500 prompt ceiling, and resolve_area
  no longer names osm_query when that tool is not offered.
This commit is contained in:
Manjunath committed 2026-11-03 19:36:25 +05:30
1 parent fb74354d30
commit 207373389a
12 files changed
+328 -22

No files matched your search

+18
View File
@@ -195,3 +195,21 @@ test('pointInRing: basic square', () => {
assert.equal(pointInRing(sq, 15, 5), false);
assert.equal(pointInRing([[0, 0], [1, 1]], 0.5, 0.5), false, 'degenerate ring');
});
test('same-name parts of one feature are one place; distant namesakes are separate places', async () => {
for (const name of ['Great Rift Valley', 'Lau Group', 'Transantarctic Mountains']) {
const region = await findNaturalRegion(name);
assert.equal(region?.places?.length, 1, `${name} is one place`);
const place = region.places[0];
assert.equal(place.polygons.length >= 2, true, `${name} keeps every part`);
assert.ok(place.areaKm2 > region.areaKm2, `${name} counts more than its largest part`);
}
for (const name of ['Flores', 'Cordillera Oriental']) {
const region = await findNaturalRegion(name);
assert.equal(region?.places?.length, 2, `${name} names two places`);
for (const place of region.places) {
assert.ok(Number.isFinite(place.center.lat) && Number.isFinite(place.center.lon));
}
}
assert.equal((await findNaturalRegion('Alps'))?.places?.length, 1);
});