From 6e62e5b81647a4ea77855b212e4ea4b553851a45 Mon Sep 17 00:00:00 2001 From: jonsowman Date: Thu, 3 Jun 2010 17:05:07 +0100 Subject: [PATCH] User selection of lat/lon deltas closes #19 --- predict/css/pred.css | 2 +- predict/includes/functions.inc.php | 17 ++++++++++++----- predict/index.php | 17 ++++++++++++++++- predict/js/pred.js | 21 ++++++++++++++++++--- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/predict/css/pred.css b/predict/css/pred.css index 7891b21..fdd4c9e 100644 --- a/predict/css/pred.css +++ b/predict/css/pred.css @@ -76,7 +76,7 @@ a { text-decoration: underline; color: #333; cursor: pointer; } #input_form { border-right: none; border-bottom: none; - height:350px; + height:370px; width: 400px; padding: 5px; bottom: 0; right: 0; diff --git a/predict/includes/functions.inc.php b/predict/includes/functions.inc.php index 69ad273..b179897 100644 --- a/predict/includes/functions.inc.php +++ b/predict/includes/functions.inc.php @@ -25,6 +25,9 @@ function createModel($post_array) { $pred_model['burst'] = $post_array['burst']; $pred_model['float'] = $post_array['float_time']; + $pred_model['delta_lat'] = $post_array['delta_lat']; + $pred_model['delta_lon'] = $post_array['delta_lon']; + $pred_model['wind_error'] = 0; $pred_model['software'] = $post_array['software']; @@ -55,10 +58,10 @@ function verifyModel($pred_model, $software_available) { foreach($pred_model as $idx => $value) { if ($idx == "software") { if (!in_array($value, $software_available)) return false; - } else { - if (!is_numeric($value)) { - return false; - } + } else if ($idx == "delta_lat" || $idx == "delta_lon") { + if ( $value < 1 || $value > 10 ) return false; + } else if (!is_numeric($value)) { + return false; } } return true; @@ -77,7 +80,11 @@ function runPred($pred_model) { // use `at` to automatically background the task $ph = popen("at now", "w"); - fwrite($ph, "cd /var/www/hab/predict/ && ./predict.py -v --latdelta=3 --londelta=3 -p1 -f5 -t ".$pred_model['timestamp']." --lat=".$predictor_lat." --lon=".$predictor_lon." " . $use_hd . $pred_model['uuid']); + fwrite($ph, "cd /var/www/hab/predict/ && ./predict.py -v --latdelta=" + .$pred_model['delta_lat']." --londelta=".$pred_model['delta_lon'] + ." -p1 -f5 -t ".$pred_model['timestamp'] + ." --lat=".$predictor_lat." --lon=".$predictor_lon." " . $use_hd + . $pred_model['uuid']); fclose($ph); } diff --git a/predict/index.php b/predict/index.php index 4c45b14..034055c 100644 --- a/predict/index.php +++ b/predict/index.php @@ -103,6 +103,7 @@ function initialize() {

Scenario Information

+ Show Debug | Hide Launch Card
@@ -175,11 +176,25 @@ function initialize() { - Landing prediction software: + Landing prediction software: + Lat/Lon Deltas: + Lat: +  Lon: + + + diff --git a/predict/js/pred.js b/predict/js/pred.js index 0dc4786..7aa6d14 100644 --- a/predict/js/pred.js +++ b/predict/js/pred.js @@ -37,10 +37,10 @@ function handlePred(pred_uuid) { $("#prediction_status").html("Searching for wind data..."); $("#input_form").hide("slide", { direction: "down" }, 500); $("#scenario_info").hide("slide", { direction: "up" }, 500); + // disable user control of the map canvas $("#map_canvas").fadeTo(1000, 0.2); // ajax to poll for progress ajaxEventHandle = setInterval("getJSONProgress('"+pred_uuid+"')", 2000); - //getCSV(pred_uuid); } function getCSV(pred_uuid) { @@ -86,8 +86,6 @@ function processProgress(progress) { $("#scenario_info").show("slide", { direction: "up" }, 500); toggleWindow("scenario_template", "showHideDebug", "Show Debug", "Hide Debug", "hide"); - // move map to new location - // map.panTo( // un-fade the map canvas $("#map_canvas").fadeTo(1500, 1); appendDebug("Server says: the predictor finished running."); @@ -203,11 +201,28 @@ function parseCSV(lines) { // pan to the new position map.panTo(launch_pt); + map.setZoom(8); return true; } +function enableMap(map, state) { + if ( state != false && state != true) { + appendDebug("Unrecognised map state"); + } else if (state == false) { + map.draggable = false; + map.disableDoubleClickZoom = true; + map.scrollwheel = false; + map.navigationControl = false; + } else if (state == true ) { + map.draggable = true; + map.disableDoubleClickZoom = false; + map.scrollwheel = false; + map.navigationControl = true; + } +} + function clearMapItems() { if(map_items.length > 0) { appendDebug("Clearing previous map trace");