Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gpx file format, what use of segment?

Tags:

gpx

Gpx file is an XML document used to track spatio-temporal information. It look like:

<gpx>
    <trk>
       <segment>
           <trkpt lat="...", lon="..."></trkpt>
       </segment>
    </trk>
</gpx>

Except gpx super-tag, every tag can be replaced more and more. The question is: What use of segment tag? Why trkpt tag can't be collected directly inside parent trk tag? What concept behind the organization of trkpt in set of segment? I've search for this on official gpx website, http://www.topografix.com/gpx.asp, but i've found nothing! :(

Best Regards MC

like image 480
BAD_SEED Avatar asked Oct 29 '11 14:10

BAD_SEED


People also ask

What are GPX files used for?

GPX, or GPS Exchange Format, is an XML schema designed as a common GPS data format for software applications. It can be used to describe waypoints, tracks, and routes. The format is open and can be used without the need to pay license fees.

What is the structure of a GPX file?

A GPX file consists of latitude and longitude location data, elevation values and other possibly other descriptive information. Location data is expressed as decimal degrees and elevation is expressed in meters. Time in a GPX file is are in Coordinated Universal Time (UTC) using ISO 8601 format.


2 Answers

Where you wrote <segment> you probably mean <trkseg>

One track can contain multiple segments. All points inside a segment are drawn as one continous line. There should however not be a line between segments. The example given for this on the gpx site is:

A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data.

Another example could be a track that contains multiple stages in different areas or where there is some (unspecified) travel between the end of one stage and the start of the other.

like image 170
Eddy Avatar answered Oct 06 '22 22:10

Eddy


The problem with the trkseg element, is that it has no default associated meta-data or subnodes, e.g. name, which is the least you'd want to meaningfully be able to work with it.

According to the GPX 1.1 spec, the element is openly extensible, so you can add you own subelements, like name, but the problem then is that you have no guarantee that this info will be read by any other piece of software.

This would suggest that it's probably a better idea to merge all trkseg's into 1 trkseg, and then work with a single trkseg - i.e. rather work at the trk level, and then use the trk element for storing info.

On the other hand, you might want to bear in mind that some popular GPS devices, e.g my Garmin eTrex 20, and anecdotally the e 30, don't display more than one track at a time on the map, which would suggest that in order to view e.g. an entire trail network on the handheld device, you should rather use a single trk, and multiple trkseg's.

Finally, you might want to be working with routes rather than tracks, depending on the situation.

like image 38
david.barkhuizen Avatar answered Oct 06 '22 22:10

david.barkhuizen