@@ -57,7 +57,8 @@ var car_index = 0;
57
57
var car_colors = [ "blue" , "red" , "green" , "yellow" , "teal" , "purple" ] ;
58
58
var balloon_index = 0 ;
59
59
var balloon_colors_name = [ "red" , "blue" , "green" , "yellow" , "purple" , "orange" , "cyan" ] ;
60
- var balloon_colors = [ "#f00" , "blue" , "green" , "#FDFC30" , "#c700e6" , "#ff8a0f" , "#0fffca" ] ;
60
+ // Yellow was #FDFC30, darker version is "#caca02"
61
+ var balloon_colors = [ "#f00" , "blue" , "green" , "#caca02" , "#c700e6" , "#ff8a0f" , "#0fffca" ] ;
61
62
62
63
var nyan_color_index = 0 ;
63
64
var nyan_colors = [ 'nyan' , 'nyan-coin' , 'nyan-mon' , 'nyan-pirate' , 'nyan-cool' , 'nyan-tothemax' , 'nyan-pumpkin' , 'nyan-afro' , 'nyan-coin' , 'nyan-mummy' ] ;
@@ -83,13 +84,14 @@ var modeList = [
83
84
"12h" ,
84
85
"1d" ,
85
86
"3d" ,
86
- "7d" , // New time periods, as of 2023-04, only available if filtering is on.
87
- "31d" ,
87
+ "7d" ,
88
+ "31d" , // New time periods, as of 2023-04, only available if filtering is on.
88
89
"186d" ,
89
90
"366d"
90
91
] ;
91
92
var modeDefault = "12h" ;
92
93
var modeDefaultMobile = "12h" ;
94
+ var longModes = [ '31d' , '186d' , '366d' ] ; // These modes only available if filtering is on.
93
95
94
96
// order of map elements
95
97
var Z_RANGE = 1 ;
@@ -640,7 +642,7 @@ function load() {
640
642
onAdd : function ( map ) {
641
643
var div = L . DomUtil . create ( 'div' ) ;
642
644
643
- div . innerHTML = '<select name="timeperiod" id="timeperiod" style="width:auto !important;height:30px;" onchange="clean_refresh(this.value)"><option value="0">Live Only</option><option value="1h">1 hour</option><option value="3h">3 hours</option><option value="6h">6 hours</option><option value="12h">12 hours</option><option value="1d" selected="selected">1 day</option><option value="3d">3 days</option><option value="7d">7 days</option></select>' ;
645
+ div . innerHTML = '<select name="timeperiod" id="timeperiod" style="width:auto !important;height:30px;" onchange="clean_refresh(this.value)"><option value="0">Live Only</option><option value="1h">1 hour</option><option value="3h">3 hours</option><option value="6h">6 hours</option><option value="12h">12 hours</option><option value="1d" selected="selected">1 day</option><option value="3d">3 days</option><option value="7d">7 days</option><option value="31d" disabled>1 month</option><option value="186d" disabled>6 months</option><option value="366d" disabled>1 year</option>< /select>' ;
644
646
div . innerHTML . onload = setTimeValue ( ) ;
645
647
646
648
return div ;
@@ -803,6 +805,22 @@ function load() {
803
805
} , 500 ) ;
804
806
}
805
807
808
+ function setLongTimePeriods ( state ) {
809
+ // Enable or disable the 'long' timeperiod settings (>1 month)
810
+ $ ( "#timeperiod option" ) . each ( function ( ) {
811
+ var $thisOption = $ ( this ) ;
812
+
813
+ if ( longModes . includes ( $thisOption . val ( ) ) ) {
814
+ if ( state ) {
815
+ $thisOption . attr ( "disabled" , false ) ;
816
+ } else {
817
+ $thisOption . attr ( "disabled" , true ) ;
818
+ }
819
+ }
820
+ } ) ;
821
+ }
822
+
823
+
806
824
function setTimeValue ( ) {
807
825
setTimeout ( function ( ) {
808
826
document . getElementById ( "timeperiod" ) . value = wvar . mode ;
@@ -1827,7 +1845,7 @@ function redrawPrediction(vcallsign) {
1827
1845
} else {
1828
1846
vehicle . prediction_polyline = new L . Wrapped . Polyline ( line , {
1829
1847
color : balloon_colors [ vehicle . color_index ] ,
1830
- opacity : 0.4 ,
1848
+ opacity : 0.5 ,
1831
1849
weight : 3 ,
1832
1850
} ) . addTo ( map ) ;
1833
1851
vehicle . prediction_polyline . on ( 'click' , function ( e ) {
@@ -1924,10 +1942,20 @@ function updatePolyline(vcallsign) {
1924
1942
}
1925
1943
1926
1944
function drawAltitudeProfile ( c1 , c2 , series , alt_max , chase ) {
1945
+ // Updated 2023-04-10 to make use of position time data to set
1946
+ // the x-coordinate. This helps resolve issues with backlog vs live data.
1927
1947
alt_max = ( alt_max < 2000 ) ? 2000 : alt_max ;
1928
1948
var alt_list = series . data ;
1949
+ var first_time = alt_list [ 0 ] [ 0 ] ;
1929
1950
var len = alt_list . length ;
1930
1951
var real_len = len - series . nulls ;
1952
+ var last_time = alt_list [ len - 1 ] [ 0 ] ;
1953
+ var time_range = last_time - first_time ;
1954
+
1955
+ // Only attempt to draw if we have more than 1 data point.
1956
+ if ( len == 1 ) {
1957
+ return ;
1958
+ }
1931
1959
1932
1960
var ctx1 = c1 . getContext ( "2d" ) ;
1933
1961
var ctx2 = c2 . getContext ( "2d" ) ;
@@ -1960,16 +1988,19 @@ function drawAltitudeProfile(c1, c2, series, alt_max, chase) {
1960
1988
ctx2 . strokeStyle = "#f53333" ;
1961
1989
}
1962
1990
1963
- var xt1 = ( cw1 - ( 2 * ratio ) ) / real_len ;
1991
+ //var xt1 = (cw1 - (2 * ratio)) / real_len;
1992
+ var xt1 = ( cw1 - ( 2 * ratio ) ) / time_range ;
1964
1993
var yt1 = ( ch1 - ( 6 * ratio ) ) / alt_max ;
1965
- var xt2 = ( cw2 - ( 2 * ratio ) ) / real_len ;
1994
+ //var xt2 = (cw2 - (2 * ratio)) / real_len;
1995
+ var xt2 = ( cw2 - ( 2 * ratio ) ) / time_range ;
1966
1996
var yt2 = ( ch2 - ( 6 * ratio ) ) / alt_max ;
1967
1997
1968
1998
xt1 = ( xt1 > 1 ) ? 1 : xt1 ;
1969
1999
yt1 = ( yt1 > 1 ) ? 1 : yt1 ;
1970
2000
xt2 = ( xt2 > 1 ) ? 1 : xt2 ;
1971
2001
yt2 = ( yt2 > 1 ) ? 1 : yt2 ;
1972
2002
2003
+
1973
2004
ctx1 . beginPath ( ) ;
1974
2005
ctx2 . beginPath ( ) ;
1975
2006
@@ -1985,26 +2016,33 @@ function drawAltitudeProfile(c1, c2, series, alt_max, chase) {
1985
2016
if ( cw1 * 2 > real_len ) {
1986
2017
for ( i = 0 ; i < real_len ; i ++ ) {
1987
2018
alt = alt_list [ i ] [ 1 ] ;
2019
+ alt_time = last_time - alt_list [ i ] [ 0 ] ;
1988
2020
1989
- ctx1 . lineTo ( 1 + ( ( i + 1 ) * xt1 ) , ch1 - ( alt * yt1 ) ) ;
1990
- ctx2 . lineTo ( 1 + ( ( i + 1 ) * xt2 ) , ch2 - ( alt * yt2 ) ) ;
2021
+ //
2022
+ //ctx1.lineTo(1+((i+1)*xt1), ch1 - (alt * yt1));
2023
+ //ctx2.lineTo(1+((i+1)*xt2), ch2 - (alt * yt2));
2024
+ ctx1 . lineTo ( cw1 - ( alt_time * xt1 ) , ch1 - ( alt * yt1 ) ) ;
2025
+ ctx2 . lineTo ( cw2 - ( alt_time * xt2 ) , ch2 - ( alt * yt2 ) ) ;
1991
2026
1992
2027
if ( i + 2 < len && alt_list [ i + 2 ] [ 1 ] === null ) i += 2 ;
1993
2028
}
1994
2029
}
1995
2030
// if they are too many, downsample to keep the loop short
1996
2031
else {
1997
- xt1 = 0.5 ;
1998
- xt2 = 0.16 ;
2032
+ // xt1 = 0.5;
2033
+ // xt2 = 0.16;
1999
2034
var max = cw1 * 2 ;
2000
2035
var step = ( 1.0 * len ) / max ;
2001
2036
2002
2037
for ( i = 0 ; i < max ; i ++ ) {
2003
2038
alt = alt_list [ Math . floor ( i * step ) ] [ 1 ] ;
2039
+ alt_time = last_time - alt_list [ Math . floor ( i * step ) ] [ 0 ] ;
2004
2040
if ( alt === null ) continue ;
2005
2041
2006
- ctx1 . lineTo ( 1 + ( ( i + 1 ) * xt1 ) , ch1 - ( alt * yt1 ) ) ;
2007
- ctx2 . lineTo ( 1 + ( ( i + 1 ) * xt2 ) , ch2 - ( alt * yt2 ) ) ;
2042
+ //ctx1.lineTo(1+((i+1)*xt1), ch1 - (alt * yt1));
2043
+ //ctx2.lineTo(1+((i+1)*xt2), ch2 - (alt * yt2));
2044
+ ctx1 . lineTo ( cw1 - ( alt_time * xt1 ) , ch1 - ( alt * yt1 ) ) ;
2045
+ ctx2 . lineTo ( cw2 - ( alt_time * xt2 ) , ch2 - ( alt * yt2 ) ) ;
2008
2046
}
2009
2047
2010
2048
// fix index for fill
@@ -2015,8 +2053,13 @@ function drawAltitudeProfile(c1, c2, series, alt_max, chase) {
2015
2053
ctx2 . stroke ( ) ;
2016
2054
2017
2055
// close the path, so it can be filled
2018
- ctx1 . lineTo ( 1 + ( ( i + 1 ) * xt1 ) , ch1 ) ;
2019
- ctx2 . lineTo ( 1 + ( ( i + 1 ) * xt2 ) , ch2 ) ;
2056
+ //ctx1.lineTo(1+((i+1)*xt1), ch1);
2057
+ //ctx2.lineTo(1+((i+1)*xt2), ch2);
2058
+ end_x1 = cw1 - ( last_time - alt_list [ len - 1 ] [ 0 ] ) * xt1 ;
2059
+ end_x2 = cw2 - ( last_time - alt_list [ len - 1 ] [ 0 ] ) * xt2 ;
2060
+
2061
+ ctx1 . lineTo ( end_x1 , ch1 ) ;
2062
+ ctx2 . lineTo ( end_x2 , ch2 ) ;
2020
2063
ctx1 . lineTo ( 0 , ch1 ) ;
2021
2064
ctx2 . lineTo ( 0 , ch2 ) ;
2022
2065
@@ -3213,8 +3256,10 @@ function refresh() {
3213
3256
3214
3257
if ( wvar . query ) {
3215
3258
var data_str = "duration=" + mode + "&payload_callsign=" + encodeURIComponent ( wvar . query ) ;
3259
+ setLongTimePeriods ( true ) ;
3216
3260
} else {
3217
3261
var data_str = "duration=" + mode ;
3262
+ setLongTimePeriods ( false ) ;
3218
3263
}
3219
3264
3220
3265
ajax_positions = $ . ajax ( {
0 commit comments