@@ -13,19 +13,11 @@ var graph_url = "http://chart.googleapis.com/chart?chf=bg,s,67676700&chxr=0,0,46
1313var receiver_names = [ ] ;
1414var receivers = [ ] ;
1515
16- var num_updates = 0 ;
1716var got_positions = false ;
1817var zoomed_in = false ;
1918var max_positions = 0 ; // maximum number of positions that ajax request should return (0 means no maximum)
20- var selector = null ;
21- var window_selector = null ;
22- var cursor = null ;
23- var selected_vehicle = 0 ;
2419var follow_vehicle = - 1 ;
2520
26- var signals = null ;
27- var signals_seq = - 1 ;
28-
2921var car_index = 0 ;
3022var car_colors = [ "blue" , "red" , "green" , "yellow" ] ;
3123var balloon_index = 0 ;
@@ -54,7 +46,6 @@ var ls_pred = false;
5446
5547var plot = null ;
5648
57-
5849var offline = {
5950 get : function ( key ) {
6051 if ( typeof localStorage == 'undefined' ) return null ;
@@ -118,25 +109,6 @@ function panTo(vehicle_index) {
118109 else map . panTo ( vehicles [ vehicle_index ] . marker . getPosition ( ) ) ;
119110}
120111
121- function optional ( caption , value , postfix ) {
122- // if(value && value != '') {
123- if ( value !== '' ) {
124- if ( value . indexOf ( "=" ) == - 1 ) {
125- return "<b>" + caption + ":</b> " + value + postfix + "<br />"
126- } else {
127- var a = value . split ( ";" ) ;
128- var result = "" ;
129- for ( var i = 0 , ii = a . length ; i < ii ; i ++ ) {
130- var b = a [ i ] . split ( "=" ) ;
131- result += "<b>" + b [ 0 ] + ":</b> " + b [ 1 ] + "<br />"
132- }
133- return result ;
134- }
135- } else {
136- return "" ;
137- }
138- }
139-
140112function title_case ( s ) {
141113 return s . replace ( / \w \S * / g, function ( txt ) {
142114 return txt . charAt ( 0 ) . toUpperCase ( ) + txt . substr ( 1 ) . toLowerCase ( ) ;
@@ -292,61 +264,59 @@ function roundNumber(number, digits) {
292264 return rndedNum ;
293265}
294266
295- function updateVehicleInfo ( index , position ) {
296- var latlng = new google . maps . LatLng ( position . gps_lat , position . gps_lon ) ;
297- if ( vehicles [ index ] . marker_shadow ) vehicles [ index ] . marker_shadow . setPosition ( latlng ) ;
298- vehicles [ index ] . marker . setPosition ( latlng ) ;
299- if ( vehicles [ index ] . vehicle_type == "balloon" ) {
267+ function updateVehicleInfo ( index , newPosition ) {
268+ var vehicle = vehicles [ index ] ;
269+ var latlng = new google . maps . LatLng ( newPosition . gps_lat , newPosition . gps_lon ) ;
270+
271+ // update position
272+ if ( vehicle . marker_shadow ) vehicle . marker_shadow . setPosition ( latlng ) ;
273+ vehicle . marker . setPosition ( latlng ) ;
274+
275+ // update horizon circles and icon
276+ if ( vehicle . vehicle_type == "balloon" ) {
300277 updateAltitude ( index ) ;
301- var horizon_km = Math . sqrt ( 12.756 * position . gps_alt ) ;
302- vehicles [ index ] . horizon_circle . setRadius ( Math . round ( horizon_km ) * 1000 ) ;
278+ var horizon_km = Math . sqrt ( 12.756 * newPosition . gps_alt ) ;
279+ vehicle . horizon_circle . setRadius ( Math . round ( horizon_km ) * 1000 ) ;
303280
304- if ( vehicles [ index ] . subhorizon_circle ) {
281+ if ( vehicle . subhorizon_circle ) {
305282 // see: http://ukhas.org.uk/communication:lineofsight
306283 var el = 5.0 ; // elevation above horizon
307284 var rad = 6378.10 ; // radius of earth
308- var h = position . gps_alt / 1000 ; // height above ground
285+ var h = newPosition . gps_alt / 1000 ; // height above ground
309286
310287 var elva = el * Math . PI / 180.0 ;
311288 var slant = rad * ( Math . cos ( Math . PI / 2 + elva ) + Math . sqrt ( Math . pow ( Math . cos ( Math . PI / 2 + elva ) , 2 ) + h * ( 2 * rad + h ) / Math . pow ( rad , 2 ) ) ) ;
312289 var x = Math . acos ( ( Math . pow ( rad , 2 ) + Math . pow ( rad + h , 2 ) - Math . pow ( slant , 2 ) ) / ( 2 * rad * ( rad + h ) ) ) * rad ;
313290
314291 var subhorizon_km = x ;
315- vehicles [ index ] . subhorizon_circle . setRadius ( Math . round ( subhorizon_km ) * 1000 ) ;
292+ vehicle . subhorizon_circle . setRadius ( Math . round ( subhorizon_km ) * 1000 ) ;
316293 }
317294
318295 // indicates whenever a payload has landed
319296 var landed = (
320- vehicles [ index ] . max_alt > 1500 // if it has gone up
321- && vehicles [ index ] . ascent_rate < 1.0 // and has negative ascent_rate, aka is descending
322- && position . gps_alt < 350 // and is under 350 meters altitude
297+ vehicle . max_alt > 1500 // if it has gone up
298+ && vehicle . ascent_rate < 1.0 // and has negative ascent_rate, aka is descending
299+ && newPosition . gps_alt < 350 // and is under 350 meters altitude
323300 ) || ( // or
324- position . gps_alt < 600 // under 600m and has no position update for more than 30 minutes
325- && ( new Date ( ( new Date ( ) ) . toISOString ( ) ) ) . getTime ( ) - ( new Date ( position . gps_time + " UTC" ) ) . getTime ( ) > 1800000
301+ newPosition . gps_alt < 600 // under 600m and has no position update for more than 30 minutes
302+ && ( new Date ( ( new Date ( ) ) . toISOString ( ) ) ) . getTime ( ) - ( new Date ( newPosition . gps_time + " UTC" ) ) . getTime ( ) > 1800000
326303 ) ;
327304
328305 if ( landed ) {
329- vehicles [ index ] . marker . setMode ( "landed" ) ;
330- vehicles [ index ] . marker . shadow . setVisible ( false ) ;
331- vehicles [ index ] . horizon_circle . setVisible ( false ) ;
332- vehicles [ index ] . subhorizon_circle . setVisible ( false ) ;
306+ vehicle . marker . setMode ( "landed" ) ;
307+ vehicle . marker . shadow . setVisible ( false ) ;
308+ vehicle . horizon_circle . setVisible ( false ) ;
309+ vehicle . subhorizon_circle . setVisible ( false ) ;
333310
334- } else if ( vehicles [ index ] . ascent_rate > - 3.0 ||
311+ } else if ( vehicle . ascent_rate > - 3.0 ||
335312 vehicle_names [ index ] == "wb8elk2" ) {
336- vehicles [ index ] . marker . setMode ( "balloon" ) ;
313+ vehicle . marker . setMode ( "balloon" ) ;
337314 } else {
338- vehicles [ index ] . marker . setMode ( "parachute" ) ;
315+ vehicle . marker . setMode ( "parachute" ) ;
339316 }
340317 }
341318
342- var pixels = Math . round ( position . gps_alt / 500 ) + 1 ;
343- if ( pixels < 0 ) {
344- pixels = 0 ;
345- } else if ( pixels >= 98 ) {
346- pixels = 98 ;
347- }
348-
349- var image = vehicles [ index ] . image_src ;
319+ var image = vehicle . image_src ;
350320
351321 var elm = $ ( '.vehicle' + index ) ;
352322
@@ -359,33 +329,33 @@ function updateVehicleInfo(index, position) {
359329
360330 // decides how to dispaly the horizonal speed
361331 var imp = offline . get ( 'opt_imperial' ) ;
362- var ascent_text = imp ? ( vehicles [ index ] . ascent_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicles [ index ] . ascent_rate . toFixed ( 1 ) + ' m/s' ;
332+ var ascent_text = imp ? ( vehicle . ascent_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicle . ascent_rate . toFixed ( 1 ) + ' m/s' ;
363333 if ( offline . get ( 'opt_haxis_hours' ) ) {
364- var hrate_text = imp ? ( vehicles [ index ] . horizontal_rate * 2.23693629 ) . toFixed ( 1 ) + ' mph' : ( vehicles [ index ] . horizontal_rate * 3.6 ) . toFixed ( 1 ) + ' km/h' ;
334+ var hrate_text = imp ? ( vehicle . horizontal_rate * 2.23693629 ) . toFixed ( 1 ) + ' mph' : ( vehicle . horizontal_rate * 3.6 ) . toFixed ( 1 ) + ' km/h' ;
365335 } else {
366- var hrate_text = imp ? ( vehicles [ index ] . horizontal_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicles [ index ] . horizontal_rate . toFixed ( 1 ) + ' m/s' ;
336+ var hrate_text = imp ? ( vehicle . horizontal_rate * 196.850394 ) . toFixed ( 1 ) + ' ft/min' : vehicle . horizontal_rate . toFixed ( 1 ) + ' m/s' ;
367337 }
368338
369339 var coords_text ;
370340 var ua = navigator . userAgent . toLowerCase ( ) ;
371341
372342 // determine how to link the vehicle coordinates to a native app, if on a mobile device
373343 if ( ua . indexOf ( 'iphone' ) > - 1 ) {
374- coords_text = '<a id="launch_mapapp" href="maps://?q=' + position . gps_lat + ',' + position . gps_lon + '">'
375- + roundNumber ( position . gps_lat , 6 ) + ', ' + roundNumber ( position . gps_lon , 6 ) + '</a>'
344+ coords_text = '<a id="launch_mapapp" href="maps://?q=' + newPosition . gps_lat + ',' + newPosition . gps_lon + '">'
345+ + roundNumber ( newPosition . gps_lat , 6 ) + ', ' + roundNumber ( newPosition . gps_lon , 6 ) + '</a>'
376346 + ' <i class="icon-location"></i>' ;
377347 } else if ( ua . indexOf ( 'android' ) > - 1 ) {
378- coords_text = '<a id="launch_mapapp" href="geo:' + position . gps_lat + ',' + position . gps_lon + '?q=' + position . gps_lat + ',' + position . gps_lon + '(' + vehicle_names [ index ] + ')">'
379- + roundNumber ( position . gps_lat , 6 ) + ', ' + roundNumber ( position . gps_lon , 6 ) + '</a>'
348+ coords_text = '<a id="launch_mapapp" href="geo:' + newPosition . gps_lat + ',' + newPosition . gps_lon + '?q=' + newPosition . gps_lat + ',' + newPosition . gps_lon + '(' + vehicle_names [ index ] + ')">'
349+ + roundNumber ( newPosition . gps_lat , 6 ) + ', ' + roundNumber ( newPosition . gps_lon , 6 ) + '</a>'
380350 + ' <i class="icon-location"></i>' ;
381351 } else {
382- coords_text = roundNumber ( position . gps_lat , 6 ) + ', ' + roundNumber ( position . gps_lon , 6 ) ;
352+ coords_text = roundNumber ( newPosition . gps_lat , 6 ) + ', ' + roundNumber ( newPosition . gps_lon , 6 ) ;
383353 }
384354
385355 // format altitude strings
386- var text_alt = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( position . gps_alt ) ) : parseInt ( position . gps_alt ) ) . toLocaleString ( "us" ) ;
356+ var text_alt = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( newPosition . gps_alt ) ) : parseInt ( newPosition . gps_alt ) ) . toLocaleString ( "us" ) ;
387357 text_alt += " " + ( ( imp ) ? 'ft' :'m' ) ;
388- var text_alt_max = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( vehicles [ index ] . max_alt ) ) : parseInt ( vehicles [ index ] . max_alt ) ) . toLocaleString ( "us" ) ;
358+ var text_alt_max = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( vehicle . max_alt ) ) : parseInt ( vehicle . max_alt ) ) . toLocaleString ( "us" ) ;
389359 text_alt_max += " " + ( ( imp ) ? 'ft' :'m' ) ;
390360
391361
@@ -395,7 +365,7 @@ function updateVehicleInfo(index, position) {
395365 + '<img class="graph" src="img/blank.png">'
396366 + '<i class="arrow"></i></div>'
397367 + '<div class="data">'
398- + '<img class="' + ( ( vehicles [ index ] . vehicle_type == "car" ) ?'car' :'' ) + '" src="' + image + '" />'
368+ + '<img class="' + ( ( vehicle . vehicle_type == "car" ) ?'car' :'' ) + '" src="' + image + '" />'
399369 + '<div class="left">'
400370 + '<dl>' ;
401371 // end
@@ -404,28 +374,28 @@ function updateVehicleInfo(index, position) {
404374 + '</div>' // data
405375 + '' ;
406376 var c = '<dt class="receivers">Recieved by:</dt><dd class="receivers">'
407- + position . callsign . split ( "," ) . join ( ", " ) + '</dd>'
377+ + newPosition . callsign . split ( "," ) . join ( ", " ) + '</dd>'
408378
409- if ( ! position . callsign ) c = '' ;
379+ if ( ! newPosition . callsign ) c = '' ;
410380
411381 // mid for portrait
412- var p = '<dt>' + position . gps_time + '</dt><dd>datetime</dd>'
382+ var p = '<dt>' + newPosition . gps_time + '</dt><dd>datetime</dd>'
413383 + '<dt>' + coords_text + '</dt><dd>coordinates</dd>'
414384 + c // receivers if any
415385 + '</dl>'
416386 + '</div>' // left
417387 + '<div class="right">'
418388 + '<dl>'
419- + ( ( vehicles [ index ] . vehicle_type == "car" ) ? '' : '<dt>' + ascent_text + ' ' + hrate_text + '</dt><dd>rate v|h</dd>' )
389+ + ( ( vehicle . vehicle_type == "car" ) ? '' : '<dt>' + ascent_text + ' ' + hrate_text + '</dt><dd>rate v|h</dd>' )
420390 + '<dt>' + text_alt + '</dt><dd>altitude</dd>'
421391 + '<dt>' + text_alt_max + '</dt><dd>max alt</dd>'
422392 + '' ;
423393 // mid for landscape
424- var l = ( ( vehicles [ index ] . vehicle_type == "car" ) ? '' : '<dt>' + ascent_text + ' ' + hrate_text + '</dt><dd>rate v|h</dd>' )
394+ var l = ( ( vehicle . vehicle_type == "car" ) ? '' : '<dt>' + ascent_text + ' ' + hrate_text + '</dt><dd>rate v|h</dd>' )
425395 + '<dt>' + text_alt + ' (' + text_alt_max + ')</dt><dd>altitude (max)</dd>'
426- + '<dt>' + position . gps_time + '</dt><dd>datetime</dd>'
396+ + '<dt>' + newPosition . gps_time + '</dt><dd>datetime</dd>'
427397 + '<dt>' + coords_text + '</dt><dd>coordinates</dd>'
428- + habitat_data ( position . data )
398+ + habitat_data ( newPosition . data )
429399 + c // receivers if any
430400 + '' ;
431401
@@ -436,14 +406,6 @@ function updateVehicleInfo(index, position) {
436406 return true ;
437407}
438408
439- function pad ( number , length ) {
440- var str = '' + number ;
441- while ( str . length < length ) {
442- str = '0' + str ;
443- }
444- return str ;
445- }
446-
447409function addMarker ( icon , latlng ) {
448410 var marker = new google . maps . Marker ( {
449411 position : latlng ,
@@ -513,16 +475,6 @@ function redrawPrediction(vehicle_index) {
513475 }
514476 var image_src ;
515477 if ( vehicle_names [ vehicle_index ] != "wb8elk2" ) { // WhiteStar
516- /*
517- //icon.infoWindowAnchor = new google.maps.Point(13,5);
518-
519- var time = new Date(data[data.length-1].time * 1000);
520- var time_string = pad(time.getUTCHours(), 2) + ':' + pad(time.getUTCMinutes(), 2) + ' UTC';
521- var html = '<b>Predicted Landing</b><br />'
522- + '<p style="font-size: 10pt;">'
523- + data[data.length-1].lat + ', ' + data[data.length-1].lon + ' at ' + time_string
524- + '</p>';
525- */
526478 var html = "" ;
527479 if ( vehicle . prediction_target ) {
528480 vehicle . prediction_target . setPosition ( latlng ) ;
@@ -535,16 +487,6 @@ function redrawPrediction(vehicle_index) {
535487 }
536488
537489 if ( burst_index != 0 && vehicle_names [ vehicle_index ] != "wb8elk2" ) {
538- /*
539- //icon.infoWindowAnchor = new google.maps.Point(18,5);
540-
541- var time = new Date(data[burst_index].time * 1000);
542- var time_string = pad(time.getUTCHours(), 2) + ':' + pad(time.getUTCMinutes(), 2) + ' UTC';
543- var html = '<b>Predicted Burst</b><br />'
544- + '<p style="font-size: 10pt;">'
545- + data[burst_index].lat + ', ' + data[burst_index].lon + ', ' + Math.round(data[burst_index].alt) + ' m at ' + time_string
546- + '</p>';
547- */
548490 if ( vehicle . prediction_burst ) {
549491 vehicle . prediction_burst . setPosition ( latlng_burst ) ;
550492 } else {
@@ -563,24 +505,6 @@ function updatePolyline(vehicle_index) {
563505}
564506
565507function convert_time ( gps_time ) {
566- // example: "2009-05-28 20:29:47"
567- /*
568- year = parseInt(gps_time.substring(0, 4), 10);
569- month = parseInt(gps_time.substring(5, 7), 10);
570- day = parseInt(gps_time.substring(8, 10), 10);
571- hour = parseInt(gps_time.substring(11, 13), 10);
572- minute = parseInt(gps_time.substring(14, 16), 10);
573- second = parseInt(gps_time.substring(17), 10);
574-
575- date = new Date();
576- date.setUTCFullYear(year);
577- date.setUTCMonth(month-1);
578- date.setUTCDate(day);
579- date.setUTCHours(hour);
580- date.setUTCMinutes(minute);
581- date.setUTCSeconds(second);
582- */
583-
584508 return ( new Date ( gps_time ) ) . getTime ( ) / 1000 ; // seconds since 1/1/1970 @ 12:00 AM
585509}
586510
@@ -1283,7 +1207,7 @@ function update(response) {
12831207 if ( vehicles . length == 0 ) return ;
12841208
12851209 zoom_timer = setInterval ( function ( ) {
1286- if ( bootstrapped && bs_idx + 1 == vehicle_names . length ) {
1210+ if ( bootstrapped && bs_idx == vehicle_names . length ) {
12871211 zoom_on_payload ( ) ;
12881212 clearInterval ( zoom_timer ) ;
12891213 }
@@ -1314,6 +1238,7 @@ function zoom_on_payload() {
13141238 if ( map . getZoom ( ) > 11 ) map . setZoom ( 11 ) ;
13151239 }
13161240
1241+
13171242 // pan and follow the vehicle
13181243 followVehicle ( i ) ;
13191244
0 commit comments