I have been running a little while now and am always in the habit of taking my phone with me to get some monitoring in on my progress with the aid of GPS and so on. I have been using a really nice app called mapmyrun. It has given me months of good service and what with the moderate amount of running I have done, I have committed a fair few hours worth of data online.
Meanwhile I have decided that it would be great to get out running with a group of people rather than on my own all the time, so I have joined up with a very friendly local running group in Caistor, Lincolnshire. Quite a number of them use a different app called Strava, and I thought that I would give it a go based on some positive recommendations from members of the group.
You might wonder what this article is doing in the software section of this site... well, read on.
All the fun started when I decided to investigate how to export my running data from mapmyrun into a format I could potentially import to another site, such as Strava. Simple, I thought, just go to each workout  in turn and export the session as a GPX file. To clarify, the GPX file standard is intended to be a commonly understood way of sharing GPS data between software applications in XML format.
Without getting too technical, GPX files are capable of describing two types of track point sets, where a track point set is a collection of one or more latitude and longitude coordinates:
- A route is a set of track points purely describing a route from start point to end point.
- A track is a set of track points describing a route that has been travelled, complete with time and date at each point.
So, after some investigation I discovered that mapmyrun does allow GPX file export, but only of route data, not track data. One might say that this left me slightly perplexed and not a little disappointed. I did a little research and found Mike Palumbo's MapMyRide GPX Converter; now I wanted something similar but for their running site.
It was time to roll up my sleeves hack some quick and dirty code.
If you are interested in using the code I have put together then it is available here from my GitHub account. It is very rough and ready, but should run out of the box, providing you have the pre-requisites sorted, i.e. Linux box etcetera.
Here follows a brief description of what the code does:
- Makes a cURL request to the mapmyrun server - specifically the end point that serves background data for the maps rendered on the workout page.
- Loads the data recovered from the request above and creates a JSON object.
- Creates a datetime object from the start time contained in the data.
- Creates a XML GPX skeleton to which the processed data will be added.
- For each item in the data series the time and date is calculated and appended to the GPX skeleton, along with lat, lon and altitude data.
- When the series has been fully processed the completely formed XML document is dumped into a GPX file locally on the file system.
Each workout needs to be publically accessible in order for the script to be able to access the data; there is no form of authentication. Actually, the mapmyrun site does have an API which supports OAuth and it may an interesting future exercise to have another attempt at getting GPX data out with it.
Running the code is a pretty basic affair also: editing the script before every run is far from ideal. The script would be much improved by being able to accept command line instruction instead.
It is fairly likely that I will stick with using Strava, for several reasons: in my testing so far it seems like a more robust app and in general a little easier to use. Strava does seem to use a little less battery than mapmyrun and in addition the interaction with the GPS on my Android phone is much improved.
Also, as previously mentioned, quite a few folks from the running club are already using Strava and therefore there is a wealth of comparison data, routes, personal bests and so on.
At some point I shall get round to improving the code; it is there mostly for my benefit, however I am leaving it as an open source project for others to use, abuse or possibly even improve.
Good luck, and free your data.
|||Workouts are what the mapmyrun site calls individual training sessions.|