diff --git a/src/apps/custom/customConfig.ts b/src/apps/custom/customConfig.ts index 7f271fb..c953d7a 100644 --- a/src/apps/custom/customConfig.ts +++ b/src/apps/custom/customConfig.ts @@ -17,7 +17,7 @@ export const config: CustomConfig = { }, }, { - type: 'osm', + type: 'nominatim', options: { limit: 10, }, diff --git a/src/interfaces/search/ingv-search-provider.ts b/src/interfaces/search/ingv-search-provider.ts index 8199140..e8c8974 100644 --- a/src/interfaces/search/ingv-search-provider.ts +++ b/src/interfaces/search/ingv-search-provider.ts @@ -37,11 +37,11 @@ export function isGeoAdminSearchProvider( return config.type === 'geoadmin'; } -export interface INGVOsmSearchProviderConfig { - type: 'osm'; +export interface INGVNominatimSearchProviderConfig { + type: 'nominatim'; options?: { - /** URL to the OSM search API. The following placeholders are supported: + /** URL to the Nominatim search API. The following placeholders are supported: * - `{input}`: the search query * - `{lang}`: the language code * - `{limit}`: see below @@ -52,16 +52,16 @@ export interface INGVOsmSearchProviderConfig { limit?: number; }; } -export function isOsmSearchProvider( +export function isNominatimSearchProvider( config: INGVSearchProviderConfigs, -): config is INGVOsmSearchProviderConfig { - return config.type === 'osm'; +): config is INGVNominatimSearchProviderConfig { + return config.type === 'nominatim'; } // Unions of all possible configs export type INGVSearchProviderConfigs = | INGVGeoAdminSearchProviderConfig - | INGVOsmSearchProviderConfig; + | INGVNominatimSearchProviderConfig; export interface INGVSearchProvider { search: (input: string, lang: string) => Promise; diff --git a/src/plugins/search/ngv-search-providers.ts b/src/plugins/search/ngv-search-providers.ts index 7dea545..f5b9e96 100644 --- a/src/plugins/search/ngv-search-providers.ts +++ b/src/plugins/search/ngv-search-providers.ts @@ -1,6 +1,6 @@ import { isGeoAdminSearchProvider, - isOsmSearchProvider, + isNominatimSearchProvider, type INGVSearchProvider, type INGVSearchProviderConfigs, } from '../../interfaces/search/ingv-search-provider.js'; @@ -13,11 +13,11 @@ export async function getProvider( './providers/ngv-geoadmin-provider.js' ); return new NGVGeoAdminSearchProvider(config.options); - } else if (isOsmSearchProvider(config)) { - const {NGVOsmSearchProvider} = await import( - './providers/ngv-osm-provider.js' + } else if (isNominatimSearchProvider(config)) { + const {NGVNominatimSearchProvider} = await import( + './providers/ngv-nominatim-provider.js' ); - return new NGVOsmSearchProvider(config.options); + return new NGVNominatimSearchProvider(config.options); } throw new Error(`Unhandled search provider type`); } diff --git a/src/plugins/search/providers/ngv-osm-provider.ts b/src/plugins/search/providers/ngv-nominatim-provider.ts similarity index 84% rename from src/plugins/search/providers/ngv-osm-provider.ts rename to src/plugins/search/providers/ngv-nominatim-provider.ts index d523619..f8bf79d 100644 --- a/src/plugins/search/providers/ngv-osm-provider.ts +++ b/src/plugins/search/providers/ngv-nominatim-provider.ts @@ -1,6 +1,6 @@ import type {Geometry} from 'geojson'; import type { - INGVOsmSearchProviderConfig, + INGVNominatimSearchProviderConfig, INGVSearchProvider, INGVSearchResult, } from '../../../interfaces/search/ingv-search-provider.js'; @@ -14,12 +14,14 @@ interface OSMFeature { lon: string; } -export class NGVOsmSearchProvider implements INGVSearchProvider { - public name: 'osm'; +export class NGVNominatimSearchProvider implements INGVSearchProvider { + public name: 'nominatim'; private searchUrl: string; private limit: number; - constructor(config: INGVOsmSearchProviderConfig['options'] | undefined) { + constructor( + config: INGVNominatimSearchProviderConfig['options'] | undefined, + ) { this.searchUrl = config?.url ?? nominatimSearchUrl; this.limit = config?.limit ?? 10; }