[cut]
Post by Roberto dalla campagnaRitengo che l'unità di misura sia la stessa usata per indicare l'argomento
Radius (nel caso in discussione il raggio della terra): se lo indichi in Km
penso che la funzione ti ritorni il risultato in KM.
esatto
Post by Roberto dalla campagnaPost by Carlo CostarellaNon so se la funzione proposta ottenga questo risultato. Nelle mie prove
ho
Post by Carlo Costarellahttp://216.147.18.102/dist/index
Non ho mai usato quella funzione, ma visto che è pubblicata da mamma
Microsoft presupponevo fosse giusta.
Ma tu che valore hai dato all'argomento Radius?
Hai memorizzaro nello stesso modulo della funzione di cui sopra anche la
Sub LatLongToXYZ(Lat As Double, Lon As Double, Radius As Double, x As
Double, y As Double, z As Double)
'
' Converts Latitude, Longitude, Radius to 3d-Cartesian coordinates
'
' X axis runs through 270 (-X) and 90 (+X) Latitude
' Y axis runs North (+Y) to South (-Y)
' Z axis runs through 0 (-Z) and 180 (+Z) Latitude
'
y = Radius * Sin(Deg2Rad(Lat))
x = Radius * Sin(Deg2Rad(Lon)) * Cos(Deg2Rad(Lat))
z = -Radius * Cos(Deg2Rad(Lon)) * Cos(Deg2Rad(Lat))
End Sub
che viene richiamata dalla funzione GreatArcDistance?
Function PI() As Double
PI = Atn(1) * 4
End Function
per la determinazione del valore di P greco, anch'essa invocata dalla
funzione GreatArcDistance?
--
Roberto
-----------------------------------------------------
il Sito Comune di it.comp.appl.access
http://www.sitocomune.com
----------------------------------------------------
Anche se è un assurdo in matematica, ma queste misure variano di molto a
seconda delle formule che si usano.
Poi c'è da considerare se si assume la terra come una sfera con raggio 6 371
000,707m o un elissoide con raggio
6 378 137,000 m.
Comunque sembra anche a me che quella formula non si molto esatta.
I dati che ho a disposizione sono in formato gradi decimali es 46,662860
12,603020 e la distanza è preferibile venga espressa in metri. Ora chiedo
comunque l'aiuto dell'esperto/i....
Ho trovato questo codice che ho rimaneggiato per quelle che sono le mie
conoscenze e sembra fornire dati attendibili:
Public Function calcoli(a1 As Double, b1 As Double, a2 As Double, b2 As
Double, De As String, Mi As String) As Double
On Error GoTo Err_Calc
If a1 = a2 And b1 = b2 Then
calcoli = 0
Exit Function
End If
Dim x As Double
Dim negX As Double
Dim r As Single
Dim radMult As Double
Dim dblPi As Double
If De = "d" Then
dblPi = 3.14159269358979
radMult = dblPi / 180
a1 = a1 * radMult
b1 = b1 * radMult
a2 = a2 * radMult
b2 = b2 * radMult
End If
If Mi = "M" Then
r = 3963.1
Else
r = 6378137
End If
x = ((Cos(a1) * Cos(a2) * Cos(b1) * Cos(b2)) + (Cos(a1) * Sin(b1) * Cos(a2)
* Sin(b2)) + (Sin(a1) * Sin(a2)))
negX = x * -1
x = Atn(negX / (Sqr((negX * x) + 1))) + 2 * Atn(1)
calcoli = x * r
Exit_Calc:
Exit Function
Err_Calc:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Calc
End Function
Per il risultato ho usato la query:
SELECT DISTINCTROW tblTest0.a AS a1, tblTest0.b AS b1, tblTest0_1.a AS a2,
tblTest0_1.b AS b2, calcoli([a1],[b1],[a2],[b2],"d","k") AS Risultato
FROM tblTest0, tblTest0 AS tblTest0_1;
la quale va rimaneggiata perchè fornisce valori duplicati non utili.
grazie
es
tblTest0 TestID a b
1 46,662860 12,603020
2 46,662880 12,602919
3 46,662962 12,602385
d a1 b1 a2 b2 Risultato
46,662860 12,603020 46,662860 12,603020 0
46,662880 12,602919 46,662860 12,603020 8,03144098926222
46,662962 12,602385 46,662860 12,603020 49,82349317781
46,662860 12,603020 46,662880 12,602919 8,03144098926222
46,662880 12,602919 46,662880 12,602919 0
46,662962 12,602385 46,662880 12,602919 41,8049305461646
46,662860 12,603020 46,662962 12,602385 49,82349317781
46,662880 12,602919 46,662962 12,602385 41,8049305461646
46,662962 12,602385 46,662962 12,602385 0