1

I'm trying to calculate the distance between points taken from a .tcx file (i.e. with latitude and longitude) when the attribute DistanceMeters is not present. In doing this I used as a test some .tcx with that attribute and I cannot obtain the same distance. I'm aware of the Haversine function (it overshoots in the found implementations btw), I'm aware of distance between GeoJSON (it overshoots using , again). Other tips and suggestions are welcome!

These are 3 points that I used as a benchmark (redacted with only the useful bits).

<Trackpoint>
                <Time>2020-11-05T17:26:33.000Z</Time>
                <Position>
                  <LatitudeDegrees>45.809465954080224</LatitudeDegrees>
                  <LongitudeDegrees>9.09074085764587</LongitudeDegrees>
                </Position>
                <AltitudeMeters>220.1999969482422</AltitudeMeters>
                <DistanceMeters>0.0</DistanceMeters>
              </Trackpoint>
              <Trackpoint>
                <Time>2020-11-05T17:26:35.000Z</Time>
                <Position>
                  <LatitudeDegrees>45.80945455469191</LatitudeDegrees>
                  <LongitudeDegrees>9.090738091617823</LongitudeDegrees>
                </Position>
                <AltitudeMeters>220.1999969482422</AltitudeMeters>
                <DistanceMeters>0.019999999552965164</DistanceMeters>
              </Trackpoint>
     <Trackpoint>
                <Time>2020-11-05T17:26:40.000Z</Time>
                <Position>
                  <LatitudeDegrees>45.80951012670994</LatitudeDegrees>
                  <LongitudeDegrees>9.090708252042532</LongitudeDegrees>
                </Position>
                <AltitudeMeters>220.0</AltitudeMeters>
                <DistanceMeters>6.46999979019165</DistanceMeters>
              </Trackpoint>
  • Have a look at this: https://en.wikipedia.org/wiki/Haversine_formula – Oliver Mason Nov 09 '20 at 10:36
  • Did you find a solution to this? – Maria Ines Parnisari May 23 '21 at 04:59
  • 1
    @MariaInesParnisari in the end the Haversine formula was useful, I started from the assumption that I had a correct reference length, which was wrong. A good implementation could be found in the first comment here https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula?rq=1 – thewritingdude May 24 '21 at 07:08

0 Answers0