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
)
This module will be useful to quickly convert an GPS coordinates into a local coordinates relative to the origin point.
Example
Typescript
;const origin: GpsPoint =lat: 35826869lng: 139688460;const p1: GpsPoint =lat: 35826910lng: 139688578;const haversine = origin;haversine; // [10.650280913694724, 4.564105542903945]haversine; // 11.587042027514038 mhaversine; // 66.80277554567647 deg// Using as static methodHaversine; // [10.650280913694724, 4.564105542903945]Haversine; // 11.587042027514038 mHaversine; // 66.80277554567647 deg
Javascript
const Haversine = Haversine;const origin =lat: 35826869lng: 139688460;const p1 =lat: 35826910lng: 139688578;const haversine = origin;haversine; // [10.650280913694724, 4.564105542903945]haversine; // 11.587042027514038 mhaversine; // 66.80277554567647 deg// Using as static methodHaversine; // [10.650280913694724, 4.564105542903945]Haversine; // 11.587042027514038 mHaversine; // 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