Skip to content

Commit 29090a9

Browse files
Mark JessopMark Jessop
authored andcommitted
Re-align processing with sondehub-tracker
1 parent b61d5ec commit 29090a9

File tree

4 files changed

+101
-78
lines changed

4 files changed

+101
-78
lines changed

build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ cat jquery* >> mobile.js
1919

2020
VERSION="`git rev-parse --short HEAD`"
2121

22+
BUILD_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`"
23+
2224
# compile the rest
2325
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge iscroll.js >> mobile.js
2426
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge chasecar.lib.js | sed "s/{VER}/$VERSION/" >> mobile.js
2527
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge tracker.js >> mobile.js
26-
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge app.js >> mobile.js
28+
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge app.js | sed "s/{VER}/$VERSION/" | sed "s/{BUILD_DATE}/$BUILD_DATE/" >> mobile.js
2729
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge colour-map.js >> mobile.js
2830
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge format.js >> mobile.js
2931
java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge flight_doc.js >> mobile.js
@@ -41,4 +43,4 @@ sed "s/^\(# version\) .*$/\1 $VERSION `date +%s`/" cache.manifest-dev > cache.ma
4143

4244
echo "Done!"
4345

44-
echo "Build version: $VERSION"
46+
echo "Build version: $VERSION Build date: $BUILD_DATE"

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ <h2>Contribute</h2>
105105
A huge thanks to RGP for developing the mobile tracker that this site is based on.
106106
<br/><br/>
107107
You can also find us on IRC in <a href="https://kiwiirc.com/nextclient/irc.libera.chat/highaltitude" target="_blank" rel="noopener">#highaltitude</a> at <b>libera.chat</b>.
108+
<br/><br/>
109+
Tracker Revision: <span class="r" id="build_version"></span>
110+
<br/>
111+
Build Date: <span class="r" id="build_date"></span>
108112
</p>
109113
</div>
110114
</div>

js/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ $(window).ready(function() {
463463
updateTime(new Date());
464464
}, 1000);
465465

466+
// Update Tracker version info
467+
$('#build_version').text("{VER}");
468+
$('#build_date').text("{BUILD_DATE}");
469+
466470
// resize elements if needed
467471
checkSize();
468472

js/tracker.js

Lines changed: 89 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,6 +3233,7 @@ function refresh() {
32333233
document.getElementById("timeperiod").disabled = false;
32343234
}
32353235
clientActive = true;
3236+
//console.log("WebSockets - Resuming Websockets updates after poll.")
32363237
clearTimeout(periodical);
32373238
ajax_inprogress = false;
32383239
}
@@ -3403,26 +3404,43 @@ function liveData() {
34033404

34043405
} else {
34053406
// Message is payload telemetry
3407+
3408+
// Single frame, as we are not using amateur-batch
34063409
var frame = [{"1":JSON.parse(message.payloadString.toString())}];
3407-
if (frame.length == null) {
3408-
var tempDate = new Date(frame.time_received).getTime();
3409-
} else {
3410-
var tempDate = new Date(frame[frame.length - 1]["1"].time_received).getTime()
3411-
}
3412-
if ((dateNow - tempDate) < 30000) {
3413-
var test = formatData(frame);
3414-
if (clientActive) {
3415-
live_data_buffer.positions.position.push.apply(live_data_buffer.positions.position,test.positions.position);
3416-
}
3410+
// If we switch to amateur-batch, we should use
3411+
// var frame = JSON.parse(message.payloadString.toString());
3412+
3413+
var test = formatData(frame);
3414+
if (clientActive) {
3415+
live_data_buffer.positions.position.push.apply(live_data_buffer.positions.position,test.positions.position)
34173416
$("#stTimer").attr("data-timestamp", dateNow);
34183417
$("#stText").text("websocket |");
3419-
} else if ((dateNow - new Date(frame[0]["1"].time_received).getTime()) > 150000) {
3420-
$("#stText").text("error |");
3421-
refresh();
3422-
} else {
3423-
$("#stText").text("error |");
34243418
}
3419+
3420+
// The old way, with data age checks.
3421+
//
3422+
// var frame = [{"1":JSON.parse(message.payloadString.toString())}];
3423+
// if (frame.length == null) {
3424+
// var tempDate = new Date(frame.time_received).getTime();
3425+
// } else {
3426+
// var tempDate = new Date(frame[frame.length - 1]["1"].time_received).getTime()
3427+
// }
3428+
// if ((dateNow - tempDate) < 30000) {
3429+
// var test = formatData(frame);
3430+
// if (clientActive) {
3431+
// live_data_buffer.positions.position.push.apply(live_data_buffer.positions.position,test.positions.position);
3432+
// }
3433+
// $("#stTimer").attr("data-timestamp", dateNow);
3434+
// $("#stText").text("websocket |");
3435+
// } else if ((dateNow - new Date(frame[0]["1"].time_received).getTime()) > 150000) {
3436+
// $("#stText").text("error |");
3437+
// refresh();
3438+
// } else {
3439+
// $("#stText").text("error |");
3440+
// }
34253441
}
3442+
} else {
3443+
console.log("WebSockets - Discarding Message, not ready yet.")
34263444
}
34273445
}
34283446
catch(err) {}
@@ -3432,7 +3450,10 @@ function liveData() {
34323450
setInterval(function(){
34333451
update(live_data_buffer);
34343452
live_data_buffer.positions.position=[];
3435-
}, 200)
3453+
}, 500)
3454+
3455+
// Event listener to update on page resume from suspend.
3456+
document.addEventListener('resume', refresh);
34363457

34373458
function refreshPatreons() {
34383459

@@ -3885,93 +3906,85 @@ function update(response, none) {
38853906
lastPPointer: lastPositions.positions.position,
38863907
idx: 0,
38873908
max: response.positions.position.length,
3888-
step: function(ctx) {
3889-
var draw_idx = -1;
3909+
run: function(ctx) {
3910+
while(ctx.idx < ctx.max){
3911+
var draw_idx = -1;
38903912

3891-
var i = ctx.idx;
3892-
var max = i + 5000;
3893-
max = (max >= ctx.max) ? ctx.max : max;
3913+
var i = ctx.idx;
3914+
var max = i + 5000;
3915+
max = (max >= ctx.max) ? ctx.max : max;
38943916

3895-
for (; i < max ; i++) {
3896-
var row = ctx.positions[i];
3917+
for (; i < max ; i++) {
3918+
var row = ctx.positions[i];
38973919

3898-
// set the position based on the last record (oldest) returned from the server. Only provide minute accuracy to allow better hit rate with cloudfront
3899-
this_position_id = new Date(row.gps_time);
3920+
// set the position based on the last record (oldest) returned from the server. Only provide minute accuracy to allow better hit rate with cloudfront
3921+
this_position_id = new Date(row.gps_time);
39003922

3901-
if (new Date(position_id) < this_position_id || position_id == 0){
3902-
if (new Date() > this_position_id) {
3903-
this_position_id.setSeconds(0)
3904-
this_position_id.setMilliseconds(0)
3905-
position_id = this_position_id.toISOString()
3923+
if (new Date(position_id) < this_position_id || position_id == 0){
3924+
if (new Date() > this_position_id) {
3925+
this_position_id.setSeconds(0)
3926+
this_position_id.setMilliseconds(0)
3927+
position_id = this_position_id.toISOString()
3928+
}
39063929
}
3907-
}
39083930

3909-
if (!row.picture) {
3910-
addPosition(row);
3911-
got_positions = true;
3931+
if (!row.picture) {
3932+
addPosition(row);
3933+
got_positions = true;
3934+
}
39123935
}
3913-
}
39143936

3915-
ctx.idx = max;
3937+
ctx.idx = max;
39163938

3917-
if(ctx.idx < ctx.max) {
3918-
setTimeout(function() { ctx.step(ctx); }, 4);
3919-
} else {
3920-
ctx.list = Object.keys(vehicles);
3921-
setTimeout(function() { ctx.draw(ctx); }, 16);
3922-
}
3923-
},
3924-
draw: function(ctx) {
3925-
if(ctx.list.length < 1) {
3926-
setTimeout(function() { ctx.end(ctx); }, 16);
3927-
return;
39283939
}
39293940

3930-
// pop a callsign from the top
3931-
var vcallsign = ctx.list.shift();
3932-
var vehicle = vehicles[vcallsign];
3941+
ctx.list = Object.keys(vehicles);
39333942

3934-
if(vehicle === undefined) return;
3943+
// draw loop
3944+
while(ctx.list.length >= 1){
3945+
// pop a callsign from the top
3946+
var vcallsign = ctx.list.shift();
3947+
var vehicle = vehicles[vcallsign];
39353948

3936-
if(vehicle.updated) {
3937-
updatePolyline(vcallsign);
3938-
3939-
updateVehicleInfo(vcallsign, vehicle.curr_position);
3949+
if(vehicle === undefined) return;
39403950

3941-
// remember last position for each vehicle
3942-
ctx.lastPPointer.push(vehicle.curr_position);
3951+
if(vehicle.updated) {
3952+
updatePolyline(vcallsign);
3953+
3954+
updateVehicleInfo(vcallsign, vehicle.curr_position);
3955+
3956+
// remember last position for each vehicle
3957+
ctx.lastPPointer.push(vehicle.curr_position);
39433958

3944-
if(listScroll) listScroll.refresh();
3945-
if(zoomed_in && follow_vehicle == vcallsign && !manual_pan) panTo(follow_vehicle);
3946-
if (follow_vehicle == vcallsign) {
3947-
update_lookangles(follow_vehicle);
3948-
drawLOSPaths(vcallsign);
3959+
if(listScroll) listScroll.refresh();
3960+
if(zoomed_in && follow_vehicle == vcallsign && !manual_pan) panTo(follow_vehicle);
3961+
if (follow_vehicle == vcallsign) {
3962+
update_lookangles(follow_vehicle);
3963+
drawLOSPaths(vcallsign);
3964+
}
39493965
}
39503966
}
3967+
// ctx.end
39513968

3952-
// step to the next callsign
3953-
setTimeout(function() { ctx.draw(ctx); }, 16);
3954-
},
3955-
end: function(ctx) {
3956-
3957-
// update graph is current vehicles is followed
3958-
if(follow_vehicle !== null &&
3959-
vehicles.hasOwnProperty(follow_vehicle) &&
3960-
vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, false);
3969+
// update graph is current vehicles is followed
3970+
if(follow_vehicle !== null &&
3971+
vehicles.hasOwnProperty(follow_vehicle) &&
3972+
vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, false);
39613973

3962-
if (got_positions && !zoomed_in && Object.keys(vehicles).length) {
3974+
if (got_positions && !zoomed_in && Object.keys(vehicles).length) {
39633975
if (vehicles.hasOwnProperty(wvar.query) && wvar.query !== "") {
39643976
zoom_on_payload();
39653977
}
39663978
// TODO: Zoom to geolocation position
39673979

3968-
}
3980+
}
3981+
3982+
if(periodical_predictions === null) refreshPredictions();
3983+
},
39693984

3970-
if(periodical_predictions === null) refreshPredictions();
3971-
}
39723985
};
39733986

3974-
ctx_init.step(ctx_init);
3987+
ctx_init.run(ctx_init);
39753988
}
39763989

39773990
function zoom_on_payload() {

0 commit comments

Comments
 (0)