Fix tests

This commit is contained in:
Pieter Vander Vennet 2024-08-21 17:52:22 +02:00
parent 00ad21d5ef
commit b4866cdbac
2 changed files with 8 additions and 6 deletions

View file

@ -908,9 +908,11 @@ export class GeoOperations {
}
/**
* GeoOperations.distanceToHuman(52.8) // => "50m"
* GeoOperations.distanceToHuman(52.3) // => "50m"
* GeoOperations.distanceToHuman(2800) // => "2.8km"
* GeoOperations.distanceToHuman(12800) // => "13km"
* GeoOperations.distanceToHuman(128000) // => "130km"
*
*
* @param meters
*/
@ -924,7 +926,7 @@ export class GeoOperations {
}
if (meters >= 10000) {
const km = Utils.roundHuman(meters / 1000)
const km = Utils.roundHuman(Math.round(meters / 1000))
return km + "km"
}

View file

@ -24,18 +24,18 @@ export default class CoordinateSearch implements GeocodingProvider {
* const ls = new CoordinateSearch()
* const results = await ls.search("https://www.openstreetmap.org/search?query=Brugge#map=11/51.2611/3.2217")
* results.length // => 1
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611"}
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611", "category": "coordinate","source": "coordinateSearch"}
*
* const ls = new CoordinateSearch()
* const results = await ls.search("https://www.openstreetmap.org/#map=11/51.2611/3.2217")
* results.length // => 1
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611"}
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611", "category": "coordinate","source": "coordinateSearch"}
*
* const ls = new CoordinateSearch()
* const results = await ls.search("51.2611 3.2217")
* results.length // => 2
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611"}
* results[1] // => {lon: 51.2611, lat: 3.2217, display_name: "lon: 51.2611, lat: 3.2217"}
* results[0] // => {lat: 51.2611, lon: 3.2217, display_name: "lon: 3.2217, lat: 51.2611", "category": "coordinate", "source": "coordinateSearch"}
* results[1] // => {lon: 51.2611, lat: 3.2217, display_name: "lon: 51.2611, lat: 3.2217", "category": "coordinate", "source": "coordinateSearch"}
*
*/
async search(query: string, options?: GeocodingOptions): Promise<GeoCodeResult[]> {