Automatically exported from code.google.com/p/planningalerts
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

97 Zeilen
2.8 KiB

  1. <?php
  2. require_once ("config.php");
  3. require_once ("phpcoord.php");
  4. $preview_page = new preview_page;
  5. class preview_page {
  6. //Properties
  7. var $warnings = "";
  8. var $center_long = 0;
  9. var $center_lat = 0;
  10. var $bottom_left_long = 0;
  11. var $bottom_left_lat = 0;
  12. var $top_right_long = 0;
  13. var $top_right_lat = 0;
  14. //Constructor
  15. function preview_page() {
  16. $this->setup();
  17. $this->bind();
  18. }
  19. //setup
  20. function setup (){
  21. //Grab the postcode and area size from the get string
  22. if (!isset($_GET['postcode'])){
  23. $this->warnings .= "No postcode specified ";
  24. }
  25. if (!isset($_GET['area_size'])){
  26. $this->warnings .= "No area size specified ";
  27. }
  28. if ($this->warnings == ""){
  29. //Get OS ref from postcode
  30. $xy = postcode_to_location($_GET['postcode']);
  31. //Get the centroid long / lat (google maps doesnt handle grid refs)
  32. $os_ref = new OSRef($xy[0], $xy[1]);
  33. $long_lat = $os_ref->toLatLng();
  34. $this->center_long = $long_lat->lng;
  35. $this->center_lat = $long_lat->lat;
  36. //get long lat for the bounding box (OS grid refs are in meters in case you were wondering)
  37. //bottom left
  38. $area_size_meters = alert_size_to_meters($_GET['area_size']);
  39. $os_ref = new OSRef($xy[0] - $area_size_meters, $xy[1] - $area_size_meters);
  40. $long_lat = $os_ref->toLatLng();
  41. $this->bottom_left_long = $long_lat->lng;
  42. $this->bottom_left_lat = $long_lat->lat;
  43. //top right
  44. $area_size_meters = alert_size_to_meters($_GET['area_size']);
  45. $os_ref = new OSRef($xy[0] + $area_size_meters, $xy[1] + $area_size_meters);
  46. $long_lat = $os_ref->toLatLng();
  47. $this->top_right_long = $long_lat->lng;
  48. $this->top_right_lat = $long_lat->lat;
  49. }
  50. }
  51. //Bind
  52. function bind () {
  53. //page vars
  54. $form_action = $_SERVER['PHP_SELF'];
  55. //smarty
  56. $smarty = new Smarty;
  57. $smarty->force_compile = true;
  58. $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
  59. $smarty->assign("warnings", $this->warnings);
  60. $smarty->assign("center_long", $this->center_long);
  61. $smarty->assign("center_lat", $this->center_lat);
  62. $smarty->assign("bottom_left_long", $this->bottom_left_long);
  63. $smarty->assign("bottom_left_lat", $this->bottom_left_lat);
  64. $smarty->assign("top_right_long", $this->top_right_long);
  65. $smarty->assign("top_right_lat", $this->top_right_lat);
  66. $smarty->assign("warnings", $this->warnings);
  67. $smarty->assign("google_maps_key", GOOGLE_MAPS_KEY);
  68. //Render
  69. $smarty->display('preview.tpl');
  70. }
  71. }
  72. ?>