| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('Api_WfsNs');
- Lib::loadClass('Request');
- Lib::loadClass('Core_AclHelper');
- Lib::loadClass('Core_XmlWriter');
- class Api_WpsV1_DescribeProcess {
- static function sendDescribeProcessXml($wpsServerUrl, $identifier) {
- header('Content-type: application/xml; charset=utf-8');
- $xmlWriter = new Core_XmlWriter();
- if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
- $xmlWriter->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));
- $wpsProcess = self::getWpsProcess($identifier);
- $xmlWriter->h('ProcessDescription', [
- [ 'ows:Identifier', $wpsProcess->identifier ],
- [ 'ows:Title', $wpsProcess->title ],
- [ 'ows:Abstract', $wpsProcess->description ],
- [ 'DataInputs', array_map(function ($dataInput) {
- return [ 'Input', [ 'maxOccurs' => $dataInput->maxOccurs, 'minOccurs' => $dataInput->minOccurs ], [
- [ 'ows:Identiier', $dataInput->identifier ],
- [ 'ows:Title', $dataInput->title ],
- [ 'ows:Abstract', $dataInput->description ],
- ('xml' === $dataInput->type)
- ? [ 'ComplexData', [
- [ 'Default', [
- [ 'Format', [
- [ 'MimeType', "text/xml; subtype=gml/3.1.1" ],
- ] ],
- ] ],
- ] ]
- : [
- [ 'LiteralData', [
- [ 'ows:AnyValue' ],
- ] ],
- ],
- ] ];
- }, $wpsProcess->dataInputs) ],
- [ 'ProcessOutputs', [
- [ 'Output', [
- [ 'ows:Identifier', "result" ],
- [ 'ows:Title', "result" ],
- [ 'ComplexOutput', [
- [ 'Default', [
- [ 'Format', [ [ 'MimeType', $wpsProcess->defaultOutput ] ] ],
- ] ],
- [ 'Supported', array_map(function ($output) {
- return [ 'Format', [ [ 'MimeType', $output ] ] ];
- }, $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 getWpsProcess($identifier) { // TODO: get from WPS Process Factory // @return Type_WpsProcess
- $wpsProcess = (object)[
- 'identifier' => $identifier,
- 'title' => "Title({$identifier})",
- 'description' => "Desc($identifier)",
- 'maxOccurs' => "1",
- 'minOccurs' => "1",
- 'dataInputs' => [
- (object)[
- 'identifier' => $identifier,
- 'title' => $title,
- 'description' => $description,
- 'type' => 'literal',
- ],
- ],
- // 'MimeType' => text/xml, 'Encoding' => base64, 'Schema' => http://foo.bar/gml/3.1.0/polygon.xsd
- 'defaultOutput' => [ 'MimeType' => "text/xml; subtype=wfs-collection/1.0" ],
- 'supportedOutput' => [
- [ 'MimeType' => "text/xml; subtype=wfs-collection/1.0" ],
- [ 'MimeType' => "text/xml; subtype=wfs-collection/1.1" ],
- [ 'MimeType' => "application/json" ],
- [ 'MimeType' => "application/wfs-collection-1.0" ],
- [ 'MimeType' => "application/wfs-collection-1.1" ],
- [ 'MimeType' => "application/zip" ],
- ]
- ];
- return $wpsProcess;
- }
- }
|