2010-05-26 20:34:08 +00:00
< ? php
2010-06-05 15:36:59 +00:00
require_once ( " includes/functions.inc.php " );
2010-05-31 07:14:04 +00:00
// get the time for pre-populating the form
2010-05-28 23:04:59 +00:00
$time = time () + 3600 ;
2010-06-05 15:36:59 +00:00
$current_uuid = ( isset ( $_GET [ 'uuid' ]) ? $_GET [ 'uuid' ] : " 0 " );
// if we were given a UUID, try and construct its model
if ( $current_uuid != 0 ) {
if ( $pred_model = getModelByUUID ( $current_uuid ) ) {
} else {
// assume we weren't given a UUID (bad FIXME)
$current_uuid = 0 ;
}
}
2010-05-26 20:34:08 +00:00
?>
2010-05-27 20:36:13 +00:00
< html >
2010-05-31 07:19:35 +00:00
< head >
< title > CUSF Landing Prediction - Version 2 </ title >
2010-05-27 20:36:13 +00:00
< meta name = " viewport " content = " initial-scale=1.0, user-scalable=no " />
2010-05-30 20:42:17 +00:00
< script type = " text/javascript " src = " http://www.google.com/jsapi?key=ABQIAAAAzpAeP4iTRyyvc3_y95bQZBSnyWegg1iFIOtWV3Ha3Qw-fH3UlBTg9lMAipYdJi6ac4b5hWAzBkkXgg " ></ script >
2010-05-27 20:36:13 +00:00
< script type = " text/javascript " src = " http://maps.google.com/maps/api/js?sensor=false " ></ script >
< link href = " css/pred.css " type = " text/css " rel = " stylesheet " >
2010-05-30 20:42:17 +00:00
< link href = " css/cupertino/jquery-ui-1.8.1.custom.css " type = " text/css " rel = " stylesheet " >
< script type = " text/javascript " >
2010-05-31 07:19:35 +00:00
// load jquery and jqueryui before loading jquery.form.js later
2010-05-30 20:42:17 +00:00
google . load ( " jquery " , " 1.4.2 " );
google . load ( " jqueryui " , " 1.8.1 " );
</ script >
2010-05-30 09:41:16 +00:00
< script src = " js/jquery.form.js " type = " text/javascript " ></ script >
2010-05-28 22:27:26 +00:00
< script src = " js/pred.js " type = " text/javascript " ></ script >
2010-05-26 20:34:08 +00:00
< script type = " text/javascript " >
2010-05-27 20:36:13 +00:00
2010-05-28 22:17:49 +00:00
var ajaxEventHandle ;
2010-06-05 15:36:59 +00:00
var current_uuid = '<?php echo $current_uuid ?>' ;
2010-05-26 20:34:08 +00:00
2010-05-27 20:36:13 +00:00
var map ;
2010-05-30 20:42:17 +00:00
var map_items = [];
2010-06-03 18:49:06 +00:00
var launch_img = " images/target-1-sm.png " ;
var land_img = " images/target-8-sm.png " ;
2010-05-27 20:36:13 +00:00
var burst_img = " images/pop-marker.png " ;
2010-06-03 18:49:06 +00:00
var clickListener ;
var clickMarker ;
2010-05-27 20:36:13 +00:00
function initialize () {
2010-06-05 16:28:49 +00:00
if ( window . location . hash != " " ) {
var ln = window . location . hash . split ( " = " );
current_uuid = ln [ 1 ];
}
2010-05-27 20:36:13 +00:00
// make the map and set center
var latlng = new google . maps . LatLng ( 52 , 0 );
var myOptions = {
zoom : 8 ,
2010-05-31 22:46:11 +00:00
scaleControl : true ,
scaleControlOptions : { position : google . maps . ControlPosition . BOTTOM_LEFT } ,
2010-06-01 19:00:21 +00:00
mapTypeId : google . maps . MapTypeId . TERRAIN ,
2010-05-27 20:36:13 +00:00
center : latlng ,
};
map = new google . maps . Map ( document . getElementById ( " map_canvas " ), myOptions );
2010-06-01 19:00:21 +00:00
// attach form submit event handler to launch card
2010-05-30 09:41:16 +00:00
$ ( " #modelForm " ) . ajaxForm ({
url : 'ajax.php?action=submitForm' ,
type : 'POST' ,
success : function ( data ) {
2010-05-30 10:06:23 +00:00
var data_split = data . split ( " | " );
if ( data_split [ 0 ] == 0 ) {
2010-05-30 22:45:08 +00:00
appendDebug ( " The server rejected the submitted form data " );
2010-06-04 08:31:55 +00:00
throwError ( " The server rejected the submitted form data " );
resetGUI ();
2010-05-30 10:06:23 +00:00
} else {
2010-06-04 08:31:55 +00:00
predSub ();
2010-05-30 22:45:08 +00:00
appendDebug ( " The server accepted the form data " );
2010-05-31 12:25:38 +00:00
// update the global current_uuid variable
current_uuid = data_split [ 1 ];
appendDebug ( " The server gave us uuid:<br> " + current_uuid );
2010-05-30 22:45:08 +00:00
appendDebug ( " Starting to poll for progress JSON " );
2010-05-31 12:25:38 +00:00
handlePred ( current_uuid );
2010-05-30 10:06:23 +00:00
}
2010-05-30 09:41:16 +00:00
}
});
2010-06-03 18:49:06 +00:00
// activate the "Set with Map" link
$ ( " #setWithClick " ) . click ( function () {
setLatLonByClick ( true );
});
// attach onchange handlers to the lat/long boxes
$ ( " #lat " ) . change ( function () {
plotClick ();
});
$ ( " #lon " ) . change ( function () {
plotClick ();
});
$ ( " #site " ) . change ( function () {
plotClick ();
});
2010-05-31 15:33:52 +00:00
$ ( " #input_form " ) . draggable ({ containment : '#map_canvas' });
2010-05-31 12:25:38 +00:00
if ( current_uuid != '0' ) {
appendDebug ( " Got an old UUID to plot:<br> " + current_uuid );
2010-05-31 15:33:52 +00:00
appendDebug ( " Trying to populate form with scenario data " );
populateFormByUUID ( current_uuid );
2010-05-31 12:25:38 +00:00
appendDebug ( " Trying to get flight path from server... " );
getCSV ( current_uuid );
}
2010-05-31 15:33:52 +00:00
$ ( " #scenario_template " ) . hide ();
2010-05-30 22:20:26 +00:00
$ ( " #showHideDebug " ) . click ( function () {
2010-05-31 15:33:52 +00:00
toggleWindow ( " scenario_template " , " showHideDebug " , " Show Debug " , " Hide Debug " );
});
$ ( " #showHideDebug_status " ) . click ( function () {
toggleWindow ( " scenario_template " , " showHideDebug " , " Show Debug " , " Hide Debug " );
});
$ ( " #showHideForm " ) . click ( function () {
toggleWindow ( " input_form " , " showHideForm " , " Show Launch Card " ,
" Hide Launch Card " );
2010-05-30 22:20:26 +00:00
});
2010-06-04 08:31:55 +00:00
$ ( " #closeErrorWindow " ) . click ( function () {
$ ( " #error_window " ) . fadeOut ();
});
2010-06-07 19:11:06 +00:00
$ ( " #about_window_close " ) . click ( function () {
$ ( " #about_window " ) . fadeOut ();
});
$ ( " #about_window_show " ) . click ( function () {
$ ( " #about_window " ) . fadeIn ();
});
2010-06-03 18:49:06 +00:00
// plot the initial launch location
plotClick ();
2010-06-03 21:37:17 +00:00
google . maps . event . addListener ( map , 'mousemove' , function ( event ) {
showMousePos ( event . latLng );
});
2010-05-27 20:36:13 +00:00
}
2010-05-26 20:34:08 +00:00
2010-05-30 09:41:16 +00:00
2010-05-30 20:42:17 +00:00
2010-05-26 20:34:08 +00:00
</ script >
2010-05-27 20:36:13 +00:00
</ head >
2010-05-30 21:49:34 +00:00
< body onload = " initialize() " bgcolor = " #000000 " >
2010-05-30 20:42:17 +00:00
< div id = " map_canvas " style = " width:100%; height:100% " ></ div >
2010-05-27 20:36:13 +00:00
< div id = " scenario_template " class = " box " >
2010-05-31 15:33:52 +00:00
< h1 > Debug Window </ h1 >
2010-05-27 20:36:13 +00:00
< span id = " debuginfo " > No Messages </ span >
</ div >
2010-05-30 20:42:17 +00:00
< div id = " status_message " class = " box " >
< div id = " prediction_progress " ></ div >
< div id = " prediction_percent " ></ div >
< br >
2010-05-31 15:33:52 +00:00
< span id = " prediction_status " ></ span >< br >
< a >< span id = " showHideDebug_status " > Toggle Debug </ span ></ a ></ span >
2010-05-30 20:42:17 +00:00
</ div >
2010-06-04 08:31:55 +00:00
< div id = " error_window " class = " box " >
< span id = " error_message " > Nothing here !</ span >
< br />< br />
< a id = " closeErrorWindow " > Close </ a >
</ div >
2010-06-04 23:59:49 +00:00
<!-- scenario info -->
2010-05-31 13:11:18 +00:00
< div id = " scenario_info " class = " box " >
2010-05-31 15:33:52 +00:00
< h1 > Scenario Information </ h1 >
2010-06-03 21:37:17 +00:00
< span id = " cursor_info " > Current mouse position :
Lat : < span id = " cursor_lat " > ? </ span >
Lon : < span id = " cursor_lon " > ? </ span >
</ span >< br />
2010-06-04 23:59:49 +00:00
< span id = " cursor_pred " style = " display:none " >
Range : < span id = " cursor_pred_range " ></ span > km ,
Flight Time : < span id = " cursor_pred_time " ></ span >< br />
Cursor range from launch : < span id = " cursor_pred_launchrange " > ? </ span > km ,
land : < span id = " cursor_pred_landrange " > ? </ span > km
</ span >
2010-06-05 07:19:43 +00:00
< br />
< a >< span id = " showHideDebug " > Show Debug </ span ></ a ></ span > |
< a >< span id = " showHideForm " > Hide Launch Card </ span ></ a ></ span >
2010-06-07 19:11:06 +00:00
< br />
< a style = " font-size: 10px " id = " about_window_show " > About this software </ a >
</ div >
<!-- the about window -->
< div id = " about_window " class = " box " >
2010-06-07 21:23:44 +00:00
< b > Cambridge University Spaceflight Landing Predictor ( < a href = " http://github.com/jonsowman/cusf-standalone-predictor " target = " _blank " > github </ a > ) </ b >
2010-06-07 19:11:06 +00:00
< br />< br />
2010-06-07 21:23:44 +00:00
A tool to predict the flight path and landing location of latex sounding balloons .
2010-06-07 19:11:06 +00:00
< br />< br />
Written by < a href = " http://github.com/jonsowman " target = " _blank " > Jon Sowman </ a > and < a href = " http://github.com/randomskk " target = " _blank " > Adam Greig </ a > for < a href = " http://www.cuspaceflight.co.uk " target = " _blank " > CUSF </ a >.
Credit also to < a href = " http://github.com/rjw57 " target = " _blank " > Rich Wareham </ a > for work on the predictor . Some parts of code taken from old landing prediction software , credit to Rob Anderson , Fergus Noble and Ed Moore .
< br />< br />
2010-06-07 21:23:44 +00:00
No guarantee is given for the accuracy , precision or reliability of the data produced by this software , and you use it entirely at your own risk . For more information , see #highaltitude on irc.freenode.net.
2010-06-07 19:11:06 +00:00
< br />< br />
< a id = " about_window_close " > Close </ a >
2010-05-31 13:11:18 +00:00
</ div >
2010-05-31 15:33:52 +00:00
< div id = " input_form " class = " box " >
2010-05-30 09:41:16 +00:00
< form action = " " id = " modelForm " name = " modelForm " >
2010-05-27 20:36:13 +00:00
< table >
< tr >
< td > Launch Site :</ td >
< td >
< select id = " site " name = " launchsite " onchange = " UpdateLaunchSite(this.selectedIndex) " >
< option value = " Churchill " > Churchill </ option >
< option value = " EARS " > EARS </ option >
< option value = " Glenrothes " > Glenrothes </ option >
< option value = " Bujaraloz, Monegros " > Bujaraloz , Monegros </ option >
< option value = " Adelaide Airport " > Adelaide Airport </ option >
2010-06-05 15:44:39 +00:00
< option id = " other " value = " other " < ? php
if ( $current_uuid != 0 ) echo " selected= \" selected \" " ;
?> >Other</option>
2010-05-27 20:36:13 +00:00
</ select >
</ td >
< tr >
2010-06-05 07:33:41 +00:00
< td > Latitude :</ td >
2010-06-05 15:36:59 +00:00
< td >< input id = " lat " type = " text " name = " lat " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'latitude' ] : " 52.2135 " );
?> " onKeyDown="SetSiteOther()"></td>
2010-05-27 20:36:13 +00:00
</ tr >
< tr >
< td > Longitude :</ td >
2010-06-05 15:36:59 +00:00
< td >< input id = " lon " type = " text " name = " lon " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'longitude' ] : " 0.0964 " );
?> " onKeyDown="SetSiteOther()"></td>
2010-05-27 20:36:13 +00:00
</ tr >
2010-06-05 07:33:41 +00:00
< tr >
< td >< a id = " setWithClick " > Set with map </ a ></ td >
< td >< a id = " requestLocationSave " > Request to save </ a ></ td >
</ tr >
2010-05-27 20:36:13 +00:00
< tr >
< td > Launch altitude ( m ) :</ td >
2010-06-05 15:36:59 +00:00
< td >< input id = " initial_alt " type = " text " name = " initial_alt " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'altitude' ] : " 0 " ); ?> "></td>
2010-05-27 20:36:13 +00:00
</ tr >
< tr >
< td > Launch Time :</ td >
< td >
2010-06-05 15:36:59 +00:00
< input id = " hour " type = " text " name = " hour " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'hour' ] : date ( " H " , $time ));
?> " maxlength="2" size="2"> :
< input id = " min " type = " text " name = " min " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'minute' ] : date ( " i " , $time ));
?> " maxlength="2" size="2">
< input id = " sec " type = " hidden " name = " second " value = " 0 " ></ td ></ tr >
2010-05-27 20:36:13 +00:00
< tr >< td > Launch Date :</ td >< td >
2010-06-05 15:36:59 +00:00
< input id = " day " type = " text " name = " day " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'day' ] : date ( " d " , $time ));
?> " maxlength="2" size="2">
< select id = " month " name = " month " >< ? php
// php enumeration
for ( $i = 1 ; $i <= 12 ; $i ++ ) {
echo " <option value= \" " . $i . " \" " ;
if ( $i == date ( " n " , $time ) && $current_uuid == 0 ) {
echo " selected= \" selected \" " ;
} else if ( $current_uuid != 0 && $i == $pred_model [ 'month' ]) {
echo " selected= \" selected \" " ;
}
echo " > " . date ( " M " , mktime ( 0 , 0 , 0 , $i , 11 , 1978 )) . " </option> \n " ;
}
?> </select>
< input id = " year " type = " text " name = " year " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'year' ] : date ( " Y " , $time ));
?> " maxlength="4" size="4">
2010-05-27 20:36:13 +00:00
</ td >
< tr >
< td > Ascent Rate ( m / s ) :</ td >
2010-06-05 15:36:59 +00:00
< td >< input id = " ascent " type = " text " name = " ascent " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'ascent-rate' ] : " 5 " );
?> "></td>
2010-05-27 20:36:13 +00:00
</ tr >
< tr >
< td > Descent Rate ( sea level m / s ) :</ td >
2010-06-05 15:36:59 +00:00
< td >< input id = " drag " type = " text " name = " drag " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'descent-rate' ] : " 5 " );
?> "></td>
2010-05-27 20:36:13 +00:00
</ tr >
< tr >
< td > Burst Altitude ( m ) :</ td >
2010-06-05 15:36:59 +00:00
< td >< input id = " burst " type = " text " name = " burst " value = " <?php
echo ( $current_uuid != 0 ? $pred_model [ 'burst-altitude' ] : " 30000 " );
?> "></td>
2010-05-27 20:36:13 +00:00
</ tr >
< tr >
2010-06-03 16:05:07 +00:00
< td > Landing prediction software : </ td >< td >
2010-05-30 09:41:16 +00:00
< select id = " software " name = " software " >
2010-05-31 13:11:18 +00:00
< option value = " gfs " selected = " selected " > GFS </ option >
< option value = " gfs_hd " > GFS HD </ option >
2010-06-03 16:05:07 +00:00
</ select ></ td ></ tr >
< tr >< td > Lat / Lon Deltas : </ td >
< td > Lat :
< select id = " delta_lat " name = " delta_lat " >
< option value = " 3 " selected = " selected " > 3 </ option >
< option value = " 5 " > 5 </ option >
< option value = " 10 " > 10 </ option >
</ select >& nbsp ; Lon :
< select id = " delta_lon " name = " delta_lon " >
< option value = " 3 " selected = " selected " > 3 </ option >
< option value = " 5 " > 5 </ option >
< option value = " 10 " > 10 </ option >
2010-05-27 20:36:13 +00:00
</ select >
2010-06-03 16:05:07 +00:00
</ td >
</ tr >
2010-05-27 20:36:13 +00:00
< tr >
< td >
</ td >
2010-05-30 09:41:16 +00:00
< td >< input type = " submit " name = " submit " id = " run_pred_btn " value = " Run Prediction! " ></ td >
2010-05-27 20:36:13 +00:00
</ tr >
</ table >
</ form >
2010-05-31 15:33:52 +00:00
</ div >
2010-05-26 20:34:08 +00:00
</ body >
</ html >