@@ -355,6 +355,7 @@ function updateVehicleInfo(index, position) {
355355
356356 var imp = offline . get ( 'opt_imperial' ) ;
357357 var ascent_text = imp ? ( vehicles [ index ] . ascent_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicles [ index ] . ascent_rate . toFixed ( 1 ) + ' m/s' ;
358+ var hrate_text = imp ? ( vehicles [ index ] . horizontal_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicles [ index ] . horizontal_rate . toFixed ( 1 ) + ' m/s' ;
358359
359360 var coords_text ;
360361 var ua = navigator . userAgent . toLowerCase ( ) ;
@@ -399,12 +400,12 @@ function updateVehicleInfo(index, position) {
399400 + '</div>' // left
400401 + '<div class="right">'
401402 + '<dl>'
402- + ( position . gps_alt != 0 ? '<dt>' + ascent_text + '</dt><dd>rate</dd>' : '' )
403+ + ( position . gps_alt != 0 ? '<dt>' + ascent_text + ' ' + hrate_text + ' </dt><dd>rate v|h </dd>' : '' )
403404 + '<dt>' + ( ( imp ) ? parseInt ( 3.2808399 * position . gps_alt ) + ' ft' : parseInt ( position . gps_alt ) + ' m' ) + '</dt><dd>altitude</dd>'
404405 + '<dt>' + ( ( imp ) ? parseInt ( 3.2808399 * vehicles [ index ] . max_alt ) + ' ft' : parseInt ( vehicles [ index ] . max_alt ) + ' m' ) + '</dt><dd>max alt</dd>'
405406 + '' ;
406407 // mid for landscape
407- var l = ( position . gps_alt != 0 ? '<dt>' + ascent_text + '</dt><dd>rate</dd>' : '' )
408+ var l = ( position . gps_alt != 0 ? '<dt>' + ascent_text + ' ' + hrate_text + ' </dt><dd>rate v|h </dd>' : '' )
408409 + '<dt>' + ( ( imp ) ? parseInt ( 3.2808399 * position . gps_alt ) + 'ft' : parseInt ( position . gps_alt ) + 'm' ) + ' (' + ( ( imp ) ? parseInt ( 3.2808399 * vehicles [ index ] . max_alt ) + 'ft' : parseInt ( vehicles [ index ] . max_alt ) + 'm' ) + ')</dt><dd>altitude (max)</dd>'
409410 + '<dt>' + position . gps_time + '</dt><dd>datetime</dd>'
410411 + '<dt>' + coords_text + '</dt><dd>coordinates</dd>'
@@ -704,6 +705,7 @@ function addPosition(position) {
704705 } ) ,
705706 prediction : null ,
706707 ascent_rate : 0.0 ,
708+ horizontal_rate : 0.0 ,
707709 max_alt : parseFloat ( position . gps_alt ) ,
708710 path_enabled : vehicle_type == "balloon" && position . vehicle . toLowerCase ( ) . indexOf ( "iss" ) == - 1 ,
709711 follow : false ,
@@ -739,25 +741,27 @@ function addPosition(position) {
739741 }
740742 } else {
741743
742- dt = convert_time ( position . gps_time )
744+ var dt = convert_time ( position . gps_time )
743745 - convert_time ( vehicle . curr_position . gps_time ) ;
744746
745747 if ( dt != 0 ) {
746- rate = ( position . gps_alt - vehicle . curr_position . gps_alt ) / dt ;
748+ // calcualte vertical rate
749+ var rate = ( position . gps_alt - vehicle . curr_position . gps_alt ) / dt ;
747750 vehicle . ascent_rate = 0.7 * rate
748751 + 0.3 * vehicle . ascent_rate ;
749752
750- // if vehicle is not a car, record altitude
751- if ( vehicle . vehicle_type != "car" ) {
752- // only record altitude values in 10minute interval
753- if ( convert_time ( vehicle . curr_position . gps_time ) - vehicle . time_last_alt >= 120 ) { // 120s = 2minutes
754- vehicle . time_last_alt = convert_time ( vehicle . curr_position . gps_time ) ;
755- var alt = parseInt ( vehicle . curr_position . gps_alt ) ;
753+ // calculate horizontal rate
754+ vehicle . horizontal_rate = google . maps . geometry . spherical . computeDistanceBetween ( new google . maps . LatLng ( position . gps_lat , position . gps_lon ) ,
755+ new google . maps . LatLng ( vehicle . curr_position . gps_lat , vehicle . curr_position . gps_lon ) ) / dt ;
756756
757- if ( alt > vehicle . alt_max ) vehicle . alt_max = alt ; // larged value in the set is required for encoding later
757+ // only record altitude values in 2minute interval
758+ if ( convert_time ( vehicle . curr_position . gps_time ) - vehicle . time_last_alt >= 120 ) { // 120s = 2minutes
759+ vehicle . time_last_alt = convert_time ( vehicle . curr_position . gps_time ) ;
760+ var alt = parseInt ( vehicle . curr_position . gps_alt ) ;
758761
759- vehicle . alt_list . push ( alt ) ; // push value to the list
760- }
762+ if ( alt > vehicle . alt_max ) vehicle . alt_max = alt ; // larged value in the set is required for encoding later
763+
764+ vehicle . alt_list . push ( alt ) ; // push value to the list
761765 }
762766 }
763767
0 commit comments