$methodName($urlQuery); } } else { $wps = new WpsServer(); $wps->parseXMLRequest(); } exit; break; } case 'import_from_postgis': { $gis_zas_id = 13102; $pgDB = DB::getDB($gis_zas_id); $db = DB::getDB(); // POSTGIS_to_MYSQL_Tables('BUILDINGS','geoportal_gml_punkty_adr_gml_id','MK_Budynki','geoportal_gml_punkty_adr_gml_id'); // function POSTGIS_to_MYSQL_Tables($local_table_mysql,$local_key,$remote_table_postgis,$remote_key){ // global $db,$gdb; $local_table_mysql = 'BUILDINGS'; $local_key = 'geoportal_gml_punkty_adr_gml_id'; $remote_table_postgis = 'MK_Budynki'; $remote_key = 'geoportal_gml_punkty_adr_gml_id'; // BUG: ST_AsEWKT @see http://postgis.org/docs/ST_AsEWKT.html $pgSql = <<query($pgSql); echo '
';
			echo "Start...\n";
			while ($r = $pgDB->fetch($pgRes)) {
				$r->{$remote_key} = trim($r->{$remote_key});
				$sql = "update `{$local_table_mysql}` set `the_geom`=GeomFromText('{$r->the_geom}')
					where `{$local_key}`='{$r->$remote_key}'
						and `{$local_key}`!=''
						and `{$local_key}` is not null
						and (`the_geom`='' or `the_geom` is null)
				";
				//echo'
sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'
'; echo "Fethed remote_key: {$remote_key}={$r->$remote_key}| "; $testRow = null; $testSql = "select t.`ID`, t.`{$local_key}`, AsWKT(t.`the_geom`) as the_geom from `{$local_table_mysql}` as t where t.`{$local_key}`='{$r->$remote_key}' "; //echo'
testSql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($testSql);echo'
'; $testRes = $db->query($testSql); if ($testRow = $db->fetch($testRes)) { echo " mysql row exists in table `{$local_table_mysql}` (ID={$testRow->ID}) "; echo " | the_geom is "; echo (!empty($testRow->the_geom))? " set " : " not set "; } else { echo " mysql row not exists in table `{$local_table_mysql}`! "; } //echo'
 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($testRow);echo'
'; $res = $db->query($sql); if (!$res) { echo "| ERROR: problem with query!"; echo'
 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'
'; } else { echo "| done "; } echo "\n"; } echo '
'; break; } default: } //$_POST['url'] = 'http://demo.opengeo.org/geoserver/wfs'; //$entityBody = file_get_contents('php://input'); $url = V::get('_url', '', $_GET); if ($url) {// @see OpenLayers/examples/proxy.cgi $allowedHosts = array('www.openlayers.org', 'openlayers.org', 'labs.metacarta.com', 'world.freemap.in', 'prototype.openmnnd.org', 'geo.openplans.org', 'sigma.openplans.org', 'demo.opengeo.org', 'www.openstreetmap.org', 'sample.azavea.com', 'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080', 'vmap0.tiles.osgeo.org', 'www.openrouteservice.org', 'maps.wien.gv.at'); if (!empty($_POST)) { // qs = os.environ["QUERY_STRING"] // d = cgi.parse_qs(qs) // if d.has_key("url"): // url = d["url"][0] // else: // url = "http://www.openlayers.org" } else { // fs = cgi.FieldStorage() // url = fs.getvalue('url', "http://www.openlayers.org") } $host = explode('/', $url); $host = $host[2]; if (!in_array($host, $allowedHosts)) { header("Status: 502 Bad Gateway"); header("Content-Type: text/plain"); echo "\nThis proxy does not allow you to access that location ({$host})."; exit; } else if (substr($url, 0, 7) == 'http://' || substr($url, 0, 8) == 'https://') { $ch = curl_init(); if (!empty($_POST)) { /* length = int(os.environ["CONTENT_LENGTH"]) headers = {"Content-Type": os.environ["CONTENT_TYPE"]} body = sys.stdin.read(length) r = urllib2.Request(url, body, headers) y = urllib2.urlopen(r) */ } else { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// return the transfer as a string //curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $response = curl_exec($ch); // Then, after your curl_exec call: $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size); curl_close($ch); $contentType = 'text/plain'; $headers = explode("\n", $header); foreach ($headers as $vHeader) { if (substr($vHeader, 0, 13) == 'Content-Type:') { $contentType = trim(substr($vHeader, 14)); } } header("Content-Type: {$contentType}"); echo $body . "\n"; } } else { header("Content-Type: text/plain"); echo "\nIllegal request."; exit; } exit; } ?>
title = 'Przypisz'; $this->description = 'Przypisuje położenie do wybranego rekordu w tabeli.'; $this->dataInputs['geom'] = new stdClass(); $this->dataInputs['geom']->title = 'geom'; $this->dataInputs['geom']->description = 'Input geometry'; $this->dataInputs['geom']->type = 'geom';// CoomplexData $this->dataInputs['idTable'] = new stdClass(); $this->dataInputs['idTable']->title = 'geom'; $this->dataInputs['idTable']->description = 'Table ID'; $this->dataInputs['idTable']->type = 'integer';// LiteralData: xs:integer $this->dataInputs['idRecord'] = new stdClass(); $this->dataInputs['idRecord']->title = 'idRecord'; $this->dataInputs['idRecord']->description = 'Record ID'; $this->dataInputs['idRecord']->type = 'integer';// LiteralData: xs:integer } } class WfsAction { /** * example: MULTIPOLYGON(((2072016.74395199 7234076.79293037,2072016.74395199 7234115.01144451,2072131.3994944 7234115.01144451,2072131.3994944 7234076.79293037,2072016.74395199 7234076.79293037))) */ public function generateGmlFromWKT($wkt) { $gml = ''; $wktParts = explode('(', $wkt, 2); ob_start(); switch ($wktParts[0]) { case 'MULTIPOLYGON': case 'POLYGON': { $points = trim($wktParts[1], '() '); $points = str_replace(',', "\n", $points); ?> -180 -90 180 90 query($sql); while ($r = $db->fetch($res)) { $buildingsGml[$r->ID] = $this->generateGmlFromWKT($r->the_geom); } /** * * * * goes to js: @see priv.addWKTInput _layer.selectedFeatures[0] * * attributes: Object recordId: "1130" tblId: "16" */ echo ''; ?> -180 -90 180 90 $vGml) : ?> _fun['przypiszDoRekordu'] = new WpsActionPrzypiszDoRekordu(); $this->_wfsAction = new WfsAction(); } public function parseXMLRequest() { $data = array(); $reqContent = file_get_contents('php://input'); $xml = new SimpleXMLElement($reqContent); if ('GetFeature' == $xml->getName()) { // TODO: parse xml and set query params $this->_wfsAction->execute($data); } else if (isset($xml->children('ows', TRUE)->Identifier)) { $identifier = (string)$xml->children('ows', TRUE)->Identifier; if (array_key_exists($identifier, $this->_fun)) { foreach ($xml->children('wps', TRUE)->DataInputs->children('wps', TRUE) as $input) { $inputIdentifier = (string)$input->children('ows', TRUE)->Identifier; if (array_key_exists($inputIdentifier, $this->_fun[$identifier]->dataInputs)) { $inputType = (string)$this->_fun[$identifier]->dataInputs[$inputIdentifier]->type; switch ($inputType) { case 'integer': $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->LiteralData; break; case 'geom': $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->ComplexData; break; default: } } else { // brak zdefiniowanego inputa } } $this->_fun['przypiszDoRekordu']->execute($data); } else { echo "TODO: brak zdefiniowanej funkcji '{$identifier}'"; var_dump($identifier); } } else { echo "TODO: '" . $xml->getName() . "' ..."; } } public function getCapabilitiesAction() { echo ''; ?> Prototype GeoServer WPS wps geoserver WPS 1.0.0 NONE NONE GeoServer _fun as $kFun => $vFun) : ?> title; ?> description; ?> en-US en-US '; if (array_key_exists($args['IDENTIFIER'], $this->_fun)) { $identifier = $this->_fun[$args['IDENTIFIER']]; ?> title; ?> description; ?> dataInputs as $kInput => $vInput) : ?> title; ?> description; ?> type == 'geom') : ?> text/xml; subtype=gml/3.1.1 text/xml; subtype=gml/3.1.1 text/xml; subtype=gml/2.1.2 application/wkt application/gml-3.1.1 application/gml-2.1.2 type == 'integer') : ?> xs:integer result result text/xml; subtype=gml/3.1.1 text/xml; subtype=gml/3.1.1 text/xml; subtype=gml/2.1.2 application/wkt application/gml-3.1.1 application/gml-2.1.2