Skip to content

Commit 742876b

Browse files
authored
Merge pull request projecthorus#331 from projecthorus/testing
Correct prediction loading for historic sondes, hashing of colours, fix for rotation
2 parents 9bb8fa4 + b1beb06 commit 742876b

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

js/tracker.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ var manual_pan = false;
7474

7575
var car_index = 0;
7676
var car_colors = ["blue", "red", "green", "yellow", "teal", "purple"];
77-
var balloon_index = 0;
7877
var balloon_colors_name = ["red", "blue", "green", "purple", "orange", "cyan"];
7978
var balloon_colors = ["#f00", "blue", "green", "#c700e6", "#ff8a0f", "#0fffca"];
8079

@@ -831,7 +830,6 @@ function clean_refresh(text, force, history_step) {
831830
}
832831

833832
car_index = 0;
834-
balloon_index = 0;
835833
nyan_color_index = 0;
836834
stopFollow(force);
837835

@@ -3088,7 +3086,11 @@ function addPosition(position) {
30883086
marker.addTo(map);
30893087
} else {
30903088
vehicle_type = "balloon";
3091-
color_index = balloon_index++ % balloon_colors.length;
3089+
let colorHash = 0;
3090+
for (let i = 0; i < vcallsign.length; i++){
3091+
colorHash += vcallsign.charCodeAt(i);
3092+
}
3093+
color_index = colorHash % balloon_colors.length;
30923094

30933095
if(wvar.nena){
30943096
// All the balloon are red.
@@ -3528,7 +3530,7 @@ function addPosition(position) {
35283530
};
35293531

35303532
// if car doesn't report heading, we calculate it from the last position
3531-
if(vehicle.num_positions > 1 && vehicle.vehicle_type == 'car' && 'gps_heading' in position && position.gps_heading === "") {
3533+
if(vehicle.num_positions > 1 && vehicle.vehicle_type == 'car') {
35323534

35333535
// Source
35343536
var startLat = toRadians(vehicle.curr_position.gps_lat);
@@ -4453,6 +4455,7 @@ function updateChase(r) {
44534455
dataTempEntry.gps_alt = last.uploader_position[2];
44544456
dataTempEntry.gps_lat = last.uploader_position[0];
44554457
dataTempEntry.gps_lon = last.uploader_position[1];
4458+
dataTempEntry.gps_heading = 90;
44564459
var date = new Date(last.ts)
44574460
var userTimezoneOffset = date.getTimezoneOffset() * 60000;
44584461
var time = new Date(date.getTime() - userTimezoneOffset).toISOString();
@@ -4831,23 +4834,26 @@ function updatePredictions(r) {
48314834
if(vcallsign == "XX") continue;
48324835

48334836
if(vehicles.hasOwnProperty(vcallsign)) {
4834-
var vehicle = vehicles[vcallsign];
4835-
4836-
if(vehicle.marker.mode == "landed") {
4837-
removePrediction(vcallsign);
4838-
continue;
4837+
var vehicle = vehicles[vcallsign];
4838+
if(vehicle.prediction && vehicle.prediction.time == r[i].time) continue;
4839+
vehicle.prediction = r[i];
4840+
vehicle.prediction.data = $.parseJSON(r[i].data);
4841+
4842+
// Figure out local ground level.
4843+
if(vehicle.prediction.data.length >= 2){
4844+
vehicle.local_ground_asl = vehicle.prediction.data[vehicle.prediction.data.length-1]['alt'];
4845+
} else {
4846+
vehicle.local_ground_asl = 0;
48394847
}
48404848

4841-
if(vehicle.prediction && vehicle.prediction.time == r[i].time) {
4842-
continue;
4843-
}
4844-
vehicle.prediction = r[i];
4845-
if(parseInt(vehicle.prediction.landed) === 0) {
4846-
vehicle.prediction.data = $.parseJSON(r[i].data);
4849+
// Only draw prediction if the last known position of the payload was > 100m above local ground level.
4850+
if( (vehicle.curr_position['gps_alt']-vehicle.local_ground_asl) > 100){
48474851
redrawPrediction(vcallsign);
48484852
} else {
4849-
removePrediction(vcallsign);
4853+
continue;
48504854
}
4855+
4856+
48514857
}
48524858
}
48534859
}

0 commit comments

Comments
 (0)