Power Query, Haversine Funktion, Ermittlung Distanz in km zwischen 2 Städten
über Datentyp Geographie kann Breiten- und Längengrad einer Stadt ermittelt werden
fxHaversineDistanz
--- SCHNIPP ---
let
HaversineDistance = (lat1 as number, lon1 as number, lat2 as number, lon2 as number) =>
let
R = 6371, // Erdradius in km
deg2rad = (deg) => deg * (2 * Number.PI) / 360,
dLat = deg2rad(lat2 - lat1),
dLon = deg2rad(lon2 - lon1),
a = Number.Power(Number.Sin((dLat / 2)),2) + Number.Cos((deg2rad(lat1))) * Number.Cos((deg2rad(lat2))) * Number.Power(Number.Sin((dLon / 2)),2),
c = 2 * Number.Atan2(Number.Sqrt(a), Number.Sqrt(1 - a)),
distance = R * c
in
distance
in
HaversineDistance
--- SCHNAPP ---
Kommentare
Kommentar veröffentlichen