TableAjaxMap.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. <?php
  2. /**
  3. * usage:
  4. *
  5. <script>
  6. jQuery('#TreeTableMap').TableAjaxMap({
  7. wpsUrl: 'http://biuro.biall-net.pl/wps',
  8. wfsUrl: 'http://biuro.biall-net.pl/wps'
  9. });
  10. </script>
  11. *
  12. */
  13. class TableAjaxMap {
  14. private $_acl;
  15. private $_zasobID;
  16. private $_width;
  17. private $_height;
  18. public function __construct($tblAcl, $width = 512, $height = 256) {
  19. $this->_acl = $tblAcl;
  20. $this->_zasobID = $tblAcl->getID();
  21. $this->_width = $width;
  22. $this->_height = $height;
  23. }
  24. public function printCSS() {
  25. // <link rel="stylesheet" href="stuff/open-layers/theme/default/style.css" type="text/css">
  26. // <link rel="stylesheet" href="stuff/open-layers/style.css" type="text/css">
  27. ?>
  28. <style type="text/css">
  29. .TableAjaxMap { width:100%; height:<?php echo $this->_height; ?>px; }
  30. .olControlEditingToolbar .olControlModifyFeatureItemInactive { background-image:url(stuff/open-layers/theme/default/img/draw_point_off.png); }
  31. .olControlEditingToolbar .olControlModifyFeatureItemActive { background-image:url(stuff/open-layers/theme/default/img/draw_point_on.png); }
  32. .olControlEditingToolbar .olControlRefreshItemInactive { background-image: url(stuff/open-layers/theme/default/img/refresh_feature_off.png); }
  33. .olControlEditingToolbar .olControlRefreshItemActive { background-image: url(stuff/open-layers/theme/default/img/refresh_feature_on.png); }
  34. .olControlEditingToolbar .olControlSaveItemInactive { background-image: url(stuff/open-layers/theme/default/img/save_features_off.png); }
  35. .olControlEditingToolbar .olControlSaveItemActive { background-image: url(stuff/open-layers/theme/default/img/save_features_on.png); }
  36. .olControlLayerSwitcher .layersDiv { border-radius:10px 0 0 10px; opacity:0.75; filter:alpha(opacity=75); }
  37. .notsupported { color:red; }
  38. .TableAjaxMap .layersDiv input { margin:0; }
  39. .TableAjaxMap .layersDiv label { display:inline; }
  40. </style>
  41. <?php
  42. }
  43. public function printJS() {
  44. ?>
  45. <script src="stuff/open-layers/OpenLayers.js"></script>
  46. <script>
  47. OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_task=PROXY&url=";
  48. (function( $ ) {
  49. var TableAjaxMap = function() {
  50. var priv = {}; //private api
  51. var publ = {}; //public api
  52. priv.options = {};
  53. var defaults = {
  54. wpsUrl: '',
  55. wfsUrl: '',
  56. layerName: 'Warstwa rysowania',
  57. debug: false
  58. };
  59. var _nodeMapId;
  60. var _nodeMap;
  61. var _nodeProcesses;
  62. var _nodeAbstract;
  63. var _nodeInput;
  64. var _nodeOutput;
  65. var _capabilities;
  66. var _process;
  67. var _layer;
  68. var _map;
  69. /*
  70. initialize the plugin.
  71. */
  72. priv.init = function() {
  73. /*
  74. <div id="map" class="TableAjaxMap"></div>
  75. <div>
  76. <select id="processes"><option>Select a process</option></select>
  77. <p id="abstract"></p>
  78. <div id="input"></div>
  79. <div id="output"></div>
  80. </div>
  81. */
  82. _nodeMapId = 'Map-' + Math.random(1).toString().substr(2);
  83. _nodeMap = $('<div id="' + _nodeMapId + '" class="TableAjaxMap"></div>');
  84. _nodeProcesses = $('<select></select>');
  85. _nodeProcesses.append('<option>Wybierz funkcję</option>');
  86. _nodeAbstract = $('<p></p>');
  87. _nodeInput = $('<div></div>');
  88. _nodeOutput = $('<div></div>');
  89. _selectedFeature = null;
  90. _selectedRecordId = 0;
  91. var div = $('<div></div>');
  92. div.append(_nodeProcesses);
  93. div.append(_nodeAbstract);
  94. div.append(_nodeInput);
  95. div.append(_nodeOutput);
  96. $(priv.options.id).append(_nodeMap);
  97. $(priv.options.id).append(div);
  98. _nodeProcesses.on('change', function() {
  99. console.log("onchange this:", this, this.selectedIndex, this.options);
  100. var selection = this.options[this.selectedIndex].value;
  101. if (this.selectedIndex > 0) {
  102. OpenLayers.Request.GET({
  103. url: priv.options.wpsUrl,
  104. params: {
  105. "SERVICE": "WPS",
  106. "REQUEST": "DescribeProcess",
  107. "VERSION": _capabilities.version,
  108. "IDENTIFIER": selection
  109. },
  110. success: function(response) {
  111. _process = new OpenLayers.Format.WPSDescribeProcess().read(
  112. response.responseText
  113. ).processDescriptions[selection];
  114. console.log("Process:", _process);
  115. priv.buildForm();
  116. }
  117. });
  118. }
  119. });
  120. priv.getCapabilities();
  121. _layer = new OpenLayers.Layer.Vector(priv.options.layerName, {
  122. strategies: [new OpenLayers.Strategy.BBOX()],
  123. projection: new OpenLayers.Projection("EPSG:4326"),
  124. protocol: new OpenLayers.Protocol.WFS({
  125. version: "1.1.0",
  126. srsName: "EPSG:4326",
  127. url: priv.options.wfsUrl,
  128. featureNS : "http://opengeo.org",
  129. featureType: "restricted",
  130. geometryName: "the_geom",
  131. schema: "http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted"
  132. }),
  133. styleMap: new OpenLayers.StyleMap({
  134. 'default': new OpenLayers.Style(null, {
  135. rules: [
  136. new OpenLayers.Rule({
  137. symbolizer: {
  138. stroke: true,
  139. fill: true,
  140. fillColor: "#90EE90",
  141. strokeColor: "#90EE90",
  142. }
  143. })
  144. , new OpenLayers.Rule({
  145. symbolizer: {
  146. stroke: true,
  147. fill: true,
  148. fillColor: "#ee9900",
  149. strokeColor: "#ee9900",
  150. },
  151. filter: new OpenLayers.Filter.Comparison({
  152. type: OpenLayers.Filter.Comparison.GREATER_THAN,
  153. property: "recordId",
  154. value: 0
  155. })
  156. })
  157. , new OpenLayers.Rule({
  158. symbolizer: {
  159. stroke: true,
  160. fill: true,
  161. fillColor: "#ff0000",
  162. strokeColor: "#ff0000",
  163. },
  164. filter: new OpenLayers.Filter.Comparison({
  165. type: OpenLayers.Filter.Comparison.GREATER_THAN,
  166. property: "_newRecordId",
  167. value: 0
  168. })
  169. })
  170. , new OpenLayers.Rule({
  171. symbolizer: {
  172. stroke: true,
  173. fill: true,
  174. fillColor: "#ff0000",
  175. strokeColor: "#ff0000",
  176. },
  177. filter: new OpenLayers.Filter.Comparison({
  178. type: OpenLayers.Filter.Comparison.GREATER_THAN,
  179. property: "_modified",
  180. value: 0
  181. })
  182. })
  183. ]
  184. })
  185. })
  186. });
  187. _layer.events.on({
  188. 'beforefeaturemodified': function(e) {
  189. console.log('Event: beforefeaturemodified modified(', e.feature.attributes._modified, ')', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
  190. // NOTE: beforefeaturemodified from new node is fired before afterfeaturemodified from old node when click from one node to enother
  191. priv.checkSelectedFeatureModifications('before');
  192. priv.setSelectedFeature(e.feature);
  193. },
  194. 'featuremodified': function(e) {
  195. console.log('Event: featuremodified modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
  196. _selectedFeature.attributes._modified = 1;
  197. },
  198. 'afterfeaturemodified': function(e) {
  199. console.log('Event: afterfeaturemodified fid('+e.feature.fid+'/'+(_selectedFeature ? _selectedFeature.fid : 'null')+') modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
  200. if (_selectedFeature && _selectedFeature.fid != e.feature.fid) {
  201. console.log('Event: afterfeaturemodified pomiń check!');
  202. } else {
  203. priv.checkSelectedFeatureModifications('after');
  204. priv.setSelectedFeature(null);
  205. }
  206. }
  207. });
  208. var toolbar = new OpenLayers.Control.EditingToolbar(_layer);
  209. toolbar.addControls([
  210. new OpenLayers.Control.ModifyFeature(_layer, {
  211. title: "Edytuj"
  212. , mode: OpenLayers.Control.ModifyFeature.DRAG | OpenLayers.Control.ModifyFeature.RESHAPE
  213. })
  214. ]);
  215. toolbar.addControls([
  216. new OpenLayers.Control.SelectFeature(_layer, {
  217. title: "Select Test",
  218. clickout: false,
  219. toggle: false,
  220. multiple: false,
  221. hover: false,
  222. toggleKey: "ctrlKey", // ctrl key removes from selection
  223. multipleKey: "shiftKey", // shift key adds to selection
  224. box: true
  225. })
  226. ]);
  227. toolbar.addControls([
  228. new OpenLayers.Control.Button({
  229. title: "Refresh",
  230. displayClass: "olControlRefresh",
  231. trigger: function() {
  232. _layer.refresh({force: true});
  233. }
  234. })
  235. ]);
  236. toolbar.addControls([
  237. new OpenLayers.Control.Button({
  238. title: "Zapisz zmiany",
  239. displayClass: "olControlSave",
  240. trigger: function() {
  241. if (_selectedFeature) {
  242. if (!_selectedRecordId) {
  243. alert('Wybierz rekord tabeli');
  244. }
  245. else {
  246. priv.saveSelectedFeature();
  247. priv.cancelSelectedFeatureModifications();
  248. }
  249. }
  250. else {
  251. alert('Wybierz element na mapie');
  252. }
  253. }
  254. })
  255. ]);
  256. var gphy = new OpenLayers.Layer.OSM("Mapa", null, {
  257. resolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
  258. 19567.87923828125, 9783.939619140625, 4891.9698095703125,
  259. 2445.9849047851562, 1222.9924523925781, 611.4962261962891,
  260. 305.74811309814453, 152.87405654907226, 76.43702827453613,
  261. 38.218514137268066, 19.109257068634033, 9.554628534317017,
  262. 4.777314267158508, 2.388657133579254, 1.194328566789627,
  263. 0.5971642833948135, 0.25, 0.1, 0.05],
  264. serverResolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
  265. 19567.87923828125, 9783.939619140625,
  266. 4891.9698095703125, 2445.9849047851562,
  267. 1222.9924523925781, 611.4962261962891,
  268. 305.74811309814453, 152.87405654907226,
  269. 76.43702827453613, 38.218514137268066,
  270. 19.109257068634033, 9.554628534317017,
  271. 4.777314267158508, 2.388657133579254,
  272. 1.194328566789627, 0.5971642833948135],
  273. transitionEffect: 'resize'
  274. });
  275. /* NOTE: map is in projection EPSG:900913 even if projection and displayProjection is set to EPSG:4326
  276. * _map.getProjectionObject(); returns EPSG:900913
  277. * restrictedExtent should be set in EPSG:900913
  278. * zoomToExtent should use EPSG:900913 - need to transform from EPSG:4326 to EPSG:900913
  279. */
  280. _map = new OpenLayers.Map(_nodeMapId, {
  281. projection: new OpenLayers.Projection("EPSG:4326"),
  282. displayProjection: new OpenLayers.Projection("EPSG:4326"),
  283. restrictedExtent: new OpenLayers.Bounds(
  284. 2035059.4410645328, 7200979.560689885, 2113330.958028555, 7279251.0776539035
  285. //18.281250002544773, 54.16243397333987, 18.984375002642665, 54.57206166093501
  286. ),
  287. controls: [
  288. toolbar,
  289. new OpenLayers.Control.ZoomPanel(),
  290. new OpenLayers.Control.PanPanel(),
  291. new OpenLayers.Control.LayerSwitcher(),
  292. new OpenLayers.Control.ScaleLine(),
  293. new OpenLayers.Control.KeyboardDefaults()
  294. ],
  295. layers: [gphy,_layer]
  296. });
  297. _map.zoomToMaxExtent();
  298. };
  299. priv.updateState = function() {
  300. // TODO: update state view
  301. //console.log('updateState: _selectedFeature:', _selectedFeature, ' _selectedRecordId:', _selectedRecordId);
  302. if (_selectedFeature || _selectedRecordId) {
  303. } else {
  304. }
  305. };
  306. priv.setSelectedFeature = function(feature) {
  307. _selectedFeature = feature;
  308. priv.updateState();
  309. };
  310. priv.setSelectedRecordId = function(id) {
  311. _selectedRecordId = id;
  312. priv.updateState();
  313. };
  314. priv.getSelectedRecordId = function() {
  315. return _selectedRecordId;
  316. };
  317. priv.isSelectedRecordId = function() {
  318. return _selectedRecordId > 0;
  319. };
  320. priv.isSelectedFeature = function() {
  321. console.log('_selectedFeature:', _selectedFeature);
  322. return (_selectedFeature)? true : false;
  323. };
  324. priv.cancelSelectedFeatureModifications = function() {
  325. if (!_selectedFeature) return false;
  326. if (_selectedFeature.attributes._newRecordId) {
  327. delete _selectedFeature.attributes._newRecordId;
  328. }
  329. if (_selectedFeature.attributes._modified) {
  330. delete _selectedFeature.attributes._modified;
  331. }
  332. };
  333. priv.isSelectedFeatureModified = function() {
  334. if (!_selectedFeature) return false;
  335. if (_selectedFeature.attributes) {
  336. if (_selectedFeature.attributes._newRecordId) {
  337. return true;
  338. }
  339. if (_selectedFeature.attributes._modified) {
  340. return true;
  341. }
  342. }
  343. };
  344. priv.saveSelectedFeature = function() {
  345. if (priv.isSelectedFeatureModified()) {
  346. if (typeof priv.options.onSaveFeature == "function") {
  347. var selFeatureExtent = new OpenLayers.Format.WKT().write(_selectedFeature);
  348. priv.options.onSaveFeature.call(this, _selectedRecordId, selFeatureExtent);
  349. }
  350. }
  351. }
  352. priv.checkSelectedFeatureModifications = function(when) {
  353. if (priv.isSelectedFeatureModified()) {
  354. if (confirm('Czy zapisać zmiany wprowadzone dla zaznaczonego elementu?')) {
  355. // _layer.refresh();
  356. priv.saveSelectedFeature();
  357. priv.cancelSelectedFeatureModifications();
  358. }
  359. else {
  360. priv.cancelSelectedFeatureModifications();
  361. _layer.refresh({force:true});
  362. }
  363. }
  364. };
  365. // using OpenLayers.Format.WPSCapabilities to read the capabilities
  366. priv.getCapabilities = function() {
  367. OpenLayers.Request.GET({
  368. url: priv.options.wpsUrl,
  369. params: {
  370. "SERVICE": "WPS",
  371. "REQUEST": "GetCapabilities"
  372. },
  373. success: function(response){
  374. _capabilities = new OpenLayers.Format.WPSCapabilities().read(
  375. response.responseText
  376. );
  377. var dropdown = _nodeProcesses;
  378. var offerings = _capabilities.processOfferings, option;
  379. // populate the dropdown
  380. for (var p in offerings) {
  381. option = document.createElement("option");
  382. option.innerHTML = offerings[p].identifier;
  383. option.value = p;
  384. dropdown.append(option);
  385. }
  386. }
  387. });
  388. };
  389. priv.buildForm = function() {
  390. _nodeAbstract.html(_process["abstract"]);
  391. _nodeInput.html("<h3>Input:</h3>");
  392. _nodeOutput.html('');
  393. var inputs = _process.dataInputs, supported = true,
  394. sld = "text/xml; subtype=sld/1.0.0",
  395. input;
  396. for (var i = 0, ii = inputs.length; i < ii; ++i) {
  397. input = inputs[i];
  398. if (input.complexData) {
  399. var formats = input.complexData.supported.formats;
  400. if (formats["application/wkt"]) {
  401. priv.addWKTInput(input);
  402. } else if (formats["text/xml; subtype=wfs-collection/1.0"]) {
  403. priv.addWFSCollectionInput(input);
  404. } else if (formats["image/tiff"]) {
  405. //priv.addRasterInput(input);
  406. } else if (formats[sld]) {
  407. priv.addXMLInput(input, sld);
  408. } else {
  409. supported = false;
  410. }
  411. } else if (input.boundingBoxData) {
  412. priv.addBoundingBoxInput(input);
  413. } else if (input.literalData) {
  414. priv.addLiteralInput(input);
  415. } else {
  416. supported = false;
  417. }
  418. if (input.minOccurs > 0) {
  419. _nodeInput.append(document.createTextNode("* "));
  420. }
  421. }
  422. if (supported) {
  423. var executeButton = document.createElement("button");
  424. executeButton.innerHTML = "Execute";
  425. _nodeInput.append(executeButton);
  426. executeButton.onclick = priv.execute;
  427. } else {
  428. _nodeInput.html('<span class="notsupported">' +
  429. "Sorry, the WPS builder does not support the selected process." +
  430. "</span>");
  431. }
  432. };
  433. // helper function to dynamically create a textarea for geometry (WKT) data
  434. // input
  435. priv.addWKTInput = function(input, previousSibling) {
  436. var name = input.identifier;
  437. var container = _nodeInput.get(0);
  438. var label = document.createElement("label");
  439. label["for"] = name;
  440. label.title = input["abstract"];
  441. label.innerHTML = name + " (select feature, then click field):";
  442. previousSibling && previousSibling.nextSibling ?
  443. container.insertBefore(label, previousSibling.nextSibling) :
  444. container.appendChild(label);
  445. var field = document.createElement("textarea");
  446. field.onclick = function () {
  447. if (_layer.selectedFeatures.length) {
  448. this.innerHTML = new OpenLayers.Format.WKT().write(
  449. _layer.selectedFeatures[0]
  450. );
  451. console.log('_layer.selectedFeatures[0]: ', _layer.selectedFeatures[0]);
  452. }
  453. priv.createCopy(input, this, priv.addWKTInput);
  454. };
  455. field.onblur = function() {
  456. input.data = field.value ? {
  457. complexData: {
  458. mimeType: "application/wkt",
  459. value: this.value
  460. }
  461. } : undefined;
  462. };
  463. field.title = input["abstract"];
  464. field.id = name;
  465. previousSibling && previousSibling.nextSibling ?
  466. container.insertBefore(field, previousSibling.nextSibling.nextSibling) :
  467. container.appendChild(field);
  468. };
  469. // helper function for xml input
  470. priv.addXMLInput = function(input, type) {
  471. var name = input.identifier;
  472. var field = document.createElement("input");
  473. field.title = input["abstract"];
  474. field.value = name + " (" + type + ")";
  475. field.onblur = function() {
  476. input.data = field.value ? {
  477. complexData: {
  478. mimeType: type,
  479. value: this.value
  480. }
  481. } : undefined;
  482. };
  483. _nodeInput.append(field);
  484. };
  485. // helper function to dynamically create a WFS collection reference input
  486. priv.addWFSCollectionInput = function(input) {
  487. var name = input.identifier;
  488. var field = document.createElement("input");
  489. field.title = input["abstract"];
  490. field.value = name + " (layer on demo server)";
  491. priv.addValueHandlers(field, function() {
  492. input.reference = field.value ? {
  493. mimeType: "text/xml; subtype=wfs-collection/1.0",
  494. href: "http://geoserver/wfs",
  495. method: "POST",
  496. body: {
  497. wfs: {
  498. version: "1.0.0",
  499. outputFormat: "GML2",
  500. featureType: field.value
  501. }
  502. }
  503. } : undefined;
  504. });
  505. _nodeInput.append(field);
  506. };
  507. // helper function to dynamically create a raster (GeoTIFF) url input
  508. priv.addRasterInput = function(input) {
  509. var name = input.identifier;
  510. var field = document.createElement("input");
  511. field.title = input["abstract"];
  512. var url = window.location.href.split("?")[0];
  513. field.value = url.substr(0, url.lastIndexOf("/")+1) + "data/tazdem.tiff";// TODO: file path to options
  514. document.getElementById("input").appendChild(field);
  515. (field.onblur = function() {
  516. input.reference = {
  517. mimeType: "image/tiff",
  518. href: field.value,
  519. method: "GET"
  520. };
  521. })();
  522. };
  523. // helper function to dynamically create a bounding box input
  524. priv.addBoundingBoxInput = function(input) {
  525. var name = input.identifier;
  526. var field = document.createElement("input");
  527. field.title = input["abstract"];
  528. field.value = "left,bottom,right,top (EPSG:4326)";
  529. _nodeInput.append(field);
  530. priv.addValueHandlers(field, function() {
  531. input.boundingBoxData = {
  532. projection: "EPSG:4326",
  533. bounds: OpenLayers.Bounds.fromString(field.value)
  534. };
  535. });
  536. };
  537. // helper function to create a literal input textfield or dropdown
  538. priv.addLiteralInput = function(input, previousSibling) {
  539. var name = input.identifier;
  540. var container = _nodeInput.get(0);
  541. var anyValue = input.literalData.anyValue;
  542. // anyValue means textfield, otherwise we create a dropdown
  543. var field = document.createElement(anyValue ? "input" : "select");
  544. field.id = name;
  545. field.title = input["abstract"];
  546. previousSibling && previousSibling.nextSibling ?
  547. container.insertBefore(field, previousSibling.nextSibling) :
  548. container.appendChild(field);
  549. if (anyValue) {
  550. var dataType = input.literalData.dataType;
  551. field.value = name + (dataType ? " (" + dataType + ")" : "");
  552. priv.addValueHandlers(field, function() {
  553. input.data = field.value ? {
  554. literalData: {
  555. value: field.value
  556. }
  557. } : undefined;
  558. priv.createCopy(input, field, priv.addLiteralInput);
  559. });
  560. } else {
  561. var option;
  562. option = document.createElement("option");
  563. option.innerHTML = name;
  564. field.appendChild(option);
  565. for (var v in input.literalData.allowedValues) {
  566. option = document.createElement("option");
  567. option.value = v;
  568. option.innerHTML = v;
  569. field.appendChild(option);
  570. }
  571. field.onchange = function() {
  572. priv.createCopy(input, field, priv.addLiteralInput);
  573. input.data = this.selectedIndex ? {
  574. literalData: {
  575. value: this.options[this.selectedIndex].value
  576. }
  577. } : undefined;
  578. };
  579. }
  580. };
  581. // if maxOccurs is > 1, this will add a copy of the field
  582. priv.createCopy = function(input, field, fn) {
  583. if (input.maxOccurs && input.maxOccurs > 1 && !field.userSelected) {
  584. // add another copy of the field - we don't check maxOccurs
  585. field.userSelected = true;
  586. var newInput = OpenLayers.Util.extend({}, input);
  587. // we recognize copies by the occurrence property
  588. newInput.occurrence = (input.occurrence || 0) + 1;
  589. _process.dataInputs.push(newInput);
  590. fn(newInput, field);
  591. }
  592. };
  593. // helper function for adding events to form fields
  594. priv.addValueHandlers = function(field, onblur) {
  595. field.onclick = function() {
  596. if (!this.initialValue) {
  597. this.initialValue = this.value;
  598. this.value = "";
  599. }
  600. };
  601. field.onblur = function() {
  602. if (!this.value) {
  603. this.value = this.initialValue;
  604. delete this.initialValue;
  605. }
  606. onblur.apply(this, arguments);
  607. };
  608. };
  609. // execute the process
  610. priv.execute = function() {
  611. var output = _process.processOutputs[0];
  612. var input;
  613. // remove occurrences that the user has not filled out
  614. for (var i = _process.dataInputs.length - 1; i >= 0; --i) {
  615. input = _process.dataInputs[i];
  616. if ((input.minOccurs === 0 || input.occurrence) && !input.data && !input.reference) {
  617. OpenLayers.Util.removeItem(_process.dataInputs, input);
  618. }
  619. }
  620. _process.responseForm = {
  621. rawDataOutput: {
  622. identifier: output.identifier
  623. }
  624. };
  625. if (output.complexOutput && output.complexOutput.supported.formats["application/wkt"]) {
  626. _process.responseForm.rawDataOutput.mimeType = "application/wkt";
  627. }
  628. OpenLayers.Request.POST({
  629. url: priv.options.wpsUrl,
  630. data: new OpenLayers.Format.WPSExecute().write(_process),
  631. success: priv.showOutput
  632. });
  633. }
  634. // add the process's output to the page
  635. priv.showOutput = function(response) {
  636. var result = _nodeOutput.get(0);
  637. result.innerHTML = "<h3>Output:</h3>";
  638. var features;
  639. var contentType = response.getResponseHeader("Content-Type");
  640. if (contentType == "application/wkt") {
  641. features = new OpenLayers.Format.WKT().read(response.responseText);
  642. } else if (contentType == "text/xml; subtype=wfs-collection/1.0") {
  643. features = new OpenLayers.Format.WFST.v1_0_0().read(response.responseText);
  644. }
  645. if (features && (features instanceof OpenLayers.Feature.Vector || features.length)) {
  646. _layer.addFeatures(features);
  647. result.innerHTML += "The result should also be visible on the map.";
  648. }
  649. result.innerHTML += "<textarea>" + response.responseText + "</textarea>";
  650. }
  651. publ.updateSize = function() {
  652. _map.updateSize();
  653. };
  654. publ.zoomToExtent = function(extent) {
  655. if (!extent) return;
  656. var sourceProj = new OpenLayers.Projection("EPSG:4326");
  657. var targetProj = _map.getProjectionObject();
  658. var extentBounds = OpenLayers.Geometry.fromWKT(extent).transform(sourceProj, targetProj).getBounds();
  659. _map.zoomToExtent(extentBounds);
  660. };
  661. publ.selectRecord = function(recordId, extent) {
  662. if (priv.isSelectedRecordId()) {
  663. if (priv.getSelectedRecordId() != recordId) {
  664. if (priv.isSelectedFeature()) {
  665. if (confirm('Aktualnie przypisany rekord to ' + priv.getSelectedRecordId() + ' czy zmienić na ' + recordId + '?')) {
  666. priv.setSelectedRecordId(recordId);
  667. }
  668. } else {
  669. priv.setSelectedRecordId(recordId);
  670. publ.zoomToExtent(extent);
  671. }
  672. } else {
  673. publ.zoomToExtent(extent);
  674. }
  675. }
  676. else {
  677. priv.setSelectedRecordId(recordId);
  678. publ.zoomToExtent(extent);
  679. }
  680. };
  681. publ.init = function(options) {
  682. if (priv.options.debug) console.log('TableAjaxMap initialization...', options);
  683. //merge supplied options with defaults
  684. $.extend(priv.options, defaults, options);
  685. priv.init();
  686. return publ;
  687. };
  688. return publ;
  689. };
  690. $.fn.TableAjaxMapUpdateSize = function(options) {
  691. options = options || {};
  692. return this.each(function() {
  693. var tblAjaxMap = $(this).data('TableAjaxMap');
  694. if (tblAjaxMap) {
  695. tblAjaxMap.updateSize();
  696. }
  697. });
  698. return this;
  699. };
  700. $.fn.TableAjaxMapZoomToExtent = function(extent) {
  701. if (!extent) return;
  702. return this.each(function() {
  703. var tblAjaxMap = $(this).data('TableAjaxMap');
  704. if (tblAjaxMap) {
  705. tblAjaxMap.zoomToExtent(extent);
  706. }
  707. });
  708. return this;
  709. };
  710. $.fn.TableAjaxMapSelectRecord = function(recordId, extent) {
  711. if (!recordId) return;
  712. return this.each(function() {
  713. var tblAjaxMap = $(this).data('TableAjaxMap');
  714. if (tblAjaxMap) {
  715. tblAjaxMap.selectRecord(recordId, extent);
  716. }
  717. });
  718. return this;
  719. };
  720. $.fn.TableAjaxMap = function(options) {
  721. options = options || {};
  722. return this.each(function() {
  723. options.id = this;
  724. if (!$(this).data('TableAjaxMap')) {
  725. $(this).data('TableAjaxMap', new TableAjaxMap().init(options));
  726. }
  727. });
  728. return this;
  729. };
  730. }(jQuery));
  731. </script>
  732. <?php
  733. }
  734. public function ajaxTask($task) {
  735. switch ($task) {
  736. case 'PROXY': {
  737. $this->sendAjaxProxy($_REQUEST);
  738. break;
  739. }
  740. default:
  741. //$this->sendAjaxData($_REQUEST);
  742. }
  743. }
  744. public function sendAjaxProxy($args) {
  745. $url = V::get('url', '', $args);
  746. // 1. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DGetCapabilities
  747. // 2. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DDescribeProcess%26VERSION%3D1.0.0%26IDENTIFIER%3Dpozdrawiam
  748. header('Content-Type: application/xml; charset=utf-8');
  749. $urlParts = parse_url($url);
  750. $urlQuery = array();
  751. $urlQueryTmp = V::get('query', '', $urlParts);
  752. $urlQueryTmp = explode('&', $urlQueryTmp);
  753. foreach ($urlQueryTmp as $vQuery) {
  754. $parts = explode('=', $vQuery, 2);
  755. $urlQuery[$parts[0]] = $parts[1];
  756. }
  757. $wpsServer = new TableAjaxMapWpsServer($this->_zasobID);
  758. if ('WPS' == V::get('SERVICE', '', $urlQuery)) {
  759. $req = V::get('REQUEST', '', $urlQuery);
  760. $methodName = "{$req}Action";
  761. if (method_exists($wpsServer, $methodName)) {
  762. $wpsServer->$methodName($urlQuery);
  763. }
  764. }
  765. else {
  766. $wpsServer->parseXMLRequest();
  767. }
  768. exit;
  769. }
  770. }
  771. class TableAjaxMapWfsAction {
  772. private $_zasobID;
  773. public function __construct($zasobID) {
  774. $this->_zasobID = $zasobID;
  775. }
  776. /**
  777. * example: MULTIPOLYGON(((2072016.74395199 7234076.79293037,2072016.74395199 7234115.01144451,2072131.3994944 7234115.01144451,2072131.3994944 7234076.79293037,2072016.74395199 7234076.79293037)))
  778. */
  779. public function generateGmlFromWKT($wkt) {
  780. $gml = '';
  781. $wktParts = explode('(', $wkt, 2);
  782. ob_start();
  783. switch ($wktParts[0]) {
  784. case 'MULTIPOLYGON':
  785. case 'POLYGON': {
  786. $points = trim($wktParts[1], '() ');
  787. $points = str_replace(',', "\n", $points);
  788. ?>
  789. <gml:boundedBy>
  790. <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  791. <gml:lowerCorner>-180 -90</gml:lowerCorner>
  792. <gml:upperCorner>180 90</gml:upperCorner>
  793. </gml:Envelope>
  794. </gml:boundedBy>
  795. <og:the_geom>
  796. <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  797. <gml:surfaceMember>
  798. <gml:Polygon srsDimension="2">
  799. <gml:exterior>
  800. <gml:LinearRing srsDimension="2">
  801. <gml:posList>
  802. <?php echo $points; ?>
  803. </gml:posList>
  804. </gml:LinearRing>
  805. </gml:exterior>
  806. </gml:Polygon>
  807. </gml:surfaceMember>
  808. </gml:MultiSurface>
  809. </og:the_geom>
  810. <?php
  811. }
  812. break;
  813. default:
  814. }
  815. $gml = ob_get_contents();
  816. ob_clean();
  817. return $gml;
  818. }
  819. public function execute($args) {
  820. /*
  821. * Mapa odczytywanie punktów: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
  822. *
  823. * CI50:
  824. 18.613243103027344 54.33614429135817
  825. 18.613243103027344 54.33634445792519
  826. 18.614273071289062 54.33634445792519
  827. 18.614273071289062 54.33614429135817
  828. */
  829. $buildingsGml = array();
  830. $db = DB::getDB();
  831. if ($this->_zasobID == 16) {// TODO: read by TableAcl from Data_Source?
  832. $sql = "select b.`ID`, AsWKT(b.`the_geom`) as the_geom
  833. from `BUILDINGS` as b
  834. where b.`the_geom` is not null and b.`the_geom`!=''
  835. limit 10;
  836. ";
  837. $res = $db->query($sql);
  838. while ($r = $db->fetch($res)) {
  839. $buildingsGml[$r->ID] = $this->generateGmlFromWKT($r->the_geom);
  840. }
  841. }
  842. /**
  843. * <og:recordId><?php echo $kId; ?></og:recordId>
  844. * <og:tblId><?php echo $tblId; ?></og:tblId>
  845. *
  846. * goes to js: @see priv.addWKTInput _layer.selectedFeatures[0]
  847. *
  848. * attributes: Object
  849. recordId: "1130"
  850. tblId: "16"
  851. */
  852. echo '<?xml version="1.0" encoding="UTF-8"?>';
  853. ?>
  854. <wfs:FeatureCollection xmlns:nasa="http://nasa.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:usgs="http://www.usgs.gov/" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:ne="http://naturalearthdata.com" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:osm="http://openstreemap.org" xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="4" timeStamp="2014-07-16T13:22:43.307Z" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=og%3Arestricted http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.1.0/wfs.xsd">
  855. <!--
  856. <?php
  857. /*
  858. * gdańsk
  859. <gml:lowerCorner>17.226562502593 53.887024366231</gml:lowerCorner>
  860. <gml:upperCorner>20.039062502593 54.847089981191</gml:upperCorner>
  861. * chełm CI50, 58, 56 i większa część 54
  862. <gml:lowerCorner>18.607629912267 54.334071453085</gml:lowerCorner>
  863. <gml:upperCorner>18.618616240393 54.337824603267</gml:upperCorner>
  864. * chełm CI50, 58, 56 i mniejsza część 54
  865. <gml:lowerCorner>18.607297318347 54.334218457914</gml:lowerCorner>
  866. <gml:upperCorner>18.618283646473 54.337971594678</gml:upperCorner>
  867. */
  868. $bounds = "Polygon((17.226562502593 53.887024366231, 20.039062502593 54.847089981191))";
  869. $bounds = "POLYGON((
  870. 18.61292099002325 54.33645952913529,
  871. 18.612985363039602 54.33478310873356,
  872. 18.616246929201676 54.33477685330538,
  873. 18.61613964084169 54.336309404721554,
  874. 18.61292099002325 54.33645952913529
  875. ))";
  876. $bounds = "POLYGON((
  877. 17.226562502593 53.887024366231,
  878. 17.226562502593 54.847089981191,
  879. 20.039062502593 54.847089981191,
  880. 20.039062502593 53.887024366231,
  881. 17.226562502593 53.887024366231
  882. ))";
  883. $bounds = "POLYGON((
  884. 18.607297318347 54.334218457914,
  885. 18.607297318347 54.337971594678,
  886. 18.618283646473 54.337971594678,
  887. 18.618283646473 54.334218457914,
  888. 18.607297318347 54.334218457914
  889. ))";
  890. $sql = "select t.`ID`
  891. , t.`S_ADDRESS_STREET`
  892. , AsWKT(t.`the_geom`) as the_geomWKT
  893. , AsWKT(GeomFromText('{$bounds}')) as boundsWKT
  894. , MBRWithin(GeomFromText('{$bounds}'), GeomFromText(AsWKT(t.`the_geom`))) as isInside
  895. , MBRWithin(GeomFromText(AsWKT(t.`the_geom`)), GeomFromText('{$bounds}')) as isInside2
  896. from `BUILDINGS` as t
  897. where t.`the_geom` is not null
  898. limit 10 ";
  899. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."\n";print_r($sql);echo "\n".'</pre>';
  900. $res = $db->query($sql);
  901. while ($r = $db->fetch($res)) {
  902. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($r);echo'</pre>';
  903. }
  904. ?>
  905. -->
  906. <gml:boundedBy>
  907. <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  908. <gml:lowerCorner>-180 -90</gml:lowerCorner>
  909. <gml:upperCorner>180 90</gml:upperCorner>
  910. </gml:Envelope>
  911. </gml:boundedBy>
  912. <gml:featureMembers>
  913. <?php foreach ($buildingsGml as $kId => $vGml) : ?>
  914. <og:restricted gml:id="restricted.<?php echo $kId; ?>">
  915. <?php echo $vGml; ?>
  916. <og:recordId><?php echo $kId; ?></og:recordId>
  917. <og:tblId><?php echo $this->_zasobID; ?></og:tblId>
  918. </og:restricted>
  919. <?php endforeach; ?>
  920. </gml:featureMembers>
  921. </wfs:FeatureCollection>
  922. <?php
  923. }
  924. }
  925. class WpsActionBase {
  926. public $title = '';
  927. public $description = '';
  928. public $dataInputs = array();
  929. public function execute($args) {
  930. var_dump($args);
  931. }
  932. }
  933. class WpsActionPrzypiszDoRekordu extends WpsActionBase {
  934. public function __construct() {
  935. $this->title = 'Przypisz';
  936. $this->description = 'Przypisuje położenie do wybranego rekordu w tabeli.';
  937. $this->dataInputs['geom'] = new stdClass();
  938. $this->dataInputs['geom']->title = 'geom';
  939. $this->dataInputs['geom']->description = 'Input geometry';
  940. $this->dataInputs['geom']->type = 'geom';// CoomplexData
  941. $this->dataInputs['idTable'] = new stdClass();
  942. $this->dataInputs['idTable']->title = 'geom';
  943. $this->dataInputs['idTable']->description = 'Table ID';
  944. $this->dataInputs['idTable']->type = 'integer';// LiteralData: xs:integer
  945. $this->dataInputs['idRecord'] = new stdClass();
  946. $this->dataInputs['idRecord']->title = 'idRecord';
  947. $this->dataInputs['idRecord']->description = 'Record ID';
  948. $this->dataInputs['idRecord']->type = 'integer';// LiteralData: xs:integer
  949. }
  950. }
  951. class TableAjaxMapWpsServer {
  952. private $_fun;// config for identifiers
  953. private $_wfsAction;
  954. private $_zasobID;
  955. public function __construct($zasobID) {
  956. $this->_fun['przypiszDoRekordu'] = new WpsActionPrzypiszDoRekordu();
  957. $this->_wfsAction = new TableAjaxMapWfsAction($zasobID);
  958. $this->_zasobID = $zasobID;
  959. }
  960. public function parseXMLRequest() {
  961. $data = array();
  962. $reqContent = file_get_contents('php://input');
  963. $xml = new SimpleXMLElement($reqContent);
  964. if ('GetFeature' == $xml->getName()) {
  965. // TODO: parse xml and set query params
  966. /*
  967. <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd http://opengeo.org http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&amp;typename=og:restricted">
  968. <wfs:Query typeName="feature:restricted" srsName="EPSG:4326" xmlns:feature="http://opengeo.org">
  969. <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
  970. <ogc:BBOX>
  971. <ogc:PropertyName>the_geom</ogc:PropertyName>
  972. <gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
  973. <gml:lowerCorner>17.226562502593 53.887024366231</gml:lowerCorner>
  974. <gml:upperCorner>20.039062502593 54.847089981191</gml:upperCorner>
  975. </gml:Envelope>
  976. </ogc:BBOX>
  977. </ogc:Filter>
  978. </wfs:Query>
  979. </wfs:GetFeature>
  980. */
  981. $this->_wfsAction->execute($data);
  982. }
  983. else if (isset($xml->children('ows', TRUE)->Identifier)) {
  984. $identifier = (string)$xml->children('ows', TRUE)->Identifier;
  985. if (array_key_exists($identifier, $this->_fun)) {
  986. foreach ($xml->children('wps', TRUE)->DataInputs->children('wps', TRUE) as $input) {
  987. $inputIdentifier = (string)$input->children('ows', TRUE)->Identifier;
  988. if (array_key_exists($inputIdentifier, $this->_fun[$identifier]->dataInputs)) {
  989. $inputType = (string)$this->_fun[$identifier]->dataInputs[$inputIdentifier]->type;
  990. switch ($inputType) {
  991. case 'integer':
  992. $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->LiteralData;
  993. break;
  994. case 'geom':
  995. $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->ComplexData;
  996. break;
  997. default:
  998. }
  999. } else {
  1000. // brak zdefiniowanego inputa
  1001. }
  1002. }
  1003. $this->_fun['przypiszDoRekordu']->execute($data);
  1004. } else {
  1005. echo "TODO: brak zdefiniowanej funkcji '{$identifier}'";
  1006. var_dump($identifier);
  1007. }
  1008. }
  1009. else {
  1010. echo "TODO: '" . $xml->getName() . "' ...";
  1011. }
  1012. }
  1013. public function getCapabilitiesAction() {
  1014. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1015. ?>
  1016. <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">
  1017. <ows:ServiceIdentification>
  1018. <ows:Title>Prototype GeoServer WPS</ows:Title>
  1019. <ows:Abstract />
  1020. <ows:Keywords>
  1021. <ows:Keyword>wps</ows:Keyword>
  1022. <ows:Keyword>geoserver</ows:Keyword>
  1023. </ows:Keywords>
  1024. <ows:ServiceType>WPS</ows:ServiceType>
  1025. <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
  1026. <ows:Fees>NONE</ows:Fees>
  1027. <ows:AccessConstraints>NONE</ows:AccessConstraints>
  1028. </ows:ServiceIdentification>
  1029. <ows:ServiceProvider>
  1030. <ows:ProviderName>GeoServer</ows:ProviderName>
  1031. <ows:ProviderSite />
  1032. <ows:ServiceContact />
  1033. </ows:ServiceProvider>
  1034. <ows:OperationsMetadata>
  1035. <ows:Operation name="GetCapabilities">
  1036. <ows:DCP>
  1037. <ows:HTTP>
  1038. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1039. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1040. </ows:HTTP>
  1041. </ows:DCP>
  1042. </ows:Operation>
  1043. <ows:Operation name="DescribeProcess">
  1044. <ows:DCP>
  1045. <ows:HTTP>
  1046. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1047. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1048. </ows:HTTP>
  1049. </ows:DCP>
  1050. </ows:Operation>
  1051. <ows:Operation name="Execute">
  1052. <ows:DCP>
  1053. <ows:HTTP>
  1054. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1055. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1056. </ows:HTTP>
  1057. </ows:DCP>
  1058. </ows:Operation>
  1059. </ows:OperationsMetadata>
  1060. <wps:ProcessOfferings>
  1061. <?php foreach($this->_fun as $kFun => $vFun) : ?>
  1062. <wps:Process wps:processVersion="1.0.0">
  1063. <ows:Identifier><?php echo $kFun; ?></ows:Identifier>
  1064. <ows:Title><?php echo $vFun->title; ?></ows:Title>
  1065. <ows:Abstract><?php echo $vFun->description; ?></ows:Abstract>
  1066. </wps:Process>
  1067. <?php endforeach; ?>
  1068. </wps:ProcessOfferings>
  1069. <wps:Languages>
  1070. <wps:Default>
  1071. <ows:Language>en-US</ows:Language>
  1072. </wps:Default>
  1073. <wps:Supported>
  1074. <ows:Language>en-US</ows:Language>
  1075. </wps:Supported>
  1076. </wps:Languages>
  1077. </wps:Capabilities>
  1078. <?php
  1079. }
  1080. public function describeProcessAction($args) {
  1081. // TODO: xml z opiesem procese $args['IDENTIFIER']
  1082. /**
  1083. * should work like JTS:densify - geom field (map object) and integer field (record ID)
  1084. * 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
  1085. * http://demo.opengeo.org/geoserver/wps?SERVICE=WPS&REQUEST=DescribeProcess&VERSION=1.0.0&IDENTIFIER=JTS%3Adensify
  1086. */
  1087. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1088. if (array_key_exists($args['IDENTIFIER'], $this->_fun)) {
  1089. $identifier = $this->_fun[$args['IDENTIFIER']];
  1090. ?>
  1091. <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">
  1092. <ProcessDescription wps:processVersion="1.0.0" statusSupported="true" storeSupported="true">
  1093. <ows:Identifier><?php echo $args['IDENTIFIER']; ?></ows:Identifier>
  1094. <ows:Title><?php echo $identifier->title; ?></ows:Title>
  1095. <ows:Abstract><?php echo $identifier->description; ?></ows:Abstract>
  1096. <DataInputs>
  1097. <?php foreach ($identifier->dataInputs as $kInput => $vInput) : ?>
  1098. <Input maxOccurs="1" minOccurs="1">
  1099. <ows:Identifier><?php echo $kInput; ?></ows:Identifier>
  1100. <ows:Title><?php echo $vInput->title; ?></ows:Title>
  1101. <ows:Abstract><?php echo $vInput->description; ?></ows:Abstract>
  1102. <?php if ($vInput->type == 'geom') : ?>
  1103. <ComplexData>
  1104. <Default>
  1105. <Format>
  1106. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1107. </Format>
  1108. </Default>
  1109. <Supported>
  1110. <Format>
  1111. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1112. </Format>
  1113. <Format>
  1114. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  1115. </Format>
  1116. <Format>
  1117. <MimeType>application/wkt</MimeType>
  1118. </Format>
  1119. <Format>
  1120. <MimeType>application/gml-3.1.1</MimeType>
  1121. </Format>
  1122. <Format>
  1123. <MimeType>application/gml-2.1.2</MimeType>
  1124. </Format>
  1125. </Supported>
  1126. </ComplexData>
  1127. <?php elseif ($vInput->type == 'integer') : ?>
  1128. <LiteralData>
  1129. <ows:DataType>xs:integer</ows:DataType>
  1130. <ows:AnyValue />
  1131. </LiteralData>
  1132. <?php else : ?>
  1133. <?php endif; ?>
  1134. </Input>
  1135. <?php endforeach; ?>
  1136. </DataInputs>
  1137. <ProcessOutputs>
  1138. <Output>
  1139. <ows:Identifier>result</ows:Identifier>
  1140. <ows:Title>result</ows:Title>
  1141. <ComplexOutput>
  1142. <Default>
  1143. <Format>
  1144. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1145. </Format>
  1146. </Default>
  1147. <Supported>
  1148. <Format>
  1149. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1150. </Format>
  1151. <Format>
  1152. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  1153. </Format>
  1154. <Format>
  1155. <MimeType>application/wkt</MimeType>
  1156. </Format>
  1157. <Format>
  1158. <MimeType>application/gml-3.1.1</MimeType>
  1159. </Format>
  1160. <Format>
  1161. <MimeType>application/gml-2.1.2</MimeType>
  1162. </Format>
  1163. </Supported>
  1164. </ComplexOutput>
  1165. </Output>
  1166. </ProcessOutputs>
  1167. </ProcessDescription>
  1168. </wps:ProcessDescriptions>
  1169. <?php
  1170. } else {
  1171. echo 'TODO: brak funkcji';
  1172. }
  1173. }
  1174. }