Differenze tra le versioni di "Estrarre le coordinate geografiche presenti in un file gpx"

Da Gambas-it.org - Wikipedia.
Riga 9: Riga 9:
 
   Dim i As Integer   
 
   Dim i As Integer   
 
    
 
    
   gpx = File.Load("<FONT Color=gray>' ''/percorso/del/file.gpx''</font>")
+
   gpx = File.Load("<FONT Color=gray>''/percorso/del/file.gpx''</font>")
 
    
 
    
 
   ss = Split(gpx, gb.NewLine, Null, False, False)
 
   ss = Split(gpx, gb.NewLine, Null, False, False)

Versione delle 12:31, 16 lug 2019

Il file di formato GPX (GPS eXchange Format) è di tipo XML contenente dati GPS.

Per estrarre i valori attinenti alla latitudine e alla longitudine di ciascun punto, referenziato dal file, si potrà utilizzare il seguente codice:

Public Sub Main()
 
 Dim gpx, s As String
 Dim ss As String[]
 Dim lat, lon As New String[]
 Dim i As Integer  
 
 gpx = File.Load("/percorso/del/file.gpx")
 
 ss = Split(gpx, gb.NewLine, Null, False, False)
 
 For Each s In ss
   If Trim(s) Begins "<trkpt lat" Then
     lat.Push(Scan(s, "*trkpt lat=\"*\"*")[1])
     lon.Push(Scan(s, "*trkpt lat=\"*\" lon=\"*\"*")[2])
   Endif
 Next
 
 For i = 0 To lat.Max
   Print lat[i], lon[i]
 Next
 
End



Riferimenti