Reference · Framing, geometry and quiz tools
groundDistancefunction
How far, in metres, two places are from each other, along the ground: the local projection centred half way between them, so within a hair of the ellipsoid up to 400 km. Past 400 km it falls back to the great circle on the mean sphere, which is within 0.5% of the ellipsoid's.
Import it
import { groundDistance } from "@johnmorrisdotca/chizu";
Definition
function groundDistance(a: readonly [number, number], b: readonly [number, number]): number
Parameters
| Name | Type | Description |
|---|---|---|
a | readonly [number, number] | The first place, as [longitude, latitude] in degrees. |
b | readonly [number, number] | The second place, as [longitude, latitude] in degrees. |
Returns
number
The distance along the ground, in metres.
Examples
import { groundDistance } from "@johnmorrisdotca/chizu";
// Tokyo Station to Shinjuku Station, about 6.1 km.
console.log(Math.round(groundDistance([139.7671, 35.6812], [139.7006, 35.6896]) / 100) / 10);
// 6.16.1What it prints (run when this page was built)