Geodesy and navigational functions
Install with the package manager of your choice
// or yarn or pnpm
npm install @gretzky/loxodrome
Returns the initial and final bearing distance between 2 points.
Param | Type | Description | Default |
---|---|---|---|
from | Coordinates |
set of starting coordinates | Required |
to | Coordinates |
set of ending coordinates | Required |
useRhumbLine | boolean |
whether or not to calculate along a rhumb line | Required |
Converts a bearing to a given compass windrose direction.
Param | Type | Description | Default |
---|---|---|---|
bearing | number |
bearing to convert | Required |
compassPoints | CompassPoints |
number of compass points to use | 16 |
Converts a distance measurement from one distance unit to another.
Param | Type | Description | Default |
---|---|---|---|
distance | number |
distance to convert | Required |
from | DistanceUnits |
original unit | Required |
to | DistanceUnits |
unit to convert to | Required |
Converts a speed measurement from one unit to another.
Param | Type | Description | Default |
---|---|---|---|
speed | number |
speed to convert | Required |
from | SpeedUnits |
original unit | Required |
to | SpeedUnits |
unit to convert to | Required |
Converts decimal degrees to decimal minutes
Param | Type | Description | Default |
---|---|---|---|
degrees | number |
decimal degrees to convert | Required |
direction | "latitude" or "longitude" |
direction of the degrees | Required |
Get the latitude and longitude center of an array of coordiantes.
Param | Type | Description | Default |
---|---|---|---|
coordinates | Coordinates[] |
array of coordinates | Required |
Returns the rhumb line between 2 longitudes.
Param | Type | Description | Default |
---|---|---|---|
from | number |
starting longitude | Required |
to | number |
ending longitude | Required |
Returns an array of windrose directions for a given number of compass points.
Param | Type | Description | Default |
---|---|---|---|
compassPoints | CompassPoints |
number of compass points to use | Required |
Returns the great-circle distance in kilometers between 2 sets of coordinates using the haversine formula.
Param | Type | Description | Default |
---|---|---|---|
from | Coordinates |
starting coordinates | Required |
to | Coordinates |
ending coordinates | Required |
useRhumbLine | boolean |
whether or not to get the distance along a rhumb line | false |
Returns the midpoint coordinate set between 2 coordinates.
Param | Type | Description | Default |
---|---|---|---|
from | Coordinates |
starting coordinates | Required |
to | Coordinates |
ending coordinates | Required |
useRhumbLine | boolean |
whether or not to get the distance along a rhumb line | false |
Returns whether or not 2 points are within a certain statue mile distance from each other.
Param | Type | Description | Default |
---|---|---|---|
from | Coordinates |
starting coordinates | Required |
to | Coordinates |
ending coordinates | Required |
range | number |
statute miles to fall within | false |
Returns the geodetic distance in kilometers between 2 points using the Vincenty inverse formula.
Param | Type | Description | Default |
---|---|---|---|
from | Coordinates |
starting coordinates | Required |
to | Coordinates |
ending coordinates | Required |