Skip to content

Commit 6f90c5d

Browse files
committed
show recovery info for historical
1 parent 920a0bf commit 6f90c5d

File tree

1 file changed

+74
-26
lines changed

1 file changed

+74
-26
lines changed

js/tracker.js

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,15 @@ function drawHistorical (data, station) {
845845
var normalisedTime = ((actualTime-minTime)/(maxTime-minTime));
846846
var iconColour = ConvertRGBtoHex(evaluate_cmap(normalisedTime, 'turbo'));
847847

848+
// Check if we have recovery data for it
849+
var recovered = false;
850+
if (historicalPlots[station].data.hasOwnProperty("recovered")) {
851+
if (historicalPlots[station].data.recovered.hasOwnProperty(serial)) {
852+
var recovery_info = historicalPlots[station].data.recovered[serial];
853+
recovered = true;
854+
}
855+
}
856+
848857
var popup = L.popup();
849858

850859
html = "<div style='line-height:16px;position:relative;'>";
@@ -864,7 +873,16 @@ function drawHistorical (data, station) {
864873
};
865874

866875
html += "<hr style='margin:0px;margin-top:5px'>";
867-
html += "<div style='font-size:11px;'>"
876+
877+
if (recovered) {
878+
html += "<div><b>Recovered:&nbsp;</b>"+recovery_info.recovered+"</div>";
879+
html += "<div><b>Recovered by:&nbsp;</b>"+recovery_info.recovered_by+"</div>";
880+
html += "<div><b>Recovery time:&nbsp;</b>"+recovery_info.datetime+"</div>";
881+
html += "<div><b>Recovery location:&nbsp;</b>"+recovery_info.position[1]+","+recovery_info.position[0] + "</div>";
882+
html += "<div><b>Recovery notes:&nbsp;</b>"+recovery_info.description+"</div>";
883+
884+
html += "<hr style='margin:0px;margin-top:5px'>";
885+
}
868886

869887
html += "<div><b>Flight Path: <b><a href=\"javascript:showRecoveredMap('" + serial + "')\">" + serial + "</a></div>";
870888
html += "<div><b>Card: <b><a href='https://www.sondehub.org/card/" + serial + "' target='_blank'>" + serial + "</a></div>";
@@ -878,7 +896,11 @@ function drawHistorical (data, station) {
878896

879897
popup.setContent(html);
880898

881-
var marker = L.circleMarker([landing.lat, landing.lon], {color: iconColour, radius: 5, fillOpacity:0.9});
899+
if (!recovered) {
900+
var marker = L.circleMarker([landing.lat, landing.lon], {fillColor: "white", color: iconColour, weight: 2, radius: 5, fillOpacity:1});
901+
} else {
902+
var marker = L.circleMarker([landing.lat, landing.lon], {fillColor: "grey", color: iconColour, weight: 2, radius: 5, fillOpacity:1});
903+
}
882904

883905
marker.bindPopup(popup);
884906

@@ -949,36 +971,62 @@ function showHistorical (station, marker) {
949971
historicalPlots[station].data.maxTime = dateNow.getTime();
950972
}
951973

952-
for (let i = 0; i < sondes.length; i++) {
953-
downloadHistorical(sondes[i]).done(handleData).fail(handleError);;
954-
}
974+
// Get station location to fetch recoveries
975+
if (!historicalPlots[station].data.hasOwnProperty("recovered")) {
976+
historicalPlots[station].data.recovered = {};
955977

956-
var completed = 0;
978+
var station_position = sites[station].position;
979+
var data_str = "lat=" + station_position[0] + "&lon=" + station_position[1] + "&distance=400000&last=0";
957980

958-
function handleData(data) {
959-
completed += 1;
960-
drawHistorical(data, station);
961-
if (completed == sondes.length) {
962-
submit.show();
963-
submitLoading.hide();
964-
deleteHistorical.show();
965-
// If modal is closed the contents needs to be forced updated
966-
if (!realpopup.isOpen()) {
967-
realpopup.setContent("<div id='popup" + station + "'>" + popup.html() + "</div>");
981+
$.ajax({
982+
type: "GET",
983+
url: recovered_sondes_url,
984+
data: data_str,
985+
dataType: "json",
986+
success: function(json) {
987+
for (var i = 0; i < json.length; i++) {
988+
historicalPlots[station].data.recovered[json[i].serial] = json[i];
989+
}
990+
processHistorical()
991+
},
992+
error: function() {
993+
processHistorical();
968994
}
969-
}
995+
});
970996
}
971997

972-
function handleError(error) {
973-
completed += 1;
974-
if (completed == sondes.length) {
975-
submit.show();
976-
submitLoading.hide();
977-
deleteHistorical.show();
998+
function processHistorical() {
999+
for (let i = 0; i < sondes.length; i++) {
1000+
downloadHistorical(sondes[i]).done(handleData).fail(handleError);;
9781001
}
979-
// If modal is closed the contents needs to be forced updated
980-
if (!realpopup.isOpen()) {
981-
realpopup.setContent("<div id='popup" + station + "'>" + popup.html() + "</div>");
1002+
1003+
var completed = 0;
1004+
1005+
function handleData(data) {
1006+
completed += 1;
1007+
drawHistorical(data, station);
1008+
if (completed == sondes.length) {
1009+
submit.show();
1010+
submitLoading.hide();
1011+
deleteHistorical.show();
1012+
// If modal is closed the contents needs to be forced updated
1013+
if (!realpopup.isOpen()) {
1014+
realpopup.setContent("<div id='popup" + station + "'>" + popup.html() + "</div>");
1015+
}
1016+
}
1017+
}
1018+
1019+
function handleError(error) {
1020+
completed += 1;
1021+
if (completed == sondes.length) {
1022+
submit.show();
1023+
submitLoading.hide();
1024+
deleteHistorical.show();
1025+
}
1026+
// If modal is closed the contents needs to be forced updated
1027+
if (!realpopup.isOpen()) {
1028+
realpopup.setContent("<div id='popup" + station + "'>" + popup.html() + "</div>");
1029+
}
9821030
}
9831031
}
9841032
}

0 commit comments

Comments
 (0)