rdechap
Messages postés25Date d'inscriptionlundi 10 février 2003StatutMembreDernière intervention 4 juillet 2008
-
14 déc. 2007 à 13:39
us_30
Messages postés2065Date d'inscriptionlundi 11 avril 2005StatutMembreDernière intervention14 mars 2016
-
15 déc. 2007 à 10:49
Bonjour,
j'ai un problème avec le source suivante, que j'ai trouvé sur VBFRANCE ... cela focntionne mais mal.... au lieu de trouver une distance d'aproximativement 620m cela me retourne 17m....
Merci d'avance pour votre aide,
'definition des variables
Global long1_lonA, long1_LatA
Private Sub P_Map_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'pour info
' long1_lonA = 430,24602
' long1_LatA = 4355,40266
' RM2.Fields("Longitude") = 430,22218
' RM2.Fields("Latitude") = 4355,28036
''''' Calcul de la distance
msgbox Dst_PP(Val(long1_lonA), Val(long1_LatA), Val(RM2.Fields("Longitude")), Val(RM2.Fields("Latitude")))
End Sub
Function Dst_PP(ByVal lonA, ByVal latA, ByVal lonB, ByVal latB)
Const PI = 3.14159265358979
Const rad = 0.0174532925
lonA = lonA * rad
lonB = lonB * rad
latA = latA * rad
latB = latB * rad
If latB - latA 0 Then Dst_PP 0: Exit Function
Dst_PP = (1 / rad) * 1.853 * 60 * ArcCos(Cos(latA) * Cos(latB) * Cos(lonB - lonA) + Sin(latA) * Sin(latB)) 'On multiplie par 1.853 pour convertir en Km car ce sont des miles
Dst_PP = FormatNumber(Dst_PP, 4)
End Function
Function ArcSin(X)
ArcSin = Atn(X / Sqr(-X * X + 1))
End Function
Function ArcCos(X)
ArcCos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function