| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <?php
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('Api_WfsNs');
- Lib::loadClass('Request');
- Lib::loadClass('Core_AclHelper');
- Lib::loadClass('Core_XmlWriter');
- class Api_WpsV2_GetCapabilities { // TODO: ...
- static function sendGetCapabilitiesCsv($wpsServerUrl, $serviceTitle, $serviceDescription, $aclList) {
- throw new Api_WfsException("Not Implemented sendGetCapabilitiesCsv for Wps version 1.0.0", 501);
- header('Content-Type: text/csv; charset=utf-8');
- $csvLineSepartor = "\n";
- $csvValueSepartor = ",";
- $csvText = function ($value) {
- return '"' . str_replace(['"'], ['\"'], $value) . '"';
- };
- echo implode(",", [
- "Name",
- "Title",
- "namespace url",
- "Keywords",
- "Abstract",
- "SRS",
- "LatLongBoundingBox - minx",
- "LatLongBoundingBox - miny",
- "LatLongBoundingBox - maxx",
- "LatLongBoundingBox - maxy",
- ]);
- echo $csvLineSepartor;
- echo implode($csvLineSepartor, array_map(function ($acl) use ($csvText, $csvValueSepartor) {
- $ns = Core_AclHelper::parseNamespaceUrl($acl->getNamespace());
- return implode($csvValueSepartor, [
- "p5_{$ns['prefix']}:{$ns['name']}", // Name
- $csvText($acl->getRawLabel()), // Title
- Api_WfsNs::getNsUri($ns['prefix']), // namespace url
- $csvText(implode(', ', [ $acl->getID(), $acl->getName(), $acl->getRawLabel() ])), // Keywords
- $csvText($acl->getRawOpis()), // Abstract
- 'EPSG:4326', // SRS
- "8.12328509871721", // LatLongBoundingBox - minx
- "38.8575126897477", // LatLongBoundingBox - miny
- "9.838674658246807", // LatLongBoundingBox - maxx
- "41.31378404137082", // LatLongBoundingBox - maxy
- ]);
- }, $aclList));
- echo $csvLineSepartor;
- echo implode($csvLineSepartor, array_map(function ($typeName) use ($csvText, $csvValueSepartor) {
- list($prefix, $name) = explode(':', $typeName);
- return implode($csvValueSepartor, [
- "p5_{$prefix}:{$name}", // Name
- $csvText($name), // Title
- Api_WfsNs::getNsUri($prefix), // namespace url
- $csvText($name), // Keywords
- $csvText($name), // Abstract
- 'EPSG:4326', // SRS
- "8.12328509871721", // LatLongBoundingBox - minx
- "38.8575126897477", // LatLongBoundingBox - miny
- "9.838674658246807", // LatLongBoundingBox - maxx
- "41.31378404137082", // LatLongBoundingBox - maxy
- ]);
- }, Core_AclHelper::getCustomAclList()));
- exit;
- }
- static function sendGetCapabilitiesXml($wpsServerUrl, $serviceTitle, $serviceDescription, $aclList) {
- throw new Api_WfsException("Not Implemented sendGetCapabilitiesXml for Wps version 1.0.0", 501);
- 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:Capabilities');
- $xmlWriter->writeAttribute('service', "WPS");
- $xmlWriter->writeAttribute('version', "2.0.0");
- // $xmlWriter->writeAttribute('xml:lang', "en-GB");
- $xmlWriter->writeAttribute('xmlns:xlink', "http://www.w3.org/1999/xlink");
- $xmlWriter->writeAttribute('xmlns:wps', "http://www.opengis.net/wps/1.0.0");
- $xmlWriter->writeAttribute('xmlns:ows', "http://www.opengis.net/ows/1.1");
- $xmlWriter->writeAttribute('xmlns:ogc', "http://www.opengis.net/ogc");
- $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");
- $xmlWriter->writeAttribute('updateSequence', "1");
- // $xmlWriter->writeAttribute('xmlns', 'http://www.opengis.net/wfs');
- // $xmlWriter->writeAttribute('xmlns:ogc', 'http://www.opengis.net/ogc');
- // $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
- 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));
- $xmlWriter->h('ows:ServiceIdentification', [
- ['ows:Title', $serviceTitle],
- ['ows:Abstract', $serviceDescription],
- ['ows:Keywords', [
- ['ows:Keyword', "WPS"],
- ] ],
- ['ows:ServiceType', "WPS"],
- ['ows:ServiceTypeVersion', "2.0.0"],
- ['ows:Fees', "NONE"],
- ['ows:AccessConstraints', "NONE"],
- ]);
- // <ows:ServiceProvider>
- // <ows:ProviderName>Agriculture and Agri-Food Canada</ows:ProviderName>
- // <ows:ProviderSite xlink:href="http://gis.agr.gc.ca/"/>
- // <ows:ServiceContact>
- // <ows:IndividualName>Peter Schut</ows:IndividualName>
- // <ows:PositionName>Information System Scientist</ows:PositionName>
- // <ows:ContactInfo>
- // <ows:Phone>
- // <ows:Voice>+1 613 759-1874</ows:Voice>
- // <ows:Facsimile>+1 613 759-1937</ows:Facsimile>
- // </ows:Phone>
- // <ows:Address>
- // <ows:DeliveryPoint>Room 1135, Neatby Building, 960, Carling Avenue</ows:DeliveryPoint>
- // <ows:City>Ottawa</ows:City>
- // <ows:AdministrativeArea>ON</ows:AdministrativeArea>
- // <ows:PostalCode>K1AOC6</ows:PostalCode>
- // <ows:Country>Canada</ows:Country>
- // <ows:ElectronicMailAddress>schutp@agr.gc.ca</ows:ElectronicMailAddress>
- // </ows:Address>
- // </ows:ContactInfo>
- // </ows:ServiceContact>
- // </ows:ServiceProvider>
- // $xmlWriter->h('ows:ServiceProvider', [
- // [ 'ows:ProviderName', "" ], // TODO: company name - from config?
- // [ 'ows:ProviderSite', [ 'xlink:href' => $wpsServerUrl ], null ],
- // // [ 'ows:ServiceContact', [
- // // [ 'ows:IndividualName', "..." ],
- // // ] ],
- // ]);
- //
- // $xmlWriter->h('ows:OperationsMetadata', [
- // [ 'ows:Operation', [ 'name' => "GetCapabilities" ], [
- // [ 'ows:DCP', [
- // [ 'ows:HTTP', [
- // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // ] ]
- // ] ]
- // ] ],
- // [ 'ows:Operation', [ 'name' => "DescribeProcess" ], [
- // [ 'ows:DCP', [
- // [ 'ows:HTTP', [
- // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
- // ] ]
- // ] ]
- // ] ],
- // [ 'ows:Operation', [ 'name' => "Execute" ], [
- // [ 'ows:DCP', [
- // [ 'ows:HTTP', [
- // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
- // ] ]
- // ] ]
- // ] ],
- // [ 'ows:Operation', [ 'name' => "GetStatus" ], [
- // [ 'ows:DCP', [
- // [ 'ows:HTTP', [
- // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
- // ] ]
- // ] ]
- // ] ],
- // [ 'ows:Operation', [ 'name' => "GetResult" ], [
- // [ 'ows:DCP', [
- // [ 'ows:HTTP', [
- // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
- // ] ]
- // ] ]
- // ] ],
- // [ 'ows:Operation', [ 'name' => "Dismiss" ], [
- // [ 'ows:DCP', [
- // [ 'ows:HTTP', [
- // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
- // ] ]
- // ] ]
- // ] ],
- // ]);
- // $xmlWriter->h('wps:ProcessOfferings', [ // TODO:? for version 1.0.0 ?
- // [ 'wps:Process', [ 'wps:processVersion' => "1" ], [
- // [ 'ows:Identifier', "buffer" ],
- // [ 'ows:Title', "Buffer a polygon feature" ],
- // [ 'ows:Abstract', "Buffer the polygon coordinates found in one GML stream by a given buffer distance, and output the results in GML." ],
- // [ 'ows:Metadata', [ 'xlink:title' => "buffer" ], null ],
- // [ 'ows:Metadata', [ 'xlink:title' => "polygon" ], null ],
- // ] ]
- // ]);
- // $xmlWriter->h('wps:Languages', [
- // [ 'wps:Default', [
- // [ 'ows:Language', "en-CA" ],
- // ] ],
- // [ 'wps:Supported', [
- // [ 'ows:Language', "pl-PL" ],
- // ] ]
- // ]);
- $xmlWriter->h('wps:Contents', [
- [ 'wps:ProcessSummary', [ 'jobControlOptions' => "sync-execute async-execute dismiss" ], [
- [ 'ows:Title', "example 1" ],
- [ 'ows:Identifier', "{$wpsServerUrl}/task/example1" ],
- ] ],
- [ 'wps:ProcessSummary', [ 'jobControlOptions' => "async-execute dismiss", 'processVersion' => "1.4.0" ], [
- [ 'ows:Title', "example 2" ],
- [ 'ows:Identifier', "{$wpsServerUrl}/task/example2" ],
- ] ],
- ]);
- $xmlWriter->h('wps:WSDL', [ 'xlink:href' => "http://foo.bar/wps?WSDL" ], null);
- $xmlWriter->endElement();// WFS_Capabilities
- $xmlWriter->endDocument();
- exit;
- }
- }
|