Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parsing of gpx files produced by garmin fenix watches #23

Closed
wants to merge 3 commits into from

Conversation

cz8s
Copy link

@cz8s cz8s commented Jun 14, 2013

the fenix watch writes a wrong time in the metadata section of the gpx.
It is even in the future.
When using this for calculating the duration, you get the time and
the pace wrong. I just ran 30km in 0.01 Minutes. That seems to be too fast :)

By using the time of the first trkseg as the starting time, everything
works as expected.

the fenix watch writes a wrong time in the metadata section of the gpx.
It is even in the future.
When using this for calculating the duration, you  get the time and
the wrong pace. I just ran 30km in 0.01 Minutes. That seems to be too fast :)

By using the time of the first trkseg as the starting time, everything
works as expected.
@eoineoineoin
Copy link

So this problem isn't limited to cz8s's watch. A GPX file can contain a date in a metadata section, which [seems like it] is the date which the device exported the GPX. I was seeing a crash when pytrainer attempted to parse a duration of "-10 days, 6 hours."

Independently, I made a similar fix, but found there was an additional change required inside pytrainer/lib/gpx.py to get the start date when importing working.

I didnt' realize there were multiple ways of specifying a route inside a GPS when I made my fix -- how many are there? I think the only reasonable fix is to check each of them.

I don't think I can append a change to this existing pull request, but this is the fix I made: eoineoineoin@0c1962f

@dgranda
Copy link
Member

dgranda commented Jul 15, 2013

According to GPX schema, we have:

  • Waypoints -> wpt
  • Routes -> rtept
  • Tracks -> trkpt

Selecting just one of them will make pytrainer to fail for the other two, so I guess the most flexible solution would be to select first "time" entry in any of the possible options. Something like (would need to check xpath syntax):

timeElement = root.find(".//{http://www.topografix.com/GPX/1/1}[trkpt|rtept|wpt]//{http://www.topografix.com/GPX/1/1}time") 

Does it make sense?

@eoineoineoin
Copy link

Yeah, that makes sense. Definitely more robust than getting the first time element in the doc.

@dgranda
Copy link
Member

dgranda commented Oct 31, 2013

Just for the records: I realized that pytrainer does not support GPX 1.0, therefore it would be a good idea to build expression so it matches both 1.0 and 1.1 definitions

@dgranda
Copy link
Member

dgranda commented Nov 3, 2013

I have realized that ElementTree has reduced xpath support, so better using full xpath support.

The approach is to get the value for the first "time" element found skipping "metadata" section. I also noticed that "time" element is optional inside "metadata"

timeElement = root.xpath(".//g:time[not(parent::g:metadata)]", namespaces={'g': 'http://www.topografix.com/GPX/1/1'})[0]

dgranda added a commit that referenced this pull request Nov 3, 2013
…andatory and sometimes unaccurated one located in metadata section - Ticket #23
cz8s and others added 2 commits November 3, 2013 17:49
@dgranda
Copy link
Member

dgranda commented Nov 3, 2013

Testing seems successful so I close current ticket.

Thanks for feedback!

@dgranda dgranda closed this Nov 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants