B4A Library Read / Write files GPX - LibGPX v1.02 & SOURCE

Hello!

Library capabilities - LibGPX version 1.0
The above library enables:

1. read the information contained in the files - GPX;
2. Write the GPS coordinates to the new file in the following format (see example).

- The included DEMO example includes all the library capabilities - LibGPX.

Regards.

File format example: "trk-1-topografix.gpx"

B4X:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.16.3" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">

  <metadata>
    <link href="http://www.garmin.com">
      <text>Garmin International</text>
    </link>
    <time>2014-11-03T17:51:45Z</time>
    <bounds maxlat="52.715650834143162" maxlon="13.296030610799789" minlat="52.130070794373751" minlon="7.670284537598491"/>
  </metadata>

  <trk>
    <name>FMO_Berlin</name>
    <extensions>
      <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        <gpxx:DisplayColor>Blue</gpxx:DisplayColor>
      </gpxx:TrackExtension>
    </extensions>
    <trkseg>
      <trkpt lat="52.131124902516603" lon="7.690135566517711">
        <ele>47.722534199999998</ele>
        <time>2012-01-27T10:05:02Z</time>
      </trkpt>
   
      ...
   
    </trkseg>
  </trk>

</gpx>
 

Attachments

  • LibGPX v1.0.zip
    9.9 KB · Views: 281
  • Example.zip
    278.9 KB · Views: 359
  • Demo for v1.01.zip
    306.2 KB · Views: 347
  • LibGPX v1.01.zip
    11.3 KB · Views: 312
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Awesome, now a sample on how to navigate with this data on a bike would be appreciated.
 

T201016

Active Member
Licensed User
Longtime User
Awesome, now a sample on how to navigate with this data on a bike would be appreciated.

In the future, I want the same library to handle the information contained in the sample files below.
 

Attachments

  • WPT-2-topografix.zip
    24.9 KB · Views: 292

T201016

Active Member
Licensed User
Longtime User
In the future, I want the same library to handle the information contained in the sample files below.

Hello!

LibGPX v1.01
- Support for segment: <wpt> ... </ wpt>
B4X:
  <wpt lat="51.6182327" lon="7.3255205">
    <time>2007-03-31T18:51:17Z</time>
    <name>Altes Schiffshebewerk Henrichenburg</name>
    <sym>Boat Ramp</sym>
    <extensions>
      <gpxx:WaypointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        <gpxx:DisplayMode>SymbolAndName</gpxx:DisplayMode>
      </gpxx:WaypointExtension>
    </extensions>
  </wpt>

Additional versions will be included
<rte> ... </ rte>:
B4X:
<rte>
    <name>Hinweg</name>
    <cmt>Zum Schiffshebewerk Henrichenburg</cmt>
    <extensions>
      <gpxx:RouteExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        <gpxx:IsAutoNamed>true</gpxx:IsAutoNamed>
      </gpxx:RouteExtension>
    </extensions>
    <rtept lat="51.8660035" lon="7.4800899">
      <time>2007-03-31T18:52:54Z</time>
      <name>Erlengrund3611</name>
      ....

- but this requires more attention.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
2. Write the GPS coordinates to the new file in the following format (see example).
May you want to share the java-source with me? I am doing a GPS-Parser for a customer and i also need the SAVE-Feature...
I´m only interested in the saving of the GPX Object with all the Informations about Routes, Tracks, Waypoints.

If you dont want to put it in public then you can create a private conversation with me.

Would be great to get the source. Have a nice day.
 

T201016

Active Member
Licensed User
Longtime User
All right, there's no big deal.
The sources I have only in B4A and you will find them in the conversations sent to you.
 

T201016

Active Member
Licensed User
Longtime User
All right, there's no big deal.
The sources I have only in B4A and you will find them in the conversations sent to you.

New version of LibGPX v.1.02
- I've included the <rte> segment in * .GPX files

(Of course - in the example of coordinates GPS will not be in the section <trkseg> and <wps> and <rte>)

B4X:
    'Creator file GPX.
    'Initializes an empty location object. You can add parameters to this method if needed.
    'path: specified Dir.
    'filename: specified FileName. See: (Initialize the Globals_Type.SavedFileName).
    'Fix_altitude: initialize the fix altitude (meters).
    'Fix_accuracy: initialize the fix accuracy (meters).
    'Fix_wpts: initialize the fix waypoit's.
    'Fix_time: initialize the fix time (HH:mm:ss).
    'Fix_trkname:  initialize the specified track name.
    'Chr_pattern:  splits the given text around matches of the pattern (default: "?").
    Dim path As String = File.DirRootExternal

    Dim Fix_time, Fix_accuracy, Fix_altitude, Fix_wpts As List
    Dim Chr_pattern As String = ","
    Dim init_boolean As Boolean
    Dim Fix_trkname As String = "TRACK-01"
    Dim DisplayColor As String = "Blue" 'see: <gpxx:DisplayColor>Blue</gpxx:DisplayColor>
    Dim html_schemas As String = "http://www.garmin.com/xmlschemas/GpxExtensions/v3" 'see: <gpxx:WaypointExtension xmlns:gpxx="...">
    Dim Fix_trkcmt As String = "Gefahrener Weg" 'see: <cmt>Gefahrener Weg</cmt>

    'Initializes the object. You can add parameters to this method if needed.
    init_boolean = CRGpx.Initialize(path, Fix_trkname, Fix_time, Fix_accuracy, Fix_altitude, Fix_wpts, Chr_pattern)

    If init_boolean Then

        ...

        'IV.  Source: RTE-1-topografix.GPX

        Dim path As String = CRGpx.Globals_Type.SavedFilePath
        Dim filename As String = "RTE-2-topografix.GPX" ' or CRGpx.Globals_Type.SavedFileName
        Dim Fix_rtes As List
    
        '<bounds maxlat="51.8661866" maxlon="7.4931479" minlat="51.6139841" minlon="7.3194265"/>
        CRGpx.SetBounds("51.8661866","7.4931479","51.6139841","7.3194265")
    
        'Fill out the segment RTE.
        '<rte>
        '  <name>Hinweg</name>
        '  <cmt>Zum Schiffshebewerk Henrichenburg</cmt>
        '  <extensions>
          '    <gpxx:RouteExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        '       <gpxx:IsAutoNamed>True</gpxx:IsAutoNamed>
          '    </gpxx:RouteExtension>
        '  </extensions>
        '  <rtept lat="51.8660035" lon="7.4800899">
          '    <time>2007-03-31T18:52:54Z</time>
          '    <name>Erlengrund3611</name>
          '    <cmt>Erlengrund 361</cmt>
          '    <desc>Erlengrund 361</desc>
          '    <sym>Residence</sym>
          '    <extensions>
        '      <gpxx:RoutePointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        Fix_rtes.Initialize
        Fix_rtes.AddAll(Array As String("Hinweg","Zum Schiffshebewerk Henrichenburg","true","51.8660035","7.4800899","2007-03-31 18:52:54","Erlengrund3611","Erlengrund 3611","Erlengrund 3611","Residence"))

        '        <gpxx:Subclass>000000000000ffffffffffffffffffffffff</gpxx:Subclass>
        CRGpx.gpxx_subclass("000000000000ffffffffffffffffffffffff")

        '        <gpxx:rpt lat="51.8652534" lon="7.4795437">
        '          <gpxx:Subclass>06000f544d00163811001f062900aef12800</gpxx:Subclass>
        '        </gpxx:rpt>
        Dim gpxx_rpt As Map
        gpxx_rpt.Initialize
        gpxx_rpt.Put("lat","51.8657684")
        gpxx_rpt.Put("lon","7.4800587")
        gpxx_rpt.Put("sub","06000f544d00163811001f062900aef12800")
        CRGpx.gpxx_rptsubclass(gpxx_rpt)
    
        '        <gpxx:rpt lat="51.8657684" lon="7.4800587"/>
        Dim gpxx_rpt As Map
        gpxx_rpt.Initialize
        gpxx_rpt.Put("lat","51.8657684")
        gpxx_rpt.Put("lon","7.4800587")
        CRGpx.gpxx_rpt(gpxx_rpt)

        '      ...
        '      </gpxx:RoutePointExtension>
          '    </extensions>
        '  </rtept>

        If CRGpx.CreateFileRoutes(path, filename, Fix_trkname, DisplayColor, Fix_trkcmt, Fix_time, Fix_accuracy, Fix_altitude, Fix_wpts, Fix_rtes, html_schemas) Then
            'Save to a file trail GPS which the move, ex.format: "RTE-2-topografix.GPX"
            'Of course - in the example of coordinates GPS will not be in the section <trkseg> and <wps> and <rte>
            Msgbox("C R E A T E" & CRLF & filename, "IV. Message")
        Else
            'Notification: "E R R O R"
            Msgbox("E R R O R" & CRLF & LastException.Message, "IV. Message")
        End If
    End If
 

Attachments

  • LibGPX v1.02.zip
    14.3 KB · Views: 321
  • Save RTE-topografix.GPX.zip
    304.7 KB · Views: 307

T201016

Active Member
Licensed User
Longtime User
I provide library sources for use in my own projects. I hope that they will be useful to somebody.
 

Attachments

  • LibGPX - Source 1.02.zip
    36.1 KB · Views: 334
Top