UX: search doesn't eternally spin anymore, add debug name for searchProviders
This commit is contained in:
parent
d00ccc9282
commit
1ecc63e5c8
10 changed files with 14 additions and 13 deletions
|
@ -1,12 +1,9 @@
|
|||
import GeocodingProvider, {
|
||||
SearchResult,
|
||||
GeocodingOptions,
|
||||
GeocodeResult,
|
||||
} from "./GeocodingProvider"
|
||||
import GeocodingProvider, { GeocodeResult, GeocodingOptions, SearchResult } from "./GeocodingProvider"
|
||||
import { Utils } from "../../Utils"
|
||||
import { Store, Stores } from "../UIEventSource"
|
||||
|
||||
export default class CombinedSearcher implements GeocodingProvider {
|
||||
public readonly name = "CombinedSearcher"
|
||||
private _providers: ReadonlyArray<GeocodingProvider>
|
||||
private _providersWithSuggest: ReadonlyArray<GeocodingProvider>
|
||||
|
||||
|
|
|
@ -2,10 +2,12 @@ import GeocodingProvider, { GeocodeResult } from "./GeocodingProvider"
|
|||
import { Utils } from "../../Utils"
|
||||
import { ImmutableStore, Store } from "../UIEventSource"
|
||||
import CoordinateParser from "coordinate-parser"
|
||||
|
||||
/**
|
||||
* A simple search-class which interprets possible locations
|
||||
*/
|
||||
export default class CoordinateSearch implements GeocodingProvider {
|
||||
public readonly name = "CoordinateSearch"
|
||||
private static readonly latLonRegexes: ReadonlyArray<RegExp> = [
|
||||
/^ *(-?[0-9]+\.[0-9]+)[ ,;/\\]+(-?[0-9]+\.[0-9]+)/,
|
||||
/^ *(-?[0-9]+,[0-9]+)[ ;/\\]+(-?[0-9]+,[0-9]+)/,
|
||||
|
|
|
@ -49,6 +49,7 @@ export interface GeocodingOptions {
|
|||
}
|
||||
|
||||
export default interface GeocodingProvider {
|
||||
readonly name: string
|
||||
search(query: string, options?: GeocodingOptions): Promise<GeocodeResult[]>
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import GeocodingProvider, { SearchResult, GeocodingOptions } from "./GeocodingProvider"
|
||||
import GeocodingProvider, { GeocodingOptions, SearchResult } from "./GeocodingProvider"
|
||||
import ThemeViewState from "../../Models/ThemeViewState"
|
||||
import { Utils } from "../../Utils"
|
||||
import { Feature } from "geojson"
|
||||
|
@ -20,7 +20,7 @@ type IntermediateResult = {
|
|||
export default class LocalElementSearch implements GeocodingProvider {
|
||||
private readonly _state: ThemeViewState
|
||||
private readonly _limit: number
|
||||
|
||||
public readonly name = "LocalElementSearch"
|
||||
constructor(state: ThemeViewState, limit: number) {
|
||||
this._state = state
|
||||
this._limit = limit
|
||||
|
|
|
@ -8,6 +8,7 @@ import GeocodingProvider, { GeocodingOptions, SearchResult } from "./GeocodingPr
|
|||
export class NominatimGeocoding implements GeocodingProvider {
|
||||
private readonly _host
|
||||
private readonly limit: number
|
||||
public readonly name = "Nominatim"
|
||||
|
||||
constructor(limit: number = 3, host: string = Constants.nominatimEndpoint) {
|
||||
this.limit = limit
|
||||
|
|
|
@ -8,7 +8,7 @@ export default class OpenLocationCodeSearch implements GeocodingProvider {
|
|||
*/
|
||||
public static readonly _isPlusCode =
|
||||
/^([2-9CFGHJMPQRVWX]{2}|00){2,4}\+([2-9CFGHJMPQRVWX]{2,3})?$/
|
||||
|
||||
public readonly name = "OpenLocationCodeSearch"
|
||||
/**
|
||||
*
|
||||
* OpenLocationCodeSearch.isPlusCode("9FFW84J9+XG") // => true
|
||||
|
@ -26,7 +26,7 @@ export default class OpenLocationCodeSearch implements GeocodingProvider {
|
|||
|
||||
async search(query: string, options?: GeocodingOptions): Promise<GeocodeResult[]> {
|
||||
if (!OpenLocationCodeSearch.isPlusCode(query)) {
|
||||
return undefined
|
||||
return [] // Must be an empty list and not "undefined", the latter is interpreted as 'still searching'
|
||||
}
|
||||
const { latitude, longitude } = pluscode_decode(query)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import OsmObjectDownloader from "../Osm/OsmObjectDownloader"
|
|||
export default class OpenStreetMapIdSearch implements GeocodingProvider {
|
||||
private static readonly regex =
|
||||
/((https?:\/\/)?(www.)?(osm|openstreetmap).org\/)?(n|node|w|way|r|relation)[/ ]?([0-9]+)/
|
||||
|
||||
public readonly name = "OpenStreetMapId"
|
||||
private static readonly types: Readonly<Record<string, "node" | "way" | "relation">> = {
|
||||
n: "node",
|
||||
w: "way",
|
||||
|
|
|
@ -5,7 +5,7 @@ import GeocodingProvider, {
|
|||
GeocodingOptions,
|
||||
GeocodingUtils,
|
||||
ReverseGeocodingProvider,
|
||||
ReverseGeocodingResult,
|
||||
ReverseGeocodingResult
|
||||
} from "./GeocodingProvider"
|
||||
import { Utils } from "../../Utils"
|
||||
import { Feature, FeatureCollection } from "geojson"
|
||||
|
@ -15,6 +15,7 @@ import { Store, Stores } from "../UIEventSource"
|
|||
|
||||
export default class PhotonSearch implements GeocodingProvider, ReverseGeocodingProvider {
|
||||
private readonly _endpoint: string
|
||||
public readonly name = "photon"
|
||||
private supportedLanguages = ["en", "de", "fr"]
|
||||
private static readonly types = {
|
||||
R: "relation",
|
||||
|
|
|
@ -60,7 +60,7 @@ export default class SearchState {
|
|||
return new ImmutableStore(true)
|
||||
}
|
||||
return Stores.concat(suggestions).map((suggestions) =>
|
||||
suggestions.some((list) => list === undefined)
|
||||
suggestions.some((list, i) => list === undefined)
|
||||
)
|
||||
})
|
||||
this.suggestions = suggestionsList.bindD((suggestions) =>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import Translations from "../i18n/Translations"
|
||||
import { Store } from "../../Logic/UIEventSource"
|
||||
import SidebarUnit from "../Base/SidebarUnit.svelte"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import Loading from "../Base/Loading.svelte"
|
||||
import { default as GeocodeResultSvelte } from "./GeocodeResult.svelte"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue