Refactoring: move all code files into a src directory

This commit is contained in:
Pieter Vander Vennet 2023-07-09 13:09:05 +02:00
parent de99f56ca8
commit e75d2789d2
389 changed files with 0 additions and 12 deletions

View file

@ -0,0 +1,30 @@
import { Utils } from "../../Utils"
import { BBox } from "../BBox"
export interface GeoCodeResult {
display_name: string
lat: number
lon: number
/**
* Format:
* [lat, lat, lon, lon]
*/
boundingbox: number[]
osm_type: "node" | "way" | "relation"
osm_id: string
}
export class Geocoding {
private static readonly host = "https://nominatim.openstreetmap.org/search?"
static async Search(query: string, bbox: BBox): Promise<GeoCodeResult[]> {
const b = bbox ?? BBox.global
const url =
Geocoding.host +
"format=json&limit=1&viewbox=" +
`${b.getEast()},${b.getNorth()},${b.getWest()},${b.getSouth()}` +
"&accept-language=nl&q=" +
query
return Utils.downloadJson(url)
}
}