function setup() { //get the call type $call = $_GET['call']; switch ($call) { case "postcode": if (!isset($_GET['area_size']) || !is_postcode($_GET['postcode'])) { array_push($this->warnings, "No valid postcode specified"); } if (!isset($_GET['area_size'])) { array_push($this->warnings, "Area size specified"); } //all good, get the data if (sizeof($this->warnings) == 0) { $xy = postcode_to_location($_GET['postcode']); $easting = $xy[0]; $northing = $xy[1]; $this->applications = Applications::query($easting, $northing, alert_size_to_meters($_GET['area_size'])); } break; case "point": //validation if (!isset($_GET['lat']) || !isset($_GET['lng'])) { array_push($this->warnings, "No longitude or latitude was specified"); } if (!isset($_GET['area_size'])) { array_push($this->warnings, "Area size specified"); } //all good, get the data if (sizeof($this->warnings) == 0) { $latlng = new LatLng($_GET['lat'], $_GET['lng']); $xy = $latlng->toOSRef(); $easting = $xy->easting; $northing = $xy->northing; $this->applications = Applications::query($easting, $northing, alert_size_to_meters($_GET['area_size'])); } break; case "pointos": //validation if (!isset($_GET['easting']) || !isset($_GET['northing'])) { array_push($this->warnings, "No easting or northing was specified"); } if (!isset($_GET['area_size'])) { array_push($this->warnings, "Area size specified"); } //all good, get the data if (sizeof($this->warnings) == 0) { $this->applications = Applications::query($_GET['easting'], $_GET['northing'], alert_size_to_meters($_GET['area_size'])); } break; case "authority": //validation if (!isset($_GET['authority'])) { array_push($this->warnings, "No authority name specified"); } //all good, get the data if (sizeof($this->warnings) == 0) { $this->applications = Applications::query_authority($_GET['authority']); } break; case "area": //validation if (!isset($_GET['bottom_left_lat']) || !isset($_GET['bottom_left_lng']) || !isset($_GET['top_right_lat']) || !isset($_GET['top_right_lng'])) { array_push($this->warnings, "Bounding box was not specified"); } //all good, get the data if (sizeof($this->warnings) == 0) { $bottom_left_latlng = new LatLng($_GET['bottom_left_lat'], $_GET['bottom_left_lng']); $bottom_left_xy = $bottom_left_latlng->toOSRef(); $top_right_latlng = new LatLng($_GET['top_right_lat'], $_GET['top_right_lng']); $top_right_xy = $top_right_latlng->toOSRef(); $this->applications = Applications::query_area($bottom_left_xy->easting, $bottom_left_xy->northing, $top_right_xy->easting, $top_right_xy->northing); } break; case "areaos": //validation if (!isset($_GET['bottom_left_easting']) || !isset($_GET['bottom_left_northing']) || !isset($_GET['top_right_easting']) || !isset($_GET['top_right_northing'])) { array_push($this->warnings, "Bounding box was not specified"); } //all good, get the data if (sizeof($this->warnings) == 0) { $this->applications = Applications::query_area($_GET['bottom_left_easting'], $_GET['bottom_left_northing'], $_GET['top_right_easting'], $_GET['top_right_easting']); } break; case "latest": $this->applications = Applications::query_latest(500); break; default: $this->warnings = "No call type specified"; } }