mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(geo): wrap longitude differences across the antimeridian in point distances (#1304)
Wrap longitude differences in annotation proximity checks and nearby-place distances so points across the antimeridian remain close. Original contribution by quanticsoul4772. Co-authored-by: quanticsoul4772 <[email protected]>
This commit is contained in:
1 parent
9d3548c27c
commit
07318cc9a4
6 files changed
+48
-2
No files matched your search
@@ -250,10 +250,13 @@ export function approximateAreaM2(coords) {
|
||||
return Math.abs(area) / 2;
|
||||
}
|
||||
|
||||
/** Local equirectangular distance in metres, the short way round 180°. */
|
||||
export function approximateDistanceM(latA, lonA, latB, lonB) {
|
||||
const latScale = 111_320;
|
||||
const lonScale = latScale * Math.cos(((latA + latB) / 2) * (Math.PI / 180));
|
||||
return Math.hypot((latB - latA) * latScale, (lonB - lonA) * lonScale);
|
||||
let dLon = lonB - lonA;
|
||||
dLon -= 360 * Math.round(dLon / 360);
|
||||
return Math.hypot((latB - latA) * latScale, dLon * lonScale);
|
||||
}
|
||||
|
||||
export function pointInPolygon(lon, lat, coords) {
|
||||
|
||||
Reference in new issue
Block a user