tkrajina / gpxpy

gpx-py is a python GPX parser. GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
Apache License 2.0
1.01k stars 223 forks source link

ZeroDivisionError: float division by zero #197

Closed thot1 closed 4 years ago

thot1 commented 4 years ago

If the same timestamp is set in two consecutive waypoints, a division by zero results.

In file gpx.py 896 timedelta = point.time - previous.time # =0 918 speeds_and_distances.append((distance / mod_utils.total_seconds(timedelta), distance, )

Ok, I admit that my sports watch has probably made a mistake :-)

tkrajina commented 4 years ago

I suppose you mean two track point, not waypoints, right? If that's the case I think this should be fixed with a37b6228ce84249e120035297014ce104d7ba5b0.

mjb6 commented 4 years ago

Hi! My Tomtom runner watch sometimes also produces multiple trackpoints per second. I was just about to propose the same bugfix ;)

Could you please create a release that contains this fix?

In case it helps for regression testing, I attached a stripped version of a gpx file that throws the FloatDivisionByZero error when calling get_moving_data() of gpxpy 1.4.0

fail_gpx.txt

tkrajina commented 4 years ago

@mjb6 1.4.1 with that fixed was already released. But I also released 1.4.2 now.