https://github.com/erickit/coordinate
Typescript coordinate class for handling coordinate input and output
https://github.com/erickit/coordinate
Last synced: 8 months ago
JSON representation
Typescript coordinate class for handling coordinate input and output
- Host: GitHub
- URL: https://github.com/erickit/coordinate
- Owner: EricKit
- Created: 2020-03-11T15:32:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-15T23:40:21.000Z (almost 5 years ago)
- Last Synced: 2025-02-22T01:43:56.886Z (over 1 year ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# coordinate
Typescript coordinate class for handling coordinate input and output. If you improve it, please create pull request.
# Usage
Liberally accepts different coordinate types
```typescript
const coordinate = new Coordinate(37.499249, 116.391663);
const sameCoordinate = new Coordinate('37 29.9549 -116 23.4998');
const sameCoordinate2 = new Coordinate('N 37 29.9549 W 116 23.4998');
const sameCoordinate3 = new Coordinate('N 37 29.9549 -116 23.4998');
console.log(coordinate.degreesDecimalDegrees());
// N 37.499249 W 116.391663
console.log(coordinate.degreesMinutesDecimalMinutes());
// N 37 29.9549 W 116 23.4998
console.log(coordinate.degreesMinutesSecondsDecimalSeconds());
// N 37 29 57.3 W 116 29 29.99
console.log(coordinate.toFormat('D.D')); // Or `D M.M` or `D M S.S`
// N 37.499249 W 116.391663
```