bfabiszewski / ulogger-server

μlogger • web viewer for tracks uploaded with μlogger mobile client
GNU General Public License v3.0
542 stars 85 forks source link

Display average speed per track #165

Closed europrimus closed 2 years ago

europrimus commented 3 years ago

On the general interface, when displaying a track, there is a Trip summary with the total distance and total time. With this two data, it's easy to calculate the average speed. I think it could be interesting to display it above the max speed.

europrimus commented 3 years ago

I make it for me screen shot this is the patch

diff --git a/js/src/trackviewmodel.js b/js/src/trackviewmodel.js
index 57fa35d..16c6602 100644
--- a/js/src/trackviewmodel.js
+++ b/js/src/trackviewmodel.js
@@ -366,7 +366,8 @@ export default class TrackViewModel extends ViewModel {
       let summary = `
         <div class="menu-title">${$._('summary')}</div>
         <div><img class="icon" alt="${$._('tdistance')}" title="${$._('tdistance')}" src="images/distance.svg"> ${$.getLocaleDistanceMajor(last.totalMeters, true)}</div>
-        <div><img class="icon" alt="${$._('ttime')}" title="${$._('ttime')}" src="images/time.svg"> ${$.getLocaleDuration(last.totalSeconds)}</div>`;
+        <div><img class="icon" alt="${$._('ttime')}" title="${$._('ttime')}" src="images/time.svg"> ${$.getLocaleDuration(last.totalSeconds)}</div>
+        <div><img class="icon" alt="${$._('aspeed')}" title="${$._('aspeed')}" src="images/speed.svg"><b>&#10547;</b> ${$.getLocaleSpeed(last.totalMeters / last.totalSeconds, true)}</div>`;
       if (track.hasSpeeds) {
         summary += `<div><img class="icon" alt="${$._('speed')}" title="${$._('speed')}" src="images/speed.svg"><b>&#10138;</b> ${$.getLocaleSpeed(track.maxSpeed, true)}</div>`;
       }

Feel free to tell me if there some think wrong or if i can do a pull request.

bfabiszewski commented 3 years ago

Thanks! I never really cared for average speed because it is calculated from total distance and total time. So it is only meaningful for cases when you don't make any longer stops during track recording. But it might be useful for some users. So please make a PR and I will merge it.

I just think you should add a check for last.totalSeconds > 0 before displaying this item. In case there is only single point or some strange track with same timestamps.

europrimus commented 3 years ago

Yes, it's better to check last.totalSeconds > 0 to avoid division by zero.

And it's true that when you have pause time, the average speed not close to reality. Maybe asplit track function can help... I have something like a1 week track to split... but it's an other possible improvement

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

bfabiszewski commented 2 years ago

Closing as merged https://github.com/bfabiszewski/ulogger-server/pull/171