Attribute VB_Name = "Fonctions_Globales" Option Explicit Public phrase As String 'phrase en provenance du GPS Public compteur As Integer 'compteur de ligne de données Public Tablo(20) As String 'tableau pour décodage phrase GPS Public Type t_pos_ll Latitude As Double Longitude As Double End Type Public Type t_pos_xy X As Double Y As Double End Type Public Actu_Lat_Lon As t_pos_ll 'Latitude/Longitude Actuelle Public Actu_X_Y As t_pos_xy 'X/Y Actuel Public Declare Sub Info Lib "wdgps.dll" () 'Public Declare Sub WGS84_Distance Lib "wdgps.dll" (ByVal dLat1 As Double, ByVal dLon1 As Double, ByVal dLat2 As Double, ByVal dLon2 As Double, ByRef dResultat As Double) Public Declare Sub LatLon_WGS84_2_LT1 Lib "wdgps.dll" (ByVal dLat As Double, ByVal dLon As Double, ByRef dX As Double, ByRef dY As Double) Public Declare Sub LatLon_WGS84_2_LT2 Lib "wdgps.dll" (ByVal dLat As Double, ByVal dLon As Double, ByRef dX As Double, ByRef dY As Double) Public Declare Sub LatLon_WGS84_2_LT2e Lib "wdgps.dll" (ByVal dLat As Double, ByVal diLon As Double, ByRef dX As Double, ByRef dY As Double) Public Declare Sub LatLon_WGS84_2_LT3 Lib "wdgps.dll" (ByVal dLat As Double, ByVal dLon As Double, ByRef dX As Double, ByRef dY As Double) Public Declare Sub LatLon_WGS84_2_LT4 Lib "wdgps.dll" (ByVal dLat As Double, ByVal dLon As Double, ByRef dX As Double, ByRef dY As Double) Public Declare Sub LatLon_WGS84_2_LT93 Lib "wdgps.dll" (ByVal dLat As Double, ByVal dLon As Double, ByRef dX As Double, ByRef dY As Double) Function Format_Coords(entree As Double, typ As String) As String Dim dd, mm, ss As String Dim reste_dd, reste_mm, reste_ss As Double ' Affichier les coords Deg Décimaux en "DDD MM SS" dd = Abs(Fix(entree)) reste_mm = (Abs(entree) - dd) * 60 mm = Fix(reste_mm) reste_ss = (reste_mm - mm) * 60 ss = reste_ss If typ = "Lat" Then 'Donnée Lat dd = Format(dd, "00") End If If typ = "Lon" Then 'Donnée Lon dd = Format(dd, "000") End If Format_Coords = dd & " " & Format(mm, "00") & " " & Format(ss, "00.00") End Function Function NSEO(entre As Double, typ As String) As String If typ = "Lat" Then If entre < 0 Then NSEO = "S" Else NSEO = "N" End If If typ = "Lon" Then If entre < 0 Then NSEO = "W" Else NSEO = "E" End If End Function Sub Fill(buff As String) 'Remplissage d'après le buffer série Dim i As Integer Dim car As String For i = 1 To Len(buff) car = Mid(buff, i, 1) If car <> Chr(10) And car <> Chr(13) Then phrase = phrase & car If car = Chr(13) Then display_coords (phrase) 'Affichage des coordonnées dans le tableau phrase = "" End If Next i End Sub Function Calculer_Coordonnees_Planes(inlat As Double, inlon As Double) Select Case Principale.Projection Case "LT1" Call LatLon_WGS84_2_LT1(inlat, inlon, Actu_X_Y.X, Actu_X_Y.Y) Case "LT2" Call LatLon_WGS84_2_LT2(inlat, inlon, Actu_X_Y.X, Actu_X_Y.Y) Case "LT2+" Call LatLon_WGS84_2_LT2e(inlat, inlon, Actu_X_Y.X, Actu_X_Y.Y) Case "LT3" Call LatLon_WGS84_2_LT3(inlat, inlon, Actu_X_Y.X, Actu_X_Y.Y) Case "LT4" Call LatLon_WGS84_2_LT4(inlat, inlon, Actu_X_Y.X, Actu_X_Y.Y) Case "LT93" Call LatLon_WGS84_2_LT93(inlat, inlon, Actu_X_Y.X, Actu_X_Y.Y) End Select End Function Sub display_coords(ent_phrase) 'Remplissage au décodage des coordonnées 'On Error GoTo ERROR Dim phrase_temp As String Dim dLat, dLon, diflat, diflon As Double phrase_temp = ent_phrase Principale.Txt_Lat.Caption = "" Principale.Txt_Lon.Caption = "" Principale.Txt_X.Caption = "" Principale.Txt_Y.Caption = "" Principale.Txt_NMEA.Text = phrase_temp If Left$(phrase, 6) = "$GPGGA" And Principale.NMEA_Trame.Text = "GGA" Then Call Spliter(phrase_temp, ",", 5) If Tablo(2) <> "" And Tablo(4) <> "" Then 'Actu_HDOP = Val(Tablo(8)) dLat = Fix(Val(Tablo(2)) / 100) dLon = Fix(Val(Tablo(4)) / 100) diflat = (Val(Tablo(2)) / 100 - dLat) / 0.6 diflon = (Val(Tablo(4)) / 100 - dLon) / 0.6 dLat = dLat + diflat dLon = dLon + diflon If Tablo(3) = "S" Then dLat = dLat * -1 If Tablo(5) = "W" Then dLon = dLon * -1 Else dLat = 0 dLon = 0 End If Actu_Lat_Lon.Latitude = dLat Actu_Lat_Lon.Longitude = dLon End If If Left$(phrase, 6) = "$GPGLL" And Principale.NMEA_Trame.Text = "GLL" Then Call Spliter(phrase_temp, ",", 5) If Tablo(1) <> "" And Tablo(3) <> "" Then 'Actu_HDOP = Val(Tablo(8)) dLat = Fix(Val(Tablo(1)) / 100) dLon = Fix(Val(Tablo(3)) / 100) diflat = (Val(Tablo(1)) / 100 - dLat) / 0.6 diflon = (Val(Tablo(3)) / 100 - dLon) / 0.6 dLat = dLat + diflat dLon = dLon + diflon If Tablo(2) = "S" Then dLat = dLat * -1 If Tablo(4) = "W" Then dLon = dLon * -1 Else dLat = 0 dLon = 0 'Actu_HDOP = 0 End If Actu_Lat_Lon.Latitude = dLat Actu_Lat_Lon.Longitude = dLon End If If Left$(phrase, 6) = "$GPRMC" And Principale.NMEA_Trame.Text = "RMC" Then Call Spliter(phrase_temp, ",", 6) If Tablo(3) <> "" And Tablo(5) <> "" Then 'Actu_HDOP = Val(Tablo(8)) dLat = Fix(Val(Tablo(3)) / 100) dLon = Fix(Val(Tablo(5)) / 100) diflat = (Val(Tablo(3)) / 100 - dLat) / 0.6 diflon = (Val(Tablo(5)) / 100 - dLon) / 0.6 dLat = dLat + diflat dLon = dLon + diflon If Tablo(4) = "S" Then dLat = dLat * -1 If Tablo(6) = "W" Then dLon = dLon * -1 Else dLat = 0 dLon = 0 End If Actu_Lat_Lon.Latitude = dLat Actu_Lat_Lon.Longitude = dLon End If 'Position GPS INEXISTANTE If Not (Actu_Lat_Lon.Latitude = 0 And Actu_Lat_Lon.Longitude = 0) Then Principale.Txt_Lat.Caption = NSEO((Actu_Lat_Lon.Latitude), "Lat") & " " & Format_Coords((Actu_Lat_Lon.Latitude), "Lat") Principale.Txt_Lon.Caption = NSEO((Actu_Lat_Lon.Longitude), "Lon") & Format_Coords((Actu_Lat_Lon.Longitude), "Lon") Call Calculer_Coordonnees_Planes((Actu_Lat_Lon.Latitude), (Actu_Lat_Lon.Longitude)) Principale.Txt_X.Caption = Format(Actu_X_Y.X, "### ### ###.###") Principale.Txt_Y.Caption = Format(Actu_X_Y.Y, "### ### ###.###") End If ERROR: End Sub Function Spliter(entree As String, sep As String, nb As Integer) Dim temp, lec As String Dim nb_champ, X As Integer If entree = "" Then GoTo FINI temp = "" nb_champ = 0 For X = 1 To Len(entree) lec = Mid$(entree, X, 1) If lec = sep Then Tablo(nb_champ) = temp nb_champ = nb_champ + 1 Tablo(nb_champ) = "" temp = "" Else temp = temp + lec End If SUITE: If nb_champ > nb Then Exit Function Next FINI: End Function