tkrajina/gpxpy

utils.total_seconds() ignores microseconds...

jeokrohn opened this issue · 2 comments

... and that leads to a division by zero exception in get_moving_data() of a segment where two consecutive points are less than one second apart; for example only by 999990 microseconds.

The implementation of datetime.timedelta.total_seconds() avoid this issue by also considering microseconds:

    def total_seconds(self):
        """Total seconds in the duration."""
        return ((self.days * 86400 + self.seconds) * 10**6 +
                self.microseconds) / 10**6

Yes, you're right, thanks!

I wrote a test to reproduce this problem here: https://github.com/tkrajina/gpxpy/commits/subsecond-times . But just changing to your fix makes some other tests fail. I need to fix those other tests before merging that in master or dev.

Fixed in 1.4.1