|
|
@@ -95,6 +95,100 @@ class Api_WpsV1_ServerBase {
|
|
|
return $usrObjList;
|
|
|
}
|
|
|
|
|
|
+ static function convertWpsExecuteDataInputsXmlArrayToArgs($tagDataInputs) {
|
|
|
+ if (empty($tagDataInputs)) throw new Exception("Missing wps:DataInputs");
|
|
|
+ if (empty($tagDataInputs[2])) throw new Exception("Missing wps:DataInputs child nodes");
|
|
|
+ $tagsInput = array_filter($tagDataInputs[2], function ($tag) {
|
|
|
+ return ( 'wps:Input' === $tag[0] );
|
|
|
+ });
|
|
|
+ if (empty($tagsInput)) throw new Exception("Missing wps:DataInputs child nodes");
|
|
|
+
|
|
|
+ $args = [];
|
|
|
+ foreach ($tagsInput as $tagInput) {
|
|
|
+ list($key, $value) = self::convertWpsExecuteInputXmlArrayToArg($tagInput);
|
|
|
+ $args[ $key ][] = $value;
|
|
|
+ }
|
|
|
+ // echo "\$tagDataInputs[2]:"; print_r($tagDataInputs[2]);
|
|
|
+ // echo "\$tagsInput:"; print_r($tagsInput);
|
|
|
+ return $args;
|
|
|
+ }
|
|
|
+ static function convertWpsExecuteInputXmlArrayToArg($tagInput) {
|
|
|
+ if (empty($tagInput)) throw new Exception("Missing wps:Input");
|
|
|
+ if (empty($tagInput[2])) throw new Exception("Missing wps:Input child nodes");
|
|
|
+ $tagsIdentifier = array_filter($tagInput[2], function ($tag) {
|
|
|
+ return ( 'ows:Identifier' === $tag[0] );
|
|
|
+ });
|
|
|
+ $tagIdentifier = reset($tagsIdentifier);
|
|
|
+ $identifier = (!empty($tagIdentifier[2][0])) ? $tagIdentifier[2][0] : null;
|
|
|
+ if (empty($identifier)) throw new Exception("Missing wps:Input/ows:Identifier");
|
|
|
+
|
|
|
+ $tagsData = array_filter($tagInput[2], function ($tag) {
|
|
|
+ return ( 'wps:Data' === $tag[0] );
|
|
|
+ });
|
|
|
+ $tagData = reset($tagsData);
|
|
|
+ if (empty($tagData)) throw new Exception("Missing wps:Input/wps:Data");
|
|
|
+
|
|
|
+ $data = self::convertWpsExecuteInputDataXmlArrayToValue($tagData);
|
|
|
+
|
|
|
+ return [ $identifier, $data ];
|
|
|
+ }
|
|
|
+ static function convertWpsExecuteInputDataXmlArrayToValue($tagData) {
|
|
|
+ $firstChild = (!empty($tagData[2])) ? reset($tagData[2]) : null;
|
|
|
+ if (empty($firstChild)) throw new Exception("Missing wps:Input/wps:Data child nodes");
|
|
|
+ if ('wps:LiteralData' !== $firstChild[0]) throw new Exception("Missing wps:Input/wps:Data/wps:LiteralData");
|
|
|
+ $value = (!empty($firstChild[2][0])) ? $firstChild[2][0] : null;
|
|
|
+ if (empty($value)) throw new Exception("Missing wps:Input/wps:Data/wps:LiteralData value");
|
|
|
+ return $value;
|
|
|
+ }
|
|
|
+ static function _parseExecuteXmlArray($xml) {
|
|
|
+ // <wps:Execute xmlns:wps="http://www.opengis.net/wps/1.0.0" version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
|
|
|
+ // <ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">p5:selectFeature</ows:Identifier>
|
|
|
+ // <wps:DataInputs>
|
|
|
+ // <wps:Input>
|
|
|
+ // <ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">typeName</ows:Identifier>
|
|
|
+ // <wps:Data><wps:LiteralData>default_db/TEST_PERMS/TestPermsAnt</wps:LiteralData></wps:Data>
|
|
|
+ // </wps:Input>
|
|
|
+ // <wps:Input>
|
|
|
+ // <ows:Identifier xmlns:ows="http://www.opengis.net/ows/1.1">primaryKey</ows:Identifier>
|
|
|
+ // <wps:Data><wps:LiteralData>97</wps:LiteralData></wps:Data>
|
|
|
+ // </wps:Input>
|
|
|
+ // </wps:DataInputs>
|
|
|
+ // <wps:ResponseForm/>
|
|
|
+ // </wps:Execute>
|
|
|
+ if (empty($xml[2])) throw new Exception("Parse WPS Execute error - empty 'wps:Execute' tag");
|
|
|
+ $childTags = array_map(function ($child) {
|
|
|
+ return $child[0];
|
|
|
+ }, $xml[2]);
|
|
|
+ // echo "\$childTags:"; print_r($childTags);
|
|
|
+ // [0] => ows:Identifier
|
|
|
+ // [1] => wps:DataInputs
|
|
|
+ // [2] => wps:ResponseForm
|
|
|
+ $childListIdentifier = array_filter($xml[2], function ($child) {
|
|
|
+ return ( 'ows:Identifier' === $child[0] );
|
|
|
+ });
|
|
|
+ // echo "\$childIdentifier:"; print_r($childIdentifier);
|
|
|
+ $childIdentifier = (!empty($childListIdentifier)) ? reset($childListIdentifier) : [];
|
|
|
+ $identifier = (!empty($childIdentifier[2])) ? reset($childIdentifier[2]) : null;
|
|
|
+ $childListDataInputs = array_filter($xml[2], function ($child) {
|
|
|
+ return ( 'wps:DataInputs' === $child[0] );
|
|
|
+ });
|
|
|
+ $childDataInputs = (!empty($childListDataInputs)) ? reset($childListDataInputs) : [];
|
|
|
+ $args = self::convertWpsExecuteDataInputsXmlArrayToArgs($childDataInputs);
|
|
|
+ // echo "\$tagsInput:"; print_r($tagsInput);
|
|
|
+ // echo "\$args:"; print_r($args);
|
|
|
+ // TODO: response format
|
|
|
+ // $childResponseForm = array_filter($xml[2], function ($child) {
|
|
|
+ // return ( 'wps:ResponseForm' === $child[0] );
|
|
|
+ // });
|
|
|
+ // // echo "\$childResponseForm:"; print_r($childResponseForm);
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'identifier' => $identifier,
|
|
|
+ 'args' => $args,
|
|
|
+ 'responseFormat' => '', // TODO: ...
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
public function _parseTransactionXmlStruct($requestXml, $requestXmlTags) {
|
|
|
$DBG = V::get('DBG_XML', 0, $_GET, 'int');// TODO: Profiler
|
|
|
$rootTagName = V::get('tag', '', $requestXmlTags[0]);
|