Author Topic: Stripping extensions out of gpx tracks  (Read 2948 times)

Manotea

  • Where there is doubt...
Stripping extensions out of gpx tracks
« on: 12 July, 2016, 07:16:36 pm »
<extension> tags in gpx tracks are upsetting my old school mapsource software. Whats the best utility for stripping them out whilst leaving the rest of the track unnchanged?

Might be as simple as a grep...

Feanor

  • It's mostly downhill from here.
Re: Stripping extensions out of gpx tracks
« Reply #1 on: 12 July, 2016, 09:18:47 pm »
Are you sure it is actually those tags that are upsetting it?

I've found 2 things that upset it.
No trkseg tags enclosing thr trkpoints inside the trk;
No Creator in the header.

You can try stripping the tags and see how you get on.
For that kind of task I'd use notepad++ which has an advanced search / replace function which allows you to wangle pretty much anything you like.

jiberjaber

  • ... Fancy Pants \o/ ...
  • ACME S&M^2
Re: Stripping extensions out of gpx tracks
« Reply #2 on: 12 July, 2016, 09:50:12 pm »
Have you tried Phil's web tool to see if that cleans it up?
Regards,

Joergen

fuaran

  • rothair gasta
Re: Stripping extensions out of gpx tracks
« Reply #3 on: 12 July, 2016, 10:02:02 pm »
Or try GPSBabel, just set it to output GPX, without any other options. It should produce a valid file for Mapsource.

frankly frankie

  • I kid you not
    • Fuchsiaphile
Re: Stripping extensions out of gpx tracks
« Reply #4 on: 13 July, 2016, 09:51:12 am »
Or GPS Visualizer (file convert page) same thing, very easy to use.

I've found 2 things that upset it.

Mapsource is intolerant of many things that don't conform precisely to the GPX schema, whereas most other software (and GPSs) is more tolerant.  Rather like web browsers with dodgy html.
All sorts of trivial-seeming things are enough to break it.  For example I discovered years ago when struggling with files exported by Bikely:
Code: [Select]
    <rtept lat="-42.87647" lon="147.32327">
        <name>Point 1</name>
        <ele>33</ele>
    </rtept>
will not work in Mapsource, whereas
Code: [Select]
    <rtept lat="-42.87647" lon="147.32327">
        <ele>33</ele>
        <name>Point 1</name>
    </rtept>
works fine.  The only difference is the order of the elevation and name attributes.  Most other software wouldn't have a problem with this. 
(Bikely have since then altered their export format.)
when you're dead you're done, so let the good times roll

Phil W

Re: Stripping extensions out of gpx tracks
« Reply #5 on: 13 July, 2016, 10:06:45 pm »
<extension> tags in gpx tracks are upsetting my old school mapsource software. Whats the best utility for stripping them out whilst leaving the rest of the track unnchanged?

Might be as simple as a grep...

Notepad ++ allows you to do find replace using regular expressions. So easy enough if you're familiar with regex.

321up

  • 59° N
Re: Stripping extensions out of gpx tracks
« Reply #6 on: 14 July, 2016, 02:05:27 pm »
using textpad www.textpad.com find and replace with regular expression option...

Code: [Select]
step 1 : insert line breaks
Find "</trkpt>"
Replace with "</trkpt>\n"

step 2 : remove the extensions tags and everything between each pair
Find "<extensions>.*</extensions>"
Replace with ""

step 3 : remove line breaks (optional)
Find "</trkpt>\n"
Replace with "</trkpt>"

(don't type the quotes, enter what's between the quotes)

explanation:
some gps devices (e.g. garmin etrex30) create gpx files with no line breaks.  If do step 2 on such a file it will remove everything between the first and last extensions tags.  By adding a line break between each trackpoint the replace will be done on the extensions in each track point.  Take care if there are other tags in the gpx file such as waypoints or routes that may extensions.

textpad also supports macros.

Manotea

  • Where there is doubt...
Re: Stripping extensions out of gpx tracks
« Reply #7 on: 28 July, 2016, 09:22:31 pm »
Update: I was orginally shipped a gpx file exported from ridewithgps which mapsource didn't like. The standout feature were some <extensions> for cadence and other metrics.

I resolved the matter by asking the rider to send me the original fit file which I ran through gpsbabel to generate a gpx track. This stripped out the <extensions> fields and the resultant gpx file loads into mapsource. I now run all files (gpx, fit and tcx) through gpsbabel, so I can accept all file types for DIY processsing, so its a win all round.

Re: Stripping extensions out of gpx tracks
« Reply #8 on: 28 July, 2016, 10:15:41 pm »
So the old hands might make it easier for you by sending a proper.gdb file ;).

Manotea

  • Where there is doubt...
Re: Stripping extensions out of gpx tracks
« Reply #9 on: 28 July, 2016, 10:33:48 pm »
So the old hands might make it easier for you by sending a proper.gdb file ;).

I think of you every time... note to self add .gdb to the list... :)