query)) { throw new Api_WfsException("Only WPS Service is allowed"); } $req = V::geti('request', '', $request->query); if (!empty($req)) { $methodName = "{$req}Action"; if (!method_exists($this, $methodName)) { throw new Api_WfsException("Not Implemented " . htmlspecialchars($req), 501); } $this->DBG("WpsServer->{$methodName}() ...", __LINE__); $document = $this->$methodName($urlQuery); } else { $this->DBG("WpsServer->parseXMLRequest() ...", __LINE__); $document = $this->parseXMLRequest(); header('Content-type: application/xml'); echo ''; echo $document; exit;// TODO: return $document; } IF(V::get('DBG','',$_GET)){echo'
$document (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($document);echo'
';} if ('raw' == V::get('outputFormat', '', $request->query)) { header('Content-type: text/plain; charset=utf-8'); echo $document; } else { header('Content-type: application/xml'); echo $document; } } public function parseXMLRequest() { $data = array(); $reqContent = Request::getRequestBody(); if (empty($reqContent)) { throw new Exception("Empty request"); } $parserXml = xml_parser_create(); xml_parser_set_option($parserXml, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parserXml, XML_OPTION_SKIP_WHITE, 1); if (0 == xml_parse_into_struct($parserXml, $reqContent, $tags)) { throw new Exception("Error parsing xml"); } xml_parser_free($parserXml); if (empty($tags)) { throw new Exception("Empty structure from request"); } $rootTagName = V::get('tag', '', $tags[0]); if ('Transaction' == $rootTagName) return $this->_parseTransactionXmlStruct($reqContent, $tags); throw new Api_WfsException("Not implemented '{$rootTagName}' #L." . __LINE__, 501); } function describeProcessAction() { $identifier = V::geti('identifier', '', $_REQUEST); if (empty($identifier)) throw new HttpException("Missing identifier", 400); if ('JTS:Aarea' === $identifier) return self::exampleDescribeProcess_JTS_Area(); if ('vec:Feature' === $identifier) return self::exampleDescribeProcess_vec_Feature(); $wpsServerUrl = $this->getBaseUri(); Api_WpsV1_DescribeProcess::sendDescribeProcessXml($wpsServerUrl, $identifier); } static function exampleDescribeProcess_JTS_Area() { header('Content-type: application/xml; charset=utf-8'); echo 'JTS:areaAreaReturns the area of a geometry, in the units of the geometry. Assumes a Cartesian plane, so this process is only recommended for non-geographic CRSes.geomgeomInput geometrytext/xml; subtype=gml/3.1.1text/xml; subtype=gml/3.1.1text/xml; subtype=gml/2.1.2application/wktapplication/jsonapplication/gml-3.1.1application/gml-2.1.2resultresultdouble'; exit; } static function exampleDescribeProcess_vec_Feature() { header('Content-type: application/xml; charset=utf-8'); echo 'vec:FeatureFeature from GeometryConverts a geometry into a feature collection.geometrygeometryInput geometrytext/xml; subtype=gml/3.1.1text/xml; subtype=gml/3.1.1text/xml; subtype=gml/2.1.2application/wktapplication/jsonapplication/gml-3.1.1application/gml-2.1.2crscrsCoordinate reference system of the input geometry (if not provided in the geometry)typeNametypeNameFeauturetype name for the feature collectionresultresulttext/xml; subtype=wfs-collection/1.0text/xml; subtype=wfs-collection/1.0text/xml; subtype=wfs-collection/1.1application/jsonapplication/wfs-collection-1.0application/wfs-collection-1.1application/zip'; exit; } public function getCapabilitiesAction() { $wpsServerUrl = $this->getBaseUri(); $serviceTitle = "Web Processing Service"; $serviceDescription = "Web Processing Service"; $idDefaultDB = DB::getPDO()->getZasobId(); $aclList = array_filter($this->_usrAcl->getTablesAcl(), function ($acl) use ($idDefaultDB) { // // $dataSourceName = 'default_db';// TODO: getSourceName // // $tblName = $tblAcl->getName(); // // try { // // $acl = $this->getAclFromTypeName($typeName = "p5_{$dataSourceName}:{$tblName}"); // // } catch (Exception $e) { // // // echo "Error for table({$tblName}): " . $e->getMessage() . "\n"; // // } // // if (!$acl) { // // // TODO: error log msg // // return false; // // } return ($acl instanceof Core_AclBase && $idDefaultDB == $acl->getDB()); // hide non default_db tables }); switch (V::get('outputFormat', 'xml', $_GET)) { case 'csv': { Api_WpsV1_GetCapabilities::sendGetCapabilitiesCsv($wpsServerUrl, $serviceTitle, $serviceDescription, $aclList); } break; case 'xml': { Api_WpsV1_GetCapabilities::sendGetCapabilitiesXml($wpsServerUrl, $serviceTitle, $serviceDescription, $aclList); } break; default: throw new Api_WfsException("Not Implemented outputFormat", 501); // , null, 'NotImplemented', 'request'); } exit; } }