예제 #1
0
 public function addProblem($problem, $category, $name, $email, $x, $y)
 {
     if ($this->isValid()) {
         $xy = reproject($x, $y, "4326", "3857");
         $q = "INSERT INTO hampshire_problems(row_gid,problem,category,x,y," . "subdate) VALUES (" . $this->the_data["properties"]["gid"] . ",'{$problem}','{$category}'," . $xy[0] . "," . $xy[1] . ",NOW()) ";
         pg_query($q);
         $msg = "Parish: " . $this->the_data["properties"]["parish"] . "\n" . "ROW number: " . $this->the_data["properties"]["routeno"] . "\nROW type: " . $this->the_data["properties"]["row_type"] . "\n\nCategory: {$category}\n\nProblem: {$problem}\n\n";
         $c = new ConversionsLatLong();
         $osgb = $c->wgs84_to_osgb36($y, $x);
         //$gr = $c->osgb36_to_gridref($osgb[0],$osgb[1]);
         $msg .= "Grid ref: easting " . round($osgb[0]) . " northing " . round($osgb[1]) . "\n\n";
         $msg .= "Reported By: {$name} (email {$email})";
         if ($this->the_data["properties"]["county"] == "Hampshire") {
             mail(HANTS_EMAIL, "Right Of Way problem reported via FixMyPaths", $msg);
         }
     }
 }
