TableAjaxMap.php 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  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. $corners = $xml->children("wfs", TRUE)->Query->children("ogc", TRUE)->Filter->BBOX->children("gml", TRUE)->Envelope;
  982. if ($corners) {
  983. $lowerCorner = (string) $corners->lowerCorner;
  984. $upperCorner = (string) $corners->upperCorner;
  985. $lowerCornerArray = explode(" ", $lowerCorner);
  986. $upperCornerArray = explode(" ", $upperCorner);
  987. if(count($lowerCornerArray) == 2 && count($upperCornerArray) == 2) {
  988. $lowerCornerDouble = (double) $lowerCornerArray[0];
  989. $upperCornerDouble = (double) $upperCornerArray[1];
  990. if(($lowerCorner == (string) $lowerCornerDouble) && ($upperCorner == (string) $upperCornerDouble)) {
  991. $data[lowerCorner] = $lowerCorner;
  992. $data[upperCorner] = $upperCorner;
  993. }
  994. }
  995. } else {
  996. // inna struktura xml'a
  997. }
  998. $this->_wfsAction->execute($data);
  999. }
  1000. else if (isset($xml->children('ows', TRUE)->Identifier)) {
  1001. $identifier = (string)$xml->children('ows', TRUE)->Identifier;
  1002. if (array_key_exists($identifier, $this->_fun)) {
  1003. foreach ($xml->children('wps', TRUE)->DataInputs->children('wps', TRUE) as $input) {
  1004. $inputIdentifier = (string)$input->children('ows', TRUE)->Identifier;
  1005. if (array_key_exists($inputIdentifier, $this->_fun[$identifier]->dataInputs)) {
  1006. $inputType = (string)$this->_fun[$identifier]->dataInputs[$inputIdentifier]->type;
  1007. switch ($inputType) {
  1008. case 'integer':
  1009. $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->LiteralData;
  1010. break;
  1011. case 'geom':
  1012. $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->ComplexData;
  1013. break;
  1014. default:
  1015. }
  1016. } else {
  1017. // brak zdefiniowanego inputa
  1018. }
  1019. }
  1020. $this->_fun['przypiszDoRekordu']->execute($data);
  1021. } else {
  1022. echo "TODO: brak zdefiniowanej funkcji '{$identifier}'";
  1023. var_dump($identifier);
  1024. }
  1025. }
  1026. else {
  1027. echo "TODO: '" . $xml->getName() . "' ...";
  1028. }
  1029. }
  1030. public function getCapabilitiesAction() {
  1031. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1032. ?>
  1033. <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">
  1034. <ows:ServiceIdentification>
  1035. <ows:Title>Prototype GeoServer WPS</ows:Title>
  1036. <ows:Abstract />
  1037. <ows:Keywords>
  1038. <ows:Keyword>wps</ows:Keyword>
  1039. <ows:Keyword>geoserver</ows:Keyword>
  1040. </ows:Keywords>
  1041. <ows:ServiceType>WPS</ows:ServiceType>
  1042. <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
  1043. <ows:Fees>NONE</ows:Fees>
  1044. <ows:AccessConstraints>NONE</ows:AccessConstraints>
  1045. </ows:ServiceIdentification>
  1046. <ows:ServiceProvider>
  1047. <ows:ProviderName>GeoServer</ows:ProviderName>
  1048. <ows:ProviderSite />
  1049. <ows:ServiceContact />
  1050. </ows:ServiceProvider>
  1051. <ows:OperationsMetadata>
  1052. <ows:Operation name="GetCapabilities">
  1053. <ows:DCP>
  1054. <ows:HTTP>
  1055. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1056. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1057. </ows:HTTP>
  1058. </ows:DCP>
  1059. </ows:Operation>
  1060. <ows:Operation name="DescribeProcess">
  1061. <ows:DCP>
  1062. <ows:HTTP>
  1063. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1064. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1065. </ows:HTTP>
  1066. </ows:DCP>
  1067. </ows:Operation>
  1068. <ows:Operation name="Execute">
  1069. <ows:DCP>
  1070. <ows:HTTP>
  1071. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1072. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1073. </ows:HTTP>
  1074. </ows:DCP>
  1075. </ows:Operation>
  1076. </ows:OperationsMetadata>
  1077. <wps:ProcessOfferings>
  1078. <?php foreach($this->_fun as $kFun => $vFun) : ?>
  1079. <wps:Process wps:processVersion="1.0.0">
  1080. <ows:Identifier><?php echo $kFun; ?></ows:Identifier>
  1081. <ows:Title><?php echo $vFun->title; ?></ows:Title>
  1082. <ows:Abstract><?php echo $vFun->description; ?></ows:Abstract>
  1083. </wps:Process>
  1084. <?php endforeach; ?>
  1085. </wps:ProcessOfferings>
  1086. <wps:Languages>
  1087. <wps:Default>
  1088. <ows:Language>en-US</ows:Language>
  1089. </wps:Default>
  1090. <wps:Supported>
  1091. <ows:Language>en-US</ows:Language>
  1092. </wps:Supported>
  1093. </wps:Languages>
  1094. </wps:Capabilities>
  1095. <?php
  1096. }
  1097. public function describeProcessAction($args) {
  1098. // TODO: xml z opiesem procese $args['IDENTIFIER']
  1099. /**
  1100. * should work like JTS:densify - geom field (map object) and integer field (record ID)
  1101. * 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
  1102. * http://demo.opengeo.org/geoserver/wps?SERVICE=WPS&REQUEST=DescribeProcess&VERSION=1.0.0&IDENTIFIER=JTS%3Adensify
  1103. */
  1104. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1105. if (array_key_exists($args['IDENTIFIER'], $this->_fun)) {
  1106. $identifier = $this->_fun[$args['IDENTIFIER']];
  1107. ?>
  1108. <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">
  1109. <ProcessDescription wps:processVersion="1.0.0" statusSupported="true" storeSupported="true">
  1110. <ows:Identifier><?php echo $args['IDENTIFIER']; ?></ows:Identifier>
  1111. <ows:Title><?php echo $identifier->title; ?></ows:Title>
  1112. <ows:Abstract><?php echo $identifier->description; ?></ows:Abstract>
  1113. <DataInputs>
  1114. <?php foreach ($identifier->dataInputs as $kInput => $vInput) : ?>
  1115. <Input maxOccurs="1" minOccurs="1">
  1116. <ows:Identifier><?php echo $kInput; ?></ows:Identifier>
  1117. <ows:Title><?php echo $vInput->title; ?></ows:Title>
  1118. <ows:Abstract><?php echo $vInput->description; ?></ows:Abstract>
  1119. <?php if ($vInput->type == 'geom') : ?>
  1120. <ComplexData>
  1121. <Default>
  1122. <Format>
  1123. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1124. </Format>
  1125. </Default>
  1126. <Supported>
  1127. <Format>
  1128. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1129. </Format>
  1130. <Format>
  1131. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  1132. </Format>
  1133. <Format>
  1134. <MimeType>application/wkt</MimeType>
  1135. </Format>
  1136. <Format>
  1137. <MimeType>application/gml-3.1.1</MimeType>
  1138. </Format>
  1139. <Format>
  1140. <MimeType>application/gml-2.1.2</MimeType>
  1141. </Format>
  1142. </Supported>
  1143. </ComplexData>
  1144. <?php elseif ($vInput->type == 'integer') : ?>
  1145. <LiteralData>
  1146. <ows:DataType>xs:integer</ows:DataType>
  1147. <ows:AnyValue />
  1148. </LiteralData>
  1149. <?php else : ?>
  1150. <?php endif; ?>
  1151. </Input>
  1152. <?php endforeach; ?>
  1153. </DataInputs>
  1154. <ProcessOutputs>
  1155. <Output>
  1156. <ows:Identifier>result</ows:Identifier>
  1157. <ows:Title>result</ows:Title>
  1158. <ComplexOutput>
  1159. <Default>
  1160. <Format>
  1161. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1162. </Format>
  1163. </Default>
  1164. <Supported>
  1165. <Format>
  1166. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1167. </Format>
  1168. <Format>
  1169. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  1170. </Format>
  1171. <Format>
  1172. <MimeType>application/wkt</MimeType>
  1173. </Format>
  1174. <Format>
  1175. <MimeType>application/gml-3.1.1</MimeType>
  1176. </Format>
  1177. <Format>
  1178. <MimeType>application/gml-2.1.2</MimeType>
  1179. </Format>
  1180. </Supported>
  1181. </ComplexOutput>
  1182. </Output>
  1183. </ProcessOutputs>
  1184. </ProcessDescription>
  1185. </wps:ProcessDescriptions>
  1186. <?php
  1187. } else {
  1188. echo 'TODO: brak funkcji';
  1189. }
  1190. }
  1191. }