Example #1
0
<?php

require_once 'getData.php';
require_once '../lib/functionsnew.php';
require_once '../lib/GoogleProjection.php';
header("Content-type: application/json");
$cleaned = clean_input($_REQUEST);
$x = $cleaned["x"];
$y = $cleaned["y"];
$z = $cleaned["z"];
$goog = new GoogleProjection();
list($w, $s) = $goog->fromPixelToLL($x * 256, ($y + 1) * 256, $z);
list($e, $n) = $goog->fromPixelToLL(($x + 1) * 256, $y * 256, $z);
getSRTM($w, $s, $e, $n);
Example #2
0
<?php

require_once "../lib/latlong.php";
require_once "../lib/functionsnew.php";
require_once "../common/defines.php";
// note $w $s $e $n in microdegrees
list($w, $s, $e, $n) = explode(",", $_GET["bbox"]);
if (!getSRTM($w, $s, $e, $n)) {
    header("HTTP/1.1 400 Bad Request");
    echo "Bad request";
}
function getSRTM($w, $s, $e, $n)
{
    $wd = $w / 1000000;
    $ed = $e / 1000000;
    $sd = $s / 1000000;
    $nd = $n / 1000000;
    $npts = 1201;
    $step = 1 / 1200;
    if ($w % 5000 || $s % 5000 || $e % 5000 || $n % 5000 || $w >= $e || $s >= $n || floor($wd) != floor($ed - 1.0E-6) || floor($sd) != floor($nd - 1.0E-6)) {
        return false;
    }
    $idx_w = round(($wd - floor($wd)) / $step);
    $idx_e = round(($ed - floor($wd)) / $step);
    $idx_n = round((ceil($nd) - $nd) / $step);
    $idx_s = round((ceil($nd) - $sd) / $step);
    $idx_e = $idx_e == 0 ? $npts - 1 : $idx_e;
    $idx_s = $idx_s == 0 ? $npts - 1 : $idx_s;
    $width = $idx_e - $idx_w + 1;
    $lon = floor($wd);
    $lat = floor($sd);