예제 #2
0
파일: Problem.php 프로젝트: Huertix/Freemap
$inProj = isset($cleaned["inProj"]) ? $cleaned["inProj"] : "4326";
$outProj = isset($cleaned["outProj"]) ? $cleaned["outProj"] : "3857";
if (isset($cleaned["x"]) && isset($cleaned["y"])) {
    $xy = reproject($cleaned["x"], $cleaned["y"], $inProj, "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 "getAllProblems":
        $bbox = array();
        if (isset($cleaned["bbox"])) {
            $bb = explode(",", $cleaned["bbox"]);
            if (count($bb) == 4) {
                $sw = reproject($bb[0], $bb[1], $cleaned["inProj"], "3857");
                $ne = reproject($bb[2], $bb[3], $cleaned["inProj"], "3857");
                $bbox[0] = $sw[0];
                $bbox[1] = $sw[1];
                $bbox[2] = $ne[0];
                $bbox[3] = $ne[1];
            }
        }
        $problems = Problem::getAllProblems($bbox);
        prob_output($problems, $format, $outProj);
        break;
    case "getProblemsByAdmUnit":
        $admunits = array("county", "district", "parish");
        $data = array();
        foreach ($admunits as $admunit) {
            if (isset($cleaned[$admunit])) {
                $data[$admunit] = $cleaned[$admunit];
예제 #3
0
 function reprojectData($outProj)
 {
     for ($f = 0; $f < count($this->data["features"]); $f++) {
         switch ($this->data["features"][$f]["geometry"]["type"]) {
             case "Point":
                 $this->data["features"][$f]["geometry"]["coordinates"] = reproject($this->data["features"][$f]["geometry"]["coordinates"][0], $this->data["features"][$f]["geometry"]["coordinates"][1], $this->SRID, $outProj);
                 break;
             case "LineString":
                 for ($i = 0; $i < count($this->data["features"][$f]["geometry"]["coordinates"]); $i++) {
                     $this->data["features"][$f]["geometry"]["coordinates"][$i] = reproject($this->data["features"][$f]["geometry"]["coordinates"][$i][0], $this->data["features"][$f]["geometry"]["coordinates"][$i][1], $this->SRID, $outProj);
                 }
                 break;
             case "MultiLineString":
             case "Polygon":
                 for ($i = 0; $i < count($this->data["features"][$f]["geometry"]["coordinates"]); $i++) {
                     for ($j = 0; $j < count($this->data["features"][$f]["geometry"]["coordinates"][$i]); $j++) {
                         $this->data["features"][$f]["geometry"]["coordinates"][$i][$j] = reproject($this->data["features"][$f]["geometry"]["coordinates"][$i][$j][0], $this->data["features"][$f]["geometry"]["coordinates"][$i][$j][1], $this->SRID, $outProj);
                     }
                 }
                 break;
             case "MultiPolygon":
                 for ($i = 0; $i < count($this->data["features"][$f]["geometry"]["coordinates"]); $i++) {
                     for ($j = 0; $j < count($this->data["features"][$f]["geometry"]["coordinates"][$i]); $j++) {
                         for ($k = 0; $k < count($this->data["features"][$f]["geometry"]["coordinates"][$i][$j]); $k++) {
                             $this->data["features"][$f]["geometry"]["coordinates"][$i][$j][$k] = reproject($this->data["features"][$f]["geometry"]["coordinates"][$i][$j][$k][0], $this->data["features"][$f]["geometry"]["coordinates"][$i][$j][$k][1], $this->SRID, $outProj);
                         }
                     }
                 }
                 break;
         }
     }
 }
예제 #4
0
$file = $_FILES["file1"]["tmp_name"];
$imageData = getimagesize($file);
if (!isset($_SESSION["gatekeeper"])) {
    header("HTTP/1.1 401 Unauthorized");
    echo "ERROR: must be logged in.";
} elseif ($imageData === false || $imageData[2] != IMAGETYPE_JPEG) {
    echo "ERROR: Not a JPEG image!";
} else {
    $photosphere = new Photosphere($file);
    if ($photosphere->hasGPano() === false) {
        echo "ERROR: This does not look like a photosphere.";
    } elseif ($photosphere->getLatitude() === false || $photosphere->getLongitude() === false) {
        echo "ERROR: Currently, photospheres must have latitude and " . "longitude information. Ensure GPS turned on when you take it.";
    } else {
        $conn = pg_connect("dbname=gis user=gis");
        $id = pg_next_id("panoramas");
        $result = upload_file("file1", OTV_UPLOADS, $id . ".jpg");
        if ($result["error"] !== null) {
            echo "ERROR: {$result['error']}";
        } else {
            $lat = $photosphere->getLatitude();
            $lon = $photosphere->getLongitude();
            list($e, $n) = reproject($lon, $lat, '4326', '900913');
            pg_query("INSERT INTO panoramas (authorised,userid,xy) " . " VALUES (0," . get_user_id($_SESSION["gatekeeper"], "users", "username", "id", "pgsql") . "," . "GeomFromText('POINT({$e} {$n})',900913))");
            echo "Successful upload";
        }
    }
}
?>

예제 #5
0
파일: bsvr2.php 프로젝트: Huertix/Freemap
    exit;
}
adjustProj($inProj);
adjustProj($outProj);
if (isset($cleaned['inUnits']) && $cleaned['inUnits'] == 'microdeg' && $inProj == '4326') {
    for ($i = 0; $i < 4; $i++) {
        $values[$i] /= 1000000.0;
    }
}
// Native projection of DB is 900913 (Google Mercator)
// 041114 ensure reprojected bbox completely contains original bbox by
// taking the min and max eastings and northings of each corner
list($sw['e'], $sw['n']) = reproject($values[0], $values[1], $inProj, '900913');
list($nw['e'], $nw['n']) = reproject($values[0], $values[3], $inProj, '900913');
list($ne['e'], $ne['n']) = reproject($values[2], $values[3], $inProj, '900913');
list($se['e'], $se['n']) = reproject($values[2], $values[1], $inProj, '900913');
$bbox = array(min($sw["e"], $nw["e"]), min($sw["n"], $se["n"]), max($ne["e"], $se["e"]), max($ne["n"], $nw["n"]));
$bg = new BboxGetter($bbox, $inProj, $outProj);
$data = $bg->getData($cleaned, null, null, $outProj);
switch ($format) {
    case "geojson":
    case "json":
        header("Content-type: application/json");
        echo json_encode($data);
        break;
    default:
        header("Content-type: text/xml");
        echo '<?xml version="1.0"?>';
        echo "<pre>";
        to_xml($data);
        echo "</pre>";
예제 #6
0
<?php

require_once '../lib/functionsnew.php';
require_once '../0.6/ws/DataGetter.php';
require_once '../0.6/ws/DBDetails.php';
require_once 'copyrights.php';
$cleaned = clean_input($_REQUEST);
$bbox_in = explode(",", $cleaned["bbox"]);
$inProj = $cleaned["inProj"];
$sw = reproject($bbox_in[0], $bbox_in[1], $inProj, "3857");
$ne = reproject($bbox_in[2], $bbox_in[3], $inProj, "3857");
$bbox = array($sw[0], $sw[1], $ne[0], $ne[1]);
$outProj = $cleaned["outProj"];
adjustProj($outProj);
$conn = pg_connect("dbname=gis user=gis");
header("Content-type: application/json");
header("Access-Control-Allow-Origin: http://www.free-map.org.uk");
$dbd = new DBDetails(null, array("table" => "hampshire", "col" => "the_geom"), null, null, null, null);
$dbd->setIntersection(false);
$bg = new BboxGetter($bbox, null, $dbd, 3857);
$bg->includePolygons(false);
$data = $bg->getData(array("way" => "all"), null, null, $outProj);
$counties = $bg->getUniqueList("county");
$arr = array();
foreach ($counties as $county) {
    $arr[$county] = getCopyright($county);
}
$bg->setCopyright($arr);
$data = $bg->simpleGetData();
echo json_encode($data);
pg_close($conn);
예제 #7
0
파일: bsvr.php 프로젝트: nickw1/Freemap
    exit;
}
adjustProj($inProj);
adjustProj($outProj);
if (isset($cleaned['inUnits']) && $cleaned['inUnits'] == 'microdeg' && $inProj == '4326') {
    for ($i = 0; $i < 4; $i++) {
        $values[$i] /= 1000000.0;
    }
}
// Native projection of DB is 3857 (Google Mercator)
// 041114 ensure reprojected bbox completely contains original bbox by
// taking the min and max eastings and northings of each corner
list($sw['e'], $sw['n']) = reproject($values[0], $values[1], $inProj, '3857');
list($nw['e'], $nw['n']) = reproject($values[0], $values[3], $inProj, '3857');
list($ne['e'], $ne['n']) = reproject($values[2], $values[3], $inProj, '3857');
list($se['e'], $se['n']) = reproject($values[2], $values[1], $inProj, '3857');
$bbox = array(min($sw["e"], $nw["e"]), min($sw["n"], $se["n"]), max($ne["e"], $se["e"]), max($ne["n"], $nw["n"]));
$bg = new BboxGetter($bbox, $inProj, $outProj, $ext);
$data = $bg->getData($cleaned, null, null);
switch ($format) {
    case "geojson":
    case "json":
        header("Content-type: application/json");
        echo json_encode($data);
        break;
    default:
        header("Content-type: text/xml");
        echo '<?xml version="1.0"?>';
        to_xml($data);
        break;
}
예제 #8
0
파일: row.php 프로젝트: Huertix/Freemap
                    }
                }
            }
            echo json_encode($json);
        } else {
            header("HTTP/1.1 404 Not Found");
            echo "Invalid id or parish/routeno";
        }
        break;
    case "getAllProblems":
        $bbox = array();
        if (isset($cleaned["bbox"])) {
            $bb = explode(",", $cleaned["bbox"]);
            if (count($bb) == 4) {
                $sw = reproject($bb[0], $bb[1], "4326", "3857");
                $ne = reproject($bb[2], $bb[3], "4326", "3857");
                $bbox[0] = $sw[0];
                $bbox[1] = $sw[1];
                $bbox[2] = $ne[0];
                $bbox[3] = $ne[1];
            }
        }
        $problems = Problem::getAllProblems($bbox);
        prob_output($problems, $format, $outProj);
        break;
}
pg_close($conn);
function prob_output($problems, $format, $outProj)
{
    if ($format == "xml") {
        header("Content-type: text/xml");
예제 #9
0
         $row = $result->fetch(PDO::FETCH_ASSOC);
         echo $row['lastid'];
     } else {
         header("HTTP/1.1 401 Unauthorized");
     }
     break;
 case 'createMulti':
     if ($userid >= 0) {
         $valid = false;
         $data = @simplexml_load_string(stripslashes($cpost['data']));
         if ($data) {
             foreach ($data->annotation as $annotation) {
                 $attrs = $annotation->attributes();
                 if (preg_match("/^-?[\\d\\.]+\$/", $attrs['x']) && preg_match("/^-?[\\d\\.]+\$/", $attrs['y'])) {
                     $desc = $annotation->description;
                     list($goog['e'], $goog['n']) = reproject($attrs['x'], $attrs['y'], $inProj, '3857');
                     // HERE 1
                     $stmt = $conn->prepare("INSERT INTO annotations(text,xy,dir,userid," . "authorised) VALUES (?," . "ST_PointFromText('POINT({$goog['e']} {$goog['n']})',3857)," . "0,{$userid}," . ($userid == 0 ? 0 : 1) . ")");
                     $stmt->bindParam(1, $desc);
                     $stmt->execute();
                 }
             }
         } else {
             header("HTTP/1.1 400 Bad Request");
             echo "Unexpected format";
         }
     } else {
         header("HTTP/1.1 401 Unauthorized");
     }
     break;
 case "delete":
예제 #10
0
         $row = $result->fetch(PDO::FETCH_ASSOC);
         echo $row['lastid'];
     } else {
         header("HTTP/1.1 401 Unauthorized");
     }
     break;
 case 'createMulti':
     if ($userid >= 0) {
         $valid = false;
         $data = @simplexml_load_string(stripslashes($cpost['data']));
         if ($data) {
             foreach ($data->annotation as $annotation) {
                 $attrs = $annotation->attributes();
                 if (preg_match("/^-?[\\d\\.]+\$/", $attrs['x']) && preg_match("/^-?[\\d\\.]+\$/", $attrs['y'])) {
                     $desc = $annotation->description;
                     list($goog['e'], $goog['n']) = reproject($attrs['x'], $attrs['y'], $inProj, '900913');
                     // HERE 1
                     $stmt = $conn->prepare("INSERT INTO annotations(text,xy,dir,userid," . "authorised) VALUES (?," . "PointFromText('POINT({$goog['e']} {$goog['n']})',900913)," . "0,{$userid}," . ($userid == 0 ? 0 : 1) . ")");
                     $stmt->bindParam(1, $desc);
                     $stmt->execute();
                 }
             }
         } else {
             header("HTTP/1.1 400 Bad Request");
             echo "Unexpected format";
         }
     } else {
         header("HTTP/1.1 401 Unauthorized");
     }
     break;
 case "delete":
예제 #11
0
 static function loadFromRow($row)
 {
     $pano = new Panorama($row["id"]);
     $m = array();
     preg_match("/POINT\\((.+)\\)/", $row['astext'], $m);
     $p = explode(" ", $m[1]);
     list($pano->lon, $pano->lat) = reproject($p[0], $p[1], "900913", "4326");
     return $pano;
 }