https://github.com/danielkov/geodaisy
🌎Geolocation related algorithms for browser and web
https://github.com/danielkov/geodaisy
Last synced: 11 months ago
JSON representation
🌎Geolocation related algorithms for browser and web
- Host: GitHub
- URL: https://github.com/danielkov/geodaisy
- Owner: danielkov
- License: mit
- Created: 2020-03-20T11:32:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-04-30T19:31:29.000Z (about 1 year ago)
- Last Synced: 2025-04-30T20:37:04.608Z (about 1 year ago)
- Language: TypeScript
- Size: 2.79 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 🌎Geodaisy - simple geodesic utilities for NodeJS and Web
## Get started
```bash
npm install geodaisy
```
Usage in JavaScript or TypeScript (typings are available):
### Distance utilities - Haversine
Uses the [Haversine Formula](https://en.wikipedia.org/wiki/Haversine_formula) to calculate the distance between two earthly points of coordinates.
```ts
import { haversine } from 'geodaisy';
const atlanta = {
latitude: 33.749,
longitude: -84.388,
};
const london = {
latitude: 51.5074,
longitude: -0.1278,
};
const distance = haversine(
atlanta.longitude,
atlanta.latitude,
london.longitude,
london.latitude,
);
console.log(distance); // > 6769.949658450232
```
### Distance utilities - distanceWithLatitude
Given a distance as a number (this formula does not care about units) and the distance between the elevation change between two points - calculates the real distance between the two points in a straight line, e.g.:
```ts
import { distanceWithLatitude } from 'geodaisy';
const distance = 13800; // m
const elevation = 1120; // m
const realDistance = distanceWithLatitude(distance, elevation);
console.log(realDistance); // > 13845.374678931588
```
### Conversion utilities
The following conversion utilities are also available:
```ts
import {
kmToMile,
mileToKm,
yardToMetre,
metreToYard,
inchToCm,
cmToInch,
} from 'geodaisy';
console.log(kmToMile(1)); // > 0.621371
console.log(mileToKm(1)); // > 1.6093444978925633
console.log(yardToMetre(1)); // > 0.9144
console.log(metreToYard(1)); // > 1.0936132983377078
console.log(inchToCm(1)); // > 2.54
console.log(cmToInch(1)); // > 0.39370078740157477
```
### Missing features
The following features I'd love to have in this library but just don't have the time to implement yet. If you'd like to help, feel free to contribute!
- [ ] Bearing calculation
- [ ] Destination point calculation
- [ ] Intersection calculation
- [ ] Path finding
- [ ] Closest point to the poles
- [ ] Rhumb lines
- [ ] Vincenty's formula