You are reading a single comment by @Greenbank and its replies. Click here to read the full conversation.
  • @TW As discussed elsewhere (Running thread) Strava sometimes thinks you've stopped mid run when you haven't, and then calculates your pace based off this incorrect "moving time". It's due to the uploaded file containing trackpoints that don't have position information in them.

    If you've got a .fit file you'll need to convert it to .tcx first (either import it to something like GC that can export it as TCX) or use a tool like fit2tcx.

    OK, UNIX (should work with cygwin) command line to remove trackpoints from a TCX file (from fit2tcx) that don't contain position information:-

    cat in.tcx | sed -e 's/^  *//' -e 's/  *$//' | tr -d '\n' | sed -e 's/<\/Trackpoint>/&\n/g' -e 's/<Trackpoint>/\n&/g' | grep -v "^$" | grep -v "Time..Alti" > out.tcx
    

    This assumes that the correct lines don't have the Altitude tag following on from the closing Time tag, i.e.

    Example OK line:-

    <Trackpoint><Time>2015-01-21T12:48:55Z</Time><Position><LatitudeDegrees>51.4546127</LatitudeDegrees><LongitudeDegrees>-0.2336897235</LongitudeDegrees></Position><AltitudeMeters>50.2</AltitudeMeters><DistanceMeters>890.66</DistanceMeters><HeartRateBpm><Value>168</Value></HeartRateBpm><Extensions><TPX xmlns="http://www.garmin.com/xmlschemas/ActivityExtension/v2"><Speed>3.407</Speed></TPX></Extensions></Trackpoint>
    

    Bad line (no position tags):-

    <Trackpoint><Time>2015-01-21T12:48:48Z</Time><AltitudeMeters>51</AltitudeMeters><DistanceMeters>872.7</DistanceMeters><HeartRateBpm><Value>170</Value></HeartRateBpm><Extensions><TPX xmlns="http://www.garmin.com/xmlschemas/ActivityExtension/v2"><Speed>2.802</Speed></TPX></Extensions></Trackpoint>
    

    You may need to tweak the grep -v argument to something that only matches the lines that don't have position information in them.

    I'll follow up with a perl script to do the same (and rip out best distance segments) which will be a bit more robust, optionally do interpolation to add position tags on the trackpoints missing them, and won't rely so much on it being a specific xml format. I can't be arsed to use an XML parser so it's all hand hacked.

  • One line bash command. Like.

    Thanks for this.

    My regex is terrible - what dies this bit cover: /^ */

    Do you have one that automatically formats / indents xml files? tcx / gpx files on one line give me a headache.

About

Avatar for Greenbank @Greenbank started