mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
feat(outlines): voice outlines without Overpass — bundled US places and neighborhoods, guarded Nominatim, OpenFreeMap streets and buildings
This commit is contained in:
1 parent
e7707d9a0f
commit
9559e7a282
333 files changed
+13203
-271
No files matched your search
@@ -54,7 +54,15 @@ export function createDefaultPlaceSearch({
|
||||
return fetchImpl(url.toString(), { signal });
|
||||
},
|
||||
}),
|
||||
createPhotonGeocoder({ fetchImpl, endpoint: endpoints.photon }),
|
||||
// `endpoints.photon === null` is the operator's "no Photon".
|
||||
...(endpoints.photon === null
|
||||
? []
|
||||
: [
|
||||
createPhotonGeocoder({
|
||||
fetchImpl,
|
||||
endpoint: endpoints.photon ?? undefined,
|
||||
}),
|
||||
]),
|
||||
// Last resort: the local Nominatim route, which answers with no key when
|
||||
// neither of the two above did. It speaks the same result shape, so it
|
||||
// rides the existing Google adapter rather than needing its own.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// PHOTON_URL: unset keeps the public default, empty disables, else a URL.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { photonEndpointSetting } from '../keylessGeocoder.js';
|
||||
import { createDefaultPlaceSearch } from './defaults.js';
|
||||
|
||||
test('the Photon setting reads unset, disabled and operator values', () => {
|
||||
assert.equal(photonEndpointSetting(undefined), undefined);
|
||||
for (const off of [
|
||||
'',
|
||||
' ',
|
||||
'off',
|
||||
'none',
|
||||
'disabled',
|
||||
'not a url',
|
||||
'ftp://x.test/',
|
||||
'https://u:[email protected]/api/',
|
||||
])
|
||||
assert.equal(photonEndpointSetting(off), null, off);
|
||||
assert.equal(
|
||||
photonEndpointSetting('https://photon.example.test/api/'),
|
||||
'https://photon.example.test/api/',
|
||||
);
|
||||
});
|
||||
|
||||
async function hosts(endpoints) {
|
||||
const asked = [];
|
||||
const search = createDefaultPlaceSearch({
|
||||
endpoints,
|
||||
fetchImpl: async (url) => {
|
||||
asked.push(new URL(String(url), 'http://local.test').host);
|
||||
return new Response(
|
||||
JSON.stringify({ features: [], status: 'ZERO_RESULTS', results: [] }),
|
||||
{ status: 200 },
|
||||
);
|
||||
},
|
||||
});
|
||||
await search.geocode(`nowhere-${Math.random()}`);
|
||||
return asked;
|
||||
}
|
||||
|
||||
test('place search follows the Photon setting', async () => {
|
||||
assert.ok(
|
||||
(await hosts({})).includes('photon.komoot.io'),
|
||||
'default is public Photon',
|
||||
);
|
||||
const own = await hosts({ photon: 'https://photon.example.test/api/' });
|
||||
assert.ok(own.includes('photon.example.test'));
|
||||
assert.ok(!own.includes('photon.komoot.io'));
|
||||
const off = await hosts({ photon: null });
|
||||
assert.ok(!off.some((host) => host.includes('photon')), off.join(','));
|
||||
});
|
||||
Reference in new issue
Block a user