Titel sagt viel, das Skript den Rest . Beispiel ist mit dabei.
Spoiler anzeigen
; Paris Observatory
$geoParis = 'E-2-20-14-N-48-50-11'
; US Naval Observatory
$geoUSA = 'W-77-3-55.5-N-38-55-17'
ConsoleWrite(@LF)
ConsoleWrite("Distance between the two given locations is " & _Geo_Diff($geoParis, $geoUSA) & " ± 0.05 km!" & @LF)
ConsoleWrite(@LF)
; #FUNCTION# ================================================================================
; Name ..........: _Geo_Diff
; Description ...: Compute the gedesic distance between two Earth surface
; ...............: coordinates to an accuracy of about ±50 meters. To get
; ...............: this degree of accuracy, this function takes into account
; ...............: the spheroidal flattening factor of the Earth rather than
; ...............: assuming that the Earth is a perfect sphere.
; Syntax ........: _Geo_Diff($geoStart, $geoFinish[, $iDec = 2[, $iUnit = 0]])
; Parameters ....: $geoStart - Location Coordinates in GeoData form (see Example)
; $geoFinish - Location Coordinates in GeoData form (see Example)
; $iDec - [optional] Number of decimal places. Default is 2.
; $iUnit - [optional] The unit to use. Default is 0.
; 0 = km (± 0.05)
; 1 = mi (± 0.03)
; 2 = nmi (± 0.03)
; Return values .: Distance in the given unit, rounded to the given number of decimal places.
; Author ........: minx
; Example .......: s. above
; ===========================================================================================
Func _Geo_Diff($geoStart, $geoFinish, $iDec = 2, $iUnit = 0)
Local $aData[4]
Local $fTemp, $aTemp
$aTemp = StringSplit($geoStart, "-", 3)
$aData[0] = ($aTemp[1] * 3600 + $aTemp[2] * 60 + $aTemp[3]) / 3600
If $aTemp[0] = "E" Then $aData[0] *= -1
$aData[1] = ($aTemp[5] * 3600 + $aTemp[6] * 60 + $aTemp[7]) / 3600
If $aTemp[0] = "S" Then $aData[0] *= -1
$aTemp = StringSplit($geoFinish, "-", 3)
$aData[2] = ($aTemp[1] * 3600 + $aTemp[2] * 60 + $aTemp[3]) / 3600
If $aTemp[0] = "E" Then $aData[0] *= -1
$aData[3] = ($aTemp[5] * 3600 + $aTemp[6] * 60 + $aTemp[7]) / 3600
If $aTemp[0] = "S" Then $aData[0] *= -1
Local $ff = (1 / 298.257)
[/autoit] [autoit][/autoit] [autoit]$UF = 1
If $iUnit = 1 Then $UF = 1.609344
If $iUnit = 2 Then $UF = 1.852
; auxiliary angles
$F = ($aData[1] + $aData[3]) / 2
$G = ($aData[1] - $aData[3]) / 2
$L = ($aData[0] - $aData[2]) / 2
; (co)sines of auxliliary angles
$SG = Sin($G * ATan(1) / 45)
$CG = Cos($G * ATan(1) / 45)
$SF = Sin($F * ATan(1) / 45)
$CF = Cos($F * ATan(1) / 45)
$SL = Sin($L * ATan(1) / 45)
$CL = Cos($L * ATan(1) / 45)
$S = ($SG * $CL) ^ 2 + ($CF * $SL) ^ 2
$C = ($CG * $CL) ^ 2 + ($SF * $SL) ^ 2
$O = ATan(Sqrt($S / $C))
$R = Sqrt($S * $C) / $O
$D = 2 * $O * 6378.14
$H1 = (3 * $R - 1) / (2 * $C)
$H2 = (3 * $R + 1) / (2 * $S)
; distance and angle between start and finish
; on the surface of a geodesic sphereoid
Return Round($D * ((($SF * $CG) ^ 2 * $H1 * $ff + 1) - (($CF * $SG) ^ 2 * $H2 * $ff)) / $UF, $iDec)
EndFunc