The Issue

I have an older GPS device I use for biking on an unregular basis, mostly when I plan longer bike trips in areas where I have not been before. It is a Bryton Rider 50.

I like to do my planning on the Komoot platform (komoot.com), which allows me to export my planned trips to a gpx formatted xml file -- which theoretically I should be able to import to the Bryton Rider 50 with its accompanying macOS application BrytonBridge2. I had done this successfully before.

Problem was though, that this time around, BrytonBridge2 failed to import the Komoot gpx file with below error message, that it would only accept BDX or GPX files -- even though the latter was the format I had the trip exported to.

import-failure

The Reason

At first glance comparing a .gpxfile exported from the Bryton Rider 50 to my computer and comparing it with the one generated at Komoot, they seemed to be pretty much the same -- letting aside a few minor differences in metadata. But even after copying everything within the xml <trk> </trk> tags from the Komoot file to the Bryton one, importing didn't work.

So I went and looked for any log files produced by the BrytonBridge2. Turns out, that when opened, this application has a menu bar icon on macOS with one of the menu item being Export Log. I do not know how this looks on Windows, but I guess there must be a menu item to export the logs some place as well.

menu-bar

I exported the log and took a look into it, finding the problem there (line 8):

2018-10-06 09:00:54,089 [Python]    Traceback (most recent call last):
  File "/Users/bryton/jenkins-build/workspace/bb3-mac/Release/common/bbweb/device.py", line 382, in check_import_track_file
  File "/Users/bryton/jenkins-build/workspace/bb3-mac/Release/common/kmlgpx.py", line 623, in gpx1to2
  File "/Users/bryton/jenkins-build/workspace/bb3-mac/Release/common/kmlgpx.py", line 394, in fromgpx
  File "/Users/bryton/jenkins-build/workspace/bb3-mac/Release/common/kmlgpx.py", line 325, in _readTrackPoints
  File "/Users/bryton/jenkins-build/workspace/bb3-mac/Release/mac/python2.7/_strptime.py", line 454, in _strptime_time
  File "/Users/bryton/jenkins-build/workspace/bb3-mac/Release/mac/python2.7/_strptime.py", line 325, in _strptime
ValueError: time data '2018-08-18T11:07:05.168Z' does not match format '%Y-%m-%dT%H:%M:%SZ'

It seems as though it didn't like the time format, then. It took me quite some time to see the difference, but sure enough, the timestamp <time> </time> in a trackpoint of the Komoot .gpx file uses a thousand of a second, while the Bryton .gpx file doesn't...

# Komoot file:
<trkpt lat="47.000000" lon="7.000000">
    <ele>358.4</ele>
    <time>2018-08-18T11:07:05.168Z</time>
</trkpt>

# Bryton file:
<trkpt lat="47.000000" lon="7.000000">
    <ele>360.2</ele>
    <time>2017-06-25T09:02:38Z</time>
</trkpt>

I am not questioning as to why Bryton is creating such a non-fogiving software as it would be just a waste of time -- at least now I knew, what was wrong.

The Fix

After I had found out, where exactly the problem was, I used Regex to fix things with the Atom editor. So I opened up the Komoot file, searched for the pattern :%S.%s, %S being seconds, %s being a thousand of a second (see line 2 below). To get rid of the thousands of a second in this expression I just had to replace it with $1, leaving only the first expression found by Regex and deleting the second expression -- those two are each encapsuled in parentheses.

# Find
(:\d{2})(.\d{3})
# Replace
$1

A Replace All in Atom now produced a .gpx file I could import to my Bryton Rider 50 successfully -- so this is a happy end after all.

Previous Post Next Post