File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -2591,18 +2591,18 @@ function addPosition(position) {
25912591
25922592 var search_matches = vehicle . positions_ts . filter ( searchPositions )
25932593
2594- if ( search_matches . length > 0 && search_matches [ search_matches . length - 1 ] >= search_ts - 5000 ) {
2594+ if ( search_matches . length > 0 && search_matches [ search_matches . length - 1 ] >= search_ts - 5000 && vehicle . positions . length >= search_matches . length ) {
25952595 var search_match = search_matches [ search_matches . length - 1 ]
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 }
You can’t perform that action at this time.
0 commit comments