Distance and Bearing: Difference between revisions

m
Line 147:
| ($pi * (lon2 - lon1) / 180) as $raddlon
| ( ($raddlon|sin) * ($radlat2|cos) ) as $y
| (($radlat1|cos) * ($radlat2|sin) - ($radlat1|sin) * ($radlat2|cos) * ($raddlon|cos)) as $x
($radlat1|sin) * ($radlat2|cos) * ($raddlon|cos)) as $x
| ((atan2($y;$x) * 180 / $pi) + 360) % 360
end;
Line 155 ⟶ 156:
airports as $airports
| reduce $airports[] as $a ([];
((calculateDistance($X; $Y; $a.latitude; $a.longitude; "N") * 10 | round) / 10) as $dist
/ 10) as $dist
| (calculateBearing($X; $Y; $a.latitude; $a.longitude)|round ) as $bear
| . + [ [$a.name, $a.country, $a.icao, $dist, $bear] ] ) ;
Line 167 ⟶ 169:
# Example:
def display($n):
"Closest 20\($n) destinations relative to position \(.[0]), \(.[1]):",
"",
" Name | Country | ICAO | Distance in NM | Bearing in ° ",
2,469

edits