forked from MapComplete/MapComplete
UX: don't search online if the searchterm clearly is an OSM-id
This commit is contained in:
parent
96fb4c457d
commit
e4ffa6c854
2 changed files with 10 additions and 2 deletions
|
|
@ -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<GeocodeResult[]> {
|
||||
public async search(query: string, options?: GeocodingOptions): Promise<GeocodeResult[]> {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue