https://github.com/vineyardbovines/loxodrome
Geodesy and navigational functions
https://github.com/vineyardbovines/loxodrome
compass-tools geodesy navigation-algorithms
Last synced: 3 months ago
JSON representation
Geodesy and navigational functions
- Host: GitHub
- URL: https://github.com/vineyardbovines/loxodrome
- Owner: vineyardbovines
- Created: 2022-07-22T00:55:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T08:18:19.000Z (over 1 year ago)
- Last Synced: 2024-11-08T01:41:19.529Z (7 months ago)
- Topics: compass-tools, geodesy, navigation-algorithms
- Language: TypeScript
- Homepage:
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# loxodrome
Geodesy and navigational functions
## Usage
Install with the package manager of your choice
```bash
// 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.
| Param | Type | Description | Default |
| ------------ | ------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------ |
| from | [`Coordinates`](/src/types/coordinates.ts) | set of starting coordinates | **Required** |
| to | [`Coordinates`](/src/types/coordinates.ts) | set of ending coordinates | **Required** |
| useRhumbLine | `boolean` | whether or not to calculate along a [rhumb line](https://en.wikipedia.org/wiki/Rhumb_line) | **Required** |### `bearingToDirection(bearing: number, compassPoints: CompassPoints): Windrose`
Converts a bearing to a given compass windrose direction.
| Param | Type | Description | Default |
| ------------- | ---------------------------------------- | ------------------------------- | ------------ |
| bearing | `number` | bearing to convert | **Required** |
| compassPoints | [`CompassPoints`](/src/types/compass.ts) | number of compass points to use | `16` |### `convertDistance({ distance, from, to }): number`
Converts a distance measurement from one distance unit to another.
| Param | Type | Description | Default |
| -------- | ----------------------------------------- | ------------------- | ------------ |
| distance | `number` | distance to convert | **Required** |
| from | [`DistanceUnits`](/src/types/distance.ts) | original unit | **Required** |
| to | [`DistanceUnits`](/src/types/distance.ts) | unit to convert to | **Required** |### `convertSpeed({ speed, from, to }): number`
Converts a speed measurement from one unit to another.
| Param | Type | Description | Default |
| ----- | ----------------------------------- | ------------------ | ------------ |
| speed | `number` | speed to convert | **Required** |
| from | [`SpeedUnits`](/src/types/speed.ts) | original unit | **Required** |
| to | [`SpeedUnits`](/src/types/speed.ts) | unit to convert to | **Required** |### `ddToDMS(dd: number, direction: "latitude" | "longitude"): string`
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** |### `getCenterOfCoordinates(coordinates: Coordinates[]): Coordinates`
Get the latitude and longitude center of an array of coordiantes.
| Param | Type | Description | Default |
| ----------- | -------------------------------------------- | -------------------- | ------------ |
| coordinates | [`Coordinates[]`](/src/types/coordinates.ts) | array of coordinates | **Required** |### `getRhumbLine({ from, to }): number`
Returns the rhumb line between 2 longitudes.
| Param | Type | Description | Default |
| ----- | -------- | ------------------ | ------------ |
| from | `number` | starting longitude | **Required** |
| to | `number` | ending longitude | **Required** |### `getWindroseDirections(compassPoints: CompassPoints): Windrose[]`
Returns an array of windrose directions for a given number of compass points.
| Param | Type | Description | Default |
| ------------- | ---------------------------------------- | ------------------------------- | ------------ |
| compassPoints | [`CompassPoints`](/src/types/compass.ts) | number of compass points to use | **Required** |### `haversine({ from, to, useRhumbLine }): number`
Returns the great-circle distance in kilometers between 2 sets of coordinates using the [haversine formula](https://en.wikipedia.org/wiki/Versine#hav).
| Param | Type | Description | Default |
| ------------ | ------------------------------------------ | ----------------------------------------------------- | ------------ |
| from | [`Coordinates`](/src/types/coordinates.ts) | starting coordinates | **Required** |
| to | [`Coordinates`](/src/types/coordinates.ts) | ending coordinates | **Required** |
| useRhumbLine | `boolean` | whether or not to get the distance along a rhumb line | `false` |### `midpoint({ from, to, useRhumbLine }): Coordinates`
Returns the midpoint coordinate set between 2 coordinates.
| Param | Type | Description | Default |
| ------------ | ------------------------------------------ | ----------------------------------------------------- | ------------ |
| from | [`Coordinates`](/src/types/coordinates.ts) | starting coordinates | **Required** |
| to | [`Coordinates`](/src/types/coordinates.ts) | ending coordinates | **Required** |
| useRhumbLine | `boolean` | whether or not to get the distance along a rhumb line | `false` |### `pointsInRange({ from, to, range }): boolean`
Returns whether or not 2 points are within a certain statue mile distance from each other.
| Param | Type | Description | Default |
| ----- | ------------------------------------------ | ---------------------------- | ------------ |
| from | [`Coordinates`](/src/types/coordinates.ts) | starting coordinates | **Required** |
| to | [`Coordinates`](/src/types/coordinates.ts) | ending coordinates | **Required** |
| range | `number` | statute miles to fall within | `false` |### `vincenty({ from, to }): number`
Returns the geodetic distance in kilometers between 2 points using the [Vincenty inverse formula](https://en.wikipedia.org/wiki/Vincenty%27s_formulae).
| Param | Type | Description | Default |
| ----- | ------------------------------------------ | -------------------- | ------------ |
| from | [`Coordinates`](/src/types/coordinates.ts) | starting coordinates | **Required** |
| to | [`Coordinates`](/src/types/coordinates.ts) | ending coordinates | **Required** |