Messes with <extensions>
Closed this issue · 2 comments
Shohreh commented
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.
Shohreh commented
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()