"", "name" => "", "latitude" => 0, "longitude" => 0, "altitude" => 0, "xy_coord_accuracy" => 0, "z_coord_accuracy" => 0, "begin_date" => "", "end_date" => "", "uncertainty_polygon" => "" ); // connections, distances and routes between the data points // the same data points can have many of these structure arrays // with all or part of the points : sorted differently, simplified or otherwise changed // (e.g. non-sorted input array, RDP simplified array, ... ) $data_structure_array = array ( "startnode" => "", "endnode" => "", "node_count" => 0, "distance" => 0, "route_array" => array() ); // suffix generated if necessary for making unique id's $point_counter = 1; http://www.php.net/ $result_page = "itin_result.php"; // folder to put the uploads in $upload_base_path = "./uploads/"; // Construct the full upload path $input_file_path = $upload_base_path . basename( $_FILES['uploadedfile']['name']); // Move uploadfile to its destination if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $input_file_path)) { //echo "The file ". basename( $_FILES['uploadedfile']['name']). //" has been uploaded
"; } else{ echo "
There was an error uploading the file, please try again!
"; } // type of operation if (isset($_POST['op'])) { $operation = $_POST['op']; } else { $operation = "itin"; } // determine which result page to call, depending on operation type (itintool; POM tool) switch ($operation) { case ("itin"): $result_page = "itin_result.php"; break; case ("pom"): $result_page = "pom_result.php"; break; default : $result_page = "itin_result.php"; } // switch // determine the distance limit in km per day if (isset($_POST['kmperday'])) { $km_per_day = $_POST['kmperday']; } else { $km_per_day = 140; } // determine the file type for the output file if (isset($_POST['output'])) { $output_type = strtolower($_POST['output']); } else { $output_type = "kmlwpt"; } // for WMS output, we use a database, so points should go there if ($output_type == "wms") {$output_type = "dbase";} // read input file $my_FileHandler1 = new FileHandler(); $data_points_array = $my_FileHandler1->readPointsFromFile($input_file_path); // go through all the data points for checks and // filling in default values where necessary foreach ($data_points_array as $point_key=>$point_value) { // put the input sequence of points into the "raw_input" structure $data_structure_array ["raw_input"]["route_array"][$point_counter] = $point_counter; // assign a default accuracy // TODO : only do this when no accuracy is provided // TODO : look at the precision given as input, calculate accuracy from there $data_points_array["xy_coord_accuracy"][$point_counter] = 0.2; $data_points_array["z_coord_accuracy"][$point_counter] = 100; $point_counter++; // TODO : put the max/min check for lat/lon/alt here, so we just have to go through // all the data point once : test have shown that inline min/max checking is // much faster than using the min()/max() functions on the arrays afterwards } // foreach // fill in other fields of the "raw_input" structure $data_structure_array ["raw_input"]["startnode"] = 1; $data_structure_array ["raw_input"]["endnode"] = $point_counter; $data_structure_array ["raw_input"]["node_count"] = $point_counter; // quick check on the input coordinates $miny = min($data_points_array ["latitude"]); $minx = min($data_points_array ["longitude"]); $minz = min($data_points_array ["altitude"]); $maxy = max($data_points_array ["latitude"]); $maxx = max($data_points_array ["longitude"]); $maxz = max($data_points_array ["altitude"]); if ( (abs($miny) > 90 ) or (abs($miny) < -90) ) { /* error message */ }; if ( (abs($minx) > 180 ) or (abs($minx) < -180) ) { /* error message */ }; if ( (abs($miny) > 90 ) or (abs($miny) < -90) ) { /* error message */ }; if ( (abs($minx) > 180 ) or (abs($minx) < 180) ) { /* error message */ }; // quick & dirty bbox computing : just add a bit of space at the edges // not sure if this work around the poles - just keep your data reasonable for now... ;-) // TODO : make a good bbox with checks and incorporating inaccuracy $bbox_miny = ($miny - 0.2); $bbox_minx = ($minx - 0.2); $bbox_minz = ($minz - 2000); $bbox_maxy = ($maxy + 0.2); $bbox_maxx = ($maxx + 0.2); $bbox_maxz = ($maxz + 2000); // write to output (file or database) : once as-is, once in simplified format // Note that the (big) data_points_array structure is passed by reference, not by value, // for performance and memory reasons (see the respective functions). This poses no risk // since the array is not altered in the functions (sorting and rearanging of the points // is done solely in the data structure array). // database $my_FileHandler2 = new FileHandler(); $out_file_path = $my_FileHandler2->writePointsToFile($data_points_array,$data_structure_array["raw_input"],"dbase","blue"); $data_structure_array // KML waypoints $my_FileHandler3 = new FileHandler(); $out_file_path = $my_FileHandler3->writePointsToFile($data_points_array,$data_structure_array["raw_input"],"kmlwpt","blue"); // KML path between the waypoints $my_FileHandler4 = new FileHandler(); $out_file_path = $my_FileHandler4->writePointsToFile($data_points_array,$data_structure_array["raw_input"],"kmlpath","ffff0000"); // CSV file $my_FileHandler5 = new FileHandler(); $out_file_path = $my_FileHandler5->writePointsToFile($data_points_array,$data_structure_array["raw_input"],"csv","blue"); // simplify the line connecting the points $my_ProcessingUnit = new ProcessingUnit(); $data_structure_array["simplified"] = $my_ProcessingUnit->simplifyLine($data_points_array,$data_structure_array["raw_input"]); // CSV simplified points $my_FileHandler8 = new FileHandler(); $out_file_path = $my_FileHandler8->writePointsToFile($data_dummy_array,$data_structure_array["simplified"],"csv","blue","test_itintool_simplified"); // simplified KML waypoints $my_FileHandler6 = new FileHandler(); $out_file_path = $my_FileHandler6->writePointsToFile($data_dummy_array,$data_structure_array["simplified"],"kmlwpt","ylw","test_itintool_simplified"); // simplified KML pathway $my_FileHandler7 = new FileHandler(); $out_file_path = $my_FileHandler7->writePointsToFile($data_dummy_array,$data_structure_array["simplified"],"kmlpath","ff00ffff","test_itintool_simplified"); // construct HTML output referring to the result page $html_output = ' ItinTool result
Results
CSS after Darjan Panic & Brian Green
'; echo($html_output); echo(' '); ?>