0.2.1 • Published 2 years ago

@gretzky/loxodrome v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

loxodrome

Geodesy and navigational functions

Usage

Install with the package manager of your choice

// or yarn or pnpm
npm install @gretzky/loxodrome

API

bearingDistanceTo({ from, to, useRhumbLine }): { initialBearing: number; finalBearing: number }

Returns the initial and final bearing distance between 2 points.

ParamTypeDescriptionDefault
fromCoordinatesset of starting coordinatesRequired
toCoordinatesset of ending coordinatesRequired
useRhumbLinebooleanwhether or not to calculate along a rhumb lineRequired

bearingToDirection(bearing: number, compassPoints: CompassPoints): Windrose

Converts a bearing to a given compass windrose direction.

ParamTypeDescriptionDefault
bearingnumberbearing to convertRequired
compassPointsCompassPointsnumber of compass points to use16

convertDistance({ distance, from, to }): number

Converts a distance measurement from one distance unit to another.

ParamTypeDescriptionDefault
distancenumberdistance to convertRequired
fromDistanceUnitsoriginal unitRequired
toDistanceUnitsunit to convert toRequired

convertSpeed({ speed, from, to }): number

Converts a speed measurement from one unit to another.

ParamTypeDescriptionDefault
speednumberspeed to convertRequired
fromSpeedUnitsoriginal unitRequired
toSpeedUnitsunit to convert toRequired

ddToDMS(dd: number, direction: "latitude" | "longitude"): string

Converts decimal degrees to decimal minutes

ParamTypeDescriptionDefault
degreesnumberdecimal degrees to convertRequired
direction"latitude" or "longitude"direction of the degreesRequired

getCenterOfCoordinates(coordinates: Coordinates[]): Coordinates

Get the latitude and longitude center of an array of coordiantes.

ParamTypeDescriptionDefault
coordinatesCoordinates[]array of coordinatesRequired

getRhumbLine({ from, to }): number

Returns the rhumb line between 2 longitudes.

ParamTypeDescriptionDefault
fromnumberstarting longitudeRequired
tonumberending longitudeRequired

getWindroseDirections(compassPoints: CompassPoints): Windrose[]

Returns an array of windrose directions for a given number of compass points.

ParamTypeDescriptionDefault
compassPointsCompassPointsnumber of compass points to useRequired

haversine({ from, to, useRhumbLine }): number

Returns the great-circle distance in kilometers between 2 sets of coordinates using the haversine formula.

ParamTypeDescriptionDefault
fromCoordinatesstarting coordinatesRequired
toCoordinatesending coordinatesRequired
useRhumbLinebooleanwhether or not to get the distance along a rhumb linefalse

midpoint({ from, to, useRhumbLine }): Coordinates

Returns the midpoint coordinate set between 2 coordinates.

ParamTypeDescriptionDefault
fromCoordinatesstarting coordinatesRequired
toCoordinatesending coordinatesRequired
useRhumbLinebooleanwhether or not to get the distance along a rhumb linefalse

pointsInRange({ from, to, range }): boolean

Returns whether or not 2 points are within a certain statue mile distance from each other.

ParamTypeDescriptionDefault
fromCoordinatesstarting coordinatesRequired
toCoordinatesending coordinatesRequired
rangenumberstatute miles to fall withinfalse

vincenty({ from, to }): number

Returns the geodetic distance in kilometers between 2 points using the Vincenty inverse formula.

ParamTypeDescriptionDefault
fromCoordinatesstarting coordinatesRequired
toCoordinatesending coordinatesRequired
0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago