@@ -736,12 +736,16 @@ function sub_to_nearby_sondes(){
736736 // If zoomed in then we sub to specific sondes
737737 for ( let vehicle in vehicles ) {
738738 let topic = "sondes/" + vehicle ;
739+ let prediction_topic = "prediction/" + vehicle ;
740+ let reverse_topic = "reverse-prediction/" + vehicle ;
739741 inside_bounds = bounds . contains ( vehicles [ vehicle ] . marker . _latlng )
740742 if ( inside_bounds ) {
741743 if ( ! clientTopic . includes ( topic ) ) {
742744 if ( sub_logging ) console . log ( "Subbing to " + topic )
743745 if ( client . isConnected ( ) ) {
744746 client . subscribe ( topic ) ;
747+ client . subscribe ( prediction_topic ) ;
748+ client . subscribe ( reverse_topic ) ;
745749 }
746750 clientTopic . push ( topic )
747751 }
@@ -752,7 +756,9 @@ function sub_to_nearby_sondes(){
752756 } else {
753757 if ( sub_logging ) console . log ( "unsubbing from " + topic )
754758 if ( client . isConnected ( ) ) {
755- client . unsubscribe ( topic )
759+ client . unsubscribe ( topic ) ;
760+ client . unsubscribe ( prediction_topic ) ;
761+ client . unsubscribe ( reverse_topic ) ;
756762 }
757763 var topic_index = clientTopic . indexOf ( topic )
758764 if ( topic_index > - 1 ) {
@@ -790,6 +796,8 @@ function clean_refresh(text, force, history_step) {
790796 if ( wvar . query && sondePrefix . indexOf ( wvar . query ) == - 1 ) {
791797 var topic = "sondes/" + wvar . query ;
792798 client . subscribe ( topic ) ;
799+ client . subscribe ( "prediction/" + wvar . query ) ;
800+ client . subscribe ( "reverse-prediction/" + wvar . query ) ;
793801 clientTopic = [ topic ] ;
794802 } else {
795803 client . subscribe ( "sondes-new/#" ) ;
@@ -1161,6 +1169,33 @@ function panTo(vcallsign) {
11611169 set_polyline_visibility ( serial , false ) ;
11621170 }
11631171 }
1172+
1173+ // update predictions
1174+ $ . ajax ( {
1175+ type : "GET" ,
1176+ url : predictions_url + vcallsign ,
1177+ data : "" ,
1178+ dataType : "json" ,
1179+ serial : vcallsign ,
1180+ success : function ( response , textStatus ) {
1181+ updatePredictions ( response ) ;
1182+ set_polyline_visibility ( serial , true ) ;
1183+ }
1184+ } ) ;
1185+
1186+ var data_str = "duration=" + wvar . mode + "&vehicles=" + vcallsign ;
1187+ $ . ajax ( {
1188+ type : "GET" ,
1189+ url : launch_predictions_url ,
1190+ data : data_str ,
1191+ dataType : "json" ,
1192+ serial : vcallsign ,
1193+ success : function ( response , textStatus ) {
1194+ updateLaunchPredictions ( response ) ;
1195+ set_polyline_visibility ( serial , true ) ;
1196+ }
1197+ } ) ;
1198+
11641199 vehicles [ vcallsign ] . polyline_visible = true ;
11651200 set_polyline_visibility ( vcallsign , true ) ;
11661201 // update lookangles
@@ -3821,6 +3856,8 @@ function liveData() {
38213856 if ( wvar . query && sondePrefix . indexOf ( wvar . query ) == - 1 ) {
38223857 var topic = "sondes/" + wvar . query ;
38233858 client . subscribe ( topic ) ;
3859+ client . subscribe ( "prediction/" + wvar . query ) ;
3860+ client . subscribe ( "reverse-prediction/" + wvar . query ) ;
38243861 clientTopic = [ topic ] ;
38253862 } else {
38263863 client . subscribe ( "sondes-new/#" ) ;
@@ -3901,7 +3938,32 @@ function liveData() {
39013938 } else {
39023939 updateReceivers ( formatted_frame , single = true ) ;
39033940 }
3941+ } else if ( message . topic . startsWith ( "prediction" ) ) {
3942+ var frame = JSON . parse ( message . payloadString . toString ( ) ) ;
39043943
3944+ var pred_data = [
3945+ {
3946+ "vehicle" : frame . serial ,
3947+ "time" : frame . datetime ,
3948+ "latitude" : frame . position [ 1 ] ,
3949+ "longitude" : frame . position [ 0 ] ,
3950+ "altitude" : frame . altitude ,
3951+ "ascent_rate" : frame . ascent_rate ,
3952+ "descent_rate" : frame . descent_rate ,
3953+ "burst_altitude" : frame . burst_altitude ,
3954+ "descending" : frame . descending ? 1 : 0 ,
3955+ "landed" : frame . descending ? 1 : 0 ,
3956+ "data" : JSON . stringify ( frame . data )
3957+ }
3958+ ]
3959+ updatePredictions ( pred_data ) ;
3960+ } else if ( message . topic . startsWith ( "reverse-prediction" ) ) {
3961+ var frame = JSON . parse ( message . payloadString . toString ( ) ) ;
3962+ var serial = frame [ "serial" ] ;
3963+ var pred_data = {
3964+ }
3965+ pred_data [ serial ] = frame
3966+ updateLaunchPredictions ( pred_data ) ;
39053967 } else {
39063968 var frame = JSON . parse ( message . payloadString . toString ( ) ) ;
39073969
@@ -4137,45 +4199,45 @@ function refreshRecoveryStats() {
41374199
41384200var ajax_predictions = null ;
41394201
4140- function refreshPredictions ( ) {
4141- if ( ajax_inprogress ) {
4142- clearTimeout ( periodical_predictions ) ;
4143- periodical_predictions = setTimeout ( refreshPredictions , 1000 ) ;
4144- return ;
4145- }
4146-
4147- ajax_predictions = $ . ajax ( {
4148- type : "GET" ,
4149- url : predictions_url + encodeURIComponent ( wvar . query ) ,
4150- data : "" ,
4151- dataType : "json" ,
4152- success : function ( response , textStatus ) {
4153- updatePredictions ( response ) ;
4154- } ,
4155- error : function ( ) {
4156- } ,
4157- complete : function ( request , textStatus ) {
4158- clearTimeout ( periodical_predictions ) ;
4159- periodical_predictions = setTimeout ( refreshPredictions , 60 * 1000 ) ;
4160- }
4161- } ) ;
4162-
4163- var data_str = "duration=" + wvar . mode + "&vehicles=" + encodeURIComponent ( wvar . query ) ;
4164-
4165- ajax_predictions = $ . ajax ( {
4166- type : "GET" ,
4167- url : launch_predictions_url ,
4168- data : data_str ,
4169- dataType : "json" ,
4170- success : function ( response , textStatus ) {
4171- updateLaunchPredictions ( response ) ;
4172- } ,
4173- error : function ( ) {
4174- } ,
4175- complete : function ( request , textStatus ) {
4176- }
4177- } ) ;
4178- }
4202+ // function refreshPredictions() {
4203+ // if(ajax_inprogress) {
4204+ // clearTimeout(periodical_predictions);
4205+ // periodical_predictions = setTimeout(refreshPredictions, 1000);
4206+ // return;
4207+ // }
4208+
4209+ // ajax_predictions = $.ajax({
4210+ // type: "GET",
4211+ // url: predictions_url + encodeURIComponent(wvar.query),
4212+ // data: "",
4213+ // dataType: "json",
4214+ // success: function(response, textStatus) {
4215+ // updatePredictions(response);
4216+ // },
4217+ // error: function() {
4218+ // },
4219+ // complete: function(request, textStatus) {
4220+ // clearTimeout(periodical_predictions);
4221+ // periodical_predictions = setTimeout(refreshPredictions, 60 * 1000);
4222+ // }
4223+ // });
4224+
4225+ // var data_str = "duration=" + wvar.mode + "&vehicles=" + encodeURIComponent(wvar.query);
4226+
4227+ // ajax_predictions = $.ajax({
4228+ // type: "GET",
4229+ // url: launch_predictions_url,
4230+ // data: data_str,
4231+ // dataType: "json",
4232+ // success: function(response, textStatus) {
4233+ // updateLaunchPredictions(response);
4234+ // },
4235+ // error: function() {
4236+ // },
4237+ // complete: function(request, textStatus) {
4238+ // }
4239+ // });
4240+ // }
41794241
41804242var periodical , periodical_focus , periodical_focus_new , periodical_receivers , periodical_listeners , periodical_recoveries ;
41814243var periodical_predictions = null ;
@@ -4883,7 +4945,7 @@ function update(response, none) {
48834945
48844946 }
48854947
4886- if ( periodical_predictions === null ) refreshPredictions ( ) ;
4948+ // if(periodical_predictions === null) refreshPredictions();
48874949 } ,
48884950
48894951 } ;
0 commit comments