forked from MapComplete/MapComplete
parent
d313153f4c
commit
c0d1cabac0
2 changed files with 26 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ import { ImmutableStore, Store } from "../UIEventSource"
|
|||
*/
|
||||
export default class CoordinateSearch implements GeocodingProvider {
|
||||
private static readonly latLonRegexes: ReadonlyArray<RegExp> = [
|
||||
/(-?[0-9]+\.[0-9]+)[ ,;]+(-?[0-9]+\.[0-9]+)/,
|
||||
/^(-?[0-9]+\.[0-9]+)[ ,;/\\]+(-?[0-9]+\.[0-9]+)/,
|
||||
/lat[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?[ ,;&]+lon[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?/,
|
||||
/lat[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?[ ,;&]+lng[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?/,
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ export default class CoordinateSearch implements GeocodingProvider {
|
|||
]
|
||||
|
||||
private static readonly lonLatRegexes: ReadonlyArray<RegExp> = [
|
||||
/(-?[0-9]+\.[0-9]+)[ ,;]+(-?[0-9]+\.[0-9]+)/,
|
||||
/^(-?[0-9]+\.[0-9]+)[ ,;/\\]+(-?[0-9]+\.[0-9]+)/,
|
||||
/lon[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?[ ,;&]+lat[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?/,
|
||||
/lng[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?[ ,;&]+lat[:=]? *['"]?(-?[0-9]+\.[0-9]+)['"]?/,
|
||||
|
||||
|
|
@ -40,6 +40,13 @@ export default class CoordinateSearch implements GeocodingProvider {
|
|||
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611", "category": "coordinate", "source": "coordinate:latlon"}
|
||||
* results[1] // => {lon: 51.2611, lat: 3.2217, display_name: "lon: 51.2611, lat: 3.2217", "category": "coordinate", "source": "coordinate:lonlat"}
|
||||
*
|
||||
* // Test format mentioned in 1599
|
||||
* const ls = new CoordinateSearch()
|
||||
* const results = ls.directSearch("51.2611/3.2217")
|
||||
* results.length // => 2
|
||||
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611", "category": "coordinate", "source": "coordinate:latlon"}
|
||||
* results[1] // => {lon: 51.2611, lat: 3.2217, display_name: "lon: 51.2611, lat: 3.2217", "category": "coordinate", "source": "coordinate:lonlat"}
|
||||
*
|
||||
* // test OSM-XML format
|
||||
* const ls = new CoordinateSearch()
|
||||
* const results = ls.directSearch(' lat="57.5802905" lon="12.7202538"')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue