einsatzprotokoll/source/Haversine.mc
EiSiMo 43f970d764 Phase 1: foundation modules
Central Config with all tunables (retention, GPS timeout, colors,
event type keys, menu item metadata). Event / EventStore handle
persistence via Application.Storage with 7-day pruning. Logger
mirrors the same retention. LayoutMetrics and Haversine provide
resolution-independent geometry helpers. German UI strings and
placeholder menu icons landed alongside so the build stays green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 19:36:15 +02:00

25 lines
774 B
MonkeyC

import Toybox.Lang;
import Toybox.Math;
// Great-circle distance between two WGS84 coordinates, in meters.
module Haversine {
const EARTH_RADIUS_M = 6371000.0;
function distance(lat1 as Float, lon1 as Float, lat2 as Float, lon2 as Float) as Float {
var dLat = _toRad(lat2 - lat1);
var dLon = _toRad(lon2 - lon1);
var rLat1 = _toRad(lat1);
var rLat2 = _toRad(lat2);
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
+ Math.cos(rLat1) * Math.cos(rLat2)
* Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.asin(Math.sqrt(a));
return (EARTH_RADIUS_M * c).toFloat();
}
function _toRad(deg as Float) as Float {
return (deg * Math.PI / 180.0).toFloat();
}
}