Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -16,8 +16,8 @@ begin % compute the distance between places using the Haversine formula %
|
|||
real d;
|
||||
integer mi, km;
|
||||
d := distance( 36.12, -86.67, 33.94, -118.4 );
|
||||
mi := round( d );
|
||||
km := round( d / 1.609344 );
|
||||
writeon( i_w := 4, s_w := 0, "distance: ", mi, " km (", km, " mi.)" )
|
||||
km := round( d );
|
||||
mi := round( d / 1.609344 );
|
||||
writeon( i_w := 4, s_w := 0, "distance: ", km, " km (", mi, " mi.)" )
|
||||
end
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
|
||||
with Ada.Numerics.Generic_Elementary_Functions;
|
||||
|
||||
procedure Haversine_Formula is
|
||||
|
||||
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
|
||||
|
||||
-- Compute great circle distance, given latitude and longitude of two points, in radians
|
||||
function Great_Circle_Distance (lat1, long1, lat2, long2 : Long_Float) return Long_Float is
|
||||
Earth_Radius : constant := 6371.0; -- in kilometers
|
||||
a : Long_Float := Sin (0.5 * (lat2 - lat1));
|
||||
b : Long_Float := Sin (0.5 * (long2 - long1));
|
||||
begin
|
||||
return 2.0 * Earth_Radius * ArcSin (Sqrt (a * a + Cos (lat1) * Cos (lat2) * b * b));
|
||||
end Great_Circle_Distance;
|
||||
|
||||
-- convert degrees, minutes and seconds to radians
|
||||
function DMS_To_Radians (Deg, Min, Sec : Long_Float := 0.0) return Long_Float is
|
||||
Pi_Over_180 : constant := 0.017453_292519_943295_769236_907684_886127;
|
||||
begin
|
||||
return (Deg + Min/60.0 + Sec/3600.0) * Pi_Over_180;
|
||||
end DMS_To_Radians;
|
||||
|
||||
begin
|
||||
Put_Line("Distance in kilometers between BNA and LAX");
|
||||
Put (Great_Circle_Distance (
|
||||
DMS_To_Radians (36.0, 7.2), DMS_To_Radians (86.0, 40.2), -- Nashville International Airport (BNA)
|
||||
DMS_To_Radians (33.0, 56.4), DMS_To_Radians (118.0, 24.0)), -- Los Angeles International Airport (LAX)
|
||||
Aft=>3, Exp=>0);
|
||||
end Haversine_Formula;
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
#!/bin/sh
|
||||
#-
|
||||
# © 2021 mirabilos Ⓕ CC0; implementation of Haversine GCD from public sources
|
||||
# © 2021 mirabilos Ⓕ CC0 or MirBSD
|
||||
#
|
||||
# now developed online:
|
||||
# implementation of Haversine GCD from public sources
|
||||
# output is in metres (rounded to millimetres), error < ¼%
|
||||
#
|
||||
# now developed online: (user/pass public)
|
||||
# https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=useful-scripts/mirkarte.git;a=blob;f=geo.sh;hb=HEAD
|
||||
|
||||
if test "$#" -ne 4; then
|
||||
|
|
@ -23,8 +26,8 @@ export BC_ENV_ARGS
|
|||
# h: haversine intermediate
|
||||
# i,j: (lat,lon) point 1
|
||||
# x,y: (lat,lon) point 2
|
||||
# k: delta lat
|
||||
# l: delta lon
|
||||
# k: delta lat/ΔΦ
|
||||
# l: delta lon/Δλ
|
||||
# m: sin(k/2) (square root of hav(k))
|
||||
# n: sin(l/2) ( partial haversine )
|
||||
# n(x): arcsin(x)
|
||||
|
|
@ -32,7 +35,7 @@ export BC_ENV_ARGS
|
|||
# v(x): sign (Vorzeichen)
|
||||
# w(x): min(1, sqrt(x)) (Wurzel)
|
||||
|
||||
bc -l <<-EOF
|
||||
exec bc -l <<-EOF
|
||||
scale=64
|
||||
define n(x) {
|
||||
if (x == -1) return (-2 * a(1))
|
||||
|
|
@ -59,7 +62,8 @@ define w(x) {
|
|||
return (sqrt(x))
|
||||
}
|
||||
/* WGS84 reference ellipsoid: große Halbachse (metres), Abplattung */
|
||||
i = 6378137.000
|
||||
/* (6378137 in WGS84); this radius from Astronomical Almanac 2021 */
|
||||
i = 6378136.600
|
||||
x = 1/298.257223563
|
||||
/* other axis */
|
||||
j = i * (1 - x)
|
||||
|
|
@ -80,5 +84,3 @@ h = ((m * m) + (c(i) * c(x) * n * n))
|
|||
d = 2 * r * n(w(h))
|
||||
r(d, 3)
|
||||
EOF
|
||||
|
||||
# output is in metres, rounded to millimetres, error < ¼% in WGS84
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Haversine(lat1,lon1,lat2,lon2)
|
|||
^ R * 2 * a.sqrt().arcsin()
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
console.printLineFormatted("The distance between coordinates {0},{1} and {2},{3} is: {4}", 36.12r, -86.67r, 33.94r, -118.40r,
|
||||
Haversine(36.12r, -86.67r, 33.94r, -118.40r))
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #008080;">function</span> <span style="color: #000000;">haversine</span><span style="color: #0000FF;">(</span><span style="color: #004080;">atom</span> <span style="color: #000000;">lat1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">long1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">lat2</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">long2</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">constant</span> <span style="color: #000000;">MER</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">6371</span><span style="color: #0000FF;">,</span> <span style="color: #000080;font-style:italic;">-- mean earth radius(km)</span>
|
||||
<span style="color: #000000;">DEG_TO_RAD</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">PI</span><span style="color: #0000FF;">/</span><span style="color: #000000;">180</span>
|
||||
<span style="color: #000000;">lat1</span> <span style="color: #0000FF;">*=</span> <span style="color: #000000;">DEG_TO_RAD</span>
|
||||
<span style="color: #000000;">lat2</span> <span style="color: #0000FF;">*=</span> <span style="color: #000000;">DEG_TO_RAD</span>
|
||||
<span style="color: #000000;">long1</span> <span style="color: #0000FF;">*=</span> <span style="color: #000000;">DEG_TO_RAD</span>
|
||||
<span style="color: #000000;">long2</span> <span style="color: #0000FF;">*=</span> <span style="color: #000000;">DEG_TO_RAD</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #000000;">MER</span><span style="color: #0000FF;">*</span><span style="color: #7060A8;">arccos</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sin</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lat1</span><span style="color: #0000FF;">)*</span><span style="color: #7060A8;">sin</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lat2</span><span style="color: #0000FF;">)+</span><span style="color: #7060A8;">cos</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lat1</span><span style="color: #0000FF;">)*</span><span style="color: #7060A8;">cos</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lat2</span><span style="color: #0000FF;">)*</span><span style="color: #7060A8;">cos</span><span style="color: #0000FF;">(</span><span style="color: #000000;">long2</span><span style="color: #0000FF;">-</span><span style="color: #000000;">long1</span><span style="color: #0000FF;">))</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
|
||||
with javascript_semantics
|
||||
constant MER = 6371, -- mean earth radius, authalic(km)
|
||||
--constant MER = 6372.8, -- mean earth radius, average(km)
|
||||
DEG_TO_RAD = PI/180
|
||||
|
||||
<span style="color: #004080;">atom</span> <span style="color: #000000;">d</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">haversine</span><span style="color: #0000FF;">(</span><span style="color: #000000;">36.12</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">86.67</span><span style="color: #0000FF;">,</span><span style="color: #000000;">33.94</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">118.4</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Distance is %f km (%f miles)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">d</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">/</span><span style="color: #000000;">1.609344</span><span style="color: #0000FF;">})</span>
|
||||
<!--
|
||||
function haversine(atom lat1, long1, lat2, long2)
|
||||
lat1 *= DEG_TO_RAD
|
||||
lat2 *= DEG_TO_RAD
|
||||
long1 *= DEG_TO_RAD
|
||||
long2 *= DEG_TO_RAD
|
||||
return MER*arccos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(long2-long1))
|
||||
end function
|
||||
|
||||
atom d = haversine(36.12,-86.67,33.94,-118.4)
|
||||
printf(1,"Distance is %.10f km (%.10f miles)\n",{d,d/1.609344})
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
Add-Type -AssemblyName System.Device
|
||||
|
||||
$BNA = New-Object System.Device.Location.GeoCoordinate 36.12, -86.67
|
||||
$LAX = New-Object System.Device.Location.GeoCoordinate 33.94, -118.40
|
||||
|
||||
$BNA.GetDistanceTo( $LAX ) / 1000
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
function Get-GreatCircleDistance ( $Coord1, $Coord2 )
|
||||
{
|
||||
# Convert decimal degrees to radians
|
||||
$Lat1 = $Coord1[0] / 180 * [math]::Pi
|
||||
$Long1 = $Coord1[1] / 180 * [math]::Pi
|
||||
$Lat2 = $Coord2[0] / 180 * [math]::Pi
|
||||
$Long2 = $Coord2[1] / 180 * [math]::Pi
|
||||
|
||||
# Mean Earth radius (km)
|
||||
$R = 6371
|
||||
|
||||
# Haversine formula
|
||||
$ArcLength = 2 * $R *
|
||||
[math]::Asin(
|
||||
[math]::Sqrt(
|
||||
[math]::Sin( ( $Lat1 - $Lat2 ) / 2 ) *
|
||||
[math]::Sin( ( $Lat1 - $Lat2 ) / 2 ) +
|
||||
[math]::Cos( $Lat1 ) *
|
||||
[math]::Cos( $Lat2 ) *
|
||||
[math]::Sin( ( $Long1 - $Long2 ) / 2 ) *
|
||||
[math]::Sin( ( $Long1 - $Long2 ) / 2 ) ) )
|
||||
return $ArcLength
|
||||
}
|
||||
|
||||
$BNA = 36.12, -86.67
|
||||
$LAX = 33.94, -118.40
|
||||
|
||||
Get-GreatCircleDistance $BNA $LAX
|
||||
Loading…
Add table
Add a link
Reference in a new issue