Ejemplo n.º 1
0
<?php

require_once '../lib/functionsnew.php';
require_once 'RightOfWay.php';
$cleaned = clean_input($_REQUEST);
$outProj = isset($cleaned["outProj"]) ? $cleaned["outProj"] : "3857";
$format = isset($cleaned["format"]) ? $cleaned["format"] : "geojson";
$mimetypes = array("geojson" => "application/json", "xml" => "text/xml");
$conn = pg_connect("dbname=gis user=gis");
switch ($cleaned["action"]) {
    case "findNearest":
        //header("Content-type: application/json");
        if (isset($cleaned["x"]) && isset($cleaned["y"])) {
            $xy = reproject($cleaned["x"], $cleaned["y"], "4326", "3857");
            $rightofway = RightOfWay::findClosest($xy[0], $xy[1], $cleaned["dist"]);
            if ($rightofway !== null) {
                if (isset($mimetypes[$format])) {
                    header("Content-type: " . $mimetypes[$format]);
                }
                $rightofway->output($format);
            } else {
                header("HTTP/1.1 404 Not Found");
                echo "No ROW found";
            }
        }
        break;
    case "addProblem":
        if (isset($cleaned["problem"]) && $cleaned["problem"] != "" && isset($cleaned["category"]) && $cleaned["category"] != "" && isset($cleaned["reporter_name"]) && $cleaned["reporter_name"] != "" && isset($cleaned["reporter_email"]) && filter_var($cleaned["reporter_email"], FILTER_VALIDATE_EMAIL)) {
            $rightofway = new RightOfWay($cleaned["id"]);
            if ($rightofway->isValid()) {
                $rightofway->addProblem($cleaned["problem"], $cleaned["category"], $cleaned["reporter_name"], $cleaned["reporter_email"], $cleaned["x"], $cleaned["y"]);