@@ -716,15 +716,16 @@ function throttle_events(event) {
716716function sub_to_nearby_sondes ( ) {
717717 let bounds = map . getBounds ( ) . pad ( 1 ) ; // expand by one viewport
718718 let zoomed_out = map . getZoom ( ) <= 6 ;
719+ const sub_logging = false ;
719720 if ( zoomed_out ) {
720721 // If we are fairly zooomed out - only give the slow feed
721722 var newClientTopic = [ clientTopic [ 0 ] ]
722723 for ( let i = 1 ; i < clientTopic . length ; i ++ ) { // skip first slow topic
723724 if ( client . isConnected ( ) && ! alwaysSub . includes ( clientTopic [ i ] . replace ( "sondes/" , "" ) ) ) {
724- console . log ( "zoomed fully out. unsubbing from " + clientTopic [ i ] )
725+ if ( sub_logging ) console . log ( "zoomed fully out. unsubbing from " + clientTopic [ i ] )
725726 client . unsubscribe ( clientTopic [ i ] ) ;
726727 } else {
727- console . log ( "retaining " + clientTopic [ i ] ) ;
728+ if ( sub_logging ) console . log ( "retaining " + clientTopic [ i ] ) ;
728729 newClientTopic . push ( clientTopic [ i ] )
729730 }
730731 }
@@ -735,10 +736,10 @@ function sub_to_nearby_sondes(){
735736 // If zoomed in then we sub to specific sondes
736737 for ( let vehicle in vehicles ) {
737738 let topic = "sondes/" + vehicle ;
738- inside_bounds = map . getBounds ( ) . pad ( 1 ) . contains ( vehicles [ vehicle ] . marker . _latlng )
739+ inside_bounds = bounds . contains ( vehicles [ vehicle ] . marker . _latlng )
739740 if ( inside_bounds ) {
740741 if ( ! clientTopic . includes ( topic ) ) {
741- console . log ( "Subbing to " + topic )
742+ if ( sub_logging ) console . log ( "Subbing to " + topic )
742743 if ( client . isConnected ( ) ) {
743744 client . subscribe ( topic ) ;
744745 }
@@ -747,9 +748,9 @@ function sub_to_nearby_sondes(){
747748 } else {
748749 if ( clientTopic . includes ( topic ) ) {
749750 if ( alwaysSub . includes ( vehicle ) ) {
750- console . log ( "retaining " + vehicle )
751+ if ( sub_logging ) console . log ( "retaining " + vehicle )
751752 } else {
752- console . log ( "unsubbing from " + topic )
753+ if ( sub_logging ) console . log ( "unsubbing from " + topic )
753754 if ( client . isConnected ( ) ) {
754755 client . unsubscribe ( topic )
755756 }
0 commit comments