The GPS Exchange format (GPX extension) is an XML standard for communicating GPS route data. One common use-case for this data format is storing fitness workout data from GPS-enabled watches. On my recent trip to India for PowerShell Conference Asia, I tracked my walks around Bangalore while I was doing some site seeing before the conference. In this post, we will look at how to convert this GPX data to a usable format so that we can draw it on a UDMap vector layer.
Below is an activity that I recorded using my Garmin 920xt and uploaded to Strava. You can export the GPX file from Strava by selecting your activity and clicking the Export GPX link in the options.
The GPX file consists of a series of nodes that track your GPS location every second. This allows you to calculate distance and velocity for use in tracker apps like Strava.
For this example, I’m using the full GPX files that you can download here.
Converting GPX to the UDMap Vector Format
When drawing polylines in a UDMap, you need to pass an array of latitude and longitudes to the Positions parameter of New-UDMapVectorLayer. It’s pretty straightforward to read the content of the GPX file, convert it to an XML object and the select all the positions from the tracking points.
Rendering the UDMap
Once we’ve configured our data to the proper model, we can then pass the values into the UDMap control to render the map. In this example, I’m using the 3 days that I walked around and creating individual layers for each day. Each day is a different color and you can toggle those days on and off.
If you run this map in UD, you will now see the individual vector layers.