function __construct($table) { logfile::write($table . "\n"); parent::__construct(); preg_match("/^[\\w'-]*\\./", $table, $matches); $_schema = $matches[0]; preg_match("/[\\w'-]*\$/", $table, $matches); $_table = $matches[0]; if (!$_schema) { $table = $this->postgisschema . "." . $table; } logfile::write($table . "\n"); $this->tableWithOutSchema = $_table; $sql = "select 1 from {$table}"; $this->execQuery($sql); if ($this->PDOerror) { $this->exits = false; } else { $this->table = $table; $this->metaData = $this->getMetaData($this->table); $this->geomField = $this->getGeometryColumns($this->table, "f_geometry_column"); $this->geomType = $this->getGeometryColumns($this->table, "type"); $this->primeryKey = $this->getPrimeryKey($this->table); //$this->id = $this->getGeometryColumns($this->table, "id"); $this->setType(); $this->exits = true; } }
public static function doCall($sql, $return = true, $debug = false) { $DBobject = parent::init(); //call the database $result = $DBobject->query($sql); if ($DBobject->errno) { $_SESSION['errors'][] = '<p>select failed: ' . $DBobject->error . '<br> statement was: <strong>' . $sql . '</strong></p>'; return array(); } elseif ($return == true) { $ret = array(); while ($row = $result->fetch_assoc()) { $ret[] = $row; } return $ret; } if ($debug == true) { logfile::doLog(__FUNCTION__ . ' : $sql is ' . $sql); } }
public static function doCall($table, $primary, $wnummer, $data, $debug = false) { $DBobject = parent::init(); $sql = "UPDATE {$table} SET "; foreach ($data as $key => $value) { if ($value == null) { $sql .= "{$key} = null, "; } else { $sql .= "{$key} = '{$value}', "; } } $sql = rtrim($sql, ", "); $sql .= " WHERE " . $primary . " = '" . $wnummer . "'"; if ($debug == true) { logfile::doLog(__FUNCTION__ . ' : $sql is ' . $sql); } $DBobject->query($sql); if ($DBobject->errno) { } }
function makeExceptionReport($value) { ob_get_clean(); ob_start(); echo '<ServiceExceptionReport version="1.2.0" xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ogc http://wfs.plansystem.dk:80/geoserver/schemas//wfs/1.0.0/OGC-exception.xsd"> <ServiceException>'; if (is_array($value)) { print_r($value); } else { print $value; } echo '</ServiceException> </ServiceExceptionReport>'; $data = ob_get_clean(); echo $data; logfile::write($data); die; }
<?php spl_autoload_register(function ($class) { include 'classes/' . $class . '.class.php'; }); $path = !isset($_REQUEST['path']) ? '\\\\NDLS018\\CaptureSV\\Logs' : $_REQUEST['path']; $logfile = new logfile($path); $latestFilename = $logfile->getFilesInPath(); $logfile->setCurrentFilename(end($latestFilename)); $logfile->readAndParseLog(); $subset = $logfile->getLogEntriesByPDFDate(date("Y/m/d", strtotime("yesterday"))); $handle = fopen(dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR . "reports" . DIRECTORY_SEPARATOR . "Output Log " . date("Y-m-d", strtotime("yesterday")) . ".csv", "x+"); fwrite($handle, implode(',', array_keys($subset[0]->getVars())) . PHP_EOL); foreach ($subset as $obj) { $line = array(); foreach ($obj->getVars() as $key => $value) { $line[] = $value; } fwrite($handle, implode(',', $line) . PHP_EOL); } fclose($handle);
}); $json_response = ""; $string_response = ""; $array_response = array(); //Set defaults for any missing querystring parameters $path = !isset($_REQUEST['path']) ? '\\\\NDLS018\\CaptureSV\\Logs' : $_REQUEST['path']; $filename = !isset($_REQUEST['filename']) ? "" : $_REQUEST['filename']; $action = !isset($_REQUEST['action']) ? 'listfiles' : $_REQUEST['action']; //debugging parameters /*$action = 'getlog'; $filename = 'log_1408_ext.txt'; $path = '\\\\NDLS018\\CaptureSV\\Logs';*/ if ($filename == "") { $logfile = new logfile($path); } else { $logfile = new logfile($path, $filename); } switch ($action) { case "listfiles": $json_response = array_reverse($logfile->getFilesInPath()); break; case "getpath": $string_response = $logfile->getPath(); break; case "getlog": try { $logfile->readAndParseLog(); $json_response = $logfile->getLogEntries(); } catch (Exception $e) { $string_response = $e->getMessage(); }
<?php $settings_viewer = new Settings_viewer(); $response = $settings_viewer->get(); if (!$_SESSION['auth'] || $_SESSION['screen_name'] != $parts[2]) { // mod_php if (isset($_SERVER['PHP_AUTH_USER'])) { $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; // most other servers } elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) { if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']), 'basic') === 0) { list($username, $password) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); } } logfile::write($password); if (is_null($username)) { header('WWW-Authenticate: Basic realm="' . $parts[2] . '"'); header('HTTP/1.0 401 Unauthorized'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past // Text to send if user hits Cancel button die("Could not authenticate you 1"); } elseif ($username != $parts[2]) { header('WWW-Authenticate: Basic realm="' . $parts[2] . '"'); header('HTTP/1.0 401 Unauthorized'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
function loadInDB(&$postgisObject, $tableName) { if ($this->arr) { //First we try to drop table $dropSql = "DROP TABLE " . $tableName . " CASCADE"; //When we try to delete row from geometry_columns $deleteFromGeometryColumns = "DELETE FROM geometry_columns WHERE f_table_name='" . $tableName . "'"; //When we insert new row in geometry_columns $sqlInsert = "INSERT INTO geometry_columns VALUES ('', '" . $postgisObject->postgisdb . "', '" . $tableName . "', 'the_geom', 2, 25832, '" . $this->geomType . "', NULL, NULL, NULL)"; //Last we create the new table $createSql = "\n\t\t\tCREATE TABLE " . $tableName . " (\n\t\t\tgid serial NOT NULL,\n\t\t\t" . $this->strForSql . " character varying,\n\t\t\tthe_geom geometry,\n\t\t\tCONSTRAINT \"\$1\" CHECK ((srid(the_geom) = 25832)),\n\t\t\tCONSTRAINT \"\$2\" CHECK (((geometrytype(the_geom) = '" . $this->geomType . "'::text) OR (the_geom IS NULL)))\n\t\t\t);"; // Check if table is already created $checkSql = "select * FROM " . $tableName; $check = $postgisObject->execQuery($checkSql); // Start of transactions block $postgisObject->execQuery(BEGIN); if ($check) { $result = $postgisObject->execQuery($dropSql); $postgisObject->free($result); //echo $tableName." dropped\n"; } $result = $postgisObject->execQuery($deleteFromGeometryColumns); $postgisObject->free($result); $result = $postgisObject->execQuery($sqlInsert); $postgisObject->free($result); $result = $postgisObject->execQuery($createSql); $postgisObject->free($result); //echo "\n"; $countRows = 0; for ($i = 0; $i < sizeof($this->arr['fields']); $i++) { $geoObj = geometryfactory::createGeometry($this->arr['geom'][$i], "25832"); if ($geoObj) { if ($geoObj->getGeomType() == "POLYGON" || $geoObj->getGeomType() == "LINESTRING" || $geoObj->getGeomType() == "POINT") { $this->arr['geom'][$i] = $geoObj->getAsMulti(); } } $sqlInsert = "insert into " . $tableName . " (" . $this->arr['fields'][$i] . ",the_geom) values(" . $this->arr['values'][$i] . ",'SRID=25832;" . $this->arr['geom'][$i] . "')"; // Check if feature has geometry if ($this->arr['geom'][$i] != "()") { $result = $postgisObject->execQuery($sqlInsert); if ($result and pg_affected_rows($result) == 1) { $countRows++; $postgisObject->free($result); } else { logfile::write("Error in #" . $i . "\n"); logfile::write("ROLLBACK\n"); logfile::write($sqlInsert . "\n"); $postgisObject->execQuery(ROLLBACK); logfile::write("Script terminated\n"); die; } } else { logfile::write("#. " . $i . " missing geometry.\n"); logfile::write("ROLLBACK\n"); $postgisObject->execQuery(ROLLBACK); logfile::write("Script terminated\n"); die; } //echo "."; } $postgisObject->execQuery(COMMIT); // End of transactions block } else { $sql = "DELETE FROM " . $tableName; $result = $postgisObject->execQuery($sql); $postgisObject->free($result); $countRows = "0"; } logfile::write(date('l jS \\of F Y h:i:s A') . " " . $countRows . " features loaded in table '" . $tableName . "'\n"); }
function wfs_server() { // Manually tested this piece of code in order to check the requests. // Code based on a similar idea but build in Java header('Content-Type:text/xml; charset=UTF-8', TRUE); header('Connection:close', TRUE); //$userFromUri = "mhoegh"; // for testing logfile::write($userFromUri . "\n\n"); // We connect to the users db $postgisdb = $userFromUri; $srs = $srsFromUri; $postgisschema = $schemaFromUri; $postgisObject = new postgis(); //$user = new users($userFromUri); //$version = new version($user); $geometryColumnsObj = new GeometryColumns(); function microtime_float() { list($utime, $time) = explode(" ", microtime()); return (double) $utime + (double) $time; } $startTime = microtime_float(); //ini_set("display_errors", "On"); $thePath = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REDIRECT_URL']; //$thePath= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; $server = "http://" . $_SERVER['SERVER_NAME']; $BBox = null; //end added $currentTable = null; $currentTag = null; $gen = array(); $gen[0] = ""; $level = 0; $depth = 0; $tables = array(); $fields = array(); $wheres = array(); $limits = array(); logfile::write("\nRequest\n\n"); logfile::write($HTTP_RAW_POST_DATA . "\n\n"); $unserializer_options = array('parseAttributes' => TRUE, 'typeHints' => FALSE); $unserializer = new XML_Unserializer($unserializer_options); /*$HTTP_RAW_POST_DATA = '<?xml version="1.0" encoding="utf-8"?><wfs:Transaction service="WFS" version="1.0.0" xmlns="http://www.opengis.net/wfs" xmlns:mrhg="http://twitter/mrhg" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Insert idgen="GenerateNew"><mrhg:hej><the_geom><gml:MultiPolygon srsName="urn:x-ogc:def:crs:EPSG:6.9:4326"><gml:polygonMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:coordinates>5.0657329559,-41.1107215881 8.4824724197,-39.3435783386 4.3241734505,-34.6001853943 5.0657329559,-41.1107215881 </gml:coordinates></gml:LinearRing></gml:exterior></gml:Polygon></gml:polygonMember></gml:MultiPolygon></the_geom></mrhg:hej></wfs:Insert></wfs:Transaction>';*/ /*$HTTP_RAW_POST_DATA = '<?xml version="1.0"?><DescribeFeatureType version="1.1.0" service="WFS" xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> <TypeName>california_coastline</TypeName></DescribeFeatureType>'; */ // Post method is used if ($HTTP_RAW_POST_DATA) { //$forUseInSpatialFilter = $HTTP_RAW_POST_DATA; // We store a unaltered version of the raw request $HTTP_RAW_POST_DATA = dropNameSpace($HTTP_RAW_POST_DATA); logfile::write($HTTP_RAW_POST_DATA . "\n\n"); $status = $unserializer->unserialize($HTTP_RAW_POST_DATA); $arr = $unserializer->getUnserializedData(); $request = $unserializer->getRootName(); //print_r($arr); switch ($request) { case "GetFeature": if (!is_array($arr['Query'][0])) { $arr['Query'] = array(0 => $arr['Query']); } for ($i = 0; $i < sizeof($arr['Query']); $i++) { if (!is_array($arr['Query'][$i]['PropertyName'])) { $arr['Query'][$i]['PropertyName'] = array(0 => $arr['Query'][$i]['PropertyName']); } } $HTTP_FORM_VARS["REQUEST"] = "GetFeature"; foreach ($arr['Query'] as $queries) { $HTTP_FORM_VARS["TYPENAME"] .= $queries['typeName'] . ","; if ($queries['PropertyName'][0]) { foreach ($queries['PropertyName'] as $PropertyNames) { // We check if typeName is prefix and add it if its not if (strpos($PropertyNames, ".")) { $HTTP_FORM_VARS["PROPERTYNAME"] .= $PropertyNames . ","; } else { $HTTP_FORM_VARS["PROPERTYNAME"] .= $queries['typeName'] . "." . $PropertyNames . ","; } } } if (is_array($queries['Filter']) && $arr['version'] == "1.0.0") { @($checkXml = simplexml_load_string($queries['Filter'])); if ($checkXml === FALSE) { makeExceptionReport("Filter is not valid"); } $wheres[$queries['typeName']] = parseFilter($queries['Filter'], $queries['typeName']); } } $HTTP_FORM_VARS["TYPENAME"] = dropLastChrs($HTTP_FORM_VARS["TYPENAME"], 1); $HTTP_FORM_VARS["PROPERTYNAME"] = dropLastChrs($HTTP_FORM_VARS["PROPERTYNAME"], 1); break; case "DescribeFeatureType": $HTTP_FORM_VARS["REQUEST"] = "DescribeFeatureType"; $HTTP_FORM_VARS["TYPENAME"] = $arr['TypeName']; //if (!$HTTP_FORM_VARS["TYPENAME"]) $HTTP_FORM_VARS["TYPENAME"] = $arr['typeName']; break; case "GetCapabilities": $HTTP_FORM_VARS["REQUEST"] = "GetCapabilities"; break; case "Transaction": $HTTP_FORM_VARS["REQUEST"] = "Transaction"; if (isset($arr["Insert"])) { $transactionType = "Insert"; } if ($arr["Update"]) { $transactionType = "update"; } if ($arr["Delete"]) { $transactionType = "Delete"; } break; } } else { if (sizeof($_GET) > 0) { logfile::write($_SERVER['QUERY_STRING'] . "\n\n"); $HTTP_FORM_VARS = $_GET; $HTTP_FORM_VARS = array_change_key_case($HTTP_FORM_VARS, CASE_UPPER); // Make keys case insensative $HTTP_FORM_VARS["TYPENAME"] = dropNameSpace($HTTP_FORM_VARS["TYPENAME"]); // We remove name space, so $where will get key without it. if ($HTTP_FORM_VARS['FILTER']) { @($checkXml = simplexml_load_string($HTTP_FORM_VARS['FILTER'])); if ($checkXml === FALSE) { makeExceptionReport("Filter is not valid"); } //$forUseInSpatialFilter = $HTTP_FORM_VARS['FILTER']; $status = $unserializer->unserialize(dropNameSpace($HTTP_FORM_VARS['FILTER'])); $arr = $unserializer->getUnserializedData(); $wheres[$HTTP_FORM_VARS['TYPENAME']] = parseFilter($arr, $HTTP_FORM_VARS['TYPENAME']); } } else { $HTTP_FORM_VARS = array(""); } } //HTTP_FORM_VARS is set in script if POST is used $HTTP_FORM_VARS = array_change_key_case($HTTP_FORM_VARS, CASE_UPPER); // Make keys case $HTTP_FORM_VARS["TYPENAME"] = dropNameSpace($HTTP_FORM_VARS["TYPENAME"]); $tables = explode(",", $HTTP_FORM_VARS["TYPENAME"]); $properties = explode(",", dropNameSpace($HTTP_FORM_VARS["PROPERTYNAME"])); $featureids = explode(",", $HTTP_FORM_VARS["FEATUREID"]); $bbox = explode(",", $HTTP_FORM_VARS["BBOX"]); // Start HTTP basic authentication //if(!$_SESSION["oauth_token"]) { $auth = $postgisObject->getGeometryColumns($postgisschema . "." . $HTTP_FORM_VARS["TYPENAME"], "authentication"); //} // End HTTP basic authentication print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ob_start(); if (!empty($properties[0])) { foreach ($properties as $property) { $__u = explode(".", $property); // Is it "/" for get method? // We first check if typeName is namespace if ($__u[1]) { foreach ($tables as $table) { if ($table == $__u[0]) { $fields[$table] .= $__u[1] . ","; } } } else { foreach ($tables as $table) { $fields[$table] .= $property . ","; } } } } if (!empty($featureids[0])) { foreach ($featureids as $featureid) { $__u = explode(".", $featureid); foreach ($tables as $table) { $primeryKey = $postgisObject->getPrimeryKey($postgisschema . "." . $table); if ($table == $__u[0]) { $wheresArr[$table][] = "{$primeryKey['attname']}={$__u[1]}"; } $wheres[$table] = implode(" OR ", $wheresArr[$table]); } } } //get the request switch (strtoupper($HTTP_FORM_VARS["REQUEST"])) { case "GETCAPABILITIES": getCapabilities($postgisObject); break; case "GETFEATURE": if (!$gmlFeatureCollection) { $gmlFeatureCollection = "wfs:FeatureCollection"; } print "<" . $gmlFeatureCollection . "\n"; print "xmlns=\"http://www.opengis.net/wfs\"\n"; print "xmlns:wfs=\"http://www.opengis.net/wfs\"\n"; print "xmlns:gml=\"http://www.opengis.net/gml\"\n"; print "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; print "xmlns:{$gmlNameSpace}=\"{$gmlNameSpaceUri}\"\n"; if ($gmlSchemaLocation) { print "xsi:schemaLocation=\"{$gmlSchemaLocation}\""; } else { //print "xsi:schemaLocation=\"{$gmlNameSpaceUri} {$thePath}?REQUEST=DescribeFeatureType&TYPENAME=".$HTTP_FORM_VARS["TYPENAME"]." http://www.opengis.net/wfs ".str_replace("server.php","",$thePath)."schemas/wfs/1.0.0/WFS-basic.xsd\""; print "xsi:schemaLocation=\"{$gmlNameSpaceUri} {$thePath}?REQUEST=DescribeFeatureType&TYPENAME=" . $HTTP_FORM_VARS["TYPENAME"] . " http://www.opengis.net/wfs http://wfs.plansystem.dk:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd\""; } print ">\n"; doQuery("Select"); print "</" . $gmlFeatureCollection . ">"; break; case "DESCRIBEFEATURETYPE": getXSD($postgisObject); break; case "TRANSACTION": doParse($arr); break; default: makeExceptionReport("Don't know that request"); break; } }
/** * * * @param unknown $arr * @return unknown */ function parseFilter($filter, $table, $operator = "=") { global $postgisObject; global $postgisschema; //global $forUseInSpatialFilter; global $srs; $st = postgis::explodeTableName($table); if (!$st['schema']) { $st['schema'] = $postgisschema; } $primeryKey = $postgisObject->getPrimeryKey($st['schema'] . "." . $st['table']); $serializer_options = array('indent' => ' '); $Serializer =& new XML_Serializer($serializer_options); if (!is_array($filter[0]) && isset($filter) && !(isset($filter['And']) or isset($filter['Or']) or isset($filter['Not']))) { $filter = array(0 => $filter); } $sridOfTable = $postgisObject->getGeometryColumns($table, "srid"); $i = 0; foreach ($filter as $key => $arr) { if ($key == "And" || $key == "Or") { $BoolOperator = $key; } if (isset($arr['Not'])) { //$where[] = parseFilter($arr['Not'],$table,"<>"); } if (isset($arr['And']) || isset($arr['Or'])) { // Recursive call $where[] = parseFilter($arr, $table); } // PropertyIsEqualTo $arr['PropertyIsEqualTo'] = addDiminsionOnArray($arr['PropertyIsEqualTo']); if (is_array($arr['PropertyIsEqualTo'])) { foreach ($arr['PropertyIsEqualTo'] as $value) { $where[] = $value['PropertyName'] . "=" . $postgisObject->quote($value['Literal']); } } // PropertyIsNotEqualTo $arr['PropertyIsNotEqualTo'] = addDiminsionOnArray($arr['PropertyIsNotEqualTo']); if (is_array($arr['PropertyIsNotEqualTo'])) { foreach ($arr['PropertyIsNotEqualTo'] as $value) { $where[] = $value['PropertyName'] . "<>'" . $value['Literal'] . "'"; } } // FeatureID if (!is_array($arr['FeatureId'][0]) && isset($arr['FeatureId'])) { $arr['FeatureId'] = array(0 => $arr['FeatureId']); } if (is_array($arr['FeatureId'])) { foreach ($arr['FeatureId'] as $value) { $value['fid'] = preg_replace("/{$table}\\./", "", $value['fid']); // remove table name $where[] = "{$primeryKey['attname']}=" . $value['fid']; } } // GmlObjectId $arr['GmlObjectId'] = addDiminsionOnArray($arr['GmlObjectId']); if (is_array($arr['GmlObjectId'])) { foreach ($arr['GmlObjectId'] as $value) { $value['id'] = preg_replace("/{$table}\\./", "", $value['id']); // remove table name $where[] = "{$primeryKey['attname']}=" . $value['id']; } } //Intersects $arr['Intersects'] = addDiminsionOnArray($arr['Intersects']); if (is_array($arr['Intersects'])) { foreach ($arr['Intersects'] as $value) { $status = $Serializer->serialize($value); $gmlCon = new gmlConverter(); //logfile::write($Serializer->getSerializedData()."\n\n"); $wktArr = $gmlCon->gmlToWKT($Serializer->getSerializedData(), array()); $sridOfFilter = $wktArr[1][0]; if (!$sridOfFilter) { $sridOfFilter = $srs; } // If no filter on BBOX we think it must be same as the requested srs if (!$sridOfFilter) { $sridOfFilter = $sridOfTable; } // If still no filter on BBOX we set it to native srs $where[] = "ST_Intersects" . "(public.ST_Transform(public.ST_GeometryFromText('" . $wktArr[0][0] . "'," . $sridOfFilter . "),{$sridOfTable})," . $value['PropertyName'] . ")"; unset($gmlCon); unset($wktArr); } } //BBox if ($arr['BBOX']) { if (is_array($arr['BBOX']['Box']['coordinates'])) { $arr['BBOX']['Box']['coordinates']['_content'] = str_replace(" ", ",", $arr['BBOX']['Box']['coordinates']['_content']); $coordsArr = explode(",", $arr['BBOX']['Box']['coordinates']['_content']); } else { $arr['BBOX']['Box']['coordinates'] = str_replace(" ", ",", $arr['BBOX']['Box']['coordinates']); $coordsArr = explode(",", $arr['BBOX']['Box']['coordinates']); } if (is_array($arr['BBOX']['Box'])) { $sridOfFilter = gmlConverter::parseEpsgCode($arr['BBOX']['Box']['srsName']); if (!$sridOfFilter) { $sridOfFilter = $srs; } // If no filter on BBOX we think it must be same as the requested srs if (!$sridOfFilter) { $sridOfFilter = $sridOfTable; } // If still no filter on BBOX we set it to native srs } if (is_array($arr['BBOX']['Envelope'])) { $coordsArr = array_merge(explode(" ", $arr['BBOX']['Envelope']['lowerCorner']), explode(" ", $arr['BBOX']['Envelope']['upperCorner'])); ob_start(); print_r($arr['BBOX']['Envelope']); print_r($coordsArr); $data = ob_get_clean(); //logfile::write($data); $sridOfFilter = gmlConverter::parseEpsgCode($arr['BBOX']['Envelope']['srsName']); if (!$sridOfFilter) { $sridOfFilter = $srs; } // If no filter on BBOX we think it must be same as the requested srs if (!$sridOfFilter) { $sridOfFilter = $sridOfTable; } // If still no filter on BBOX we set it to native srs } /* $coordsArr[0] = floor($coordsArr[0]/1000)*1000; $coordsArr[1] = floor($coordsArr[1]/1000)*1000; $coordsArr[2] = ceil($coordsArr[2]/1000)*1000; $coordsArr[3] = ceil($coordsArr[3]/1000)*1000; */ $where[] = "public.ST_Transform(public.ST_GeometryFromText('POLYGON((" . $coordsArr[0] . " " . $coordsArr[1] . "," . $coordsArr[0] . " " . $coordsArr[3] . "," . $coordsArr[2] . " " . $coordsArr[3] . "," . $coordsArr[2] . " " . $coordsArr[1] . "," . $coordsArr[0] . " " . $coordsArr[1] . "))'," . $sridOfFilter . "),{$sridOfTable}) && " . $arr['BBOX']['PropertyName']; } // End of filter parsing $i++; } ob_start(); print_r($where); $data = ob_get_clean(); logfile::write($data); if (!$BoolOperator) { $BoolOperator = "OR"; } return "(" . implode(" " . $BoolOperator . " ", $where) . ")"; }
function execQuery($query, $conn = "PDO", $queryType = "select") { logfile::write($query . "\n"); switch ($conn) { case "PG": if (!$this->db) { $this->connect("PG"); } $result = pg_query($this->db, $query); return $result; break; case "PDO": if (!$this->db) { $this->connect("PDO"); } try { $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); switch ($queryType) { case "select": $result = $this->db->query($query); // Return PDOStatement object break; case "transaction": $result = $this->db->exec($query); // Return interger } //$db = NULL; } catch (PDOException $e) { $this->PDOerror[] = $e->getMessage(); } return $result; break; } }
function parseEpsgCode($epsg) { //if (strtoupper(substr($epsg, 0, 5)=="EPSG:")) $epsg=substr($epsg, 5,strlen($epsg)); //preg_match_all("/[0-9]*$/",$epsg,$arr); //$clean=$arr[0][0]; $split = explode(":", $epsg); ob_start(); print_r($split); $data = ob_get_clean(); logfile::write($data); $clean = end($split); $clean = preg_replace("/[\\w]\\./", "", $clean); return $clean; }