示例#1
0
function getLayersForTokenWithPROJ4($token, $where = NULL)
{
    $pgc = postgis_connect();
    global $postgis_table_layers, $postgis_table_sessions;
    if ($where != NULL) {
        $array = postgis_query("SELECT l.* FROM {$postgis_table_layers} AS l LEFT OUTER JOIN {$postgis_table_sessions} AS s ON l.owner=s.user_id WHERE (s.token='{$token}' OR l.owner = 0) AND {$where};", $pgc);
    } else {
        $array = postgis_query("SELECT l.* FROM {$postgis_table_layers} AS l LEFT OUTER JOIN {$postgis_table_sessions} AS s ON l.owner=s.user_id WHERE (s.token='{$token}' OR l.owner = 0);", $pgc);
    }
    for ($i = 1; $i < count($array); $i++) {
        $arr = postgis_query("SELECT proj4text as proj4 FROM spatial_ref_sys as s,geometry_columns as g WHERE g.f_table_name='" . $array[$i]['name'] . "' AND s.srid=g.srid;", $pgc);
        if (count($arr) > 1) {
            $array[$i]['PROJ4'] = $arr[1]['proj4'];
        }
    }
    pg_close($pgc);
    return $array;
}
示例#2
0
文件: state.php 项目: rvaidya/FlexGIS
		<state_response result="EMPTY" reason="No session exists."/>';
        die;
    }
    $user_id = $qresult[1]['user_id'];
    if ((int) $qresult[1]['state_size'] == 0) {
        postgis_query("INSERT INTO {$postgis_table_states}(user_id,state) VALUES({$user_id},'{$state}');");
    } else {
        postgis_query("UPDATE {$postgis_table_states} SET state='{$state}' WHERE user_id={$user_id};");
    }
    echo '<?xml version="1.0"?>
		<state_response result="OK" token="' . $token . '"/>';
    die;
} else {
    if (strtolower($xml->getName()) == "state_load") {
        $token = $xml['token'];
        $qresult = postgis_query("SELECT s.user_id,state FROM {$postgis_table_sessions} AS s,{$postgis_table_states} AS t WHERE s.user_id=t.user_id AND s.token='{$token}';");
        if (count($qresult) < 2) {
            echo '<?xml version="1.0"?>
		<state_response result="EMPTY" reason="No state exists."/>';
            die;
        }
        $xmlresponse = new SimpleXMLElement("<state_response />");
        $xmlresponse->addAttribute("result", "OK");
        $xmlresponse->addAttribute("token", $token);
        $xmlresponse->addChild("state", $qresult[1]['state']);
        echo formatXML($xmlresponse);
    } else {
        echo '<?xml version="1.0"?>
		<state_response result="ERROR" reason="Invalid state request."/>';
        die;
    }
示例#3
0
     foreach ($result[1] as $k => $v) {
         if ($k == $g_name || $k == "calc_dist" || $k == "oid") {
             continue;
         }
         $field = $xml->addChild("field", htmlspecialchars($v));
         $field->addAttribute("name", $k);
     }
     echo formatXML($xml);
     break;
 case "multipolygon":
 case "polygon":
     /* Since polygons are container objects, they are handled differently from points
      * and lines.  The function checks to see within which geometry the query was
      * initiated from, and will return that geometry.
      */
     $result = postgis_query("SELECT * FROM {$layer} as l WHERE ST_Contains(l.{$g_name},GeomFromText('POINT({$lng} {$lat})')) = true LIMIT 1;");
     if (count($result) <= 1) {
         die('<identify_response result="EMPTY" reason="NO MATCHING VALUES"/>');
     }
     $xml = new SimpleXMLElement("<identify_response/>");
     $xml->addAttribute("token", $token);
     $xml->addAttribute("result", "OK");
     foreach ($result[1] as $k => $v) {
         if ($k == $g_name || $k == "oid") {
             continue;
         }
         $field = $xml->addChild("field", $v);
         $field->addAttribute("name", $k);
     }
     echo formatXML($xml);
     break;