superedit-OPEN_LAYERS_WPS.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. <?php
  2. /**
  3. * http://openlayers.org/dev/examples/wps.html
  4. * http://geoinformatyka.com.pl/usluga-wfs-jak-to-dziala/
  5. *
  6. * TODO: brak ModifyFeature - html btn: olControlModifyFeatureItemInactive
  7. */
  8. function OPEN_LAYERS_WPS() {
  9. $task = V::get('task', '', $_GET);
  10. switch ($task) {
  11. case 'proxy':
  12. $url = V::get('url', '', $_GET);
  13. // 1. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DGetCapabilities
  14. // 2. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DDescribeProcess%26VERSION%3D1.0.0%26IDENTIFIER%3Dpozdrawiam
  15. header('Content-Type: application/xml; charset=utf-8');
  16. $urlParts = parse_url($url);
  17. $urlQuery = array();
  18. $urlQueryTmp = V::get('query', '', $urlParts);
  19. $urlQueryTmp = explode('&', $urlQueryTmp);
  20. foreach ($urlQueryTmp as $vQuery) {
  21. $parts = explode('=', $vQuery, 2);
  22. $urlQuery[$parts[0]] = $parts[1];
  23. }
  24. if ('WPS' == V::get('SERVICE', '', $urlQuery)) {
  25. $req = V::get('REQUEST', '', $urlQuery);
  26. $wps = new WpsServer();
  27. $methodName = "{$req}Action";
  28. if (method_exists($wps, $methodName)) {
  29. $wps->$methodName($urlQuery);
  30. }
  31. }
  32. exit;
  33. break;
  34. default:
  35. }
  36. //$_POST['url'] = 'http://demo.opengeo.org/geoserver/wfs';
  37. //$entityBody = file_get_contents('php://input');
  38. $url = V::get('_url', '', $_GET);
  39. if ($url) {// @see OpenLayers/examples/proxy.cgi
  40. $allowedHosts = array('www.openlayers.org', 'openlayers.org',
  41. 'labs.metacarta.com', 'world.freemap.in',
  42. 'prototype.openmnnd.org', 'geo.openplans.org',
  43. 'sigma.openplans.org', 'demo.opengeo.org',
  44. 'www.openstreetmap.org', 'sample.azavea.com',
  45. 'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080',
  46. 'vmap0.tiles.osgeo.org', 'www.openrouteservice.org',
  47. 'maps.wien.gv.at');
  48. if (!empty($_POST)) {
  49. // qs = os.environ["QUERY_STRING"]
  50. // d = cgi.parse_qs(qs)
  51. // if d.has_key("url"):
  52. // url = d["url"][0]
  53. // else:
  54. // url = "http://www.openlayers.org"
  55. }
  56. else {
  57. // fs = cgi.FieldStorage()
  58. // url = fs.getvalue('url', "http://www.openlayers.org")
  59. }
  60. $host = explode('/', $url);
  61. $host = $host[2];
  62. if (!in_array($host, $allowedHosts)) {
  63. header("Status: 502 Bad Gateway");
  64. header("Content-Type: text/plain");
  65. echo "\nThis proxy does not allow you to access that location ({$host}).";
  66. exit;
  67. }
  68. else if (substr($url, 0, 7) == 'http://' || substr($url, 0, 8) == 'https://') {
  69. $ch = curl_init();
  70. if (!empty($_POST)) {
  71. /*
  72. length = int(os.environ["CONTENT_LENGTH"])
  73. headers = {"Content-Type": os.environ["CONTENT_TYPE"]}
  74. body = sys.stdin.read(length)
  75. r = urllib2.Request(url, body, headers)
  76. y = urllib2.urlopen(r)
  77. */
  78. }
  79. else {
  80. curl_setopt($ch, CURLOPT_URL, $url);
  81. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// return the transfer as a string
  82. //curl_setopt($ch, CURLOPT_VERBOSE, 1);
  83. curl_setopt($ch, CURLOPT_HEADER, 1);
  84. $response = curl_exec($ch);
  85. // Then, after your curl_exec call:
  86. $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  87. $header = substr($response, 0, $header_size);
  88. $body = substr($response, $header_size);
  89. curl_close($ch);
  90. $contentType = 'text/plain';
  91. $headers = explode("\n", $header);
  92. foreach ($headers as $vHeader) {
  93. if (substr($vHeader, 0, 13) == 'Content-Type:') {
  94. $contentType = trim(substr($vHeader, 14));
  95. }
  96. }
  97. header("Content-Type: {$contentType}");
  98. echo $body . "\n";
  99. }
  100. }
  101. else {
  102. header("Content-Type: text/plain");
  103. echo "\nIllegal request.";
  104. exit;
  105. }
  106. exit;
  107. }
  108. ?>
  109. <link rel="stylesheet" href="stuff/open-layers/theme/default/style.css" type="text/css">
  110. <link rel="stylesheet" href="stuff/open-layers/style.css" type="text/css">
  111. <style type="text/css">
  112. .olControlEditingToolbar .olControlModifyFeatureItemInactive {
  113. background-image: url(stuff/open-layers/theme/default/img/draw_point_off.png);
  114. }
  115. .olControlEditingToolbar .olControlModifyFeatureItemActive {
  116. background-image: url(stuff/open-layers/theme/default/img/draw_point_on.png);
  117. }
  118. textarea {
  119. display: block;
  120. width: 100%;
  121. height: 3em;
  122. }
  123. label {
  124. display: block;
  125. }
  126. .notsupported {
  127. color: red;
  128. }
  129. button {
  130. display: block;
  131. margin-top: 10px;
  132. }
  133. #docs {
  134. top: 6em;
  135. left: 550px;
  136. position: absolute;
  137. margin-right: 10px;
  138. }
  139. </style>
  140. <h1 id="title">WPS Builder Example</h1>
  141. <div id="tags">
  142. wps, process, advanced
  143. </div>
  144. <div id="shortdesc">Using WPS formats to interact with WPS</div>
  145. <div id="docs">
  146. <p>This example shows WPS in action by using the WPSCapabilities,
  147. WPSDescribeProcess and WPSExecute formats. See
  148. <a target="_blank" href="wps.js">wps.js</a> for the
  149. source code. <b>Note: For applications using WPS, the high level
  150. approach shown in the <a href="wps-client.html">wps-client</a> example
  151. is recommended instead.</b></p>
  152. <ol>
  153. <li>Select a process from the list below the map. The list is
  154. populated with the result of a WPS GetCapabilities request, parsed
  155. using <code>OpenLayers.Format.WPSCapabilities::read</code>.</li>
  156. <li>Fill out the Input form. Hover over fields to get a description.
  157. Required fields are marked with a "*".
  158. To use a geometry from the map as input, select the geometry on the
  159. map (using the pen symbol on the left of the toolbar) and just
  160. click the field. The form is generated from the object returned by
  161. <code>OpenLayers.Format.WPSDescribeProcess::read</code></li>
  162. <li>Click "Execute" and examine the result in the result text area.
  163. If the result can be parsed as features, it will be displayed on
  164. the map as well. The process data is sent to the server with the
  165. serialized XML from <code>OpenLayers.Format.WPSExecute::write</code>,
  166. which can use a modified
  167. <code>OpenLayers.Format.WPSDescribeProcess</code> result object as
  168. input.</li>
  169. </ol>
  170. </div>
  171. <div id="example" style="width:520px">
  172. <div id="map" class="smallmap"></div>
  173. <div>
  174. <select id="processes"><option>Select a process</option></select>
  175. <p id="abstract"></p>
  176. <div id="input"></div>
  177. <div id="output"></div>
  178. </div>
  179. </div>
  180. <script src="stuff/open-layers/lib/OpenLayers.js"></script>
  181. <!-- <script src="stuff/open-layers/wps.js"></script> -->
  182. <script>
  183. //OpenLayers.ProxyHost = "proxy.cgi?url=";
  184. //OpenLayers.ProxyHost = "index.php?FUNCTION_INIT=OPEN_LAYERS_WPS&HEADER_NOT_INIT=YES&_url=";
  185. OpenLayers.ProxyHost = "index.php?FUNCTION_INIT=<?php echo __FUNCTION__; ?>&HEADER_NOT_INIT=YES&task=proxy&url=";
  186. var wps = 'http://biuro.biall-net.pl/wps',//"http://demo.opengeo.org/geoserver/wps",
  187. capabilities, // the capabilities, read by Format.WPSCapabilities::read
  188. process; // the process description from Format.WPSDescribeProcess::read
  189. // get some capabilities
  190. getCapabilities();
  191. // create the UI
  192. var layer = new OpenLayers.Layer.Vector("Scratchpad");
  193. /*
  194. var saveStrategy = new OpenLayers.Strategy.Save();
  195. var wfsLayer = new OpenLayers.Layer.Vector("Editable Features", {
  196. strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
  197. projection: new OpenLayers.Projection("EPSG:4326"),
  198. protocol: new OpenLayers.Protocol.WFS({
  199. version: "1.1.0",
  200. srsName: "EPSG:4326",
  201. url: "http://demo.opengeo.org/geoserver/wfs",
  202. featureNS : "http://opengeo.org",
  203. featureType: "restricted",
  204. geometryName: "the_geom",
  205. schema: "http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted",
  206. outputFormat: 'json'
  207. })
  208. });
  209. */
  210. var toolbar = new OpenLayers.Control.EditingToolbar(layer);
  211. toolbar.addControls([new OpenLayers.Control.ModifyFeature(layer, {
  212. title: "Select feature"
  213. })]);
  214. var map = new OpenLayers.Map('map', {
  215. controls: [
  216. toolbar,
  217. new OpenLayers.Control.ZoomPanel(),
  218. new OpenLayers.Control.PanPanel()
  219. ],
  220. layers: [
  221. new OpenLayers.Layer.WMS(
  222. "OSM", "http://maps.opengeo.org/geowebcache/service/wms",
  223. {layers: "openstreetmap", format: "image/png"}
  224. ),
  225. layer
  226. // , wfsLayer
  227. ]
  228. });
  229. map.zoomToMaxExtent();
  230. // add behavior to html elements
  231. document.getElementById("processes").onchange = describeProcess;
  232. // using OpenLayers.Format.WPSCapabilities to read the capabilities
  233. function getCapabilities() {
  234. OpenLayers.Request.GET({
  235. url: wps,
  236. params: {
  237. "SERVICE": "WPS",
  238. "REQUEST": "GetCapabilities"
  239. },
  240. success: function(response){
  241. capabilities = new OpenLayers.Format.WPSCapabilities().read(
  242. response.responseText
  243. );
  244. var dropdown = document.getElementById("processes");
  245. var offerings = capabilities.processOfferings, option;
  246. // populate the dropdown
  247. for (var p in offerings) {
  248. option = document.createElement("option");
  249. option.innerHTML = offerings[p].identifier;
  250. option.value = p;
  251. dropdown.appendChild(option);
  252. }
  253. }
  254. });
  255. }
  256. // using OpenLayers.Format.WPSDescribeProcess to get information about a
  257. // process
  258. function describeProcess() {
  259. var selection = this.options[this.selectedIndex].value;
  260. OpenLayers.Request.GET({
  261. url: wps,
  262. params: {
  263. "SERVICE": "WPS",
  264. "REQUEST": "DescribeProcess",
  265. "VERSION": capabilities.version,
  266. "IDENTIFIER": selection
  267. },
  268. success: function(response) {
  269. process = new OpenLayers.Format.WPSDescribeProcess().read(
  270. response.responseText
  271. ).processDescriptions[selection];
  272. buildForm();
  273. }
  274. });
  275. }
  276. // dynamically create a form from the process description
  277. function buildForm() {
  278. document.getElementById("abstract").innerHTML = process["abstract"];
  279. document.getElementById("input").innerHTML = "<h3>Input:</h3>";
  280. document.getElementById("output").innerHTML = "";
  281. var inputs = process.dataInputs, supported = true,
  282. sld = "text/xml; subtype=sld/1.0.0",
  283. input;
  284. for (var i=0,ii=inputs.length; i<ii; ++i) {
  285. input = inputs[i];
  286. if (input.complexData) {
  287. var formats = input.complexData.supported.formats;
  288. if (formats["application/wkt"]) {
  289. addWKTInput(input);
  290. } else if (formats["text/xml; subtype=wfs-collection/1.0"]) {
  291. addWFSCollectionInput(input);
  292. } else if (formats["image/tiff"]) {
  293. addRasterInput(input);
  294. } else if (formats[sld]) {
  295. addXMLInput(input, sld);
  296. } else {
  297. supported = false;
  298. }
  299. } else if (input.boundingBoxData) {
  300. addBoundingBoxInput(input);
  301. } else if (input.literalData) {
  302. addLiteralInput(input);
  303. } else {
  304. supported = false;
  305. }
  306. if (input.minOccurs > 0) {
  307. document.getElementById("input").appendChild(document.createTextNode("* "));
  308. }
  309. }
  310. if (supported) {
  311. var executeButton = document.createElement("button");
  312. executeButton.innerHTML = "Execute";
  313. document.getElementById("input").appendChild(executeButton);
  314. executeButton.onclick = execute;
  315. } else {
  316. document.getElementById("input").innerHTML = '<span class="notsupported">' +
  317. "Sorry, the WPS builder does not support the selected process." +
  318. "</span>";
  319. }
  320. }
  321. // helper function to dynamically create a textarea for geometry (WKT) data
  322. // input
  323. function addWKTInput(input, previousSibling) {
  324. var name = input.identifier;
  325. var container = document.getElementById("input");
  326. var label = document.createElement("label");
  327. label["for"] = name;
  328. label.title = input["abstract"];
  329. label.innerHTML = name + " (select feature, then click field):";
  330. previousSibling && previousSibling.nextSibling ?
  331. container.insertBefore(label, previousSibling.nextSibling) :
  332. container.appendChild(label);
  333. var field = document.createElement("textarea");
  334. field.onclick = function () {
  335. if (layer.selectedFeatures.length) {
  336. this.innerHTML = new OpenLayers.Format.WKT().write(
  337. layer.selectedFeatures[0]
  338. );
  339. }
  340. createCopy(input, this, addWKTInput);
  341. };
  342. field.onblur = function() {
  343. input.data = field.value ? {
  344. complexData: {
  345. mimeType: "application/wkt",
  346. value: this.value
  347. }
  348. } : undefined;
  349. };
  350. field.title = input["abstract"];
  351. field.id = name;
  352. previousSibling && previousSibling.nextSibling ?
  353. container.insertBefore(field, previousSibling.nextSibling.nextSibling) :
  354. container.appendChild(field);
  355. }
  356. // helper function for xml input
  357. function addXMLInput(input, type) {
  358. var name = input.identifier;
  359. var field = document.createElement("input");
  360. field.title = input["abstract"];
  361. field.value = name + " (" + type + ")";
  362. field.onblur = function() {
  363. input.data = field.value ? {
  364. complexData: {
  365. mimeType: type,
  366. value: this.value
  367. }
  368. } : undefined;
  369. };
  370. document.getElementById("input").appendChild(field);
  371. }
  372. // helper function to dynamically create a WFS collection reference input
  373. function addWFSCollectionInput(input) {
  374. var name = input.identifier;
  375. var field = document.createElement("input");
  376. field.title = input["abstract"];
  377. field.value = name + " (layer on demo server)";
  378. addValueHandlers(field, function() {
  379. input.reference = field.value ? {
  380. mimeType: "text/xml; subtype=wfs-collection/1.0",
  381. href: "http://geoserver/wfs",
  382. method: "POST",
  383. body: {
  384. wfs: {
  385. version: "1.0.0",
  386. outputFormat: "GML2",
  387. featureType: field.value
  388. }
  389. }
  390. } : undefined;
  391. });
  392. document.getElementById("input").appendChild(field);
  393. }
  394. // helper function to dynamically create a raster (GeoTIFF) url input
  395. function addRasterInput(input) {
  396. var name = input.identifier;
  397. var field = document.createElement("input");
  398. field.title = input["abstract"];
  399. var url = window.location.href.split("?")[0];
  400. field.value = url.substr(0, url.lastIndexOf("/")+1) + "data/tazdem.tiff";
  401. document.getElementById("input").appendChild(field);
  402. (field.onblur = function() {
  403. input.reference = {
  404. mimeType: "image/tiff",
  405. href: field.value,
  406. method: "GET"
  407. };
  408. })();
  409. }
  410. // helper function to dynamically create a bounding box input
  411. function addBoundingBoxInput(input) {
  412. var name = input.identifier;
  413. var field = document.createElement("input");
  414. field.title = input["abstract"];
  415. field.value = "left,bottom,right,top (EPSG:4326)";
  416. document.getElementById("input").appendChild(field);
  417. addValueHandlers(field, function() {
  418. input.boundingBoxData = {
  419. projection: "EPSG:4326",
  420. bounds: OpenLayers.Bounds.fromString(field.value)
  421. };
  422. });
  423. }
  424. // helper function to create a literal input textfield or dropdown
  425. function addLiteralInput(input, previousSibling) {
  426. var name = input.identifier;
  427. var container = document.getElementById("input");
  428. var anyValue = input.literalData.anyValue;
  429. // anyValue means textfield, otherwise we create a dropdown
  430. var field = document.createElement(anyValue ? "input" : "select");
  431. field.id = name;
  432. field.title = input["abstract"];
  433. previousSibling && previousSibling.nextSibling ?
  434. container.insertBefore(field, previousSibling.nextSibling) :
  435. container.appendChild(field);
  436. if (anyValue) {
  437. var dataType = input.literalData.dataType;
  438. field.value = name + (dataType ? " (" + dataType + ")" : "");
  439. addValueHandlers(field, function() {
  440. input.data = field.value ? {
  441. literalData: {
  442. value: field.value
  443. }
  444. } : undefined;
  445. createCopy(input, field, addLiteralInput);
  446. });
  447. } else {
  448. var option;
  449. option = document.createElement("option");
  450. option.innerHTML = name;
  451. field.appendChild(option);
  452. for (var v in input.literalData.allowedValues) {
  453. option = document.createElement("option");
  454. option.value = v;
  455. option.innerHTML = v;
  456. field.appendChild(option);
  457. }
  458. field.onchange = function() {
  459. createCopy(input, field, addLiteralInput);
  460. input.data = this.selectedIndex ? {
  461. literalData: {
  462. value: this.options[this.selectedIndex].value
  463. }
  464. } : undefined;
  465. };
  466. }
  467. }
  468. // if maxOccurs is > 1, this will add a copy of the field
  469. function createCopy(input, field, fn) {
  470. if (input.maxOccurs && input.maxOccurs > 1 && !field.userSelected) {
  471. // add another copy of the field - we don't check maxOccurs
  472. field.userSelected = true;
  473. var newInput = OpenLayers.Util.extend({}, input);
  474. // we recognize copies by the occurrence property
  475. newInput.occurrence = (input.occurrence || 0) + 1;
  476. process.dataInputs.push(newInput);
  477. fn(newInput, field);
  478. }
  479. }
  480. // helper function for adding events to form fields
  481. function addValueHandlers(field, onblur) {
  482. field.onclick = function() {
  483. if (!this.initialValue) {
  484. this.initialValue = this.value;
  485. this.value = "";
  486. }
  487. };
  488. field.onblur = function() {
  489. if (!this.value) {
  490. this.value = this.initialValue;
  491. delete this.initialValue;
  492. }
  493. onblur.apply(this, arguments);
  494. };
  495. }
  496. // execute the process
  497. function execute() {
  498. var output = process.processOutputs[0];
  499. var input;
  500. // remove occurrences that the user has not filled out
  501. for (var i=process.dataInputs.length-1; i>=0; --i) {
  502. input = process.dataInputs[i];
  503. if ((input.minOccurs === 0 || input.occurrence) && !input.data && !input.reference) {
  504. OpenLayers.Util.removeItem(process.dataInputs, input);
  505. }
  506. }
  507. process.responseForm = {
  508. rawDataOutput: {
  509. identifier: output.identifier
  510. }
  511. };
  512. if (output.complexOutput && output.complexOutput.supported.formats["application/wkt"]) {
  513. process.responseForm.rawDataOutput.mimeType = "application/wkt";
  514. }
  515. OpenLayers.Request.POST({
  516. url: wps,
  517. data: new OpenLayers.Format.WPSExecute().write(process),
  518. success: showOutput
  519. });
  520. }
  521. // add the process's output to the page
  522. function showOutput(response) {
  523. var result = document.getElementById("output");
  524. result.innerHTML = "<h3>Output:</h3>";
  525. var features;
  526. var contentType = response.getResponseHeader("Content-Type");
  527. if (contentType == "application/wkt") {
  528. features = new OpenLayers.Format.WKT().read(response.responseText);
  529. } else if (contentType == "text/xml; subtype=wfs-collection/1.0") {
  530. features = new OpenLayers.Format.WFST.v1_0_0().read(response.responseText);
  531. }
  532. if (features && (features instanceof OpenLayers.Feature.Vector || features.length)) {
  533. layer.addFeatures(features);
  534. result.innerHTML += "The result should also be visible on the map.";
  535. }
  536. result.innerHTML += "<textarea>" + response.responseText + "</textarea>";
  537. }
  538. </script>
  539. <?php
  540. function get_location($ip) {
  541. $content = @file_get_contents('http://api.hostip.info/?ip='.$ip);
  542. if ($content != FALSE) {
  543. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">content (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($content);echo'</pre>';
  544. $xml = new SimpleXmlElement($content);
  545. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">xml (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($xml);echo'</pre>';
  546. $coordinates = $xml->children('gml', TRUE)->featureMember->children('', TRUE)->Hostip->ipLocation->children('gml', TRUE)->pointProperty->Point->coordinates;
  547. $longlat = explode(',', $coordinates);
  548. $location['longitude'] = $longlat[0];
  549. $location['latitude'] = $longlat[1];
  550. $location['citystate'] = '==>'.$xml->children('gml', TRUE)->featureMember->children('', TRUE)->Hostip->children('gml', TRUE)->name;
  551. $location['country'] = '==>'.$xml->children('gml', TRUE)->featureMember->children('', TRUE)->Hostip->countryName;
  552. return $location;
  553. }
  554. else return false;
  555. }
  556. $ip = '94.158.130.34';// biuro.biall-net.pl
  557. $location_info = get_location($ip);
  558. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">location_info('.$ip.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($location_info);echo'</pre>';
  559. /*
  560. $the_xml = file_get_contents('');
  561. $feed = new SimpleXMLElement($the_xml);
  562. $namespaces = $feed->getNamespaces(true);
  563. foreach ($feed->entry as $entry) {
  564. $event = $entry->children($namespaces['gd']);
  565. echo "<p>Event = " . $entry->title . "<br />startTime = " . $event->when->startTime . " and endTime = " . $event->when->endTime . "</p>\n";
  566. }
  567. */
  568. }
  569. class WpsServer {
  570. public function getCapabilitiesAction() {
  571. echo '<?xml version="1.0" encoding="UTF-8"?>';
  572. ?>
  573. <wps:Capabilities xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" service="WPS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  574. <ows:ServiceIdentification>
  575. <ows:Title>Prototype GeoServer WPS</ows:Title>
  576. <ows:Abstract />
  577. <ows:Keywords>
  578. <ows:Keyword>wps</ows:Keyword>
  579. <ows:Keyword>geoserver</ows:Keyword>
  580. </ows:Keywords>
  581. <ows:ServiceType>WPS</ows:ServiceType>
  582. <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
  583. <ows:Fees>NONE</ows:Fees>
  584. <ows:AccessConstraints>NONE</ows:AccessConstraints>
  585. </ows:ServiceIdentification>
  586. <ows:ServiceProvider>
  587. <ows:ProviderName>GeoServer</ows:ProviderName>
  588. <ows:ProviderSite />
  589. <ows:ServiceContact />
  590. </ows:ServiceProvider>
  591. <ows:OperationsMetadata>
  592. <ows:Operation name="GetCapabilities">
  593. <ows:DCP>
  594. <ows:HTTP>
  595. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  596. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  597. </ows:HTTP>
  598. </ows:DCP>
  599. </ows:Operation>
  600. <ows:Operation name="DescribeProcess">
  601. <ows:DCP>
  602. <ows:HTTP>
  603. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  604. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  605. </ows:HTTP>
  606. </ows:DCP>
  607. </ows:Operation>
  608. <ows:Operation name="Execute">
  609. <ows:DCP>
  610. <ows:HTTP>
  611. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  612. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  613. </ows:HTTP>
  614. </ows:DCP>
  615. </ows:Operation>
  616. </ows:OperationsMetadata>
  617. <wps:ProcessOfferings>
  618. <wps:Process wps:processVersion="1.0.0">
  619. <ows:Identifier>pozdrawiam</ows:Identifier>
  620. <ows:Title>Area</ows:Title>
  621. <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.</ows:Abstract>
  622. </wps:Process>
  623. </wps:ProcessOfferings>
  624. <wps:Languages>
  625. <wps:Default>
  626. <ows:Language>en-US</ows:Language>
  627. </wps:Default>
  628. <wps:Supported>
  629. <ows:Language>en-US</ows:Language>
  630. </wps:Supported>
  631. </wps:Languages>
  632. </wps:Capabilities>
  633. <?php
  634. }
  635. public function DescribeProcess($args) {
  636. // TODO: xml z opiesem procese $args['IDENTIFIER']
  637. /**
  638. * should work like JTS:densify - geom field (map object) and integer field (record ID)
  639. * http://openlayers.org/dev/examples/proxy.cgi?url=http%3A%2F%2Fdemo.opengeo.org%2Fgeoserver%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DDescribeProcess%26VERSION%3D1.0.0%26IDENTIFIER%3DJTS%253Adensify
  640. * http://demo.opengeo.org/geoserver/wps?SERVICE=WPS&REQUEST=DescribeProcess&VERSION=1.0.0&IDENTIFIER=JTS%3Adensify
  641. */
  642. echo '<?xml version="1.0" encoding="UTF-8"?>';
  643. ?>
  644. <wps:ProcessDescriptions xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" service="WPS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  645. <ProcessDescription wps:processVersion="1.0.0" statusSupported="true" storeSupported="true">
  646. <ows:Identifier>JTS:densify</ows:Identifier>
  647. <ows:Title>Densify</ows:Title>
  648. <ows:Abstract>Returns a spatially equivalent geometry with vertices added to ensure line segments are no longer than a given distance.</ows:Abstract>
  649. <DataInputs>
  650. <Input maxOccurs="1" minOccurs="1">
  651. <ows:Identifier>geom</ows:Identifier>
  652. <ows:Title>geom</ows:Title>
  653. <ows:Abstract>Input geometry</ows:Abstract>
  654. <ComplexData>
  655. <Default>
  656. <Format>
  657. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  658. </Format>
  659. </Default>
  660. <Supported>
  661. <Format>
  662. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  663. </Format>
  664. <Format>
  665. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  666. </Format>
  667. <Format>
  668. <MimeType>application/wkt</MimeType>
  669. </Format>
  670. <Format>
  671. <MimeType>application/gml-3.1.1</MimeType>
  672. </Format>
  673. <Format>
  674. <MimeType>application/gml-2.1.2</MimeType>
  675. </Format>
  676. </Supported>
  677. </ComplexData>
  678. </Input>
  679. <Input maxOccurs="1" minOccurs="1">
  680. <ows:Identifier>distance</ows:Identifier>
  681. <ows:Title>distance</ows:Title>
  682. <ows:Abstract>The maximum segment length in the result, in the units of the geometry</ows:Abstract>
  683. <LiteralData>
  684. <ows:DataType>xs:double</ows:DataType>
  685. <ows:AnyValue />
  686. </LiteralData>
  687. </Input>
  688. </DataInputs>
  689. <ProcessOutputs>
  690. <Output>
  691. <ows:Identifier>result</ows:Identifier>
  692. <ows:Title>result</ows:Title>
  693. <ComplexOutput>
  694. <Default>
  695. <Format>
  696. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  697. </Format>
  698. </Default>
  699. <Supported>
  700. <Format>
  701. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  702. </Format>
  703. <Format>
  704. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  705. </Format>
  706. <Format>
  707. <MimeType>application/wkt</MimeType>
  708. </Format>
  709. <Format>
  710. <MimeType>application/gml-3.1.1</MimeType>
  711. </Format>
  712. <Format>
  713. <MimeType>application/gml-2.1.2</MimeType>
  714. </Format>
  715. </Supported>
  716. </ComplexOutput>
  717. </Output>
  718. </ProcessOutputs>
  719. </ProcessDescription>
  720. </wps:ProcessDescriptions>
  721. <?php
  722. }
  723. }