@@ -1142,15 +1142,16 @@ function addPosition(position) {
11421142
11431143 // if position array has at least 1 position
11441144 if ( vehicle . num_positions > 0 ) {
1145- if ( convert_time ( vehicle . curr_position . gps_time ) > = convert_time ( position . gps_time ) ) {
1145+ if ( convert_time ( vehicle . curr_position . gps_time ) = = convert_time ( position . gps_time ) ) {
11461146 if ( ( "," + vehicle . curr_position . callsign + "," ) . indexOf ( "," + position . callsign + "," ) === - 1 ) {
11471147 vehicle . curr_position . callsign += "," + position . callsign ;
11481148 }
1149- } else {
11501149
1150+ vehicle . updated = true ;
1151+ } else {
11511152 var dt = ( convert_time ( position . gps_time ) - convert_time ( vehicle . curr_position . gps_time ) ) / 1000 ; // convert to seconds
11521153
1153- if ( dt != 0 ) {
1154+ if ( dt > 0 ) {
11541155 // calculate vertical rate
11551156 var rate = ( position . gps_alt - vehicle . curr_position . gps_alt ) / dt ;
11561157 vehicle . ascent_rate = 0.7 * rate
@@ -1170,29 +1171,21 @@ function addPosition(position) {
11701171 vehicle . alt_list . push ( alt ) ; // push value to the list
11711172 }
11721173 }
1173-
1174- if ( vehicle . curr_position . gps_lat != position . gps_lat
1175- || vehicle . curr_position . gps_lon != position . gps_lon ) {
1176- // add the new position
1177- vehicle . positions . push ( new_latlng ) ;
1178- vehicle . num_positions ++ ;
1179-
1180- vehicle . curr_position = position ;
1181- graphAddLastPosition ( vehicle_index ) ;
1182- vehicle . updated = true ;
1183-
1184- var poslen = vehicle . positions . length ;
1185- if ( poslen > 1 ) vehicle . path_length += google . maps . geometry . spherical . computeDistanceBetween ( vehicle . positions [ poslen - 2 ] , vehicle . positions [ poslen - 1 ] ) ;
1186- }
11871174 }
1188- } else {
1189- vehicle . updated = true ;
1175+ }
1176+
1177+ if ( ! vehicle . curr_position
1178+ || vehicle . curr_position . gps_lat != position . gps_lat
1179+ || vehicle . curr_position . gps_lon != position . gps_lon ) {
1180+ // add the new position
11901181 vehicle . positions . push ( new_latlng ) ;
11911182 vehicle . num_positions ++ ;
1183+
11921184 vehicle . curr_position = position ;
11931185 graphAddLastPosition ( vehicle_index ) ;
1186+ vehicle . updated = true ;
11941187
1195- var poslen = vehicle . positions . length ;
1188+ var poslen = vehicle . num_positions ;
11961189 if ( poslen > 1 ) vehicle . path_length += google . maps . geometry . spherical . computeDistanceBetween ( vehicle . positions [ poslen - 2 ] , vehicle . positions [ poslen - 1 ] ) ;
11971190 }
11981191 } else { // if car
0 commit comments