mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
The flights records and the mesh-floor sampler kept identical copies of the equirectangular distance; both now import src/data/approxDistance.js. The changelog entry moves to changelog.d (#787), and CURRENT-STATE notes the antimeridian behaviour.
13 lines
445 B
JavaScript
13 lines
445 B
JavaScript
/**
|
|
* Local equirectangular distance in km, for viewer-proximity gates. Takes the
|
|
* short way round, so points either side of 180° stay close.
|
|
*/
|
|
export function approxDistanceKm(lat1, lon1, lat2, lon2) {
|
|
const dLat = (lat2 - lat1) * 111.32;
|
|
let dLonDeg = lon2 - lon1;
|
|
dLonDeg -= 360 * Math.round(dLonDeg / 360);
|
|
const dLon =
|
|
dLonDeg * 111.32 * Math.cos((((lat1 + lat2) / 2) * Math.PI) / 180);
|
|
return Math.hypot(dLat, dLon);
|
|
}
|