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 Locale from "../../UI/i18n/Locale"
|
||||||
import GeocodingProvider, { GeocodeResult, GeocodingOptions } from "./GeocodingProvider"
|
import GeocodingProvider, { GeocodeResult, GeocodingOptions } from "./GeocodingProvider"
|
||||||
import { Store, UIEventSource } from "../UIEventSource"
|
import { Store, UIEventSource } from "../UIEventSource"
|
||||||
|
import OpenStreetMapIdSearch from "./OpenStreetMapIdSearch"
|
||||||
|
|
||||||
export class NominatimGeocoding implements GeocodingProvider {
|
export class NominatimGeocoding implements GeocodingProvider {
|
||||||
private readonly _host
|
private readonly _host
|
||||||
|
|
@ -17,7 +18,10 @@ export class NominatimGeocoding implements GeocodingProvider {
|
||||||
this._host = host
|
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 b = options?.bbox ?? BBox.global
|
||||||
const url = `${this._host}search?format=json&limit=${
|
const url = `${this._host}search?format=json&limit=${
|
||||||
this.limit
|
this.limit
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,14 @@ import GeocodingProvider, {
|
||||||
GeocodingOptions,
|
GeocodingOptions,
|
||||||
GeocodingUtils,
|
GeocodingUtils,
|
||||||
ReverseGeocodingProvider,
|
ReverseGeocodingProvider,
|
||||||
ReverseGeocodingResult,
|
ReverseGeocodingResult
|
||||||
} from "./GeocodingProvider"
|
} from "./GeocodingProvider"
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
import { Feature, FeatureCollection } from "geojson"
|
import { Feature, FeatureCollection } from "geojson"
|
||||||
import Locale from "../../UI/i18n/Locale"
|
import Locale from "../../UI/i18n/Locale"
|
||||||
import { GeoOperations } from "../GeoOperations"
|
import { GeoOperations } from "../GeoOperations"
|
||||||
import { Store, UIEventSource } from "../UIEventSource"
|
import { Store, UIEventSource } from "../UIEventSource"
|
||||||
|
import OpenStreetMapIdSearch from "./OpenStreetMapIdSearch"
|
||||||
|
|
||||||
export default class PhotonSearch implements GeocodingProvider, ReverseGeocodingProvider {
|
export default class PhotonSearch implements GeocodingProvider, ReverseGeocodingProvider {
|
||||||
private readonly _endpoint: string
|
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
|
// Photon gives a '403 forbidden' when this is part of the search string
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
if (OpenStreetMapIdSearch.extractId(query) !== undefined) {
|
||||||
|
return [] // This is an OSM-id, no need to search online
|
||||||
|
}
|
||||||
const limit = this.searchLimit
|
const limit = this.searchLimit
|
||||||
let bbox = ""
|
let bbox = ""
|
||||||
if (options?.bbox && !this.ignoreBounds) {
|
if (options?.bbox && !this.ignoreBounds) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue