Distance and Bearing: Difference between revisions

Content added Content deleted
Line 215: Line 215:
my(D = vector(#M[,1]), R = matrix(r+1, 5));
my(D = vector(#M[,1]), R = matrix(r+1, 5));
R[1,1] = "NAME"; R[1,2] = "COUNTRY"; R[1,3] = "ICAO"; R[1,4] = "DISTANCE"; R[1,5] = "BEARING";
R[1,1] = "NAME"; R[1,2] = "COUNTRY"; R[1,3] = "ICAO"; R[1,4] = "DISTANCE"; R[1,5] = "BEARING";
printf("%-36s%-18s\t%-5s\t%s\t%s\n", R[1,1], R[1,2], R[1,3], R[1,4], R[1,5]);
printf("%-38s\t%-16s\t%-4s\t%s\t%s\n", R[1,1], R[1,2], R[1,3], R[1,4], R[1,5]);
for(i = 1, #M[,1],
for(i = 1, #M[,1],
D[i] = [distance(lat, lon, M[i,7], M[i,8], unit) , i];
D[i] = [distance(lat, lon, M[i,7], M[i,8], unit) , i];
Line 223: Line 223:
R[i+1,1] = M[D[i][2],2]; R[i+1,2] = M[D[i][2],4]; R[i+1,3] = M[D[i][2],6];
R[i+1,1] = M[D[i][2],2]; R[i+1,2] = M[D[i][2],4]; R[i+1,3] = M[D[i][2],6];
R[i+1,4] = D[i][1]; R[i+1,5] = bearing(lat, lon, M[D[i][2],7], M[D[i][2],8]);
R[i+1,4] = D[i][1]; R[i+1,5] = bearing(lat, lon, M[D[i][2],7], M[D[i][2],8]);
printf("%-36s%-18s\t%-5s\t%.1f\t\t%.0f\n", R[i+1,1], R[i+1,2], R[i+1,3], R[i+1,4], R[i+1,5]);
printf("%-38s\t%-16s\t%-4s\t%8.1f\t%7.0f\n", R[i+1,1], R[i+1,2], R[i+1,3], R[i+1,4], R[i+1,5]);
);
);
}
}
Line 229: Line 229:
request(51.514669, 2.198581)</syntaxhighlight>
request(51.514669, 2.198581)</syntaxhighlight>
{{out}}
{{out}}
<pre>NAME COUNTRY ICAO DISTANCE BEARING
<pre>NAME COUNTRY ICAO DISTANCE BEARING
Koksijde Air Base Belgium EBFN 30.7 146
Koksijde Air Base Belgium EBFN 30.7 146
Ostend-Bruges International Airport Belgium EBOS 31.3 127
Ostend-Bruges International Airport Belgium EBOS 31.3 127
Kent International Airport United Kingdom EGMH 33.5 252
Kent International Airport United Kingdom EGMH 33.5 252
Calais-Dunkerque Airport France LFAC 34.4 196
Calais-Dunkerque Airport France LFAC 34.4 196
Westkapelle heliport Belgium EBKW 42.6 105
Westkapelle heliport Belgium EBKW 42.6 105
Lympne Airport United Kingdom EGMK 51.6 240
Lympne Airport United Kingdom EGMK 51.6 240
Ursel Air Base Belgium EBUL 52.8 114
Ursel Air Base Belgium EBUL 52.8 114
Southend Airport United Kingdom EGMC 56.2 274
Southend Airport United Kingdom EGMC 56.2 274
Merville-Calonne Airport France LFQT 56.4 163
Merville-Calonne Airport France LFQT 56.4 163
Wevelgem Airport Belgium EBKT 56.5 137
Wevelgem Airport Belgium EBKT 56.5 137
Midden-Zeeland Airport Netherlands EHMZ 57.3 90
Midden-Zeeland Airport Netherlands EHMZ 57.3 90
Lydd Airport United Kingdom EGMD 58.0 235
Lydd Airport United Kingdom EGMD 58.0 235
RAF Wattisham United Kingdom EGUW 59.0 309
RAF Wattisham United Kingdom EGUW 59.0 309
Beccles Airport United Kingdom EGSM 59.3 339
Beccles Airport United Kingdom EGSM 59.3 339
Lille/Marcq-en-Baroeul Airport France LFQO 59.7 146
Lille/Marcq-en-Baroeul Airport France LFQO 59.7 146
Lashenden (Headcorn) Airfield United Kingdom EGKH 62.2 250
Lashenden (Headcorn) Airfield United Kingdom EGKH 62.2 250
Le Touquet-Côte d'Opale Airport France LFAT 63.7 200
Le Touquet-Côte d'Opale Airport France LFAT 63.7 200
Rochester Airport United Kingdom EGTO 64.2 262
Rochester Airport United Kingdom EGTO 64.2 262
Lille-Lesquin Airport France LFQQ 66.2 149
Lille-Lesquin Airport France LFQQ 66.2 149
Thurrock Airfield United Kingdom EGMT 68.4 272
Thurrock Airfield United Kingdom EGMT 68.4 272
cpu time = 183 ms, real time = 183 ms.</pre>
cpu time = 183 ms, real time = 183 ms.</pre>

=={{header|Phix}}==
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">(notonline)-->
<!--<syntaxhighlight lang="phix">(notonline)-->