Skip to content

Commit 17023fc

Browse files
added switch to enable graph interpolation
1 parent bcbd5b8 commit 17023fc

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ <h2>Contribute</h2>
105105
<div class="slimContainer">
106106
<h2><i class="icon-settings rfloat"></i>Settings</h2>
107107
<hr/>
108+
<div class="row option">
109+
<span><b>Interpolate gaps in telemetry</b></span>
110+
<div class="switch off" id="sw_interpolate">
111+
<span class="thumb"></span>
112+
<input type="checkbox" id="opt_interpolate">
113+
</div>
114+
</div>
108115
<div class="row option">
109116
<span><b>Hide welcome on start-up</b></span>
110117
<div class="switch off" id="sw_nowelcome">

js/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ $(window).ready(function() {
780780
"#sw_hide_timebox",
781781
"#sw_hilight_vehicle",
782782
"#sw_nowelcome",
783+
"#sw_interpolate",
783784
];
784785

785786
// applies functionality when switches are toggled
@@ -845,6 +846,12 @@ $(window).ready(function() {
845846
case "opt_layers_clouds":
846847
if(on) { layers_clouds.setMap(map); }
847848
else { layers_clouds.setMap(null); }
849+
break;
850+
case "opt_interpolate":
851+
if(on) { graph_gap_size = graph_gap_size_max; }
852+
else { graph_gap_size = graph_gap_size_default; }
853+
clean_refresh(wvar.mode, true, false);
854+
break;
848855
}
849856
});
850857

js/tracker.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,11 @@ function updateGraph(vcallsign, reset_selection) {
20272027
vehicles[vcallsign].graph_data_updated = false;
20282028
}
20292029

2030+
var graph_gap_size_default = 180000; // 3 mins in milis
2031+
var graph_gap_size_max = 31536000000;
2032+
var graph_gap_size = offline.get('opt_interpolate') ? graph_gap_size_max : graph_gap_size_default;
2033+
var graph_pad_size = 120000; // 2 min
2034+
20302035
function graphAddPosition(vcallsign, new_data) {
20312036

20322037
var vehicle = vehicles[vcallsign];
@@ -2038,8 +2043,6 @@ function graphAddPosition(vcallsign, new_data) {
20382043
var splice_idx = 0;
20392044
var splice_remove = 0;
20402045
var splice_pad = false;
2041-
var gap_size = 180000; // 3 mins in milis
2042-
var pad_size = 120000; // 2 min
20432046
var i;
20442047

20452048
if(data.length) {
@@ -2065,7 +2068,7 @@ function graphAddPosition(vcallsign, new_data) {
20652068

20662069
if(i > -1) {
20672070
// this is if new datum hits padded area
2068-
if((xref[i][1] === null && xref[i][0] - 1 + (gap_size - pad_size) >= ts)) {
2071+
if((xref[i][1] === null && xref[i][0] - 1 + (graph_gap_size - graph_pad_size) >= ts)) {
20692072
splice_remove = 2;
20702073
splice_idx = i-1;
20712074
}
@@ -2079,12 +2082,12 @@ function graphAddPosition(vcallsign, new_data) {
20792082

20802083
}
20812084
// should we pad before the new datum
2082-
else if (xref[i][1] !== null && xref[i][0] + gap_size < ts) {
2085+
else if (xref[i][1] !== null && xref[i][0] + graph_gap_size < ts) {
20832086
// pad with previous datum
20842087
$.each(data, function(k,v) {
20852088
if(k==1) return; // skip prediction series
20862089

2087-
v.data.splice(i+1, 0, [xref[i][0]+pad_size, v.data[i][1]], [xref[i][0]+pad_size+1, null]);
2090+
v.data.splice(i+1, 0, [xref[i][0]+graph_pad_size, v.data[i][1]], [xref[i][0]+graph_pad_size+1, null]);
20882091
v.nulls += 2;
20892092
});
20902093

@@ -2094,19 +2097,19 @@ function graphAddPosition(vcallsign, new_data) {
20942097
}
20952098

20962099
// should we pad after
2097-
if(ts + gap_size < xref[splice_idx+splice_remove][0]) {
2100+
if(ts + graph_gap_size < xref[splice_idx+splice_remove][0]) {
20982101
splice_pad = true;
20992102
}
21002103

21012104
}
21022105
else {
21032106
//insert gap when there are 3mins, or more, without telemetry
2104-
if(ts_last + gap_size < ts) {
2107+
if(ts_last + graph_gap_size < ts) {
21052108
$.each(data, function(k,v) {
21062109
if(k==1) return; // skip prediction series
21072110

2108-
v.data.push([ts_last+pad_size, v.data[ts_last_idx][1]]);
2109-
v.data.push([ts_last+pad_size+1, null]);
2111+
v.data.push([ts_last+graph_pad_size, v.data[ts_last_idx][1]]);
2112+
v.data.push([ts_last+graph_pad_size+1, null]);
21102113
v.nulls += 2;
21112114
});
21122115
}
@@ -2211,7 +2214,7 @@ function graphAddPosition(vcallsign, new_data) {
22112214
for(k in data_matrix) {
22122215
if(splice) {
22132216
if(splice_pad) {
2214-
data[k].data.splice(splice_idx, splice_remove, data_matrix[k], [ts+pad_size, data_matrix[k][1]], [ts+pad_size+1, null]);
2217+
data[k].data.splice(splice_idx, splice_remove, data_matrix[k], [ts+graph_pad_size, data_matrix[k][1]], [ts+graph_pad_size+1, null]);
22152218
data[k].nulls += 2;
22162219
} else {
22172220
data[k].data.splice(splice_idx, splice_remove, data_matrix[k]);
@@ -2226,7 +2229,7 @@ function graphAddPosition(vcallsign, new_data) {
22262229
// push latest altitude
22272230
if(splice) {
22282231
if(splice_pad) {
2229-
data[0].data.splice(splice_idx, splice_remove, [ts, parseInt(new_data.gps_alt)], [ts+pad_size, parseInt(new_data.gps_alt)], [ts+pad_size+1, null]);
2232+
data[0].data.splice(splice_idx, splice_remove, [ts, parseInt(new_data.gps_alt)], [ts+graph_pad_size, parseInt(new_data.gps_alt)], [ts+graph_pad_size+1, null]);
22302233
data[0].nulls += 2;
22312234
} else {
22322235
data[0].data.splice(splice_idx, splice_remove, [ts, parseInt(new_data.gps_alt)]);

0 commit comments

Comments
 (0)