示例#1
0
############################################################################################
# This class takes care of getting and creating layers
# XML (SOAP) layers are implemented as tables that are deleted when the user deletes them, and can only be refreshed explicitly.
# Metalayers are implemented as SQL views on other tables.
require_once "include.php";
header("Content-type: text/xml");
$post = trim(file_get_contents('php://input'));
global $xml;
try {
    $xml = new SimpleXMLElement($post);
} catch (Exception $e) {
    echo '<?xml version="1.0"?>
	<layers_response result="ERROR" reason="Unable to parse layer request XML."/>';
    die;
}
if (strtolower($xml->getName()) == "layers_request") {
    $token = $xml['token'];
    $array = getLayersForToken($token);
    $response = new SimpleXMLElement("<layers_response/>");
    $response->addAttribute("token", $token);
    $response->addAttribute("result", "OK");
    $keys = array_keys($array[0]);
    for ($i = 1; $i < count($array); $i++) {
        $layer = $response->addChild("layer");
        for ($j = 0; $j < count($keys); $j++) {
            $layer->addAttribute($keys[$j], $array[$i][$keys[$j]]);
        }
    }
    echo formatXML($response);
}
示例#2
0
$post = trim(file_get_contents('php://input'));
global $xml;
try {
    $xml = new SimpleXMLElement($post);
} catch (Exception $e) {
    echo '<?xml version="1.0"?>
	<identify_response result="ERROR" reason="Unable to parse identify request XML."/>';
    die;
}
if (strtolower($xml->getName()) == "identify_request") {
    // Get all of the parameters in the request XML.
    $token = $xml['token'];
    $layer = $xml['layer'];
    $lat = $xml['lat'];
    $lng = $xml['lng'];
    $qresult = getLayersForToken($token, "l.name = '{$layer}'");
    if (count($qresult) <= 1) {
        die('<identify_response result="ERROR" reason="TABLE NOT FOUND"/>');
    }
    $g_type = $qresult[1]['geometry_type'];
    $g_name = $qresult[1]['geometry_name'];
    switch (strtolower($g_type)) {
        case "linestring":
        case "multilinestring":
        case "line":
        case "multipoint":
        case "point":
            /* Get the identify information for lines and points.
             * Lines and points are dealt with in the same manner.
             * The function will get the CLOSEST point or line from the point clicked, and
             * will get the information for that.  It will then format the response as XML.