# haversine-position

> Convert GPS coordinates into local coordinate system relative to the origin with output of [x, y] in meter, bearing(degree) and distance(m)

Latest version **1.0.3** (published 2017-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install haversine-position
pnpm add haversine-position
yarn add haversine-position
bun add haversine-position
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-03-31 |
| First published | 2017-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Tim |
| Maintainers | timx |
| Keywords | haversine, gps, distance, geolocation, coordinates |

## Links

- npm: https://www.npmjs.com/package/haversine-position
- Repository: https://github.com/sweetim/haversine-position
- Homepage: https://github.com/sweetim/haversine-position#readme
- Issues: https://github.com/sweetim/haversine-position/issues
- npm.io page: https://npm.io/package/haversine-position

## Dependencies (1)

- [wgs84](https://npm.io/package/wgs84.md) 0.0.0

## Recent versions

- 1.0.3 (latest) — 2017-03-31
- 1.0.2 — 2017-03-30
- 1.0.1 — 2017-03-30
- 1.0.0 — 2017-03-30

## README

## Haversine Position 
[![Build Status](https://travis-ci.org/sweetim/haversine-position.svg?branch=master)](https://travis-ci.org/sweetim/haversine-position)
[![codecov](https://codecov.io/gh/sweetim/haversine-position/branch/master/graph/badge.svg)](https://codecov.io/gh/sweetim/haversine-position)
[![devDependency Status](https://david-dm.org/sweetim/haversine-position/dev-status.svg)](https://david-dm.org/sweetim/haversine-position#info=devDependencies)

Convert GPS coordinates into local coordinate system relative to the origin with output of `[x, y]` in `meter`, bearing(`degree`) and distance(`m`)

This module will be useful to quickly convert an GPS coordinates into a local coordinates relative to the origin point.

### Example

#### Typescript
``` javascript
import { Haversine, GpsPoint } from 'haversine-position';

const origin: GpsPoint = {
    lat: 35.826869, 
    lng: 139.688460
};

const p1: GpsPoint = {
    lat: 35.826910, 
    lng: 139.688578
};

const haversine = new Haversine(origin);
haversine.getPosition(p1); // [10.650280913694724, 4.564105542903945]
haversine.getDistance(p1); // 11.587042027514038 m 
haversine.getBearing(p1); // 66.80277554567647 deg

// Using as static method
Haversine.getPosition(origin, p1); // [10.650280913694724, 4.564105542903945]
Haversine.getDistance(origin, p1); // 11.587042027514038 m 
Haversine.getBearing(origin, p1); // 66.80277554567647 deg

```

#### Javascript
``` javascript
const Haversine = require('haversine-position').Haversine;

const origin = {
    lat: 35.826869, 
    lng: 139.688460
};

const p1 = {
    lat: 35.826910, 
    lng: 139.688578
};

const haversine = new Haversine(origin);
haversine.getPosition(p1); // [10.650280913694724, 4.564105542903945]
haversine.getDistance(p1); // 11.587042027514038 m 
haversine.getBearing(p1); // 66.80277554567647 deg

// Using as static method
Haversine.getPosition(origin, p1); // [10.650280913694724, 4.564105542903945]
Haversine.getDistance(origin, p1); // 11.587042027514038 m 
Haversine.getBearing(origin, p1); // 66.80277554567647 deg

```

### API
#### Haversine.getPosition(origin, next)
Return an array of position `[x, y]` in meter relative to the origin point

#### Haversine.getDistance(origin, next)
Return the distance relative to the origin in `meter`

#### Haversine.getBearing(origin, next)
Return the bearing relative to the origin in `degree`

---
_Source: https://npm.io/package/haversine-position · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
