Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

Merge remote-tracking branch 'origin/main' into upstream/geocode-place-region

quanticsoul4772c13c2fc1f0ff
diff --cc docs/CURRENT-STATE.md
index 529ffb6e6,8be9af204..0ca016713
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@@ -5191,13 -5197,14 +5197,19 @@@ HTTP refusals and outages remain retrya
deadline, with Photon requests capped at six seconds each. Caller/application
cancellation stops retries and late cache writes. Replacing a location search
cancels the previous lookup; disposing its controls cancels the active lookup. Photon uses a soft proximity bias, up to five
-candidates, and an unbiased retry for name mismatches. Invalid or wrapped bounds returned by providers
+candidates, and an unbiased retry for name mismatches. A "place, region" query
+only accepts a candidate named exactly for the place whose city, county, state,
+country or country code (or USA/UK) contains the region; nearby results that
+fail that check are retried unbiased, and a nearby place whose whole name is the
- query (one with a comma in it) is the last choice. Invalid/wrapped bounds
++query (one with a comma in it) is the last choice. Invalid or wrapped bounds
++returned by providers
are omitted rather than framing the wrong part of the globe.
+ For request viewport bias, Photon unwraps antimeridian-crossing longitude bounds
+ before computing their midpoint, then wraps that midpoint back into ±180 degrees.
+ Malformed viewport bounds add no proximity bias. Nominatim omits a crossing
+ request viewbox and continues searching without that geographic preference.
+
### Map Stack Switcher (June 2026)
- `src/mapStackController.js` switches between Google Photorealistic 3D (`photoreal`, the default when a Google or ion key is present), keyless Esri World Imagery (the zero-key default landing, with keyless terrain), Bing Aerial / Aerial-with-Labels via Cesium ion world imagery (require `CESIUM_ION_TOKEN`), and OSM tile fallback. Bing Road is **retired**: it is gone from `MAP_STACKS`, from the `set_map_stack` enum, and from the voice aliases (road phrasings now resolve to OSM, the one shipped road basemap). An old `map=bing-road` link is simply an unknown id and takes `setStack()`'s existing photoreal fallback with the Google 3D tile lit — pinned live in `scripts/qa-map-source-tray.mjs`.
diff --cc src/keylessGeocoder.test.mjs
index 7759d5226,1a702fd02..b7078d9d0
--- a/src/keylessGeocoder.test.mjs
+++ b/src/keylessGeocoder.test.mjs
@@@ -500,86 -453,13 +500,97 @@@ function readGeocodingConsumer(file)
return files.map((name) => fs.readFileSync(path.join(ROOT, 'src', name), 'utf8')).join('\n');
}
+test('"USA" and "UK" name their countries, and a trailing comma keeps the nearby answer', async () => {
+ const pubFirst = [PARIS_TEXAS_PUB, PARIS_TX];
+ assert.equal(selectQualifiedFeature(pubFirst, 'Paris, Texas, USA'), PARIS_TX);
+ // "Paris," names no region: the camera-biased pass still answers.
+ const fetchImpl = photonPair([PARIS_TX], []);
+ const result = await geocodeKeyless('Paris,', {
+ bias: '33.60,-95.60|33.70,-95.50',
+ fetchImpl,
+ });
+ assert.equal(Math.round(result.lat), 34, `got ${result.label}`);
+ assert.equal(fetchImpl.urls.length, 1);
+});
+
+test('a region match takes the place itself, not a place whose name starts with it', () => {
+ const station = {
+ geometry: { type: 'Point', coordinates: [4.86, 45.76] },
+ properties: {
+ osm_key: 'railway',
+ name: 'Paris Gare de Lyon',
+ city: 'Lyon',
+ country: 'France',
+ countrycode: 'FR',
+ },
+ };
+ const paris = {
+ geometry: { type: 'Point', coordinates: [2.35, 48.86] },
+ properties: {
+ osm_key: 'place',
+ name: 'Paris',
+ state: 'Île-de-France',
+ country: 'France',
+ countrycode: 'FR',
+ },
+ };
+ assert.equal(selectQualifiedFeature([station, paris], 'Paris, France'), paris);
+ assert.equal(selectQualifiedFeature([station], 'Paris, France'), null);
+});
+
+test('"UK" names the United Kingdom', () => {
+ const london = {
+ geometry: { type: 'Point', coordinates: [-0.13, 51.51] },
+ properties: {
+ osm_key: 'place',
+ name: 'London',
+ country: 'United Kingdom',
+ countrycode: 'GB',
+ },
+ };
+ const ontario = {
+ geometry: { type: 'Point', coordinates: [-81.25, 42.98] },
+ properties: {
+ osm_key: 'place',
+ name: 'London',
+ state: 'Ontario',
+ country: 'Canada',
+ countrycode: 'CA',
+ },
+ };
+ 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');
+});
++
+
+ test('wrapped view bias stays near the antimeridian and malformed coordinates are omitted', () => {
+ for (const [bias, expected] of [['-20,170|-10,-171', 179.5], ['50,175|60,-165', -175], ['0,180|10,-180', 180], ['0,-180|10,180', 0]]) {
+ const params = new URL(photonSearchUrl('island', { bias })).searchParams;
+ assert.equal(Number(params.get('lon')), expected);
+ }
+ for (const bias of ['-91,0|0,1', '0,181|1,0', '10,0|0,1', ',|,', '0,1,2|3,4', '0,1|Infinity,2']) {
+ assert.equal(new URL(photonSearchUrl('island', { bias })).searchParams.has('lon'), false);
+ }
+ });