@@ -29,13 +29,21 @@ var car_index = 0;
2929var car_colors = [ "blue" , "red" , "green" , "yellow" ] ;
3030var balloon_index = 0 ;
3131var balloon_colors_name = [ "red" , "blue" , "green" , "yellow" , "purple" , "orange" , "cyan" ] ;
32- var balloon_colors = [ "red " , "blue" , "green" , "#ff0" , "#c700e6" , "#ff8a0f" , "#0fffca" ] ;
32+ var balloon_colors = [ "#f00 " , "blue" , "green" , "#ff0" , "#c700e6" , "#ff8a0f" , "#0fffca" ] ;
3333
3434var map = null ;
3535var overlay = null ;
3636
3737var notamOverlay = null ;
3838
39+ // order of map elements
40+ var Z_RANGE = 1 ;
41+ var Z_STATION = 2 ;
42+ var Z_PATH = 3 ;
43+ var Z_SHADOW = 4 ;
44+ var Z_CAR = 5 ;
45+ var Z_PAYLOAD = 6 ;
46+
3947function load ( ) {
4048 //initialize map object
4149 map = new google . maps . Map ( document . getElementById ( 'map' ) , {
@@ -204,6 +212,9 @@ function updateAltitude(index) {
204212 var pixel_altitude = 0 ;
205213 var zoom = map . getZoom ( ) ;
206214 var position = vehicles [ index ] . curr_position ;
215+
216+ if ( vehicles [ index ] . marker . mode == 'landed' ) return ;
217+
207218 if ( zoom > 18 ) zoom = 18 ;
208219 if ( position . gps_alt > 0 ) {
209220 pixel_altitude = Math . round ( position . gps_alt / ( 1000 / 3 ) * ( zoom / 18.0 ) ) ;
@@ -253,8 +264,8 @@ function roundNumber(number, digits) {
253264
254265function updateVehicleInfo ( index , position ) {
255266 var latlng = new google . maps . LatLng ( position . gps_lat , position . gps_lon ) ;
256- vehicles [ index ] . marker . setPosition ( latlng ) ;
257267 if ( vehicles [ index ] . marker_shadow ) vehicles [ index ] . marker_shadow . setPosition ( latlng ) ;
268+ vehicles [ index ] . marker . setPosition ( latlng ) ;
258269 if ( vehicles [ index ] . vehicle_type == "balloon" ) {
259270 updateAltitude ( index ) ;
260271 var horizon_km = Math . sqrt ( 12.756 * position . gps_alt ) ;
@@ -274,12 +285,22 @@ function updateVehicleInfo(index, position) {
274285 vehicles [ index ] . subhorizon_circle . setRadius ( Math . round ( subhorizon_km ) * 1000 ) ;
275286 }
276287
277- var landed = vehicles [ index ] . max_alt > 1000
278- && vehicles [ index ] . ascent_rate < 1.0
279- && position . gps_alt < 300 ;
280-
288+ // indicates whenever a payload has landed
289+ var landed = (
290+ vehicles [ index ] . max_alt > 1500 // if it has gone up
291+ && vehicles [ index ] . ascent_rate < 1.0 // and has negative ascent_rate, aka is descending
292+ && position . gps_alt < 350 // and is under 350 meters altitude
293+ ) || ( // or
294+ position . gps_alt < 600 // under 600m and has no position update for more than 30 minutes
295+ && ( new Date ( ( new Date ( ) ) . toISOString ( ) ) ) . getTime ( ) - ( new Date ( position . gps_time + " UTC" ) ) . getTime ( ) > 1800000
296+ ) ;
297+
281298 if ( landed ) {
282299 vehicles [ index ] . marker . setMode ( "landed" ) ;
300+ vehicles [ index ] . marker . shadow . setVisible ( false ) ;
301+ vehicles [ index ] . horizon_circle . setVisible ( false ) ;
302+ vehicles [ index ] . subhorizon_circle . setVisible ( false ) ;
303+
283304 } else if ( vehicles [ index ] . ascent_rate > - 3.0 ||
284305 vehicle_names [ vehicle_index ] == "wb8elk2" ) {
285306 vehicles [ index ] . marker . setMode ( "balloon" ) ;
@@ -379,6 +400,7 @@ function pad(number, length) {
379400function addMarker ( icon , latlng ) {
380401 var marker = new google . maps . Marker ( {
381402 position : latlng ,
403+ zIndex : Z_SHADOW ,
382404 icon : new google . maps . MarkerImage (
383405 icon ,
384406 null ,
@@ -432,6 +454,7 @@ function redrawPrediction(vehicle_index) {
432454 } else {
433455 vehicle . prediction_polyline = new google . maps . Polyline ( {
434456 map : map ,
457+ zIndex : Z_PATH ,
435458 path : line ,
436459 strokeColor : balloon_colors [ vehicle . color_index ] ,
437460 strokeOpacity : 0.4 ,
@@ -510,10 +533,7 @@ function convert_time(gps_time) {
510533}
511534
512535function addPosition ( position ) {
513-
514- position . sequence = position . sequence ? parseInt ( position . sequence , 10 ) : null ;
515-
516- // check if the vehicle is already in the list, if not create a new item
536+ // check if the vehicle is already in the list, if not create a new item
517537 if ( $ . inArray ( position . vehicle , vehicle_names ) == - 1 ) {
518538 vehicle_names . push ( position . vehicle ) ;
519539 var marker = null ;
@@ -533,8 +553,8 @@ function addPosition(position) {
533553
534554 marker = new google . maps . Marker ( {
535555 icon : image_src ,
556+ zIndex : Z_CAR ,
536557 position : point ,
537- size : new google . maps . Size ( 55 , 25 ) ,
538558 map : map
539559 } ) ;
540560 } else {
@@ -545,6 +565,7 @@ function addPosition(position) {
545565 image_src = host_url + markers_url + "balloon-" + balloon_colors_name [ c ] + ".png" ;
546566 marker_shadow = new google . maps . Marker ( {
547567 map : map ,
568+ zIndex : Z_SHADOW ,
548569 position : point ,
549570 icon : new google . maps . MarkerImage (
550571 host_url + markers_url + "shadow.png" ,
@@ -556,16 +577,20 @@ function addPosition(position) {
556577 } ) ;
557578 marker = new google . maps . Marker ( {
558579 map : map ,
580+ zIndex : Z_PAYLOAD ,
559581 position : point ,
560582 icon : image_src ,
561583 title : position . vehicle ,
562584 } ) ;
563585 marker . shadow = marker_shadow ;
564586 marker . balloonColor = balloon_colors_name [ c ] ;
587+ marker . mode = 'balloon' ;
565588 marker . setMode = function ( mode ) {
589+ this . mode = mode ;
566590 var img ;
567591 if ( mode == "landed" ) {
568- img = host_url + markers_url + "landed-" + this . balloonColor + ".png" ;
592+ img = host_url + markers_url + "payload-" + this . balloonColor + ".png" ;
593+ img = new google . maps . MarkerImage ( img , null , null , new google . maps . Point ( 8 , 15 ) ) ;
569594 } else if ( mode == "parachute" ) {
570595 img = host_url + markers_url + "parachute-" + this . balloonColor + ".png" ;
571596 } else {
@@ -582,11 +607,12 @@ function addPosition(position) {
582607
583608 horizon_circle = new google . maps . Circle ( {
584609 map : map ,
610+ zIndex : Z_RANGE ,
585611 radius : 1 ,
586612 fillColor : '#00F' ,
587- fillOpacity : 0 ,
613+ fillOpacity : 0.05 ,
588614 strokeColor : '#00F' ,
589- strokeOpacity : 0.5 ,
615+ strokeOpacity : 0.6 ,
590616 strokeWeight : 3 ,
591617 clickable : false ,
592618 editable : false
@@ -595,10 +621,11 @@ function addPosition(position) {
595621 subhorizon_circle = new google . maps . Circle ( {
596622 map : map ,
597623 radius : 1 ,
624+ zIndex : Z_RANGE ,
598625 fillColor : '#0F0' ,
599- fillOpacity : 0 ,
626+ fillOpacity : 0.05 ,
600627 strokeColor : '#0F0' ,
601- strokeOpacity : 0.6 ,
628+ strokeOpacity : 0.8 ,
602629 strokeWeight : 3 ,
603630 clickable : false ,
604631 editable : false
@@ -618,6 +645,7 @@ function addPosition(position) {
618645 line : [ ] ,
619646 polyline : new google . maps . Polyline ( {
620647 map : map ,
648+ zIndex : Z_PATH ,
621649 strokeColor : balloon_colors [ c ] ,
622650 strokeOpacity : 0.8 ,
623651 strokeWeight : 3 ,
@@ -642,15 +670,13 @@ function addPosition(position) {
642670
643671 // if position array has at least 1 position
644672 if ( vehicle . num_positions > 0 ) {
645- if ( vehicle . curr_position . gps_lat == position . gps_lat
646- && vehicle . curr_position . gps_lon == position . gps_lon ) {
673+ if ( ( new Date ( vehicle . curr_position . gps_time ) ) . getTime ( ) >= ( new Date ( position . gps_time ) ) . getTime ( ) ) {
674+ //if(vehicle.curr_position.gps_lat == position.gps_lat
675+ // && vehicle.curr_position.gps_lon == position.gps_lon) {
647676 if ( ( "," + vehicle . curr_position . callsign + "," ) . indexOf ( "," + position . callsign + "," ) === - 1 ) {
648677 vehicle . curr_position . callsign += "," + position . callsign ;
649678 }
650679 } else {
651- // add the new position
652- vehicle . positions . push ( new_latlng ) ;
653- vehicle . num_positions ++ ;
654680
655681 dt = convert_time ( position . gps_time )
656682 - convert_time ( vehicle . curr_position . gps_time ) ;
@@ -661,7 +687,14 @@ function addPosition(position) {
661687 + 0.3 * vehicles [ vehicle_index ] . ascent_rate ;
662688 }
663689
664- vehicle . curr_position = position ;
690+ if ( vehicle . curr_position . gps_lat != position . gps_lat
691+ || vehicle . curr_position . gps_lon != position . gps_lon ) {
692+ // add the new position
693+ vehicle . positions . push ( new_latlng ) ;
694+ vehicle . num_positions ++ ;
695+
696+ vehicle . curr_position = position ;
697+ }
665698 }
666699 } else {
667700 vehicle . positions . push ( new_latlng ) ;
@@ -772,6 +805,7 @@ function updateCurrentPosition(lat, lon) {
772805 currentPosition = { marker : null , lat : lat , lon : lon } ;
773806 currentPosition . marker = new google . maps . Marker ( {
774807 icon : "img/marker-you.png" ,
808+ zIndex : Z_CAR ,
775809 position : latlng ,
776810 size : new google . maps . Size ( 19 , 40 ) ,
777811 anchor : new google . maps . Point ( 9 , 40 ) ,
@@ -792,6 +826,7 @@ function updateReceiverMarker(receiver) {
792826 //icon.infoWindowAnchor = new google.maps.Point(13,3);
793827 receiver . marker = new google . maps . Marker ( {
794828 icon : host_url + markers_url + "antenna-green.png" ,
829+ zIndex : Z_STATION ,
795830 position : latlng ,
796831 size : new google . maps . Size ( 26 , 32 ) ,
797832 anchor : new google . maps . Point ( 13 , 30 ) ,
0 commit comments