openUri('php://output'); $xmlWriter->setIndent(true); $xmlWriter->startDocument('1.0','UTF-8'); $xmlWriter->startElement('wps:ProcessDescriptions'); $xmlWriter->writeAttribute('service', "WPS"); $xmlWriter->writeAttribute('version', "1.0.0"); // $xmlWriter->writeAttribute('xml:lang', "en"); $xmlWriter->writeAttribute('xmlns:xs', 'http://www.w3.org/2001/XMLSchema'); $xmlWriter->writeAttribute('xmlns:ows', "http://www.opengis.net/ows/1.1"); $xmlWriter->writeAttribute('xmlns:wps', "http://www.opengis.net/wps/1.0.0"); $xmlWriter->writeAttribute('xmlns:xlink', "http://www.w3.org/1999/xlink"); $xmlWriter->writeAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); // $xmlWriter->writeAttribute('xsi:schemaLocation', "http://www.opengis.net/wps/1.0.0 ../wpsGetCapabilities_response.xsd"); foreach (Api_WfsNs::getNsList() as $uri => $prefix) { $xmlWriter->writeAttribute("xmlns:{$prefix}", $uri); } // $schemaLocations = []; //$schemaLocations[] = 'http://www.opengis.net/wfs http://webgis.regione.sardegna.it:80/geoserver/schemas/wfs/1.0.0/WFS-capabilities.xsd';// @from http://webgis.regione.sardegna.it/geoserver/ows?service=WFS&request=GetCapabilities // if (!empty($schemaLocations)) $xmlWriter->writeAttribute('xsi:schemaLocation', implode(' ', $schemaLocations)); DBG::log($wpsProcess, 'array', "\$wpsProcess"); $xmlWriter->h('ProcessDescription', [ [ 'ows:Identifier', $wpsProcess->identifier ], [ 'ows:Title', $wpsProcess->title ], [ 'ows:Abstract', $wpsProcess->description ], [ 'DataInputs', array_map([ self, 'convertInputToXmlWriter' ], $wpsProcess->dataInputs) ], [ 'ProcessOutputs', [ [ 'Output', [ [ 'ows:Identifier', "result" ], [ 'ows:Title', "result" ], [ 'ComplexOutput', [ [ 'Default', [ self::convertOutputFormatToXmlWriter($wpsProcess->defaultOutput) ] ], [ 'Supported', array_map([ self, 'convertOutputFormatToXmlWriter' ], $wpsProcess->supportedOutput) ], // [ 'Supported', [ // [ 'Format', [ [ 'MimeType', "text/xml; subtype=wfs-collection/1.0" ] ] ], // [ 'Format', [ [ 'MimeType', "text/xml; subtype=wfs-collection/1.1" ] ] ], // [ 'Format', [ [ 'MimeType', "application/json" ] ] ], // [ 'Format', [ [ 'MimeType', "application/wfs-collection-1.0" ] ] ], // [ 'Format', [ [ 'MimeType', "application/wfs-collection-1.1" ] ] ], // [ 'Format', [ [ 'MimeType', "application/zip" ] ] ], // ] ], ] ], ] ], ] ], ]); $xmlWriter->endElement();// wps:ProcessDescriptions $xmlWriter->endDocument(); exit; } static function convertInputToXmlWriter($input) { DBG::log($input, 'array', "convertInputToXmlWriter(\$input)"); return [ 'Input', [ 'maxOccurs' => $input->maxOccurs, 'minOccurs' => $input->minOccurs ], array_filter([ [ 'ows:Identifier', $input->identifier ], [ 'ows:Title', $input->title ], (!empty($input->description)) ? [ 'ows:Abstract', $input->description ] : null, self::convertInputFormChoiceToXmlWriter($input), ], [ 'V', 'filterNotEmpty' ]) ]; // (isset($input->description)) ? [ [ 'ows:Abstract', $input->description ] ] : [], } static function convertInputFormChoiceToXmlWriter($input) { switch ($input->dataType) { case 'literal': return self::convertInputLiteralDataToXmlWriter($input); case 'complex': return self::convertInputComplexDataToXmlWriter($input); case 'boundingBox': return self::convertInputBoundingBoxDataToXmlWriter($input); } } static function convertInputLiteralDataToXmlWriter($input) { $owsDataTypeAttribs = ( !empty($input->xsdType) ) ? [ 'ows:reference' => $input->xsdType ] : []; return [ 'LiteralData', [], array_merge( [ [ 'ows:AnyValue' ] ], ( !empty($input->xsdType) ) ? [ [ 'ows:DataType', $owsDataTypeAttribs, $input->xsdType ] ] : [] ) ]; } static function convertInputComplexDataToXmlWriter($input) { return [ 'ComplexData', [], [ [ 'Default', [ [ 'Format', [ [ 'MimeType', "text/xml" ], ] ], ] ], ] ]; } static function convertInputBoundingBoxDataToXmlWriter($input) { return [ 'BoundingBoxData', [], [ ] ]; } static function convertOutputFormatToXmlWriter($output) { DBG::log($output, 'array', "convertOutputFormatToXmlWriter(\$output)"); // 'MimeType' => text/xml, 'Encoding' => base64, 'Schema' => http://foo.bar/gml/3.1.0/polygon.xsd // return text/xmlbase64http://foo.bar/gml/3.1.0/polygon.xsd return [ 'Format', array_merge( (!empty($output['MimeType'])) ? [ [ 'MimeType', $output['MimeType'] ] ] : [], (!empty($output['Encoding'])) ? [ [ 'Encoding', $output['Encoding'] ] ] : [], (!empty($output['Schema'])) ? [ [ 'Schema', $output['Schema'] ] ] : [] ) ]; } }