diff --git a/types/haversine/haversine-tests.ts b/types/haversine/haversine-tests.ts index b7238fbd15..2bfac64856 100644 --- a/types/haversine/haversine-tests.ts +++ b/types/haversine/haversine-tests.ts @@ -1,11 +1,11 @@ import haversine = require('haversine'); -const start: haversine.CoordinateLongNames = { +const start = { longitude: 48.1548256, latitude: 11.4017529 }; -const end: haversine.CoordinateLongNames = { +const end = { longitude: 52.5065133, latitude: 13.1445551 }; @@ -17,19 +17,17 @@ const options: haversine.Options = { haversine(start, end, options); -const startShort: haversine.CoordinateShortNames = { +const startShort = { lon: 48.1548256, lat: 11.4017529 }; -const endShort: haversine.CoordinateShortNames = { +const endShort = { lon: 52.5065133, lat: 13.1445551 }; const optionsShort: haversine.Options = { - unit: 'km', - threshold: 1, format: '{lon,lat}' }; @@ -40,9 +38,29 @@ const startLatLon: haversine.LatLonTuple = [11.4017529, 48.1548256]; const endLatLon: haversine.LatLonTuple = [13.1445551, 52.5065133]; const optionsLatLon: haversine.Options = { - unit: 'km', - threshold: 1, format: '[lat,lon]' }; haversine(startLatLon, endLatLon, optionsLatLon); + +const startGeoJSON = { + type: "Feature", + geometry: { + type: "LineString", + coordinates: startLatLon + } +}; + +const endGeoJSON = { + type: "Feature", + geometry: { + type: "LineString", + coordinates: endLatLon + } +}; + +const optionsGeoJSON: haversine.Options = { + format: 'geojson' +}; + +haversine(startGeoJSON, endGeoJSON, optionsGeoJSON); diff --git a/types/haversine/index.d.ts b/types/haversine/index.d.ts index e5ddb1273c..d828b8eb5a 100644 --- a/types/haversine/index.d.ts +++ b/types/haversine/index.d.ts @@ -4,20 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace haversine { - interface CoordinateLongNames { - longitude: number; - latitude: number; - } - - interface CoordinateShortNames { - lat: number; - lon: number; - } - - interface LatLonTuple extends Array { - 0: number; - 1: number; - } + type LatLonTuple = [number, number]; interface GeoJSON { geometry: { @@ -25,7 +12,13 @@ declare namespace haversine { }; } - type Coordinate = (CoordinateLongNames | CoordinateShortNames | LatLonTuple | GeoJSON); + type Coordinate = ({ + longitude: number; + latitude: number; + } | { + lat: number; + lon: number; + } | LatLonTuple | GeoJSON); interface Options { /**