https://github.com/mikemitterer/ts-latlong
https://github.com/mikemitterer/ts-latlong
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/mikemitterer/ts-latlong
- Owner: MikeMitterer
- License: other
- Created: 2019-06-27T07:00:51.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-02T03:11:37.000Z (almost 2 years ago)
- Last Synced: 2025-07-16T06:44:42.941Z (about 1 year ago)
- Language: TypeScript
- Size: 5.84 MB
- Stars: 8
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LatLong - Lightweight library for common latitude and longitude calculation
> [Live-Example](#) | [GitHub-Home](https://github.com/MikeMitterer/ts-latlong)
This library supports both, the "Haversine" and the "Vincenty" algorithm.
"Haversine" is a bit faster but "Vincenty" is far more accurate!
[Catmull-Rom algorithm](http://hawkesy.blogspot.co.at/2010/05/catmull-rom-spline-curve-implementation.html) is used for smoothing out the path.
## Basic usage
### Distance
```typescript
const distance = new Distance();
// km = 423
const km = distance.as(LengthUnit.Kilometer,
new LatLng(52.518611,13.408056),new LatLng(51.519475,7.46694444));
// meter = 422591.551
const meter = distance.distance(
new LatLng(52.518611,13.408056),
new LatLng(51.519475,7.46694444)
);
```
## Offset
```typescript
const distance = new Distance();
const distanceInMeter = Math.round(EARTH_RADIUS * Math.PI / 4));
const p1 = new LatLng(0.0, 0.0);
const p2 = distance.offset(p1, distanceInMeter, 180);
// LatLng(latitude:-45.219848, longitude:0.0)
console.log(p2.round());
// 45° 13' 11.45" S, 0° 0' 0.00" O
console.log(p2.toSexagesimal());
```
## Path smoothing
```typescript
// zigzag is a list of coordinates
const path = new Path.from(zigzag);
// Result is below
const steps = path.equalize(8,smoothPath: true);
```
For more - check out my tests