@scratching-platypus/geodesy-ts
v1.0.0
Published
Vincenty’s formula in TypeScript for computing distances and azimuths between geographic coordinates.
Maintainers
Readme
@scratching-platypus/geodesy-ts
Vincenty’s formula in TypeScript for computing distances and azimuths between geographic coordinates.
Install
npm install @scratching-platypus/geodesy-tsTypes
export type Ellipsoid = {
a: number; // semi-major axis
b: number; // semi-minor axis
f: number; // flattening
};type GeodesicForwardResult = {
coordinate: Coordinate; // target coordinate
finalAzimuth: number; // target direction
};type GeodesicInverseResult = {
distance: number; // distance between A and B (meters)
initialAzimuth: number; // azimuth A -> B (degrees)
finalAzimuth: number; // azimuth B -> A (degrees)
};Coordinate is provided by @scratching-platypus/coordinate-ts
Geodesy
All geodesic functions accept an optional ellipsoid parameter. If omitted, the WGS84 ellipsoid is used by default.
import { vincentyInverse } from "@scratching-platypus/geodesy-ts";
vincentyInverse(A, B) // implicit WGS84
vincentyInverse(A, B, GRS80) // custom ellipsoid
vincentyInverse(A, B, { a: 1: b: 1: f: 0 }) // sphereimport { vincentyForward } from "@scratching-platypus/geodesy-ts";
vincentyForward(A, initialAzimuth, direction) // implicit WGS84
vincentyForward(A, initialAzimuth, direction, GRS80) // custom ellipsoid
vincentyForward(A, initialAzimuth, direction, { a: 1: b: 1: f: 0 }) // sphere