xue35 / TCX.jl

TCX parses TCX/XML sports file.
MIT License
1 stars 2 forks source link

Fixed issue which causes reams of EzXML warnings. Also fixed bug. #22

Open michael-prange opened 3 years ago

michael-prange commented 3 years ago

When I ran the TCX package (from the julia package manager) on a TCX file generated by my new Garmin GPSMAP 66i, it crashed. Digging into the code I found that this version of the TCX.jl has strong dependencies on the node ordering in the XML archive. Those assumptions were violated in the XML that Garmin generates for my GPS. I then grabbed the latest version from GitHub and found that those dependencies had been largely removed. That version works on my file. Unfortunately, there are reams of warning messages generated. These appear in the image below. I tracked that down to the use of findfirst() and findall() in TCX.jl. I made a PR and fixed the problem by removing all instances of those two functions. This also removed even more order dependencies. I also fixed a bug in TCX.jl in which the last two arguments in aTrackPoints = vcat(aTrackPoints, TrackPoint(tp_time, tp_lat, tp_lont, tp_bpm, tp_dist, tp_alt)) should have been in the reverse order. This new version passes all the package tests. I'm about to submit my changes to GitHub for your consideration.

outputScreen

test.tcx:

<?xml version="1.0" encoding="UTF-8"?>
<TrainingCenterDatabase
  xsi:schemaLocation="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd"
  xmlns:ns5="http://www.garmin.com/xmlschemas/ActivityGoals/v1"
  xmlns:ns3="http://www.garmin.com/xmlschemas/ActivityExtension/v2"
  xmlns:ns2="http://www.garmin.com/xmlschemas/UserProfile/v2"
  xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="http://www.garmin.com/xmlschemas/ProfileExtension/v1">
  <Activities>
    <Activity Sport="Other">
      <Id>2020-10-31T13:31:06.000Z</Id>
      <Lap StartTime="2020-10-31T13:31:06.000Z">
        <TotalTimeSeconds>13491.0</TotalTimeSeconds>
        <DistanceMeters>10886.65</DistanceMeters>
        <MaximumSpeed>2.490000009536743</MaximumSpeed>
        <Calories>0</Calories>
        <AverageHeartRateBpm>
          <Value>108</Value>
        </AverageHeartRateBpm>
        <MaximumHeartRateBpm>
          <Value>146</Value>
        </MaximumHeartRateBpm>
        <Intensity>Active</Intensity>
        <TriggerMethod>Manual</TriggerMethod>
        <Track>
          <Trackpoint>
            <Time>2020-10-31T13:31:06.000Z</Time>
            <Position>
              <LatitudeDegrees>44.414741825312376</LatitudeDegrees>
              <LongitudeDegrees>-71.09249182976782</LongitudeDegrees>
            </Position>
            <AltitudeMeters>228.8000030517578</AltitudeMeters>
            <HeartRateBpm>
              <Value>115</Value>
            </HeartRateBpm>
            <Extensions>
              <ns3:TPX>
                <ns3:Speed>0.0</ns3:Speed>
              </ns3:TPX>
            </Extensions>
          </Trackpoint>
          <Trackpoint>
            <Time>2020-10-31T13:31:51.000Z</Time>
            <Position>
              <LatitudeDegrees>44.414734449237585</LatitudeDegrees>
              <LongitudeDegrees>-71.09259953722358</LongitudeDegrees>
            </Position>
            <AltitudeMeters>228.39999389648438</AltitudeMeters>
            <DistanceMeters>8.619999885559082</DistanceMeters>
            <HeartRateBpm>
              <Value>101</Value>
            </HeartRateBpm>
            <Extensions>
              <ns3:TPX>
                <ns3:Speed>0.4300000071525574</ns3:Speed>
              </ns3:TPX>
            </Extensions>
          </Trackpoint>
        </Track>
        <Extensions>
          <ns3:LX>
            <ns3:AvgSpeed>0.8069565184660143</ns3:AvgSpeed>
          </ns3:LX>
        </Extensions>
      </Lap>
      <Creator xsi:type="Device_t">
        <Name>GPSMAP 66i</Name>
        <UnitId>3344676145</UnitId>
        <ProductID>3284</ProductID>
        <Version>
          <VersionMajor>6</VersionMajor>
          <VersionMinor>30</VersionMinor>
          <BuildMajor>0</BuildMajor>
          <BuildMinor>0</BuildMinor>
        </Version>
      </Creator>
    </Activity>
  </Activities>
  <Author xsi:type="Application_t">
    <Name>Connect Api</Name>
    <Build>
      <Version>
        <VersionMajor>0</VersionMajor>
        <VersionMinor>0</VersionMinor>
        <BuildMajor>0</BuildMajor>
        <BuildMinor>0</BuildMinor>
      </Version>
    </Build>
    <LangID>en</LangID>
    <PartNumber>006-D2449-00</PartNumber>
  </Author>
</TrainingCenterDatabase>