diff --git a/src/Logic/Search/NominatimGeocoding.ts b/src/Logic/Search/NominatimGeocoding.ts index ccbf14800..947b21dbb 100644 --- a/src/Logic/Search/NominatimGeocoding.ts +++ b/src/Logic/Search/NominatimGeocoding.ts @@ -5,6 +5,7 @@ import { FeatureCollection } from "geojson" import Locale from "../../UI/i18n/Locale" import GeocodingProvider, { GeocodeResult, GeocodingOptions } from "./GeocodingProvider" import { Store, UIEventSource } from "../UIEventSource" +import OpenStreetMapIdSearch from "./OpenStreetMapIdSearch" export class NominatimGeocoding implements GeocodingProvider { private readonly _host @@ -17,7 +18,10 @@ export class NominatimGeocoding implements GeocodingProvider { this._host = host } - public search(query: string, options?: GeocodingOptions): Promise { + public async search(query: string, options?: GeocodingOptions): Promise { + if (OpenStreetMapIdSearch.extractId(query) !== undefined) { + return [] // This is an OSM-id, no need to search online + } const b = options?.bbox ?? BBox.global const url = `${this._host}search?format=json&limit=${ this.limit diff --git a/src/Logic/Search/PhotonSearch.ts b/src/Logic/Search/PhotonSearch.ts index b02234373..5063e2c9d 100644 --- a/src/Logic/Search/PhotonSearch.ts +++ b/src/Logic/Search/PhotonSearch.ts @@ -5,13 +5,14 @@ import GeocodingProvider, { GeocodingOptions, GeocodingUtils, ReverseGeocodingProvider, - ReverseGeocodingResult, + ReverseGeocodingResult } from "./GeocodingProvider" import { Utils } from "../../Utils" import { Feature, FeatureCollection } from "geojson" import Locale from "../../UI/i18n/Locale" import { GeoOperations } from "../GeoOperations" import { Store, UIEventSource } from "../UIEventSource" +import OpenStreetMapIdSearch from "./OpenStreetMapIdSearch" export default class PhotonSearch implements GeocodingProvider, ReverseGeocodingProvider { private readonly _endpoint: string @@ -129,6 +130,9 @@ export default class PhotonSearch implements GeocodingProvider, ReverseGeocoding // Photon gives a '403 forbidden' when this is part of the search string return [] } + if (OpenStreetMapIdSearch.extractId(query) !== undefined) { + return [] // This is an OSM-id, no need to search online + } const limit = this.searchLimit let bbox = "" if (options?.bbox && !this.ignoreBounds) {