mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 03:31:47 +00:00
haversine: add format support
haversine now supports supplying coordinates in a variety of formats
This commit is contained in:
Vendored
+25
-3
@@ -4,10 +4,28 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace haversine {
|
||||
interface Coordinate {
|
||||
interface CoordinateLongNames {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
}
|
||||
|
||||
interface CoordinateShortNames {
|
||||
lat: number;
|
||||
lon: number;
|
||||
}
|
||||
|
||||
interface LatLonTuple extends Array<number> {
|
||||
0: number;
|
||||
1: number;
|
||||
}
|
||||
|
||||
interface GeoJSON {
|
||||
geometry: {
|
||||
coordinates: LatLonTuple
|
||||
}
|
||||
}
|
||||
|
||||
type coordinate = (CoordinateLongNames | CoordinateShortNames | LatLonTuple | GeoJSON);
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
@@ -18,6 +36,10 @@ declare namespace haversine {
|
||||
* If passed, will result in library returning boolean value of whether or not the start and end points are within that supplied threshold. Default: null.
|
||||
*/
|
||||
threshold?: number;
|
||||
/**
|
||||
* Format of coordinate arguments.
|
||||
*/
|
||||
format?: '[lat,lon]' | '[lon,lat]' | '{lon,lat}' | 'geojson'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +47,8 @@ declare namespace haversine {
|
||||
* Determines the great-circle distance between two points on a sphere given their longitudes and latitudes
|
||||
*/
|
||||
declare function haversine(
|
||||
start: haversine.Coordinate,
|
||||
end: haversine.Coordinate,
|
||||
start: coordinate,
|
||||
end: coordinate,
|
||||
options?: haversine.Options
|
||||
): number;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user