Loading ...
Sorry, an error occurred while loading the content.

Read and write Gpx files in vb .net

Expand Messages
  • drummerdavee@hotmail.com
    Hi, I am a newbie to this group. I would like to ask if anyone has source code for reading from and writing to gpx files in vb. I probably could have a go at
    Message 1 of 4 , Dec 5, 2009
    • 0 Attachment
      Hi, I am a newbie to this group. I would like to ask if anyone has source code for reading from and writing to gpx files in vb. I probably could have a go at writing my own but don't really want to reinvent the wheel if I don't have to.
    • Alan
      If you mean VB.NET, then there are heaps of tools using the XmlSerializer classes after you have created a class for the GPX schema using the XSD tool.
      Message 2 of 4 , Dec 5, 2009
      • 0 Attachment
        If you mean VB.NET, then there are heaps of tools using the XmlSerializer
        classes after you have created a class for the GPX schema using the XSD
        tool.



        [Non-text portions of this message have been removed]
      • drummerdavee@hotmail.com
        Hi, I have already created the class using xsd tool and would like some source code for reading and writing to the gpx file. I have a sql server database and
        Message 3 of 4 , Dec 7, 2009
        • 0 Attachment
          Hi, I have already created the class using xsd tool and would like some source code for reading and writing to the gpx file. I have a sql server database and want to create gpx file from some of the entries in the database. They have OSGB grid refs and I am changing this into lat and long values and then want to write them to gpx file so that I can transfer to Garmin GPS 60.
        • Alan
          So where are you stuck? Here is some of code to read a gpx file that may help: Private Sub LoadGPXData() Dim MyFileStream As FileStream = New
          Message 4 of 4 , Dec 8, 2009
          • 0 Attachment
            So where are you stuck?
            Here is some of code to read a gpx file that may help:

            Private Sub LoadGPXData()
            Dim MyFileStream As FileStream = New FileStream(openFileName, FileMode.Open)
            Dim i As Integer = 0
            Dim Myserializer As XmlSerializer = New XmlSerializer(GetType(gpxType))
            Dim mygpx As gpxType = New gpxType
            Try
            mygpx = CType(Myserializer.Deserialize(MyFileStream), gpxType)
            Catch ex As Exception
            MsgBox("Unable to convert the GPX file - ensure that it conforms to GPX 1.1 (http://www.topografix.com/GPX/1/1 and try again")
            Exit Sub
            End Try
            Dim Singletrk As trkType
            Dim SingletrkSeg As trksegType
            Dim SingletrkPt As wptType
            For Each Singletrk In mygpx.trk
            For Each SingletrkSeg In Singletrk.trkseg()
            For Each SingletrkPt In SingletrkSeg.trkpt()
            ReDim Preserve TrkPts(i)
            TrkPts(i) = New TrkPtClass
            With TrkPts(i)
            .lat = SingletrkPt.lat
            .lon = SingletrkPt.lon
            .lat = SingletrkPt.lat
            .reportedAlt = SingletrkPt.ele / feetToMetres ' GPX data ele is provided in metres
            .Time = SingletrkPt.time.ToOADate()
            End With
            i += 1
            Next
            Next
            Next
            End Sub

            As you can see, it's pretty powerful stuff.
            Enjoy,



            --- In gpsxml@yahoogroups.com, drummerdavee@... wrote:
            >
            > Hi, I have already created the class using xsd tool and would like some source code for reading and writing to the gpx file. I have a sql server database and want to create gpx file from some of the entries in the database. They have OSGB grid refs and I am changing this into lat and long values and then want to write them to gpx file so that I can transfer to Garmin GPS 60.
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.