# GPX Tutorial: A GPX file, built up line by line

Learn the parts of a GPX file by building one: a route, the track a router makes from it, trackpoints, turn-by-turn instructions and a waypoint, line by line on a map.

Interactive version: https://pitstopper.net/gpx-tutorial.html

Every element is checked against the GPX 1.1 schema (https://www.topografix.com/GPX/1/1/). Where a slide describes what some apps do rather than what GPX 1.1 says, it is marked as a convention.

## Chapter 1: The spec: standard GPX

### 1. The empty file (GPX 1.1)

GPX is written in XML, which stores a file as text made of elements. An element is a pair of tags, like `<gpx>` and `</gpx>`, with whatever it holds in between. A GPX file is a single `gpx` element. Its opening tag carries a few settings written as name="value", called attributes. `version` says this is GPX 1.1, `xmlns` is a web address telling apps that the element names come from GPX 1.1, and `creator` names the app that wrote the file. GPX 1.1 requires `version` and `creator`. There's nothing inside yet, so the map is empty.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="PitStopper example" xmlns="http://www.topografix.com/GPX/1/1">
</gpx>
```

### 2. Where to start, where to go (GPX 1.1)

Planning starts with a route (`rte`), which is a list of route points (`rtept`) to pass through in order. Each route point has a latitude (`lat`) and a longitude (`lon`), and the route itself can have a `name`. These route points hold nothing inside, so each is written as one tag ending in `/>`. They could hold more, as chapter 2 shows. These first two are the church in Damme, where the loop starts, and a crossroads east of the village. The file says nothing about the roads in between, so an app can only join them with a straight line. Tick **Show as an app would** to see it.

```xml
  <rte>
    <name>Around Damme</name>
    <rtept lat="51.24962" lon="3.28297"/>
    <rtept lat="51.25076" lon="3.29042"/>
  </rte>
```

### 3. Round and back (GPX 1.1)

Three more route points. Two pull the route round the north of the village, and the last one is the church again, which closes the loop. Tick **Show as an app would** to see the line and arrows for the order. In a route planner, these are the points you'd click on the map.

```xml
    <rtept lat="51.25349" lon="3.28671"/>
    <rtept lat="51.25371" lon="3.28335"/>
    <rtept lat="51.24962" lon="3.28297"/>
```

### 4. A track and its segment (GPX 1.1)

A route says where to go but not which roads to take. A track (`trk`) is the line itself, following every bend in the road. Its points live in a track segment (`trkseg`), one unbroken stretch of line. A planned track usually has just the one. This segment is still empty, and a router fills it in the next step.

```xml
  <trk>
    <name>Around Damme</name>
    <trkseg>
    </trkseg>
  </trk>
```

### 5. The router fills in the track (GPX 1.1)

A planning app sends the route points to a router, which works out the roads between them from map data. Here the router is BRouter, an open-source router built on OpenStreetMap data. PitStopper uses it, and Locus Map and Cruiser can use it for offline routing. There are others too, open-source ones such as GraphHopper (which both of those also offer online), OSRM and Valhalla, and private ones that apps like Komoot, Garmin and Locus Map (LoRouter) run for themselves. It sends back trackpoints (`trkpt`) that follow the actual roads and paths, here 93 of them over 2.2 km. Like a route point, a trackpoint only needs a latitude and a longitude. Apps draw a straight line from each trackpoint to the next, so with enough of them the line follows the road. They crowd together on bends and spread out on the straights. The file shows a few and folds the rest away.

### 6. Track or route: which to follow? (GPX 1.1)

The file now holds the same loop twice. The route is the plan, just a few points. An app that can plan routes works out the roads between them for itself, so it may pick different roads from the ones you planned, and it can plan again if you go off course. An app that can't plan routes, such as Organic Maps, joins the route points with straight lines. The track is the line itself. An app follows it as drawn and can guide you along it, or warn you when you leave it. It never re-plans the line itself, though some will find you a way back to it if you stray. If you want to be sure of riding your own roads, follow the track. Some apps write both, as here.

### 7. Height and time (GPX 1.1)

Each trackpoint can also carry its height in metres (`ele`, usually above sea level) and a `time`, for when you were there or plan to be. GPX 1.1 only calls it a timestamp and has nothing to mark a planned one, so the file can't say which of the two a time is. GPX times are in UTC, world time, and usually end in a Z. Clocks in Belgium run one or two hours ahead of it. Heights give an app its elevation profile, which is flat here, between 3 and 7 m. Times let it work out speeds and stops. Both are optional. Planned tracks often have heights but no times. This one has planned times, at 15 km/h.

### 8. A café on the way (GPX 1.1)

With the track done, you can look along it for places to stop, and many planning apps, PitStopper among them, will search along it for you. A waypoint (`wpt`) is a single place. Here it's a café on Kerkstraat, just off the Markt, but it could just as well be a water tap or a campsite. It isn't part of any line, and the file gives waypoints no order (though an app may still list them), and GPX keeps them apart from the route and the track, ahead of them near the top of the file. The café's `name` is the label an app puts on the map, and `sym`, short for symbol, names an icon, here `Restaurant`. Which picture you see for that name is up to the app. Chapter 2 explains where names like this come from.

```xml
  <wpt lat="51.25173" lon="3.28075">
    <name>Eetcafé d'Oude Speye</name>
    <sym>Restaurant</sym>
  </wpt>
```

### 9. Two segments (GPX 1.1)

A side step. This is the same track with a break in it, the kind you get when a device loses its GPS signal for a while. Ten trackpoints are missing, and a second segment starts after the gap. A new segment means the line was broken there, so many apps leave the gap empty, as this map does. Some join the two anyway, QMapShack among them. Planned tracks rarely have more than one segment, but recorded ones often do.

```xml
    </trkseg>
    <trkseg>
```

### 10. Summary: standard GPX (GPX 1.1)

Everything in this chapter is plain GPX 1.1, which almost every GPX app can open, though not every app uses every element. A route (`rte`) is the plan, route points in order, and the app works out the roads. A track (`trk`) is the line to follow, trackpoints in segments, and here BRouter drew it from the route. Trackpoints can carry a height and a time. A waypoint (`wpt`) is one place, with no order.

The whole file so far: https://pitstopper.net/examples/gpx-tutorial-chapter-1.gpx

### 11. Test yourself: standard GPX (GPX 1.1)

1. Which element is the line to follow?
   - `rte`
   - `trk` (right)
   - `wpt`
   The track (`trk`) is the line itself. A route (`rte`) is the plan, and a waypoint (`wpt`) is one place.

2. What is a route point (`rtept`)?
   - A place to go through, in order (right)
   - A single place, in no order
   - A point the GPS recorded
   Route points are passed in order, and an app that can plan routes works out the roads between them.

3. A route with only route points is opened in an app that cannot plan routes. What do you see?
   - The roads between the points
   - Straight lines between the points (right)
   The file says nothing about the roads between route points, so the map can only join them with straight lines.

4. You want your device to follow your exact roads, not choose its own. What should it follow?
   - The track (right)
   - The route
   A track is followed as drawn. With a route, a device that plans routes works out the roads itself, and may pick different ones.

5. You want to mark a water tap you might stop at. Which element do you add?
   - `wpt` (right)
   - `rtept`
   - `trkpt`
   A water tap is one place you might visit, and the line doesn't have to pass it, so it's a waypoint.

6. Your app shows no elevation profile for a track. What is missing from its trackpoints?
   - `ele` (right)
   - `time`
   - `sym`
   An elevation profile is drawn from each trackpoint's height, which is `ele`, in metres.

7. What is wrong with this track?

```xml
<trk>
  <name>Around Damme</name>
  <trkpt lat="51.24962" lon="3.28297"/>
</trk>
```

   - The trackpoint should be inside a `trkseg` (right)
   - A trackpoint needs a `name`
   - `lat` and `lon` are the wrong way round
   In GPX 1.1 a track's points always sit inside a track segment.

## Chapter 2: Conventions: extras on trackpoints

### 12. One recipe for three kinds of point (GPX 1.1)

Underneath, GPX 1.1 treats waypoints, route points and trackpoints as the same kind of point, and all three may hold the same elements, in a fixed order. You've met four of them already: `ele` and `time` on the trackpoints, `name` and `sym` on the café. This chapter brings in three more, `cmt`, `desc` and `type`, over the next few slides. Most apps only read `ele` and `time` on a trackpoint, but GPX allows the others there too, and that is where this chapter writes turn-by-turn instructions.

### 13. What sym and cmt are for (GPX 1.1)

GPX 1.1 gives both of these a meaning. `sym` is the "GPS symbol name", the icon for the point, like `Restaurant` on the café. GPX has no list of symbols. It just asks for the spelling the GPS device itself uses. The next slide shows where names like this come from. `cmt` is a comment, which GPX 1.1 says is "sent to GPS", meaning to the device. Its neighbour `desc` is a description for the person. Both are free text, and neither has anything to do with turns. The café now has one of each: a short `cmt` for the device and a `desc` for you. Not every app keeps them apart. Garmin's BaseCamp often writes the same text, such as an address, in `name`, `cmt` and `desc`. Tick **Show as an app would**, on the map, to see the café with the icon an app might pick for `Restaurant`.

```xml
    <cmt>Coffee stop</cmt>
    <desc>Café on Kerkstraat, by the Markt in Damme.</desc>
```

### 14. Icon names: Garmin's list and app icon packs (GPX 1.1)

The GPX 1.1 schema says only this about `sym`: "Text of GPS symbol name. For interchange with other programs, use the exact spelling of the symbol as displayed on the GPS. If the GPS abbreviates words, spell them out." It gives no list of names. In practice Garmin's names became the common set. Garmin's MapSource defined a fixed list of a few hundred, such as `Restaurant`, `Drinking Water`, `Campground`, `Restroom`, `Lodging` and `Summit`, spelled exactly so, capitals and spaces included. A Garmin device shows a default icon for a name it doesn't know, often a flag, though it has changed over the years. Other apps carry icon packs of their own, and PitStopper has [a set of its own](tests/poi-icons.html). Locus Map and Cruiser, for two, have icons for Garmin's names, and each app draws its own picture, so `Restaurant` looks different from app to app. Not every app reads `sym` at all: OsmAnd uses an extension of its own for icons. A name that no app knows, such as PitStopper's `PS_cafe`, needs its own icon file, which is what chapter 6 is about. GPSBabel keeps a [list of Garmin's icon names](https://www.gpsbabel.org/htmldoc-1.10.0/GarminIcons.html).

### 15. A turn in sym (convention: Locus Map and Cruiser)

Turn-by-turn means the device tells you about each turn as you come to it, with an arrow on the screen and often a beep or a voice: "in 100 m, turn left onto Rabattestraat". To do that, the file needs somewhere to write "turn left here", and GPX 1.1 doesn't have one. Locus Map, which did it first, and Cruiser use `sym` on the trackpoint at the junction, with turn names from their own list such as `left`, `right`, `left_slight`, `stay_right` and `roundabout_e2` (a roundabout, second exit). `sym` belongs to GPX 1.1, but reading it as a turn is a convention, an agreement between some apps that isn't part of GPX. In this file the turns came from BRouter, along with the track. Other apps and routers work out turns their own way, and PitStopper can also work them out itself, with its own JavaScript version of BRouter's turn rules. A Garmin device doesn't read them. It takes its turns from a FIT file instead (chapter 7), or works them out from its own map. Cruiser can also take turns from a route, the way BRouter writes them for it, with a turn code on each route point. Tick **Show as an app would** to see the arrows such an app draws from these names.

```xml
        <sym>left</sym>
        <sym>left</sym>
        <sym>stay_right</sym>
```

### 16. The road in cmt (convention: Locus Map and Cruiser)

Cruiser and Locus Map read `cmt` on the same trackpoint as the street name, here Rabattestraat and Kerkstraat, the roads you turn onto. Other apps put it elsewhere: GraphHopper and OsmAnd write it in `desc`, as "turn left onto Rabattestraat". Like `sym`, it's a GPX 1.1 element with a convention on top. An app that doesn't know the convention just sees a comment, and may never show it.

```xml
        <cmt>Rabattestraat</cmt>
        <cmt>Kerkstraat</cmt>
        <cmt>Kerkstraat</cmt>
```

### 17. Via and shaping points (convention: Locus Map and Cruiser)

When a planner builds the track, it marks the trackpoint where the line passes each of your route points with a `type`. Which word a point gets is the planner's to decide: some let you choose for each point, and BRouter, which wrote this file, made the start and finish via points and the points between shaping. GPX 1.1 allows a `type` on a waypoint, a route, a track and every route point and trackpoint, and it can hold any text you like. The schema only calls it a classification, so each app picks its own words. Routemaster writes Food on a café waypoint, a recording app may write the activity on a track, such as cycling, and Geocaching.com writes the kind of cache. Inside a `link`, `type` means something else again: the kind of file it points to, such as image/jpeg. In this convention a trackpoint's type is one of two words. `via` marks a place you mean to reach on the way, usually a stop between the start and the finish, such as a café or a checkpoint, and an app can announce it as you get there, often by its `name`. Planners mark the start and the finish as via points too, and on this loop they're the only ones, because every point between only shapes the line. `shaping` marks a point that only pulls the line onto a road you chose, and it's passed without a word. The map marks both. Garmin's BaseCamp makes the same split on route points, in its own extension: `trp:ViaPoint` or `trp:ShapingPoint`. A plain `type` needs no extension, so any app that reads GPX 1.1 can see it.

```xml
        <sym>pass_place</sym>
        <type>via</type>
        <sym>pass_place</sym>
        <type>shaping</type>
        <sym>pass_place</sym>
        <type>shaping</type>
        <sym>pass_place</sym>
        <type>shaping</type>
        <sym>pass_place</sym>
        <type>via</type>
```

### 18. pass_place: so Locus Map reads it (convention: Locus Map and Cruiser)

Each of these points also gets `pass_place` in its `sym`, the name for a point on the way that isn't a turn. Locus Map only picks up a navigation point when its `sym` holds a name from its own list, so without it Locus Map would see an ordinary trackpoint. Then the `type` says which kind. Locus Map treats `pass_place` with `via` as a via point, and with `shaping` as a via point it doesn't announce. Cruiser goes by the `type`: it announces a via point and passes a shaping point silently. A via point that is also a turn keeps the turn in `sym` instead. Cruiser then announces the turn and the via point's name, Locus Map only the turn. GPX 1.1 has no via, shaping or pass_place: this is another Locus Map and Cruiser convention. Garmin's BaseCamp marks via and shaping its own way, with an extension on route points, so the meaning doesn't always survive a move from one app to another.

### 19. Summary: extras on trackpoints (convention: Locus Map and Cruiser)

The file is still plain GPX 1.1. This chapter only wrote instructions into elements a trackpoint was always allowed to hold. `sym` holds the turn, or `pass_place` on a via or shaping point, `cmt` holds the street, and `type` says whether a point is via or shaping. Cruiser and Locus Map read the turns and the street. Other apps show the same track without the instructions.

The whole file so far: https://pitstopper.net/examples/gpx-tutorial-chapter-2.gpx

### 20. Test yourself: extras on trackpoints (convention: Locus Map and Cruiser)

1. Is `sym` a standard GPX 1.1 element?
   - Yes: GPX 1.1 defines it as the GPS symbol name (right)
   - No: Locus Map and Cruiser added it
   `sym` is part of GPX 1.1. Using it for turns is the convention.

2. In the convention this chapter uses (Locus Map and Cruiser), where does a turn instruction go?
   - On the trackpoint at the junction (right)
   - In a waypoint
   - In the route
   Locus Map and Cruiser read turns from the trackpoint at the junction. A FIT course does it differently, with course points.

3. Which element holds the turn itself, such as `left`?
   - `cmt`
   - `sym` (right)
   - `type`
   On a waypoint, sym names an icon. On a trackpoint, Locus Map and Cruiser read a turn name such as left from it. The street name goes in cmt.

4. Which kind of point can an app announce?
   - A via point (right)
   - A shaping point
   A via point is a place to reach, so Cruiser can announce it. A shaping point only shapes the line and is passed without a word.

5. A trackpoint has `<type>shaping</type>`. What does Cruiser do there?
   - Passes it silently (right)
   - Announces it
   A shaping point only pulls the line onto a road, so there's nothing to announce.

6. A via point should work in Locus Map as well as in Cruiser. What does its trackpoint need?
   - `pass_place` in `sym`, and `via` in `type` (right)
   - Only `via` in `type`
   Locus Map only reads a trackpoint whose `sym` holds a name it knows, so the type alone isn't enough.

7. An app that does not know these conventions opens the file. What happens?
   - It rejects the file
   - It shows the track, without the instructions (right)
   The file is still valid GPX. To that app the extras are just a comment and a symbol name, which it may show as plain text or not at all.

8. This trackpoint won't validate. Why?

```xml
<trkpt lat="51.25047" lon="3.29094">
  <sym>left</sym>
  <cmt>Rabattestraat</cmt>
</trkpt>
```

   - `cmt` must come before `sym` (right)
   - `sym` is not allowed on a trackpoint
   - `left` is not a GPX 1.1 value
   GPX 1.1 fixes the order of a point's elements, and cmt comes before sym. sym is allowed on any point, and GPX has no list of values for it.

## Chapter 3: Extensions: what GPX leaves open

### 21. A door for anything else (GPX 1.1)

GPX 1.1 can't list everything every app might want to store, so it leaves a door open, called `extensions`. GPX says nothing about what goes inside, except that it has to use another vocabulary, a set of element names defined by someone else, such as an app maker. An app that doesn't understand what's inside skips it, and the file stays valid. The file, its metadata and each waypoint, route, track, track segment and point can all have their own `extensions`.

```xml
    <extensions>
    </extensions>
```

### 22. Colour and width (extension: OsmAnd, Organic Maps and others)

Track colour is the obvious example, and GPX 1.1 has none. Several apps, among them OsmAnd and Organic Maps, read it from an `xsi:gpx` block in the track's extensions, with `color` as a colour code such as #FF0000 for red. OsmAnd also reads `width` there, the thickness of the line on screen. The map now draws the track that way. The `xsi:` in front is a prefix, a short label for the vocabulary a name comes from, and it only works once it's declared, here on the `gpx` element with the new `xmlns:xsi`. It borrows the prefix of a standard XML vocabulary that plenty of GPX files declare anyway. Cruiser started using it for this block, and other apps followed. Locus Map reads neither: it takes the colour and width from Topografix's `gpx_style`, or the colour from Garmin's own block, so a file that should be coloured everywhere carries more than one.

```xml
<gpx version="1.1" creator="PitStopper example" xmlns="http://www.topografix.com/GPX/1/1"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <xsi:gpx>
        <color>#7B1FA2</color>
        <width>6</width>
      </xsi:gpx>
```

### 23. Summary: extensions (GPX 1.1)

GPX 1.1 can't hold everything an app might want, so it leaves a door open: `extensions`, for whatever it doesn't cover, such as the track colour in `xsi:gpx`. What goes inside comes from another vocabulary, named by its prefix. An app that doesn't know an extension skips it and reads the rest, and the file stays valid. That is also the limit: whatever was in the extension is lost to that app. So what you need to get there, such as the via and shaping points in chapter 2, is safer in standard elements than in an extension. Colour comes in more than one form. Garmin keeps it in its own extension, as one of 16 named colours, and gpx.studio uses another called gpx_style, so PitStopper writes all three.

The whole file so far: https://pitstopper.net/examples/gpx-tutorial-chapter-3.gpx

### 24. Test yourself: extensions (GPX 1.1)

1. Is a track's colour part of GPX 1.1?
   - Yes
   - No: apps keep it in extensions (right)
   GPX 1.1 has no colour. Apps keep it in extensions, each in its own block: OsmAnd and Organic Maps read `xsi:gpx`, Locus Map reads `gpx_style` or Garmin's own block.

2. An app opens a file with an extension it does not know. What does it do?
   - It rejects the file
   - It skips the extension and reads the rest (right)
   The file is valid GPX with or without extensions, and an app that does not know one is meant to skip it.

3. What is wrong here?

```xml
<trk>
  <name>Around Damme</name>
  <trkseg>…</trkseg>
  <extensions>…</extensions>
</trk>
```

   - `extensions` must come before `trkseg` (right)
   - A track cannot have `extensions`
   - `name` must come last
   In a track, GPX 1.1 puts extensions after the name and before the segments.

4. What is the `xsi:` in `xsi:gpx`?
   - A prefix: a short label for the vocabulary the name comes from (right)
   - Part of GPX 1.1
   A prefix says which vocabulary a name belongs to, and it only works once it is declared with `xmlns:` on the `gpx` element.

## Chapter 4: Final items: metadata and links

### 25. The file's own details (GPX 1.1)

A file can describe itself in `metadata`, which always comes first, before any waypoint. It holds the file's `name`, a description (`desc`), the `time` the file was made and its `bounds`, the smallest box that holds everything in the file (dashed on the map). There's room for an author, a copyright, links and keywords too. All of it is optional.

```xml
  <metadata>
    <name>Around Damme</name>
    <desc>A 2.2 km loop round Damme, from the church and back.</desc>
    <time>2026-06-13T18:30:00Z</time>
    <bounds minlat="51.24815" minlon="3.28069" maxlat="51.25453" maxlon="3.29094"/>
  </metadata>
```

### 26. More about the café (GPX 1.1)

A waypoint can say more than its name, its comment and its description. `link` points to a web page about the place, in this case its OpenStreetMap page, with the address in `href` and the label you see in `text`. Apps often show the description and the link in the point's popup.

```xml
    <link href="https://www.openstreetmap.org/node/1341487775">
      <text>OpenStreetMap</text>
    </link>
```

### 27. Summary: final items (GPX 1.1)

That finishes the file. `metadata` describes the file itself: its name, a description, when it was made and its bounds. A point can say more with `desc` and a `link`. All of it is plain GPX 1.1 and all of it is optional, so the file worked without it, but an app has more to show with it.

The whole file so far: https://pitstopper.net/examples/gpx-tutorial-chapter-4.gpx

### 28. Test yourself: final items (GPX 1.1)

1. Where does the file's own name go?
   - In `metadata` (right)
   - In the track's `name`
   - In the first waypoint
   `metadata` describes the file. A track's name only names that one track.

2. What are the `bounds`?
   - The smallest box that holds everything in the file (right)
   - The highest and lowest points of the track
   Bounds are four numbers, the lowest and highest latitude and longitude of anything in the file.

3. Which element links a waypoint to a web page?
   - `link` (right)
   - `desc`
   - `text`
   link holds the address, in href. text is just the label you see.

4. Where in the file does `metadata` go?
   - First, before any waypoint (right)
   - Anywhere
   - Last, after the tracks
   GPX 1.1 fixes the order of the file, and metadata comes first.

## Chapter 5: A recorded ride

### 29. What a recording looks like (GPX 1.1)

This is a new file. It's the same loop as a bike computer might have recorded it on the day (it's simulated). A recording is just a track, where you went rather than a plan of where to go, so it has no route, waypoints or turns. The device writes a trackpoint every few seconds, every six here, each with a height and a time. GPS is only accurate to a few metres, so the line wobbles about the road instead of following it exactly.

### 30. A stop (GPX 1.1)

Near the end of the loop the rider stopped at the café for twenty minutes. Nothing in the file says so. The trackpoints just bunch up in one place while their times keep moving on (highlighted, and amber on the map). That's how apps find stops and work out moving time, because a lot of time passes over very little distance. Some devices write fewer points when not much is changing (Garmin calls it smart recording), and this one wrote one a minute.

### 31. Paused (GPX 1.1)

Here's the same ride with auto-pause on. The device stopped recording at the café, and this one started a new track segment when the rider set off again. Other devices keep one segment. Either way the stop has gone from the file and the time jumps by twenty minutes. On the map the gap is tiny, because the rider set off from the spot where they stopped. The gap is in the time.

```xml
    </trkseg>
    <trkseg>
```

### 32. Heart rate and cadence (extension: Garmin TrackPointExtension)

With a heart-rate strap and a cadence sensor, each trackpoint carries their readings as well. GPX 1.1 has nowhere to put them, so they go in extensions, in Garmin's TrackPointExtension, under the prefix `gpxtpx` (declared at the top, like `xsi`). The prefix is only a label, and recent Garmin software writes another, such as `ns3`: what counts is the web address it's declared with. `hr` is heart rate in beats a minute, and `cad` is cadence, which on a bike means how many times a minute the pedals go round. It's Garmin's own vocabulary, but it's written so widely that many apps read it, PitStopper included.

### 33. Into PitStopper (PitStopper)

Load a recording into PitStopper and it treats the recorded track like a planned one. It keeps the file's own times, draws the elevation profile from the heights and searches along the line for places to stop. The wobbles and the bunch of points at the café stay as they are. For a clean track with turn-by-turn, use Track to Paths/Roads. It looks up the paths and roads around your recording in a map (PitStopper's own copy of OpenStreetMap), works out which ones you rode, and draws a new line along them, with the turns worked out. Where there's no road, on a beach or a ferry, it keeps the line as recorded. The new line arrives in PitStopper as a second route beside your recording, which stays as it was. They're two routes in the app, not two tracks in one file: you export the one you want.

### 34. Summary: a recorded ride (GPX 1.1)

A recording is a track with a time on every point, and nothing else. Its line wobbles by a few metres, a stop shows up as points bunched in one place, and a pause shows as a jump in time, sometimes with a new segment. Sensor readings go in extensions, usually Garmin's TrackPointExtension.

The whole file so far: https://pitstopper.net/examples/gpx-tutorial-chapter-5.gpx

### 35. Test yourself: a recorded ride (GPX 1.1)

1. What does a recording usually hold?
   - A track, with a time on every point (right)
   - A route and waypoints
   - Turn-by-turn instructions
   A device writes down where you were and when. It has no plan to write, so no route, waypoints or turns.

2. How does a stop show in a recording?
   - As a waypoint called Stop
   - As points bunched in one place while the time moves on (right)
   Nothing in the file says stop. You just see a lot of time pass over very little distance.

3. Auto-pause stops recording, then starts again. What does the file show?
   - A jump in the time (right)
   - A new track
   - A waypoint called Pause
   Some devices also start a new segment. Either way the times jump across the pause, unless software has rewritten them later.

4. Where does heart rate go?
   - In `desc`
   - In extensions, such as Garmin's TrackPointExtension (right)
   - In `cmt`
   GPX 1.1 has no element for heart rate, so it goes in extensions.

5. Why does a recorded line wobble about the road?
   - GPS is only accurate to a few metres (right)
   - The rider weaved about
   Each point is the device's best guess, a few metres either way.

6. These two trackpoints follow each other in a recording. What is odd?

```xml
<trkpt lat="51.24928" lon="3.28327"><time>2026-06-14T09:00:12Z</time></trkpt>
<trkpt lat="51.24911" lon="3.28343"><time>2026-06-14T09:00:06Z</time></trkpt>
```

   - The second time is earlier than the first (right)
   - GPX times must not end in Z
   - A recording cannot carry times
   A recording's times only go forward. A time that goes back usually means the file was edited or joined wrongly.

## Chapter 6: Beyond GPX: files that travel together (GPZ)

### 36. A GPX in a zip (GPZ)

A .gpz is a zip file, several files packed into one, like a folder you might send by email. It isn't part of GPX 1.1, just a way of packaging files that some apps share. This one holds a GPX file along with the files it uses, such as icons and photos. Locus Map, Cruiser and GPX Viewer all read them, though none of them writes one. For now it holds only the GPX from chapter 4, named after the .gpz, so nothing has changed yet. The list under the map shows what's inside.

```xml
  <metadata>
    <name>Around Damme</name>
    <desc>A 2.2 km loop round Damme, from the church and back.</desc>
    <time>2026-06-13T18:30:00Z</time>
    <bounds minlat="51.24815" minlon="3.28069" maxlat="51.25453" maxlon="3.29094"/>
  </metadata>
    <link href="https://www.openstreetmap.org/node/1341487775">
      <text>OpenStreetMap</text>
    </link>
```

### 37. An icon file in the .gpz (GPZ)

Now the café gets an icon file of its own. An app finds a waypoint's icon file by matching its `sym` against the file names in the .gpz, exactly, capitals and all, so `PS_cafe` finds `PS_cafe.png`. Locus Map and GPX Viewer draw these icons. An icon can be a PNG, a picture made of pixels, or an SVG, a drawing that stays sharp at any size. Locus Map reads SVG as well, but not every app does, so PitStopper sends both by default, `PS_cafe.png` and `PS_cafe.svg`. Cruiser opens the file but doesn't show them yet. Tick **Show as an app would** to see it.

```xml
    <sym>PS_cafe</sym>
```

### 38. Why not Restaurant? (GPZ)

Apps don't agree on which comes first, their own icon or the file. Recent versions of Locus Map and GPX Viewer take the file, but an app that checks its own icons first would draw its own Restaurant and never use Restaurant.png. So when icons travel in a .gpz, PitStopper renames the `sym` with a `PS_` prefix that no app uses.

### 39. Garmin, and photos (GPZ)

A Garmin device can't open a .gpz, so for a Garmin PitStopper writes a plain .gpx, where the café keeps the name Restaurant. A .gpz can carry photos as well. A waypoint's `link` then points to a photo file inside the .gpz instead of a web page.

### 40. Summary: GPZ (GPZ)

A .gpz is a GPX file zipped up with the files it uses. An app finds a waypoint's icon file by matching its `sym` against the file names in the .gpz. Some apps check their own icons first, which is why PitStopper uses `PS_` names there. A Garmin device gets a plain .gpx instead.

### 41. Test yourself: GPZ (GPZ)

1. What is a .gpz?
   - A zip holding a GPX file and the files it uses (right)
   - A newer version of GPX
   - A picture of the route
   Inside, a .gpz is still GPX 1.1. The zip just lets icons and photos travel with it.

2. How does an app find a waypoint's picture in a .gpz?
   - It matches `sym` against a file name in the archive (right)
   - It uses the waypoint's `name`
   - It reads `desc`
   `PS_cafe` finds `PS_cafe.png` because the names match exactly.

3. Why does PitStopper rename the café's `sym` to `PS_cafe` in a .gpz?
   - So the app's own Restaurant icon does not win over the picture in the archive (right)
   - Because GPX does not allow the name Restaurant
   Some apps check their own icons first. A name no app has means every app uses the icon file in the .gpz.

4. Can a Garmin device open a .gpz?
   - No: give it a plain .gpx (right)
   - Yes, if the GPX inside is plain
   Garmin devices don't open zip files, so give them a plain .gpx.

5. The café shows no icon. Why?

```xml
around-damme.gpz
  around-damme.gpx   (the café: <sym>PS_cafe</sym>)
  ps_cafe.png
```

   - The file name's capitals do not match the `sym` (right)
   - PNG files cannot be used
   - The `sym` must be Restaurant
   Apps match sym against the file name exactly, capitals included, so PS_cafe needs PS_cafe.png.

## Chapter 7: Beyond GPX: the same loop as FIT

### 42. What FIT is (FIT)

Chapters 1 to 5 were all about GPX. Garmin devices, and plenty of other bike computers, also read a different format called FIT, which Garmin created. It's binary, written for a device, not as text a person can read, so what you see here is decoded, one message to a line. A message is roughly what an element is in GPX, a row of named values called fields. Garmin publishes the list of messages and fields. Devices also record rides as FIT activity files, which add messages for the ride as a whole, such as a session. This chapter is about a FIT course, a file to follow, which is a different kind of FIT file.

### 43. The order of messages (FIT)

A course starts with `file_id` (type course) and `course`, which holds its name and sport. Then comes a single `lap`. That isn't a time round a circuit here. It's a summary of the whole course, with its start, end, distance and time. Two timer `event`s, start and stop, sit either side of the records and course points and mark where the course's times begin and end. `file_creator` closes the file.

### 44. Trackpoints become records (FIT)

Each trackpoint becomes a `record`, with a time, a position, an `altitude` (FIT's name for `ele`) and a `distance`, which is how far along the course it is in metres. GPX 1.1 has no element for that. Positions are stored as whole numbers called semicircles, and the decoder turns them back into degrees, shown in brackets. The church's latitude, 51.24962°, is stored as 611431783 (degrees × 2³¹ ÷ 180). PitStopper always writes times into a course, here the planned ones from chapter 1. It also adds a record wherever two are more than 100 m apart, so there are more records than trackpoints, and makes sure every course point sits exactly on a record.

### 45. Turns become course points (FIT)

A `course_point` is where FIT puts something along the course, and its `type` says what it is. Unlike GPX, FIT has a fixed list of turn types, so every device knows what each one means. PitStopper turns each turn's `sym` into a type. `left` stays `left`, and `stay_right` becomes `right_fork`. The street name from `cmt` becomes the course point's `name`. FIT has no roundabout type, so PitStopper writes a roundabout as a `generic` course point named after its exit.

### 46. The café becomes a course point too (FIT)

A course has no separate place for waypoints, so the café becomes a course point too, of type `food`, at the distance along the course where you pass it. PitStopper makes sure it sits exactly on a record on the line, because some apps only announce a course point there. Course points are written in order of distance, which is how a device lists what's coming up. This file holds the café's full name, as it would with Use full POI names ticked. By default PitStopper writes a shorter name, because a Garmin Edge 1040 bike computer showed only about the first 15 characters.

### 47. What is left behind (FIT)

A course has nowhere to put a route, so the route points are gone. FIT has no course point type for via or shaping either. PitStopper writes a via point in the middle of a route as a `generic` course point with its name, and leaves shaping points out. The only via points on this loop are its start and finish, which a course has anyway. The metadata, the café's description and link, and the track colour stay behind as well. What reaches the device is the line with its times and heights, the turns and the café.

### 48. And back again (FIT)

Open a FIT course in PitStopper and it all works in reverse. The records become trackpoints, with their times and heights. Turn course points become turns again, so `right_fork` comes back as `stay_right`, and a roundabout point that PitStopper wrote is recognised by its name. A generic course point on the line comes back as a via point. The café, and any other course point that isn't a turn or a via, becomes a waypoint again. The route, the shaping points and the extras from chapters 3 and 4 don't come back, because the FIT file never had them.

### 49. Summary: the same loop as FIT (FIT)

A FIT course is a list of messages. Trackpoints become records, with positions in semicircles and a distance along the course. The turns and the café both become course points, with types from a fixed list, and a via point in the middle of a route travels as a generic one. The route, shaping points, metadata and extensions have no place in a course and get left behind.

### 50. Test yourself: the same loop as FIT (FIT)

1. What is a FIT file made of?
   - Messages, each a row of named fields (right)
   - XML elements, like GPX
   - A zipped GPX
   FIT is binary, so it has no elements. The decoder shows each message as a row of fields.

2. What does a GPX trackpoint become in a FIT course?
   - A `record` (right)
   - A `course_point`
   - A `lap`
   Records make up the line, and course points are things along it.

3. Where does a turn go in a FIT course?
   - In a `course_point` with a turn type (right)
   - In the `course` message
   - Nowhere: FIT has no turns
   FIT has its own list of turn types, such as left and right_fork.

4. What happens to the route points and the shaping points in a FIT course?
   - They are left behind (right)
   - They become course points
   A course has no place for a route, and FIT has no course point type for shaping. A via point in the middle of a route does travel, as a generic course point.

5. In the decoded file, what is 611431783?
   - The church's latitude, in semicircles (right)
   - The distance along the course, in millimetres
   - A serial number
   FIT stores positions as whole numbers, and 611431783 is 51.24962° in semicircles.

6. A tool wrote this course point. What is wrong?

```xml
course_point  distance=736.7  type=roundabout  name=Exit 2
```

   - FIT has no `roundabout` type (right)
   - A course point cannot have a type
   - A course point cannot have a name
   FIT has no course point type for a roundabout. PitStopper writes a generic point named after the exit instead.

### 51. Common mistakes (GPX)

- Mistaken: I'll send the route, it's the same thing.
  In fact: A route (`rte`) is only the points to pass. An app that plans routes works out the roads between them again, and may pick different ones. One that doesn't, such as Organic Maps, just joins them with straight lines. To ride the roads you planned, send the track (`trk`).
- Mistaken: A track is something a GPS recorded.
  In fact: A track is just a line. It can be a recording, or planned, like the loop in this tutorial, which a router drew.
- Mistaken: Every point in a GPX file is a waypoint.
  In fact: Only `wpt` is a waypoint: a single place outside any line. Route points (`rtept`) and trackpoints (`trkpt`) are different elements, even though they hold the same kinds of data.
- Mistaken: GPX has turn-by-turn instructions.
  In fact: GPX 1.1 has no element for a turn. Turns written in `sym` and `cmt` are a convention that only some apps read. A Garmin device takes its turns from a FIT course instead, or works them out itself.
- Mistaken: If the file is valid GPX, every app will show it the same way.
  In fact: Valid only means the file follows the rules. Each app picks what it reads, and many skip extensions, symbols or whole elements they don't use.
- Mistaken: My track colour will go wherever the file goes.
  In fact: Colour lives in `extensions`, not in GPX 1.1. An app that doesn't know the extension ignores it, and many drop it when they save the file again.
- Mistaken: The times are in my own time zone.
  In fact: GPX times are in UTC, marked with a Z. A file whose times are an hour or two out was usually written in local time by a converter. Leave the Z off and apps disagree: some read the time as UTC, some as local time, and gpx.studio drops it.
- Mistaken: Writing via in a trackpoint's type is enough to make a via point.
  In fact: Locus Map only reads a trackpoint whose `sym` holds a name it knows, so a via or shaping point needs `pass_place` in `sym` as well as its `type`. Apps outside this convention ignore both.
- Mistaken: The order of the elements doesn't matter.
  In fact: GPX 1.1 fixes the order: waypoints, then routes, then tracks, and inside a point `ele` before `time`, `cmt` before `sym`. A file in the wrong order won't validate, and strict tools such as BaseCamp may refuse it.
- Mistaken: A .gpz is a kind of GPX that every app opens.
  In fact: A .gpz is a zip file holding a GPX file and its icons and photos. It isn't part of GPX 1.1, and a Garmin device can't open one.

## Glossary

| Element | Name | What it means |
|---|---|---|
| `XML` | XML | A common way of writing text files as elements. GPX is written in it. |
| `attribute` | attribute | A setting inside an opening tag, written name="value", such as lat="51.25". |
| `gpx` | the file | The whole GPX file. Everything else sits inside it. |
| `version` | GPX version | Which version of GPX the file follows. 1.1 has been the current one since 2004. |
| `creator` | creator | The app or device that wrote the file. |
| `xmlns` | vocabulary address | A web address that says which vocabulary the element names come from. On the gpx element it names GPX 1.1. |
| `rte` | route | A list of route points to pass through, in order. An app that can plan routes works out the roads between them. Without one, it draws straight lines. |
| `name` | name | The name of whatever it sits in, which can be the file (in metadata), a track, a route or a point. |
| `rtept` | route point | One place a route must pass, in order. A route planner makes one each time you click the map. |
| `lat` | latitude | North-south position in decimal degrees, on WGS84, the datum GPS uses. |
| `lon` | longitude | East-west position in decimal degrees, on WGS84, the datum GPS uses. |
| `trk` | track | A line made of trackpoints, either the way to follow or the way you went. |
| `trkseg` | track segment | One unbroken stretch of a track. A new segment means the line was broken there. |
| `trkpt` | trackpoint | One point on a track's line, with a latitude and longitude and often a height and a time. |
| `UTC` | UTC | World time, the time zone GPX times are written in, marked with a Z. |
| `ele` | elevation | Height in metres, usually above sea level. |
| `time` | time | When you were at the point, or plan to be, in UTC (world time). |
| `wpt` | waypoint | A single place, such as a café. Not part of a line, and in no order. |
| `sym` | symbol | The icon for a point, given by name. GPX has no list of names. By convention, Cruiser and Locus Map also read it on a trackpoint, as a turn or as pass_place for a via or shaping point, and in a .gpz an app matches it against an icon file's name. |
| `cmt` | comment | Free text about the point, which GPX 1.1 says is sent to the GPS. Cruiser and Locus Map read a turn's street name from it. |
| `desc` | description | A description of the file or the point, meant for the reader. |
| `convention` | convention | An agreement between some apps to read a GPX 1.1 element in a certain way. It isn't part of GPX 1.1. |
| `type` | type | A word for what kind of point it is. GPX 1.1 sets no values. Locus Map and Cruiser use via and shaping, with pass_place in sym. |
| `extensions` | extensions | A place for anything GPX 1.1 does not cover, written in another vocabulary. Apps skip what they do not know. |
| `prefix` | prefix | A short label before an element name, such as xsi: or gpxtpx:, saying which vocabulary it comes from. It's declared on the gpx element. |
| `xsi` | xsi:gpx block | A block of display settings, such as a track's colour, written under the prefix xsi, which is declared at the top of the file. OsmAnd and Organic Maps read its colour, and OsmAnd its width too. Locus Map does not read it. |
| `color` | colour | A line or marker colour, as #RRGGBB, inside xsi:gpx. |
| `width` | width | A line's thickness on screen, inside xsi:gpx. |
| `metadata` | metadata | The file's own details, such as its name, description, time and bounds. It always comes first. |
| `bounds` | bounds | The smallest box that holds everything in the file. |
| `link` | link | A web page or other file about the file or the point, in href. |
| `href` | web address | The address in a link, usually a web page, or a file inside a .gpz. |
| `text` | link text | The label shown for a link. |
| `gpxtpx` | Garmin sensor data | Garmin's TrackPointExtension, which adds heart rate (hr), cadence (cad) and more to each trackpoint. |
| `.gpz` | .gpz | A zip file holding a GPX file and the files it uses, such as icons and photos. |
| `FIT` | FIT | Garmin's binary file format for courses and recorded rides, read by many bike computers. |
| `message` | message | One entry in a FIT file, such as a record or a course point. It's FIT's version of a GPX element. |
| `field` | field | One named value in a FIT message, such as distance or name. |
| `file_id` | file id | The first FIT message, saying what kind of file this is, here a course. |
| `course` | course | FIT's kind of file for something to follow, like a planned track. Also the message inside it that holds the name and sport. |
| `lap` | lap | A FIT message summing up a stretch, with its start, end, distance and time. A course usually has one lap covering the whole course. |
| `event` | event | A FIT message for something that happens, such as the timer starting or stopping. |
| `semicircle` | semicircle | FIT's whole-number unit for latitude and longitude. |
| `record` | record | A FIT message for one point on the line, with its time, position, altitude and distance. |
| `course_point` | course point | A FIT message for something along a course, such as a turn or a place to stop for food or water. |
