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
Conversation
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.
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 |
According to GPX schema, we have:
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):
Does it make sense? |
Yeah, that makes sense. Definitely more robust than getting the first time element in the doc. |
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 |
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"
|
…andatory and sometimes unaccurated one located in metadata section - Ticket #23
…andatory and sometimes unaccurated one located in metadata section - Ticket pytrainer#23
Testing seems successful so I close current ticket. Thanks for feedback! |
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.