GetCapabilities.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. Lib::loadClass('Api_WfsException');
  3. Lib::loadClass('Api_WfsNs');
  4. Lib::loadClass('Request');
  5. Lib::loadClass('Core_AclHelper');
  6. Lib::loadClass('Core_XmlWriter');
  7. class Api_WpsV2_GetCapabilities { // TODO: ...
  8. static function sendGetCapabilitiesCsv($wpsServerUrl, $serviceTitle, $serviceDescription, $aclList) {
  9. throw new Api_WfsException("Not Implemented sendGetCapabilitiesCsv for Wps version 1.0.0", 501);
  10. header('Content-Type: text/csv; charset=utf-8');
  11. $csvLineSepartor = "\n";
  12. $csvValueSepartor = ",";
  13. $csvText = function ($value) {
  14. return '"' . str_replace(['"'], ['\"'], $value) . '"';
  15. };
  16. echo implode(",", [
  17. "Name",
  18. "Title",
  19. "namespace url",
  20. "Keywords",
  21. "Abstract",
  22. "SRS",
  23. "LatLongBoundingBox - minx",
  24. "LatLongBoundingBox - miny",
  25. "LatLongBoundingBox - maxx",
  26. "LatLongBoundingBox - maxy",
  27. ]);
  28. echo $csvLineSepartor;
  29. echo implode($csvLineSepartor, array_map(function ($acl) use ($csvText, $csvValueSepartor) {
  30. $ns = Core_AclHelper::parseNamespaceUrl($acl->getNamespace());
  31. return implode($csvValueSepartor, [
  32. "p5_{$ns['prefix']}:{$ns['name']}", // Name
  33. $csvText($acl->getRawLabel()), // Title
  34. Api_WfsNs::getNsUri($ns['prefix']), // namespace url
  35. $csvText(implode(', ', [ $acl->getID(), $acl->getName(), $acl->getRawLabel() ])), // Keywords
  36. $csvText($acl->getRawOpis()), // Abstract
  37. 'EPSG:4326', // SRS
  38. "8.12328509871721", // LatLongBoundingBox - minx
  39. "38.8575126897477", // LatLongBoundingBox - miny
  40. "9.838674658246807", // LatLongBoundingBox - maxx
  41. "41.31378404137082", // LatLongBoundingBox - maxy
  42. ]);
  43. }, $aclList));
  44. echo $csvLineSepartor;
  45. echo implode($csvLineSepartor, array_map(function ($typeName) use ($csvText, $csvValueSepartor) {
  46. list($prefix, $name) = explode(':', $typeName);
  47. return implode($csvValueSepartor, [
  48. "p5_{$prefix}:{$name}", // Name
  49. $csvText($name), // Title
  50. Api_WfsNs::getNsUri($prefix), // namespace url
  51. $csvText($name), // Keywords
  52. $csvText($name), // Abstract
  53. 'EPSG:4326', // SRS
  54. "8.12328509871721", // LatLongBoundingBox - minx
  55. "38.8575126897477", // LatLongBoundingBox - miny
  56. "9.838674658246807", // LatLongBoundingBox - maxx
  57. "41.31378404137082", // LatLongBoundingBox - maxy
  58. ]);
  59. }, Core_AclHelper::getCustomAclList()));
  60. exit;
  61. }
  62. static function sendGetCapabilitiesXml($wpsServerUrl, $serviceTitle, $serviceDescription, $aclList) {
  63. throw new Api_WfsException("Not Implemented sendGetCapabilitiesXml for Wps version 1.0.0", 501);
  64. header('Content-type: application/xml; charset=utf-8');
  65. $xmlWriter = new Core_XmlWriter();
  66. if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
  67. $xmlWriter->openUri('php://output');
  68. $xmlWriter->setIndent(true);
  69. $xmlWriter->startDocument('1.0','UTF-8');
  70. $xmlWriter->startElement('wps:Capabilities');
  71. $xmlWriter->writeAttribute('service', "WPS");
  72. $xmlWriter->writeAttribute('version', "2.0.0");
  73. // $xmlWriter->writeAttribute('xml:lang', "en-GB");
  74. $xmlWriter->writeAttribute('xmlns:xlink', "http://www.w3.org/1999/xlink");
  75. $xmlWriter->writeAttribute('xmlns:wps', "http://www.opengis.net/wps/1.0.0");
  76. $xmlWriter->writeAttribute('xmlns:ows', "http://www.opengis.net/ows/1.1");
  77. $xmlWriter->writeAttribute('xmlns:ogc', "http://www.opengis.net/ogc");
  78. $xmlWriter->writeAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
  79. // $xmlWriter->writeAttribute('xsi:schemaLocation', "http://www.opengis.net/wps/1.0.0 ../wpsGetCapabilities_response.xsd");
  80. $xmlWriter->writeAttribute('updateSequence', "1");
  81. // $xmlWriter->writeAttribute('xmlns', 'http://www.opengis.net/wfs');
  82. // $xmlWriter->writeAttribute('xmlns:ogc', 'http://www.opengis.net/ogc');
  83. // $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
  84. foreach (Api_WfsNs::getNsList() as $uri => $prefix) {
  85. $xmlWriter->writeAttribute("xmlns:{$prefix}", $uri);
  86. }
  87. $schemaLocations = [];
  88. //$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
  89. if (!empty($schemaLocations)) $xmlWriter->writeAttribute('xsi:schemaLocation', implode(' ', $schemaLocations));
  90. $xmlWriter->h('ows:ServiceIdentification', [
  91. ['ows:Title', $serviceTitle],
  92. ['ows:Abstract', $serviceDescription],
  93. ['ows:Keywords', [
  94. ['ows:Keyword', "WPS"],
  95. ] ],
  96. ['ows:ServiceType', "WPS"],
  97. ['ows:ServiceTypeVersion', "2.0.0"],
  98. ['ows:Fees', "NONE"],
  99. ['ows:AccessConstraints', "NONE"],
  100. ]);
  101. // <ows:ServiceProvider>
  102. // <ows:ProviderName>Agriculture and Agri-Food Canada</ows:ProviderName>
  103. // <ows:ProviderSite xlink:href="http://gis.agr.gc.ca/"/>
  104. // <ows:ServiceContact>
  105. // <ows:IndividualName>Peter Schut</ows:IndividualName>
  106. // <ows:PositionName>Information System Scientist</ows:PositionName>
  107. // <ows:ContactInfo>
  108. // <ows:Phone>
  109. // <ows:Voice>+1 613 759-1874</ows:Voice>
  110. // <ows:Facsimile>+1 613 759-1937</ows:Facsimile>
  111. // </ows:Phone>
  112. // <ows:Address>
  113. // <ows:DeliveryPoint>Room 1135, Neatby Building, 960, Carling Avenue</ows:DeliveryPoint>
  114. // <ows:City>Ottawa</ows:City>
  115. // <ows:AdministrativeArea>ON</ows:AdministrativeArea>
  116. // <ows:PostalCode>K1AOC6</ows:PostalCode>
  117. // <ows:Country>Canada</ows:Country>
  118. // <ows:ElectronicMailAddress>schutp@agr.gc.ca</ows:ElectronicMailAddress>
  119. // </ows:Address>
  120. // </ows:ContactInfo>
  121. // </ows:ServiceContact>
  122. // </ows:ServiceProvider>
  123. // $xmlWriter->h('ows:ServiceProvider', [
  124. // [ 'ows:ProviderName', "" ], // TODO: company name - from config?
  125. // [ 'ows:ProviderSite', [ 'xlink:href' => $wpsServerUrl ], null ],
  126. // // [ 'ows:ServiceContact', [
  127. // // [ 'ows:IndividualName', "..." ],
  128. // // ] ],
  129. // ]);
  130. //
  131. // $xmlWriter->h('ows:OperationsMetadata', [
  132. // [ 'ows:Operation', [ 'name' => "GetCapabilities" ], [
  133. // [ 'ows:DCP', [
  134. // [ 'ows:HTTP', [
  135. // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
  136. // ] ]
  137. // ] ]
  138. // ] ],
  139. // [ 'ows:Operation', [ 'name' => "DescribeProcess" ], [
  140. // [ 'ows:DCP', [
  141. // [ 'ows:HTTP', [
  142. // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
  143. // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
  144. // ] ]
  145. // ] ]
  146. // ] ],
  147. // [ 'ows:Operation', [ 'name' => "Execute" ], [
  148. // [ 'ows:DCP', [
  149. // [ 'ows:HTTP', [
  150. // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
  151. // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
  152. // ] ]
  153. // ] ]
  154. // ] ],
  155. // [ 'ows:Operation', [ 'name' => "GetStatus" ], [
  156. // [ 'ows:DCP', [
  157. // [ 'ows:HTTP', [
  158. // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
  159. // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
  160. // ] ]
  161. // ] ]
  162. // ] ],
  163. // [ 'ows:Operation', [ 'name' => "GetResult" ], [
  164. // [ 'ows:DCP', [
  165. // [ 'ows:HTTP', [
  166. // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
  167. // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
  168. // ] ]
  169. // ] ]
  170. // ] ],
  171. // [ 'ows:Operation', [ 'name' => "Dismiss" ], [
  172. // [ 'ows:DCP', [
  173. // [ 'ows:HTTP', [
  174. // [ 'ows:Get', [ 'xlink:href' => $wpsServerUrl ], null ],
  175. // [ 'ows:Post', [ 'xlink:href' => $wpsServerUrl ], null ],
  176. // ] ]
  177. // ] ]
  178. // ] ],
  179. // ]);
  180. // $xmlWriter->h('wps:ProcessOfferings', [ // TODO:? for version 1.0.0 ?
  181. // [ 'wps:Process', [ 'wps:processVersion' => "1" ], [
  182. // [ 'ows:Identifier', "buffer" ],
  183. // [ 'ows:Title', "Buffer a polygon feature" ],
  184. // [ 'ows:Abstract', "Buffer the polygon coordinates found in one GML stream by a given buffer distance, and output the results in GML." ],
  185. // [ 'ows:Metadata', [ 'xlink:title' => "buffer" ], null ],
  186. // [ 'ows:Metadata', [ 'xlink:title' => "polygon" ], null ],
  187. // ] ]
  188. // ]);
  189. // $xmlWriter->h('wps:Languages', [
  190. // [ 'wps:Default', [
  191. // [ 'ows:Language', "en-CA" ],
  192. // ] ],
  193. // [ 'wps:Supported', [
  194. // [ 'ows:Language', "pl-PL" ],
  195. // ] ]
  196. // ]);
  197. $xmlWriter->h('wps:Contents', [
  198. [ 'wps:ProcessSummary', [ 'jobControlOptions' => "sync-execute async-execute dismiss" ], [
  199. [ 'ows:Title', "example 1" ],
  200. [ 'ows:Identifier', "{$wpsServerUrl}/task/example1" ],
  201. ] ],
  202. [ 'wps:ProcessSummary', [ 'jobControlOptions' => "async-execute dismiss", 'processVersion' => "1.4.0" ], [
  203. [ 'ows:Title', "example 2" ],
  204. [ 'ows:Identifier', "{$wpsServerUrl}/task/example2" ],
  205. ] ],
  206. ]);
  207. $xmlWriter->h('wps:WSDL', [ 'xlink:href' => "http://foo.bar/wps?WSDL" ], null);
  208. $xmlWriter->endElement();// WFS_Capabilities
  209. $xmlWriter->endDocument();
  210. exit;
  211. }
  212. }