Been playing around with some of my scripts for messing with GPX files, getting them ready for events and for looking at them afterwards.
My usual method (for long rides such as Audaxes) is this:
1) Plot route on bikely with follow-roads mode off, and using one point per routesheet instruction, naming each point with a shortened version of the instruction (L/R/SO/LR/E3/etc)
2) Download this sparse GPX file (bikely gives you a bunch of named waypoints plus a track with elevations of these points). I junk the track section and convert the waypoints to a route by changing "wpt" to "rtept" and adding in a <rte><name>name</name> ... </rte> bits.
3) Manually check that I've not mislabeled any of the L/R instructions
4) Plot the route on bikehike using follow roads and download the GPX (track with elevations). Find the summits of the major climbs (annoyingly tricky to find the actual locations and heights) and add these as summit points on the route for the GPX.
5) Split the route GPX file at the appropriate places (to keep within limits).
6) Add in any other appropriate routes (between stations, hotels, start/finish, etc) from a library of previously made routes, or from a new one.
7) Check that the points with the route GPX are uniquely named, and not more than 6 characters.
8) Upload to GPS.
Certain bits of this are a real faff so I want to automate some of it.
Plotting the route (1) is good as I get to see where I'm going, can tell if the routesheet is off for any reason, and I've usually got a good memory for knowing where I'll be passing towns/shops/pubs or train stations. This will always be manual.
2) Splitting the file and changing the waypoints to routepoints can be automated.
3) I've got a script that checks the angle of the turn at each routepoint (compare bearings of lines from previous routepoint to current, and from current to next routepoint). Not perfect but it does help catch the odd one that creeps through.
4) The summit point finding is annoying and I've just sorted out a script to do this. It works by doing thing following:-
do {
for each point
delete it if the previous elevation is lower and the next point's elevation is higher
or, delete it if the previous elevation is higher and the next point's elevation is lower
# at this point we have a series of peaks and troughs although many of the troughs
# are very small climbs/descents which need to be removed
for each point
if this is a trough point (i.e. previous and next points are higher)
if previous elevation is less than 50m higher then remove this current point
or, if next elevation is less than 50m higher then remove this current point
} while( number of points removed in this iteration > 0 )
The second part slowly filters out all of the small climbs (under 50m), or bits where it descends for a few meters, and the first part then repeats the cleanup of subsequent series of descents/ascents.
The 50m figure is what I'd consider a minimum "climb" that I'd like to know about in advance. The lower the figure you use here and the more climbs it will identify. Running this against the BCM elevation plot it found the peak of every climb I'd identified by looking at the elevation plot, plus the Bow Street climb (which I'd missed). It's also a hell of a lot quicker!
Once I've found the peaks I can make routepoints for them with the summit heights in their name, and then merge them into my route in the right place (by looking for the nearest routepoints, easy for a computer to do, tricky for a human to look at a lat/lon and work out where it goes). I also want to warn if they appear very shortly after a turn (i.e. I'd have no real warning of the end of the climb if I didn't look at the map page) and decide if I need to move it.
This one single job (finding the summit points and adding them to the GPX) took me over an hour for the BCM route. This new script does it in seconds and the manual check is only a minute or so.
The rest of the jobs are more checking (unique names, character limits).
Upload is manual using GPS Trackmaker but I could automate it with gpsbabel, but I know that GPSTM works and I trust it.
Post ride I want to look at how much climbing there was, filtering out the glitches, and see how much time in hand I had/lost as the ride went along. It's a bit more time consuming as the ride is often split over various tracklogs/segments and also includes non-ride sections such as rides to the start from a hotel or station.
All done in Perl at the moment with no proper XML parsing (just regexp) so it only really works on GPX files in a certain format. Proper XML parsers are complex and too feature rich for my needs. I'm planning on cleaning it all up and sticking it up somewhere for downloading. I could, theoretically, make it into one single application that could produce the graphing too, but that's time consuming.
So, are there any other things I could be doing? Anything else that people are constantly doing with GPX files that could be made easier?
<awaits tumbleweed>