Skip to content

Conversation

@aronsommer
Copy link
Contributor

Description

This pull request fixes a bug where the total time calculation was dependent on the selected display units (metric vs. imperial), leading to incorrect results.

The root cause was that the distance increment (dx) was derived from this._data[i].dist, a value that changes based on the unit system. The fix ensures the distance is always calculated in meters using latlng.distanceTo() and then converted to kilometers, making the time calculation consistent regardless of the selected display units.

This change resolves the issue described in #300.


How to Test

  1. Use url: "../examples/tracks/very-long.gpx", in the demo.
  2. Switch between imperial and metric units (imperial: true/false).

Before this change:

  • imperial: true shows a total time of 3d 01:52'38".
  • imperial: false shows a total time of 4d 22:53'38".

After this change:

  • imperial: true shows a total time of 4d 22:53'35".
  • imperial: false shows a total time of 4d 22:53'35".

The results are now consistent.


Additional Observation

While using url: "../examples/tracks/only-few-points.gpx", I observed a separate issue. A mismatch occurs between the durata value in the tooltip and the value on the top time axis when hovering between data points. This happens because the tooltip's time only updates when the cursor is directly over a point, not continuously. This behavior may also contribute to the user confusion mentioned in #170.

@Raruto
Copy link
Owner

Raruto commented Oct 1, 2025

@aronsommer please edit/add a new .spec.js file to test this use case (ie. test assertions):

image

In this folder you can find some other sample tests:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants