Skip to content

Commit 8334df3

Browse files
authored
Merge pull request projecthorus#150 from projecthorus/testing
Launch Site Trails!
2 parents 8ce0a3c + aa4966a commit 8334df3

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

js/tracker.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var newdata_url = "https://api.v2.sondehub.org/sondes/telemetry";
44
var olddata_url = "https://api.v2.sondehub.org/sondes";
55
var receivers_url = "https://api.v2.sondehub.org/listeners/telemetry";
66
var predictions_url = "https://api.v2.sondehub.org/predictions?vehicles=";
7+
var launch_predictions_url = "https://api.v2.sondehub.org/predictions/reverse";
78
var recovered_sondes_url = "https://api.v2.sondehub.org/recovered";
89

910
var livedata = "wss://ws-reader.v2.sondehub.org/";
@@ -1677,6 +1678,35 @@ function removePrediction(vcallsign) {
16771678
}
16781679
}
16791680

1681+
function drawLaunchPrediction(vcallsign) {
1682+
var vehicle = vehicles[vcallsign];
1683+
var data = vehicle.prediction_launch.data;
1684+
1685+
var line = [];
1686+
var latlng = null;
1687+
var path_length = 0;
1688+
1689+
for(var i = 0, ii = data.length; i < ii; i++) {
1690+
latlng = new L.LatLng(data[i].lat, data[i].lon);
1691+
line.push(latlng);
1692+
if(i > 1) path_length += line[i-1].distanceTo(line[i]);
1693+
}
1694+
1695+
vehicle.prediction_launch_path = line;
1696+
1697+
vehicle.prediction_launch_polyline = new L.Polyline(line, {
1698+
color: balloon_colors[vehicle.color_index],
1699+
opacity: 0.4,
1700+
weight: 3,
1701+
}).addTo(map);
1702+
1703+
vehicle.prediction_launch_polyline.on('click', function (e) {
1704+
mapInfoBox_handle_prediction_path(e);
1705+
});
1706+
1707+
vehicle.prediction_launch_polyline.path_length = path_length;
1708+
}
1709+
16801710
function redrawPrediction(vcallsign) {
16811711
var vehicle = vehicles[vcallsign];
16821712
var data = vehicle.prediction.data;
@@ -2467,6 +2497,8 @@ function addPosition(position) {
24672497
prediction_polyline: null,
24682498
prediction_target: null,
24692499
prediction_burst: null,
2500+
prediction_launch: null,
2501+
prediction_launch_polyline: null,
24702502
ascent_rate: 0.0,
24712503
horizontal_rate: 0.0,
24722504
max_alt: parseFloat(position.gps_alt),
@@ -2525,6 +2557,9 @@ function addPosition(position) {
25252557
if (map.hasLayer(vehicle_info["prediction_polyline"])) {
25262558
map.removeLayer(vehicle_info["prediction_polyline"]);
25272559
}
2560+
if (map.hasLayer(vehicle_info["prediction_launch_polyline"])) {
2561+
map.removeLayer(vehicle_info["prediction_launch_polyline"]);
2562+
}
25282563
if (map.hasLayer(vehicle_info["prediction_target"])) {
25292564
map.removeLayer(vehicle_info["prediction_target"]);
25302565
}
@@ -3627,6 +3662,22 @@ function refreshPredictions() {
36273662
periodical_predictions = setTimeout(refreshPredictions, 60 * 1000);
36283663
}
36293664
});
3665+
3666+
var data_str = "duration=" + wvar.mode;
3667+
3668+
ajax_predictions = $.ajax({
3669+
type: "GET",
3670+
url: launch_predictions_url,
3671+
data: data_str,
3672+
dataType: "json",
3673+
success: function(response, textStatus) {
3674+
updateLaunchPredictions(response);
3675+
},
3676+
error: function() {
3677+
},
3678+
complete: function(request, textStatus) {
3679+
}
3680+
});
36303681
}
36313682

36323683
var periodical, periodical_focus, periodical_focus_new, periodical_receivers, periodical_recoveries, periodical_listeners;
@@ -4059,6 +4110,21 @@ function updateLeaderboardPane(r){
40594110

40604111
}
40614112

4113+
function updateLaunchPredictions(r) {
4114+
for (serial in r) {
4115+
prediction = r[serial];
4116+
if(prediction.hasOwnProperty("launch_site")) {
4117+
if(vehicles.hasOwnProperty(serial)) {
4118+
vehicle = vehicles[serial];
4119+
if (vehicle.prediction_launch == null) {
4120+
vehicle.prediction_launch = prediction;
4121+
drawLaunchPrediction(serial);
4122+
}
4123+
}
4124+
}
4125+
}
4126+
}
4127+
40624128
function updatePredictions(r) {
40634129
if(!r) return;
40644130
ls_pred = true;

0 commit comments

Comments
 (0)