| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <?php
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('Api_WfsNs');
- Lib::loadClass('Request');
- Lib::loadClass('Core_AclHelper');
- Lib::loadClass('Core_XmlWriter');
- class Api_WpsV1_GetCapabilities { // TODO: ...
- static function sendGetCapabilitiesCsv($wpsServerUrl, $serviceTitle, $serviceDescription, $wpsProcessList) {
- 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
- ]);
- }, $wpsProcessList));
- 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, $wpsProcessList) {
- 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', "1.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: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:ogc', "http://www.opengis.net/ogc");
- // $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', "1.0.0"],
- // ['ows:Profile', ...],
- // Unordered list of identifiers of Application Profiles that are implemented by this server.
- // This element should be included for each specified application profile implemented by this server.
- // The identifier value should be specified by each Application Profile. If this element is omitted, no meaning is implied.
- // ['ows:Fees', "NONE"],
- // ['ows:AccessConstraints', "NONE"], // @from xsd: Unordered list of access constraints applied to assure the protection of privacy or intellectual property,
- // and any other restrictions on retrieving or using data from or otherwise using this server.
- // The reserved value NONE (case insensitive) shall be used to mean no access constraints are imposed.
- // When this element is omitted, no meaning is implied.
- ]);
- // @from http://schemas.opengis.net/wps/1.0.0/examples/20_wpsGetCapabilities_response.xml
- // <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', $_SERVER['SERVER_NAME'] ], // 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 ], // TODO: POST xml with DescribeProcess
- ] ]
- ] ]
- ] ],
- [ 'ows:Operation', [ 'name' => "Execute" ], [
- [ 'ows:DCP', [
- [ 'ows:HTTP', [
- [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
- // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ], // TODO: POST xml with DescribeProcess
- ] ]
- ] ]
- ] ],
- ]);
- // @from http://schemas.opengis.net/wps/1.0.0/examples/20_wpsGetCapabilities_response.xml
- // <wps:ProcessOfferings>
- // <wps:Process wps:processVersion="1">
- // <ows:Identifier>buffer</ows:Identifier>
- // <ows:Title>Buffer a polygon feature</ows:Title>
- // <ows:Abstract>Buffer the polygon coordinates found in one GML stream by a given buffer distance, and output the results in GML.</ows:Abstract>
- // <ows:Metadata xlink:title="buffer" />
- // <ows:Metadata xlink:title="polygon" />
- // </wps:Process>
- // </wps:ProcessOfferings>
- // <wps:Languages>
- // <wps:Default>
- // <ows:Language>en-CA</ows:Language>
- // </wps:Default>
- // <wps:Supported>
- // <ows:Language>en-CA</ows:Language>
- // <ows:Language>fr-CA</ows:Language>
- // </wps:Supported>
- // </wps:Languages>
- // </wps:Capabilities>
- $xmlWriter->h('wps:ProcessOfferings', array_map(function ($wpsProcess) {
- return [ 'wps:Process', [ 'wps:processVersion' => $wpsProcess->version ], [
- [ 'ows:Identifier', $wpsProcess->identifier ],
- [ 'ows:Title', $wpsProcess->title ],
- [ 'ows:Abstract', $wpsProcess->description ],
- ] ];
- }, $wpsProcessList));
- // $xmlWriter->h('wps:ProcessOfferings', [
- // [ 'wps:Process', [ 'wps:processVersion' => "1.0.0" ], [
- // [ '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." ],
- // ] ],
- // [ 'wps:Process', [ 'wps:processVersion' => "1.0.0" ], [
- // [ 'ows:Identifier', "JTS:area" ],
- // [ 'ows:Title', "Area" ],
- // [ 'ows:Abstract', "Returns 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." ],
- // ] ]
- // ]);
- $xmlWriter->h('wps:Languages', [
- [ 'wps:Default', [
- [ 'ows:Language', "en-GB" ],
- ] ],
- [ '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;
- }
- }
|