Skip to content

Commit 9f5e5b4

Browse files
authored
Fix crash (projecthorus#38)
1 parent d940405 commit 9f5e5b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

js/tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,13 +2596,13 @@ function addPosition(position) {
25962596
var dtt = (curr_ts - search_match) / 1000;
25972597

25982598
// calculate vertical rate
2599-
var rate = (position.gps_alt - vehicle.positions_alts[search_matches.length]) / dtt;
2599+
var rate = (position.gps_alt - vehicle.positions_alts[search_matches.length-1]) / dtt;
26002600
if (!isNaN(rate) && isFinite(rate)) {
26012601
vehicle.ascent_rate = 0.5 * rate + 0.5 * vehicle.ascent_rate;
26022602
}
26032603

26042604
// calculate horizontal rate
2605-
horizontal_rate_temp = new_latlng.distanceTo(vehicle.positions[search_matches.length]) / dtt;
2605+
horizontal_rate_temp = new_latlng.distanceTo(vehicle.positions[search_matches.length-1]) / dtt;
26062606
if (!isNaN(horizontal_rate_temp) && isFinite(horizontal_rate_temp)) {
26072607
vehicle.horizontal_rate = horizontal_rate_temp;
26082608
}

0 commit comments

Comments
 (0)