I occasionally make simple mashup of of gpx, google maps and flickr photos of walks. I record gpx on the Trails app on my phone, take photos with the phone too as they are nicely geo tagged and flickr can use that information and provide in the API 1.
One of the things I noticed was that the GPX files can be pretty big, over a megabyte each. I know there was probably a lot of information in the file that was not needed to display the path on the map but was not sure of how to do so easily. I think I’ve used online services for this before. Finding a site, uploading a file and downloading is a lot of bother for something that I hope will be quick and simple. I also expect that the audience for the pages produced is one.
Having a look inside the gpx files I though that you could probably slim them down considerably, each point is recorded like this:
<trkpt lat="55.996687" lon="-4.389713"><ele>188.609</ele><time>2016-06-05T10:12:58Z</time><extensions><gpxtpx:TrackPointExtension><gpxtpx:speed>1.30</gpxtpx:speed><gpxtpx:course>206.37</gpxtpx:course></gpxtpx:TrackPointExtension><trailsio:TrackPointExtension><trailsio:hacc>5.00</trailsio:hacc><trailsio:vacc>3.00</trailsio:vacc><trailsio:steps>2</trailsio:steps></trailsio:TrackPointExtension></extensions></trkpt>
I am pretty sure all we need is:
<trkpt lat="55.996687" lon="-4.389713"><ele>188.609</ele></trkpt>
and that a regular expression could do the trick.
I don’t know anything about RegEx other than I’ve found it offered as a solution when googling text replacement problems but this:
replace: <extensions>.?</extensions> with nothing
followed by replace: <time>.?</time> with nothing
I am guessing I could combine these, but it din’t take long to run through a few files using them in this crude form.
did the trick. My 1MB file was now 160KB
This works both in BBEdit and TextMate. TextMate struggled a bit with the size of the files.
This post will be of little interest to anyone but myself and might just fit in the suchlike bit of this blogs sub title.
Featured Image: two screenshots, layered. my own CC-BY.