You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(TrackPointExtension/v2 is a common way to include heart rate data.)
It is not under my control how they do this, and I believe it is perfectly valid. These files open and parse correctly in all the other GPX applications I use. They open but don't parse correctly in gpxpy. In particular, no tracks are found.
Yes, it is definitely not handling the case where the default namespace is not http://www.topografix.com/GPX/1/1. That seems to be a bug to me. In fact, even ElementTree by default will use ns0 for http://www.topografix.com/GPX/1/1 and no default namespace. It is valid.
I fixed it by using ElementTree to parse the file after setting the default namespace to be http://www.topografix.com/GPX/1/1 and then passing the resulting XML to gpxpy.parse.
import xml.etree.ElementTree as ET
# Ensure GPX/1/1 is the default namespace
ET.register_namespace('', "http://www.topografix.com/GPX/1/1")
tree = ET.parse(file_name)
root = tree.getroot();
xml = ET.tostring(root, encoding='unicode');
# Parse the xml string
gpx = gpxpy.parse(xml)
Normally the default namespace for a GPX file is http://www.topografix.com/GPX/1/1.
However it doesn't have to be. Many of my files have the default namespace as http://www.garmin.com/xmlschemas/TrackPointExtension/v2
(TrackPointExtension/v2 is a common way to include heart rate data.)
It is not under my control how they do this, and I believe it is perfectly valid. These files open and parse correctly in all the other GPX applications I use. They open but don't parse correctly in gpxpy. In particular, no tracks are found.
The difference is
Ok Files:
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:ns2="http://www.garmin.com/xmlschemas/TrackPointExtension/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" creator="Polar Access Manager" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
Not OK files:
<ns2:gpx xmlns="http://www.garmin.com/xmlschemas/TrackPointExtension/v2" xmlns:ns2="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" creator="Polar Access Manager" xsi:schemaLocation="http://www.topografix.com/GPX/1/1
gpx.nsmap gives:
Ok Files:
Not Ok files:
Notice xsi is not all there.
Sample files:
gpxpy_issue.zip
The text was updated successfully, but these errors were encountered: