tidying up
rodzic
c698d54235
commit
2c71e152ec
172
index.php
172
index.php
|
@ -155,28 +155,41 @@ function SetSiteOther() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function predSub() {
|
function predSub() {
|
||||||
|
appendDebug(null, 1);
|
||||||
appendDebug("Sending data to server for uuid: " + document.form1.uuid.value);
|
appendDebug("Sending data to server for uuid: " + document.form1.uuid.value);
|
||||||
appendDebug("Downloading GRIB data for tile, this could take some time...");
|
appendDebug("Downloading GRIB data for tile, this could take some time...");
|
||||||
|
appendDebug("Do NOT stop or refresh your browser.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePred(pred_uuid) {
|
function handlePred(pred_uuid) {
|
||||||
|
appendDebug(null, 1);
|
||||||
appendDebug("Prediction running with uuid: " + running_uuid);
|
appendDebug("Prediction running with uuid: " + running_uuid);
|
||||||
appendDebug("Prediction done for uuid: " + running_uuid);
|
appendDebug("Prediction done for uuid: " + running_uuid);
|
||||||
// now go get the prediction data from the server
|
// now go get the prediction data from the server
|
||||||
|
appendDebug("Getting flight path from server....");
|
||||||
getCSV(pred_uuid);
|
getCSV(pred_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCSV(pred_uuid) {
|
function getCSV(pred_uuid) {
|
||||||
$.get("ajax.php", { "action":"getCSV", "uuid":pred_uuid }, function(data) {
|
$.get("ajax.php", { "action":"getCSV", "uuid":pred_uuid }, function(data) {
|
||||||
//alert(data.length);
|
//alert(data.length);
|
||||||
parseCSV(data);
|
appendDebug("Got JSON response from server for flight path, parsing...");
|
||||||
|
if (parseCSV(data) ) {
|
||||||
|
appendDebug("Parsing function returned all OK - DONE");
|
||||||
|
} else {
|
||||||
|
appendDebug("The parsing function failed");
|
||||||
|
}
|
||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendDebug(appendage) {
|
function appendDebug(appendage, clear) {
|
||||||
var curr = $("#debuginfo").html();
|
if ( clear == null ){
|
||||||
curr += "<br>" + appendage;
|
var curr = $("#debuginfo").html();
|
||||||
$("#debuginfo").html(curr);
|
curr += "<br>" + appendage;
|
||||||
|
$("#debuginfo").html(curr);
|
||||||
|
} else {
|
||||||
|
$("#debuginfo").html("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,82 +213,85 @@ function initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCSV(lines) {
|
function parseCSV(lines) {
|
||||||
alert(lines[0]);
|
var path = [];
|
||||||
var path = [];
|
var max_height = -10; //just any -ve number
|
||||||
var max_height = -10; //just any -ve number
|
var max_point = null;
|
||||||
var max_point = null;
|
var launch_pt;
|
||||||
var launch_pt;
|
var land_pt;
|
||||||
var land_pt;
|
$.each(lines, function(idx, line) {
|
||||||
$.each(lines, function(idx, line) {
|
entry = line.split(',');
|
||||||
entry = line.split(',');
|
if(entry.length >= 4) { // check valid entry length
|
||||||
if(entry.length >= 4) { // check valid entry length
|
var point = new google.maps.LatLng( parseFloat(entry[1]), parseFloat(entry[2]) );
|
||||||
var point = new google.maps.LatLng( parseFloat(entry[1]), parseFloat(entry[2]) );
|
if ( idx == 0 ) { // get the launch lat/long for marker
|
||||||
if ( idx == 0 ) { // get the launch lat/long for marker
|
var launch_lat = entry[1];
|
||||||
var launch_lat = entry[1];
|
var launch_lon = entry[2];
|
||||||
var launch_lon = entry[2];
|
launch_pt = point;
|
||||||
launch_pt = point;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set on every iteration, last valid entry
|
|
||||||
// gives landing position
|
|
||||||
var land_lat = entry[1];
|
|
||||||
var land_lon = entry[2];
|
|
||||||
land_pt = point;
|
|
||||||
|
|
||||||
if(parseFloat(entry[3]) > max_height) {
|
|
||||||
max_height = parseFloat(entry[3]);
|
|
||||||
max_point = point;
|
|
||||||
}
|
|
||||||
path.push(point);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// make some nice icons
|
// set on every iteration, last valid entry
|
||||||
var launch_icon = new google.maps.MarkerImage(launch_img,
|
// gives landing position
|
||||||
new google.maps.Size(16,16),
|
var land_lat = entry[1];
|
||||||
new google.maps.Point(0, 0),
|
var land_lon = entry[2];
|
||||||
new google.maps.Point(8, 8)
|
land_pt = point;
|
||||||
);
|
|
||||||
|
if(parseFloat(entry[3]) > max_height) {
|
||||||
var land_icon = new google.maps.MarkerImage(land_img,
|
max_height = parseFloat(entry[3]);
|
||||||
new google.maps.Size(16,16),
|
max_point = point;
|
||||||
new google.maps.Point(0, 0),
|
}
|
||||||
new google.maps.Point(8, 8)
|
path.push(point);
|
||||||
);
|
}
|
||||||
|
});
|
||||||
var launch_marker = new google.maps.Marker({
|
|
||||||
position: launch_pt,
|
appendDebug("Flight data parsed, creating map plot...");
|
||||||
|
|
||||||
|
// make some nice icons
|
||||||
|
var launch_icon = new google.maps.MarkerImage(launch_img,
|
||||||
|
new google.maps.Size(16,16),
|
||||||
|
new google.maps.Point(0, 0),
|
||||||
|
new google.maps.Point(8, 8)
|
||||||
|
);
|
||||||
|
|
||||||
|
var land_icon = new google.maps.MarkerImage(land_img,
|
||||||
|
new google.maps.Size(16,16),
|
||||||
|
new google.maps.Point(0, 0),
|
||||||
|
new google.maps.Point(8, 8)
|
||||||
|
);
|
||||||
|
|
||||||
|
var launch_marker = new google.maps.Marker({
|
||||||
|
position: launch_pt,
|
||||||
|
map: map,
|
||||||
|
icon: launch_icon,
|
||||||
|
title: 'Balloon launch'
|
||||||
|
});
|
||||||
|
|
||||||
|
var land_marker = new google.maps.Marker({
|
||||||
|
position: land_pt,
|
||||||
|
map:map,
|
||||||
|
icon: land_icon,
|
||||||
|
title: 'Predicted Landing'
|
||||||
|
});
|
||||||
|
|
||||||
|
// now add the launch/land markers to map
|
||||||
|
launch_marker.setMap(map);
|
||||||
|
land_marker.setMap(map);
|
||||||
|
|
||||||
|
var path_polyline = new google.maps.Polyline({
|
||||||
|
path:path,
|
||||||
|
strokeColor: '#000000',
|
||||||
|
strokeWeight: 3,
|
||||||
|
strokeOpacity: 0.75
|
||||||
|
});
|
||||||
|
|
||||||
|
path_polyline.setMap(map);
|
||||||
|
|
||||||
|
var pop_marker = new google.maps.Marker({
|
||||||
|
position: max_point,
|
||||||
map: map,
|
map: map,
|
||||||
icon: launch_icon,
|
icon: burst_img,
|
||||||
title: 'Balloon launch'
|
title: 'Balloon burst (max. altitude: ' + max_height + 'm)',
|
||||||
});
|
});
|
||||||
|
|
||||||
var land_marker = new google.maps.Marker({
|
return true;
|
||||||
position: land_pt,
|
|
||||||
map:map,
|
|
||||||
icon: land_icon,
|
|
||||||
title: 'Predicted Landing'
|
|
||||||
});
|
|
||||||
|
|
||||||
// now add the launch/land markers to map
|
|
||||||
launch_marker.setMap(map);
|
|
||||||
land_marker.setMap(map);
|
|
||||||
|
|
||||||
var path_polyline = new google.maps.Polyline({
|
|
||||||
path:path,
|
|
||||||
strokeColor: '#000000',
|
|
||||||
strokeWeight: 3,
|
|
||||||
strokeOpacity: 0.75
|
|
||||||
});
|
|
||||||
|
|
||||||
path_polyline.setMap(map);
|
|
||||||
|
|
||||||
var pop_marker = new google.maps.Marker({
|
|
||||||
position: max_point,
|
|
||||||
map: map,
|
|
||||||
icon: burst_img,
|
|
||||||
title: 'Balloon burst (max. altitude: ' + max_height + 'm)',
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue