tkrajina/gpxpy

Messes with <extensions>

Closed this issue · 2 comments

Hello,

When reading tracks from an input GPX file and saving them into an output file, I notice gpxpy (1.4.0) rewrites what's in [extensions], which prevents GpsTrackEditor (a Windows application) from opening the output file.

Here's an example from the input file:

    <extensions>
      <gpxx:TrackExtension>
        <gpxx:DisplayColor>DarkGray</gpxx:DisplayColor>
      </gpxx:TrackExtension>
    </extensions>

And here's what ends up in the output file:

    <extensions>
      <http://www.garmin.com/xmlschemas/GpxExtensions/v3:TrackExtension>
        <http://www.garmin.com/xmlschemas/GpxExtensions/v3:DisplayColor>DarkGray</http://www.garmin.com/xmlschemas/GpxExtensions/v3:DisplayColor>
      </http://www.garmin.com/xmlschemas/GpxExtensions/v3:TrackExtension>
    </extensions>

Any idea why?

Thank you.

Is there a better solution than simply removing all [extensions] from the file created by gpxpy?

with open('input.from.gpxpy..gpx', 'r') as file:
	data = file.read()
	data = re.sub('<extensions>.+?</extensions>', '', data,flags=re.DOTALL|re.I)
f=open("input.from.gpxpy.cleaned.gpx","w")
f.write(data)
f.close()

This is most likely because the gpx file is missing namespaces inside <gpx ...>. I made a test in ac394b9 and this works (if proper namespaces are present).

PS. If you can reproduce a bug with a test script + gpx file (with all the namespaces) -- reopen the issue.