Merge and adapt PR #95 car-eco/fast + display energy/time
This commit is contained in:
commit
102e978581
3 changed files with 25 additions and 3 deletions
|
|
@ -3,11 +3,19 @@ BR.TrackStats = L.Class.extend({
|
|||
var stats = this.calcStats(polyline, segments),
|
||||
length1 = L.Util.formatNum(stats.trackLength/1000,1),
|
||||
length3 = L.Util.formatNum(stats.trackLength/1000,3),
|
||||
meanCostFactor = stats.trackLength ? L.Util.formatNum(stats.cost / stats.trackLength, 2) : ''
|
||||
meanCostFactor = stats.trackLength ? L.Util.formatNum(stats.cost / stats.trackLength, 2) : '',
|
||||
formattedTime = L.Util.formatNum(stats.totalTime / 60., 1),
|
||||
formattedEnergy = L.Util.formatNum(stats.totalEnergy / 3600000., 2),
|
||||
meanEnergy = stats.trackLength ? L.Util.formatNum(stats.totalEnergy / 36. / stats.trackLength, 2) : '';
|
||||
|
||||
$('#distance').html(length1 + ' <abbr title="kilometer">km</abbr>');
|
||||
$('#ascend').html(stats.filteredAscend + ' (' + stats.plainAscend +')' + ' <abbr title="meter">m</abbr>');
|
||||
$('#cost').html(stats.cost + ' (' + meanCostFactor + ')');
|
||||
$('#totaltime').html(formattedTime + ' <abbr title="minutes">min</abbr>');
|
||||
$('#totalenergy').html(formattedEnergy + ' (' + meanEnergy +') kWh');
|
||||
|
||||
document.getElementById('totaltime').parentElement.hidden = !stats.totalTime;
|
||||
document.getElementById('totalenergy').parentElement.hidden = !stats.totalEnergy;
|
||||
},
|
||||
|
||||
calcStats: function(polyline, segments) {
|
||||
|
|
@ -15,6 +23,8 @@ BR.TrackStats = L.Class.extend({
|
|||
trackLength: 0,
|
||||
filteredAscend: 0,
|
||||
plainAscend: 0,
|
||||
totalTime: 0,
|
||||
totalEnergy: 0,
|
||||
cost: 0
|
||||
};
|
||||
var i, props;
|
||||
|
|
@ -24,6 +34,8 @@ BR.TrackStats = L.Class.extend({
|
|||
stats.trackLength += +props['track-length'];
|
||||
stats.filteredAscend += +props['filtered ascend'];
|
||||
stats.plainAscend += +props['plain-ascend'];
|
||||
stats.totalTime += +props['total-time'];
|
||||
stats.totalEnergy += +props['total-energy'];
|
||||
stats.cost += +props['cost'];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue