Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haimkastner/geodesy-js
A lightweight library represents a location with an easy to use API (using unitsnet-js API).
https://github.com/haimkastner/geodesy-js
Last synced: about 17 hours ago
JSON representation
A lightweight library represents a location with an easy to use API (using unitsnet-js API).
- Host: GitHub
- URL: https://github.com/haimkastner/geodesy-js
- Owner: haimkastner
- License: bsd-3-clause
- Created: 2019-12-29T07:59:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:23:25.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T01:08:28.472Z (7 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/geodesy-js
- Size: 340 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# geodesy-js
A lightweight library represents a location with an easy to use API (using [unitsnet-js](https://www.npmjs.com/package/unitsnet-js) units structs).
Supports getting the curve between two locations and getting a destination location based on curve data.
> The calculations is from the great [Geodesy](https://github.com/juergenpf/Geodesy) project.
[![CI CD Status](https://github.com/haimkastner/geodesy-js/workflows/geodesy-js/badge.svg?branch=master)](https://github.com/haimkastner/geodesy-js/actions)
[![Tests Coverage Status](https://coveralls.io/repos/github/haimkastner/geodesy-js/badge.svg?branch=master)](https://coveralls.io/github/haimkastner/geodesy-js?branch=master)## Install via NPM:
```bash
npm install geodesy-js
```
## Using examples
Example with the class driven API
```typescript
import { GeoLocation } from 'geodesy-js';
import { Angle, Length } from 'unitsnet-js';// Create a world location
const location = new GeoLocation({
Latitude: Angle.FromDegrees(32),
Longitude: Angle.FromDegrees(35),
});// Get a location based on the curve from the location
const destinationLocation = location.destination(Angle.FromDegrees(10), Length.FromMeters(3000));console.log(`The destination coordinates:`);
console.log(`Latitude: ${destinationLocation.Latitude.toString()}`); // Latitude: 32.026643406143805 °
console.log(`Longitude: ${destinationLocation.Longitude.toString()}`); // Longitude: 35.005514633016986 °// Get the distance between the location and the destinationLocation.
const distance = location.distance(destinationLocation);
console.log(`The distance: ${distance.toString()}`); // The distance: 2999.998518387958 m// Get the curve (distance & azimuth) between the location and the destinationLocation.
const curve = location.curve(destinationLocation);
console.log(`The curve:`);
console.log(`Distance: ${curve.Distance.toString()}`); // Distance: 2999.998518387958 m
console.log(`Azimuth: ${curve.Azimuth.toString()}`); // Azimuth: 9.999999999995072 °
```Example with the methods driven API
```typescriptimport { GeoPoint, getDestinationGeoPoint, getDistance, getGeoPointsCurve } from 'geodesy-js';
import { Angle, Length } from 'unitsnet-js';// Create a world location
const location: GeoPoint = {
Latitude: Angle.FromDegrees(32),
Longitude: Angle.FromDegrees(35),
};// Get a location based on the curve from the location
const destinationLocation = getDestinationGeoPoint(location, Angle.FromDegrees(10), Length.FromMeters(3000));console.log(`The destination coordinates:`);
console.log(`Latitude: ${destinationLocation.Latitude.toString()}`); // Latitude: 32.026643406143805 °
console.log(`Longitude: ${destinationLocation.Longitude.toString()}`); // Longitude: 35.005514633016986 °// Get the distance between the location and the destinationLocation.
const distance = getDistance(location, destinationLocation);
console.log(`The distance: ${distance.toString()}`); // The distance: 2999.998518387958 m// Get the curve (distance & azimuth) between the location and the destinationLocation.
const curve = getGeoPointsCurve(location, destinationLocation);
console.log(`The curve:`);
console.log(`Distance: ${curve.Distance.toString()}`); // Distance: 2999.998518387958 m
console.log(`Azimuth: ${curve.Azimuth.toString()}`); // Azimuth: 9.999999999995072 °
```> Currently the library supports only WGS84 datum.