query); if (!empty($req)) { if ('WPS' != V::geti('service', '', $request->query)) { throw new Api_WfsException("Only WPS Service is allowed"); } $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; } } function parseXMLRequest() { $data = array(); $tags = []; $reqContent = Request::getRequestBody(); if (empty($reqContent)) throw new Exception("Empty request"); Lib::loadClass('XML'); $xml = XML::xmlToArray($reqContent); if (empty($xml)) throw new Exception("Error structure from request"); $rootTagName = $xml[0]; switch ($rootTagName) { case 'wps:Execute': return $this->_runExecute($xml); default: throw new Api_WfsException("Not implemented WPS xml request '{$rootTagName}'" . __LINE__, 501); } } function _runExecute($xml) { $funInfo = self::_parseExecuteXmlArray($xml); $identifier = V::get('identifier', '', $funInfo); $args = V::get('args', [], $funInfo, 'array'); if (empty($identifier)) throw new Exception("Parse xml request error - missing identifier"); Lib::loadClass('Api_WpsHelper'); $wpsProcess = Api_WpsHelper::getUserWpsProcess($identifier); Api_WpsHelper::validateProcessArgs($wpsProcess, $args); Api_WpsHelper::executeProcess($wpsProcess, $args); exit; } 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(); $wpsProcess = Api_WpsHelper::getUserWpsProcess($identifier); if (!$wpsProcess) throw new Api_WfsException("Forbidden", 403); Api_WpsV1_DescribeProcess::sendDescribeProcessXml($wpsServerUrl, $wpsProcess); } 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(); $wpsProcessList = Api_WpsHelper::getUserWpsProcessList(); switch (V::get('outputFormat', 'xml', $_GET)) { case 'csv': { Api_WpsV1_GetCapabilities::sendGetCapabilitiesCsv($wpsServerUrl, $serviceTitle, $serviceDescription, $wpsProcessList); } break; case 'xml': { Api_WpsV1_GetCapabilities::sendGetCapabilitiesXml($wpsServerUrl, $serviceTitle, $serviceDescription, $wpsProcessList); } break; case 'html': { Api_WpsV1_GetCapabilities::sendGetCapabilitiesHtml($wpsServerUrl, $serviceTitle, $serviceDescription, $wpsProcessList); } break; default: throw new Api_OwsException("Not Implemented outputFormat", 501, null, 'Not Implemented', 'request'); } exit; } }