TableAjaxMap.php 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744
  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 .olControlSelectFeatureItemInactive { background-image:url(stuff/open-layers/theme/default/img/move_feature_off.png); }
  33. .olControlEditingToolbar .olControlSelectFeatureItemActive { background-image:url(stuff/open-layers/theme/default/img/move_feature_on.png); }
  34. .olControlEditingToolbar .olControlRefreshItemInactive { background-image: url(stuff/open-layers/theme/default/img/refresh_feature_off.png); }
  35. .olControlEditingToolbar .olControlRefreshItemActive { background-image: url(stuff/open-layers/theme/default/img/refresh_feature_on.png); }
  36. .olControlEditingToolbar .olControlSaveItemInactive { background-image: url(stuff/open-layers/theme/default/img/save_features_off.png); }
  37. .olControlEditingToolbar .olControlSaveItemActive { background-image: url(stuff/open-layers/theme/default/img/save_features_on.png); }
  38. .olControlEditingToolbar .olControlUserLocationItemInactive { background-image: url(stuff/open-layers/theme/default/img/geolocation-off.png); }
  39. .olControlEditingToolbar .olControlUserLocationItemActive { background-image: url(stuff/open-layers/theme/default/img/geolocation-on.png); }
  40. .olControlLayerSwitcher .layersDiv { border-radius:10px 0 0 10px; opacity:0.75; filter:alpha(opacity=75); }
  41. .notsupported { color:red; }
  42. .TableAjaxMap .layersDiv input { margin:0; }
  43. .TableAjaxMap .layersDiv label { display:inline; }
  44. .olControlSelectedRecord { background: rgba(255, 255, 255, 0.6); padding:1px 0 0 3px; position:absolute; bottom:0; right:0; }
  45. .olControlSelectedRecordClear { cursor:pointer; color:#bbb; }
  46. .olControlSelectedRecordClear:hover { color:#f00; }
  47. .olControlSelectedRecordMsg { color:#000; }
  48. .olControlManageLayers { background: rgba(255, 255, 255, 0.6); padding:1px 0 0 3px; position:absolute; bottom:20px; right:0; }
  49. .olControlManageLayersBtn { cursor:pointer; color:#bbb; }
  50. .olControlManageLayersBtn:hover { color:#f00; }
  51. .olControlManageLayersMsg { color:#000; }
  52. </style>
  53. <?php
  54. }
  55. public function printJS() {
  56. ?>
  57. <script src="stuff/open-layers/OpenLayers.js"></script>
  58. <script>
  59. OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_task=PROXY&url=";
  60. var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
  61. selectedRecordId: 0,
  62. msgNode: null,
  63. clearNode: null,
  64. /**
  65. * Method: draw
  66. *
  67. * Returns:
  68. * {DOMElement}
  69. */
  70. draw: function() {
  71. OpenLayers.Control.prototype.draw.apply(this, arguments);
  72. if (!this.msgNode) {
  73. this.msgNode = document.createElement("span");
  74. this.msgNode.className = this.displayClass + "Msg";
  75. this.div.appendChild(this.msgNode);
  76. }
  77. if (!this.clearNode) {
  78. this.clearNode = document.createElement("span");
  79. this.clearNode.title = "Usuń zaznaczenie";
  80. this.clearNode.className = this.displayClass + "Clear";
  81. this.clearNode.className += ' glyphicon glyphicon-remove';
  82. var that = this;
  83. jQuery(this.clearNode).on('click', function(e) {
  84. e.stopPropagation();
  85. e.preventDefault();
  86. that.clearSelectedRecordId();
  87. return false;
  88. });
  89. this.div.appendChild(this.clearNode);
  90. }
  91. //this.map.events.register('moveend', this, this.update);
  92. this.updateView();
  93. return this.div;
  94. },
  95. setSelectedRecordId: function(recordId) {
  96. this.selectedRecordId = recordId;
  97. this.updateView();
  98. },
  99. getSelectedRecordId: function() {
  100. return this.selectedRecordId;
  101. },
  102. isSelectedRecordId: function() {
  103. return (this.selectedRecordId > 0);
  104. },
  105. clearSelectedRecordId: function() {
  106. this.selectedRecordId = 0;
  107. this.updateView();
  108. },
  109. /**
  110. * Method: updateView
  111. * Update the size of the bars, and the labels they contain.
  112. */
  113. updateView: function() {
  114. this.clearNode.style.visibility = "hidden";
  115. if (this.selectedRecordId > 0) {
  116. this.msgNode.innerHTML = 'Zaznaczony rekord nr: ' + this.selectedRecordId + ' ';
  117. this.clearNode.style.visibility = "visible";
  118. } else {
  119. this.msgNode.innerHTML = 'Brak zaznaczonego rekordu ';
  120. }
  121. },
  122. CLASS_NAME: "OpenLayers.Control.SelectedRecord"
  123. });
  124. var myOpenLayers_Control_ManageLayers = OpenLayers.Class(OpenLayers.Control, {
  125. mapWidget: null,
  126. msgNode: null,
  127. testBtn: null,
  128. layers: [],
  129. draw: function() {
  130. OpenLayers.Control.prototype.draw.apply(this, arguments);
  131. if (!this.msgNode) {
  132. this.msgNode = document.createElement("span");
  133. this.msgNode.className = this.displayClass + "Msg";
  134. this.div.appendChild(this.msgNode);
  135. }
  136. if (!this.testBtn) {
  137. this.testBtn = document.createElement("span");
  138. this.testBtn.title = "Dodaj warstwę - test babidol";
  139. this.testBtn.className = this.displayClass + "Btn";
  140. this.testBtn.className += ' glyphicon glyphicon-plus';
  141. var that = this;
  142. jQuery(this.testBtn).on('click', function(e) {
  143. e.stopPropagation();
  144. e.preventDefault();
  145. that.testAddLayerBabidol();
  146. return false;
  147. });
  148. this.div.appendChild(this.testBtn);
  149. }
  150. this.updateView();
  151. return this.div;
  152. },
  153. setMapWidget: function(mapWidget) {
  154. this.mapWidget = mapWidget;
  155. },
  156. testAddLayerBabidol: function() {
  157. if (this.layers.length > 0) {
  158. return false;
  159. }
  160. var layerName = 'Babidol';
  161. var wfsUrl = 'http://biuro.biall-net.pl/wps';
  162. wfsUrl += '/21176/BABIDOL_DXF_SHP';// TODO: user choise by perms/item links
  163. var _styleMap = new OpenLayers.StyleMap({
  164. 'default': new OpenLayers.Style(null, {
  165. rules: [
  166. new OpenLayers.Rule({
  167. symbolizer: {
  168. stroke: true,
  169. strokeWidth: 1,
  170. fill: true,
  171. fillColor: "#00a5ee",
  172. strokeColor: "#00a5ee",
  173. }
  174. })
  175. ]
  176. })
  177. });
  178. var testLayerBabidol = new OpenLayers.Layer.Vector(layerName, {
  179. strategies: [new OpenLayers.Strategy.BBOX()],//, new OpenLayers.Strategy.Cluster({distance:20, threshold:16})
  180. projection: new OpenLayers.Projection("EPSG:4326"),
  181. protocol: new OpenLayers.Protocol.WFS({
  182. version: "1.1.0",
  183. srsName: "EPSG:4326",
  184. url: wfsUrl,
  185. featureNS : "http://opengeo.org",
  186. featureType: "restricted",
  187. geometryName: "the_geom",
  188. schema: "http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted"
  189. }),
  190. styleMap: _styleMap
  191. });
  192. this.layers.push(testLayerBabidol);
  193. this.map.addLayers(this.layers);
  194. this.updateView();
  195. },
  196. updateView: function() {
  197. this.msgNode.innerHTML = 'Warstwy ' + this.layers.length + ' ';
  198. },
  199. CLASS_NAME: "OpenLayers.Control.ManageLayers"
  200. });
  201. (function( $ ) {
  202. var TableAjaxMap = function() {
  203. var priv = {}; //private api
  204. var publ = {}; //public api
  205. priv.options = {};
  206. var defaults = {
  207. wpsUrl: '',
  208. wfsUrl: '',
  209. layerName: 'Warstwa rysowania',
  210. zoomStrategyActivate: 15,
  211. onSaveFeature: null,
  212. onSelectBox: null,
  213. addBtn: null,
  214. showAddLayerWidget: false,
  215. debug: false
  216. };
  217. var _nodeMapId;
  218. var _nodeMap;
  219. var _nodeProcesses;
  220. var _nodeAbstract;
  221. var _nodeInput;
  222. var _nodeOutput;
  223. var _capabilities;
  224. var _process;
  225. var _layer;
  226. var _map;
  227. var _styleMap;
  228. var _controlSelectedRecord;
  229. /*
  230. initialize the plugin.
  231. */
  232. priv.init = function() {
  233. /*
  234. <div id="map" class="TableAjaxMap"></div>
  235. <div>
  236. <select id="processes"><option>Select a process</option></select>
  237. <p id="abstract"></p>
  238. <div id="input"></div>
  239. <div id="output"></div>
  240. </div>
  241. */
  242. _nodeMapId = 'Map-' + Math.random(1).toString().substr(2);
  243. _nodeMap = $('<div id="' + _nodeMapId + '" class="TableAjaxMap"></div>');
  244. _nodeProcesses = $('<select></select>');
  245. _nodeProcesses.append('<option>Wybierz funkcję</option>');
  246. _nodeAbstract = $('<p></p>');
  247. _nodeInput = $('<div></div>');
  248. _nodeOutput = $('<div></div>');
  249. _selectedFeature = null;
  250. priv.options.zoomStrategyActivate = (priv.options.zoomStrategyActivate > 0)? priv.options.zoomStrategyActivate : 15;
  251. var div = $('<div></div>');
  252. div.css({display: 'none'});
  253. div.append(_nodeProcesses);
  254. div.append(_nodeAbstract);
  255. div.append(_nodeInput);
  256. div.append(_nodeOutput);
  257. $(priv.options.id).append(_nodeMap);
  258. $(priv.options.id).append(div);
  259. _nodeProcesses.on('change', function() {
  260. if (priv.options.debug) console.log("onchange this:", this, this.selectedIndex, this.options);
  261. var selection = this.options[this.selectedIndex].value;
  262. if (this.selectedIndex > 0) {
  263. OpenLayers.Request.GET({
  264. url: priv.options.wpsUrl,
  265. params: {
  266. "SERVICE": "WPS",
  267. "REQUEST": "DescribeProcess",
  268. "VERSION": _capabilities.version,
  269. "IDENTIFIER": selection
  270. },
  271. success: function(response) {
  272. _process = new OpenLayers.Format.WPSDescribeProcess().read(
  273. response.responseText
  274. ).processDescriptions[selection];
  275. if (priv.options.debug) console.log("Process:", _process);
  276. priv.buildForm();
  277. }
  278. });
  279. }
  280. });
  281. priv.getCapabilities();
  282. _styleMap = new OpenLayers.StyleMap({
  283. 'default': new OpenLayers.Style(null, {
  284. rules: [
  285. new OpenLayers.Rule({
  286. symbolizer: {
  287. stroke: true,
  288. strokeWidth: 3,
  289. fill: true,
  290. fillColor: "#ee9900",
  291. strokeColor: "#ee9900",
  292. }
  293. })
  294. , new OpenLayers.Rule({
  295. symbolizer: {
  296. stroke: true,
  297. fill: true,
  298. strokeWidth: 3,
  299. fillColor: "#ee9900",
  300. strokeColor: "#ee9900",
  301. // label : "rekord: ${recordId}",
  302. fontColor : "#333",
  303. fontOpacity: 0.7,
  304. ontSize: "12px",
  305. },
  306. filter: new OpenLayers.Filter.Comparison({
  307. type: OpenLayers.Filter.Comparison.GREATER_THAN,
  308. property: "recordId",
  309. value: 0
  310. })
  311. })
  312. , new OpenLayers.Rule({
  313. symbolizer: {
  314. stroke: true,
  315. fill: true,
  316. strokeWidth: 3,
  317. fillColor: "#ff0000",
  318. strokeColor: "#ff0000",
  319. // label : "rekord: ${_newRecordId}",
  320. fontColor : "#333",
  321. fontOpacity: 0.7,
  322. ontSize: "12px",
  323. },
  324. filter: new OpenLayers.Filter.Comparison({
  325. type: OpenLayers.Filter.Comparison.GREATER_THAN,
  326. property: "_newRecordId",
  327. value: 0
  328. })
  329. })
  330. , new OpenLayers.Rule({
  331. symbolizer: {
  332. stroke: true,
  333. fill: true,
  334. strokeWidth: 3,
  335. fillColor: "#ff0000",
  336. strokeColor: "#ff0000",
  337. },
  338. filter: new OpenLayers.Filter.Comparison({
  339. type: OpenLayers.Filter.Comparison.GREATER_THAN,
  340. property: "_modified",
  341. value: 0
  342. })
  343. })
  344. ]
  345. })
  346. });
  347. _layer = new OpenLayers.Layer.Vector(priv.options.layerName, {
  348. strategies: [new OpenLayers.Strategy.BBOX(), new OpenLayers.Strategy.Cluster({distance:30, threshold:3})],
  349. projection: new OpenLayers.Projection("EPSG:4326"),
  350. protocol: new OpenLayers.Protocol.WFS({
  351. version: "1.1.0",
  352. srsName: "EPSG:4326",
  353. url: priv.options.wfsUrl,
  354. featureNS : "http://opengeo.org",
  355. featureType: "restricted",
  356. geometryName: "the_geom",
  357. schema: "http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted"
  358. }),
  359. // @doc: http://dev.openlayers.org/releases/OpenLayers-2.13.1/doc/apidocs/files/OpenLayers/Feature/Vector-js.html
  360. styleMap: _styleMap
  361. });
  362. // @doc OpanLayers events http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html#link33
  363. _layer.events.on({
  364. 'sketchcomplete': function(e) {// turn off cluster strategy on start drawing
  365. if (priv.options.debug) console.log('Event: sketchcomplete e.feature.attributes: ', e.feature.attributes, '; selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');
  366. if (priv.isSelectedRecordId()) {
  367. e.feature.attributes._newRecordId = priv.getSelectedRecordId();
  368. }
  369. },
  370. 'sketchstarted': function(e) {// turn off cluster strategy on start drawing
  371. if (priv.options.debug) console.log('Event: sketchstarted e.feature.attributes: ', e.feature.attributes, '; selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');
  372. if (!priv.isSelectedRecordId()) {
  373. alert('Najpierw wybierz rekord z tabeli, żeby móc narysować dla niego figurę.');
  374. return false;
  375. }
  376. _layer.strategies[1].deactivate();
  377. _layer.refresh({force:false});
  378. },
  379. // 'beforefeatureadded': function(e) {
  380. // if (priv.options.debug) console.log('Event: beforefeatureadded e.feature.attributes: ', e.feature.attributes, '; selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');
  381. // if (priv.options.debug) console.log('Event: beforefeatureadded attr.count(' + e.feature.attributes.count + ')')
  382. // },
  383. 'beforefeaturemodified': function(e) {
  384. if (priv.options.debug) console.log('Event: beforefeaturemodified modified(', e.feature.attributes._modified, ')', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
  385. // NOTE: beforefeaturemodified from new node is fired before afterfeaturemodified from old node when click from one node to enother
  386. priv.checkSelectedFeatureModifications('before');
  387. priv.setSelectedFeature(e.feature);
  388. priv.showPopup(e.feature);
  389. },
  390. 'featuremodified': function(e) {
  391. if (priv.options.debug) console.log('Event: featuremodified modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
  392. if (_selectedFeature && _selectedFeature.attributes) {
  393. _selectedFeature.attributes._modified = 1;
  394. }
  395. },
  396. 'afterfeaturemodified': function(e) {
  397. if (priv.options.debug) 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
  398. if (_selectedFeature && _selectedFeature.fid != e.feature.fid) {
  399. if (priv.options.debug) console.log('Event: afterfeaturemodified pomiń check!');
  400. } else {
  401. priv.checkSelectedFeatureModifications('after');
  402. priv.setSelectedFeature(null);
  403. }
  404. priv.hidePopup(e.feature);
  405. }
  406. });
  407. var toolbar = new OpenLayers.Control.EditingToolbar(_layer);
  408. toolbar.addControls([
  409. new OpenLayers.Control.Button({
  410. title: "Twoja lokalizacja",
  411. displayClass: "olControlUserLocation",
  412. trigger: function() {
  413. if (navigator.geolocation) {
  414. navigator.geolocation.getCurrentPosition(drawFromUserLocation);
  415. } else {
  416. alert("Geolocation is not supported by this browser.");
  417. }
  418. function drawFromUserLocation(position) {
  419. var coords = position.coords;
  420. console.log("Latitude: " + coords.latitude + "<br>Longitude: " + coords.longitude);
  421. publ.zoomToExtent('POINT(' + coords.longitude + ' ' + coords.latitude + ')');
  422. if (!priv.isSelectedRecordId()) {
  423. alert('Najpierw wybierz rekord z tabeli, żeby móc narysować dla niego figurę.');
  424. return false;
  425. }
  426. setTimeout(function() {
  427. var geometry = new OpenLayers.Geometry.Point(coords.longitude, coords.latitude);
  428. var sourceProj = new OpenLayers.Projection("EPSG:4326");
  429. var targetProj = _map.getProjectionObject();
  430. var geometryTransformed = geometry.transform(sourceProj, targetProj);
  431. var pointFeature = new OpenLayers.Feature.Vector(geometryTransformed, {_newRecordId: priv.getSelectedRecordId()});//, _styleMap);
  432. pointFeature.geometry.clearBounds();
  433. console.log("pointFeature: ", pointFeature);
  434. _layer.addFeatures([pointFeature], {silent: true});
  435. _selectedFeature = pointFeature;
  436. console.log("_layer: ", _layer);
  437. }, 200);
  438. }
  439. }
  440. })
  441. ]);
  442. toolbar.addControls([
  443. new OpenLayers.Control.ModifyFeature(_layer, {
  444. title: "Edytuj"
  445. , mode: OpenLayers.Control.ModifyFeature.DRAG | OpenLayers.Control.ModifyFeature.RESHAPE
  446. })
  447. ]);
  448. var btnSelectFeature = new OpenLayers.Control.SelectFeature(_layer, {
  449. title: "Select Test",
  450. clickout: false,
  451. toggle: false,
  452. multiple: false,
  453. hover: false,
  454. toggleKey: "ctrlKey", // ctrl key removes from selection
  455. multipleKey: "shiftKey", // shift key adds to selection
  456. box: true
  457. /* copy from OpenLayers source lib/OpenLayers/Control/SelectFeature.js
  458. * add bounds to trigger "boxselectionend" event
  459. */
  460. , selectBox: function(position) {
  461. if (position instanceof OpenLayers.Bounds) {
  462. var minXY = this.map.getLonLatFromPixel({
  463. x: position.left,
  464. y: position.bottom
  465. });
  466. var maxXY = this.map.getLonLatFromPixel({
  467. x: position.right,
  468. y: position.top
  469. });
  470. var bounds = new OpenLayers.Bounds(
  471. minXY.lon, minXY.lat, maxXY.lon, maxXY.lat
  472. );
  473. // if multiple is false, first deselect currently selected features
  474. if (!this.multipleSelect()) {
  475. this.unselectAll();
  476. }
  477. // because we're using a box, we consider we want multiple selection
  478. var prevMultiple = this.multiple;
  479. this.multiple = true;
  480. var layers = this.layers || [this.layer];
  481. this.events.triggerEvent("boxselectionstart", {layers: layers});
  482. var layer;
  483. for(var l=0; l<layers.length; ++l) {
  484. layer = layers[l];
  485. for(var i=0, len = layer.features.length; i<len; ++i) {
  486. var feature = layer.features[i];
  487. // check if the feature is displayed
  488. if (!feature.getVisibility()) {
  489. continue;
  490. }
  491. if (this.geometryTypes == null || OpenLayers.Util.indexOf(
  492. this.geometryTypes, feature.geometry.CLASS_NAME) > -1) {
  493. if (bounds.toGeometry().intersects(feature.geometry)) {
  494. if (OpenLayers.Util.indexOf(layer.selectedFeatures, feature) == -1) {
  495. this.select(feature);
  496. }
  497. }
  498. }
  499. }
  500. }
  501. this.multiple = prevMultiple;
  502. this.events.triggerEvent("boxselectionend", {layers: layers, bounds: bounds});
  503. }
  504. }
  505. });
  506. btnSelectFeature.events.on({
  507. "boxselectionend": function(e) {
  508. if (priv.options.debug) console.log('SelectFeature boxselectionend event', e, e.bounds);
  509. if (typeof priv.options.onSelectBox == "function") {
  510. var layerProj = _map.getProjectionObject();
  511. var targetProj = new OpenLayers.Projection("EPSG:4326");
  512. var bounds = e.bounds.transform(layerProj, targetProj);
  513. if (priv.options.debug) console.log('SelectFeature boxselectionend event bounds', bounds);
  514. priv.options.onSelectBox.call(this, bounds);
  515. }
  516. }
  517. });
  518. toolbar.addControls([btnSelectFeature]);
  519. toolbar.addControls([
  520. new OpenLayers.Control.Button({
  521. title: "Refresh",
  522. displayClass: "olControlRefresh",
  523. trigger: function() {
  524. _layer.refresh({force: true});
  525. }
  526. })
  527. ]);
  528. toolbar.addControls([
  529. new OpenLayers.Control.Button({
  530. title: "Zapisz zmiany",
  531. displayClass: "olControlSave",
  532. trigger: function() {
  533. if (_selectedFeature) {
  534. var selectedRecordId = priv.getSelectedRecordId();
  535. if (!selectedRecordId) {
  536. alert('Wybierz rekord tabeli');
  537. }
  538. else {
  539. priv.saveSelectedFeature();
  540. priv.cancelSelectedFeatureModifications();
  541. }
  542. }
  543. else {
  544. alert('Wybierz element na mapie');
  545. }
  546. }
  547. })
  548. ]);
  549. if (priv.options.addBtn) {
  550. toolbar.addControls([
  551. new OpenLayers.Control.Button({
  552. title: priv.options.addBtn.title,
  553. displayClass: priv.options.addBtn.displayClass,
  554. trigger: function() {
  555. if (typeof priv.options.addBtn.trigger == "function") {
  556. priv.options.addBtn.trigger.call(this);
  557. }
  558. }
  559. })
  560. ]);
  561. }
  562. var gphy = new OpenLayers.Layer.OSM("Mapa", null, {
  563. resolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
  564. 19567.87923828125, 9783.939619140625, 4891.9698095703125,
  565. 2445.9849047851562, 1222.9924523925781, 611.4962261962891,
  566. 305.74811309814453, 152.87405654907226, 76.43702827453613,
  567. 38.218514137268066, 19.109257068634033, 9.554628534317017,
  568. 4.777314267158508, 2.388657133579254, 1.194328566789627,
  569. 0.5971642833948135, 0.25, 0.1, 0.05],
  570. serverResolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
  571. 19567.87923828125, 9783.939619140625,
  572. 4891.9698095703125, 2445.9849047851562,
  573. 1222.9924523925781, 611.4962261962891,
  574. 305.74811309814453, 152.87405654907226,
  575. 76.43702827453613, 38.218514137268066,
  576. 19.109257068634033, 9.554628534317017,
  577. 4.777314267158508, 2.388657133579254,
  578. 1.194328566789627, 0.5971642833948135],
  579. transitionEffect: 'resize'
  580. });
  581. var mapControls = [];
  582. mapControls.push(toolbar);
  583. mapControls.push(new OpenLayers.Control.ZoomPanel());
  584. mapControls.push(new OpenLayers.Control.PanPanel());
  585. mapControls.push(new OpenLayers.Control.LayerSwitcher());
  586. mapControls.push(new OpenLayers.Control.ScaleLine());
  587. _controlSelectedRecord = new myOpenLayers_Control_SelectedRecord();
  588. mapControls.push(_controlSelectedRecord);
  589. if (priv.options.showAddLayerWidget) {
  590. _controlManageLayers = new myOpenLayers_Control_ManageLayers();
  591. _controlManageLayers.setMapWidget(priv);
  592. mapControls.push(_controlManageLayers);
  593. }
  594. // TODO: add box with selected record from table, x for remove selection
  595. mapControls.push(new OpenLayers.Control.KeyboardDefaults());
  596. /* NOTE: map is in projection EPSG:900913 even if projection and displayProjection is set to EPSG:4326
  597. * _map.getProjectionObject(); returns EPSG:900913
  598. * restrictedExtent should be set in EPSG:900913
  599. * zoomToExtent should use EPSG:900913 - need to transform from EPSG:4326 to EPSG:900913
  600. */
  601. _map = new OpenLayers.Map(_nodeMapId, {
  602. projection: new OpenLayers.Projection("EPSG:4326"),
  603. displayProjection: new OpenLayers.Projection("EPSG:4326"),
  604. restrictedExtent: new OpenLayers.Bounds(
  605. 1526390.4410645328, 6273526.00, 2693330.958028555, 7352240.00
  606. ),
  607. controls: mapControls,
  608. layers: [gphy,_layer]
  609. });
  610. _map.events.register("zoomend", this, function(e) {
  611. var zoom = _map.getZoom();
  612. if (priv.options.debug) console.log('zoom(',zoom,', ',priv.options.zoomStrategyActivate,')');
  613. if (zoom > priv.options.zoomStrategyActivate && _layer.strategies[1].active) {
  614. _layer.strategies[1].deactivate();
  615. _layer.refresh({force:true});
  616. } else if (zoom <= priv.options.zoomStrategyActivate && !_layer.strategies[1].active) {
  617. _layer.strategies[1].activate();
  618. _layer.refresh({force:true});
  619. }
  620. });
  621. _map.zoomToMaxExtent();
  622. };
  623. priv.showPopup = function(feature) {
  624. if (priv.options.debug) console.log('showPopup() ... ');
  625. if (!feature) return;
  626. var popupContent = '';
  627. if (feature.attributes._newRecordId > 0) {
  628. popupContent = 'Rekord: ' + feature.attributes._newRecordId;
  629. } else if (feature.attributes.recordId > 0) {
  630. popupContent = 'Rekord: ' + feature.attributes.recordId;
  631. }
  632. if (!popupContent) return;
  633. popupContent = '<div style="font-size:.8em">' + popupContent + '</div>';
  634. var popup = new OpenLayers.Popup("popups",
  635. feature.geometry.getBounds().getCenterLonLat(),
  636. new OpenLayers.Size(100,20),
  637. popupContent,
  638. true);
  639. popup.setBorder('1px solid #333');
  640. popup.setOpacity(0.7);
  641. feature.popup = popup;
  642. _map.addPopup(popup);
  643. };
  644. priv.hidePopup = function(feature) {
  645. if (priv.options.debug) console.log('hidePopup() ... ');
  646. if (feature && feature.popup) {
  647. _map.removePopup(feature.popup);
  648. feature.popup.destroy();
  649. feature.popup = null;
  650. }
  651. };
  652. priv.onPopupClose = function() {
  653. if (priv.options.debug) console.log('onPopupClose() ...');
  654. priv.hidePopup(_selectedFeature);
  655. };
  656. priv.setSelectedFeature = function(feature) {
  657. _selectedFeature = feature;
  658. if (_selectedFeature && _selectedFeature.attributes && _selectedFeature.attributes.recordId > 0) {
  659. if (_selectedFeature.attributes.recordId != priv.getSelectedRecordId()) {
  660. priv.setSelectedRecordId(_selectedFeature.attributes.recordId);
  661. }
  662. }
  663. };
  664. priv.setSelectedRecordId = function(id) {
  665. if (_controlSelectedRecord) {
  666. _controlSelectedRecord.setSelectedRecordId(id);
  667. }
  668. };
  669. priv.getSelectedRecordId = function() {
  670. if (_controlSelectedRecord) {
  671. return _controlSelectedRecord.getSelectedRecordId();
  672. }
  673. return null;
  674. };
  675. priv.isSelectedRecordId = function() {
  676. if (_controlSelectedRecord) {
  677. return _controlSelectedRecord.isSelectedRecordId();
  678. }
  679. return false;
  680. };
  681. priv.isSelectedFeature = function() {
  682. if (priv.options.debug) console.log('_selectedFeature:', _selectedFeature);
  683. return (_selectedFeature)? true : false;
  684. };
  685. priv.changeSelectedFeatureRecordId = function(recordId) {
  686. if (priv.options.debug) console.log('priv.changeSelectedFeatureRecordId(',recordId,')::_selectedFeature:', _selectedFeature);
  687. if (_selectedFeature) {
  688. _selectedFeature.attributes.recordId = recordId;
  689. _selectedFeature.attributes._modified = 1;
  690. }
  691. };
  692. priv.cancelSelectedFeatureModifications = function() {
  693. if (!_selectedFeature) return false;
  694. if (_selectedFeature.attributes._newRecordId) {
  695. delete _selectedFeature.attributes._newRecordId;
  696. }
  697. if (_selectedFeature.attributes._modified) {
  698. delete _selectedFeature.attributes._modified;
  699. }
  700. };
  701. priv.isSelectedFeatureModified = function() {
  702. if (!_selectedFeature) return false;
  703. if (_selectedFeature.attributes) {
  704. if (_selectedFeature.attributes._newRecordId) {
  705. return true;
  706. }
  707. if (_selectedFeature.attributes._modified) {
  708. return true;
  709. }
  710. }
  711. return false;
  712. };
  713. priv.saveSelectedFeature = function() {
  714. if (priv.isSelectedFeatureModified()) {
  715. if (typeof priv.options.onSaveFeature == "function") {
  716. var sourceProj = _map.getProjectionObject();
  717. var targetProj = new OpenLayers.Projection("EPSG:4326");
  718. var selFeatureGeometry = _selectedFeature.geometry.clone();
  719. var selFeatureGeomTransformed = selFeatureGeometry.transform(sourceProj, targetProj);
  720. var selFeatureExtent = new OpenLayers.Format.WKT().extractGeometry(selFeatureGeomTransformed);
  721. priv.options.onSaveFeature.call(this, priv.getSelectedRecordId(), selFeatureExtent);
  722. }
  723. }
  724. }
  725. priv.checkSelectedFeatureModifications = function(when) {
  726. if (priv.isSelectedFeatureModified()) {
  727. var selectedRecordId = priv.getSelectedRecordId();
  728. var msgRecordId = (selectedRecordId > 0)? ' - rekord nr ' + selectedRecordId : '';
  729. // TODO: if !selectedRecordId then "Create new record"
  730. if (confirm('Czy zapisać zmiany wprowadzone dla zaznaczonego elementu' + msgRecordId + '?')) {
  731. // _layer.refresh();
  732. priv.saveSelectedFeature();
  733. priv.cancelSelectedFeatureModifications();
  734. }
  735. else {
  736. priv.cancelSelectedFeatureModifications();
  737. _layer.refresh({force:true});
  738. }
  739. }
  740. };
  741. // using OpenLayers.Format.WPSCapabilities to read the capabilities
  742. priv.getCapabilities = function() {
  743. OpenLayers.Request.GET({
  744. url: priv.options.wpsUrl,
  745. params: {
  746. "SERVICE": "WPS",
  747. "REQUEST": "GetCapabilities"
  748. },
  749. success: function(response){
  750. _capabilities = new OpenLayers.Format.WPSCapabilities().read(
  751. response.responseText
  752. );
  753. var dropdown = _nodeProcesses;
  754. var offerings = _capabilities.processOfferings, option;
  755. // populate the dropdown
  756. for (var p in offerings) {
  757. option = document.createElement("option");
  758. option.innerHTML = offerings[p].identifier;
  759. option.value = p;
  760. dropdown.append(option);
  761. }
  762. }
  763. });
  764. };
  765. priv.buildForm = function() {
  766. _nodeAbstract.html(_process["abstract"]);
  767. _nodeInput.html("<h3>Input:</h3>");
  768. _nodeOutput.html('');
  769. var inputs = _process.dataInputs, supported = true,
  770. sld = "text/xml; subtype=sld/1.0.0",
  771. input;
  772. for (var i = 0, ii = inputs.length; i < ii; ++i) {
  773. input = inputs[i];
  774. if (input.complexData) {
  775. var formats = input.complexData.supported.formats;
  776. if (formats["application/wkt"]) {
  777. priv.addWKTInput(input);
  778. } else if (formats["text/xml; subtype=wfs-collection/1.0"]) {
  779. priv.addWFSCollectionInput(input);
  780. } else if (formats["image/tiff"]) {
  781. //priv.addRasterInput(input);
  782. } else if (formats[sld]) {
  783. priv.addXMLInput(input, sld);
  784. } else {
  785. supported = false;
  786. }
  787. } else if (input.boundingBoxData) {
  788. priv.addBoundingBoxInput(input);
  789. } else if (input.literalData) {
  790. priv.addLiteralInput(input);
  791. } else {
  792. supported = false;
  793. }
  794. if (input.minOccurs > 0) {
  795. _nodeInput.append(document.createTextNode("* "));
  796. }
  797. }
  798. if (supported) {
  799. var executeButton = document.createElement("button");
  800. executeButton.innerHTML = "Execute";
  801. _nodeInput.append(executeButton);
  802. executeButton.onclick = priv.execute;
  803. } else {
  804. _nodeInput.html('<span class="notsupported">' +
  805. "Sorry, the WPS builder does not support the selected process." +
  806. "</span>");
  807. }
  808. };
  809. // helper function to dynamically create a textarea for geometry (WKT) data
  810. // input
  811. priv.addWKTInput = function(input, previousSibling) {
  812. var name = input.identifier;
  813. var container = _nodeInput.get(0);
  814. var label = document.createElement("label");
  815. label["for"] = name;
  816. label.title = input["abstract"];
  817. label.innerHTML = name + " (select feature, then click field):";
  818. previousSibling && previousSibling.nextSibling ?
  819. container.insertBefore(label, previousSibling.nextSibling) :
  820. container.appendChild(label);
  821. var field = document.createElement("textarea");
  822. field.onclick = function () {
  823. if (_layer.selectedFeatures.length) {
  824. this.innerHTML = new OpenLayers.Format.WKT().write(
  825. _layer.selectedFeatures[0]
  826. );
  827. if (priv.options.debug) console.log('_layer.selectedFeatures[0]: ', _layer.selectedFeatures[0]);
  828. }
  829. priv.createCopy(input, this, priv.addWKTInput);
  830. };
  831. field.onblur = function() {
  832. input.data = field.value ? {
  833. complexData: {
  834. mimeType: "application/wkt",
  835. value: this.value
  836. }
  837. } : undefined;
  838. };
  839. field.title = input["abstract"];
  840. field.id = name;
  841. previousSibling && previousSibling.nextSibling ?
  842. container.insertBefore(field, previousSibling.nextSibling.nextSibling) :
  843. container.appendChild(field);
  844. };
  845. // helper function for xml input
  846. priv.addXMLInput = function(input, type) {
  847. var name = input.identifier;
  848. var field = document.createElement("input");
  849. field.title = input["abstract"];
  850. field.value = name + " (" + type + ")";
  851. field.onblur = function() {
  852. input.data = field.value ? {
  853. complexData: {
  854. mimeType: type,
  855. value: this.value
  856. }
  857. } : undefined;
  858. };
  859. _nodeInput.append(field);
  860. };
  861. // helper function to dynamically create a WFS collection reference input
  862. priv.addWFSCollectionInput = function(input) {
  863. var name = input.identifier;
  864. var field = document.createElement("input");
  865. field.title = input["abstract"];
  866. field.value = name + " (layer on demo server)";
  867. priv.addValueHandlers(field, function() {
  868. input.reference = field.value ? {
  869. mimeType: "text/xml; subtype=wfs-collection/1.0",
  870. href: "http://geoserver/wfs",
  871. method: "POST",
  872. body: {
  873. wfs: {
  874. version: "1.0.0",
  875. outputFormat: "GML2",
  876. featureType: field.value
  877. }
  878. }
  879. } : undefined;
  880. });
  881. _nodeInput.append(field);
  882. };
  883. // helper function to dynamically create a raster (GeoTIFF) url input
  884. priv.addRasterInput = function(input) {
  885. var name = input.identifier;
  886. var field = document.createElement("input");
  887. field.title = input["abstract"];
  888. var url = window.location.href.split("?")[0];
  889. field.value = url.substr(0, url.lastIndexOf("/")+1) + "data/tazdem.tiff";// TODO: file path to options
  890. document.getElementById("input").appendChild(field);
  891. (field.onblur = function() {
  892. input.reference = {
  893. mimeType: "image/tiff",
  894. href: field.value,
  895. method: "GET"
  896. };
  897. })();
  898. };
  899. // helper function to dynamically create a bounding box input
  900. priv.addBoundingBoxInput = function(input) {
  901. var name = input.identifier;
  902. var field = document.createElement("input");
  903. field.title = input["abstract"];
  904. field.value = "left,bottom,right,top (EPSG:4326)";
  905. _nodeInput.append(field);
  906. priv.addValueHandlers(field, function() {
  907. input.boundingBoxData = {
  908. projection: "EPSG:4326",
  909. bounds: OpenLayers.Bounds.fromString(field.value)
  910. };
  911. });
  912. };
  913. // helper function to create a literal input textfield or dropdown
  914. priv.addLiteralInput = function(input, previousSibling) {
  915. var name = input.identifier;
  916. var container = _nodeInput.get(0);
  917. var anyValue = input.literalData.anyValue;
  918. // anyValue means textfield, otherwise we create a dropdown
  919. var field = document.createElement(anyValue ? "input" : "select");
  920. field.id = name;
  921. field.title = input["abstract"];
  922. previousSibling && previousSibling.nextSibling ?
  923. container.insertBefore(field, previousSibling.nextSibling) :
  924. container.appendChild(field);
  925. if (anyValue) {
  926. var dataType = input.literalData.dataType;
  927. field.value = name + (dataType ? " (" + dataType + ")" : "");
  928. priv.addValueHandlers(field, function() {
  929. input.data = field.value ? {
  930. literalData: {
  931. value: field.value
  932. }
  933. } : undefined;
  934. priv.createCopy(input, field, priv.addLiteralInput);
  935. });
  936. } else {
  937. var option;
  938. option = document.createElement("option");
  939. option.innerHTML = name;
  940. field.appendChild(option);
  941. for (var v in input.literalData.allowedValues) {
  942. option = document.createElement("option");
  943. option.value = v;
  944. option.innerHTML = v;
  945. field.appendChild(option);
  946. }
  947. field.onchange = function() {
  948. priv.createCopy(input, field, priv.addLiteralInput);
  949. input.data = this.selectedIndex ? {
  950. literalData: {
  951. value: this.options[this.selectedIndex].value
  952. }
  953. } : undefined;
  954. };
  955. }
  956. };
  957. // if maxOccurs is > 1, this will add a copy of the field
  958. priv.createCopy = function(input, field, fn) {
  959. if (input.maxOccurs && input.maxOccurs > 1 && !field.userSelected) {
  960. // add another copy of the field - we don't check maxOccurs
  961. field.userSelected = true;
  962. var newInput = OpenLayers.Util.extend({}, input);
  963. // we recognize copies by the occurrence property
  964. newInput.occurrence = (input.occurrence || 0) + 1;
  965. _process.dataInputs.push(newInput);
  966. fn(newInput, field);
  967. }
  968. };
  969. // helper function for adding events to form fields
  970. priv.addValueHandlers = function(field, onblur) {
  971. field.onclick = function() {
  972. if (!this.initialValue) {
  973. this.initialValue = this.value;
  974. this.value = "";
  975. }
  976. };
  977. field.onblur = function() {
  978. if (!this.value) {
  979. this.value = this.initialValue;
  980. delete this.initialValue;
  981. }
  982. onblur.apply(this, arguments);
  983. };
  984. };
  985. // execute the process
  986. priv.execute = function() {
  987. var output = _process.processOutputs[0];
  988. var input;
  989. // remove occurrences that the user has not filled out
  990. for (var i = _process.dataInputs.length - 1; i >= 0; --i) {
  991. input = _process.dataInputs[i];
  992. if ((input.minOccurs === 0 || input.occurrence) && !input.data && !input.reference) {
  993. OpenLayers.Util.removeItem(_process.dataInputs, input);
  994. }
  995. }
  996. _process.responseForm = {
  997. rawDataOutput: {
  998. identifier: output.identifier
  999. }
  1000. };
  1001. if (output.complexOutput && output.complexOutput.supported.formats["application/wkt"]) {
  1002. _process.responseForm.rawDataOutput.mimeType = "application/wkt";
  1003. }
  1004. OpenLayers.Request.POST({
  1005. url: priv.options.wpsUrl,
  1006. data: new OpenLayers.Format.WPSExecute().write(_process),
  1007. success: priv.showOutput
  1008. });
  1009. }
  1010. // add the process's output to the page
  1011. priv.showOutput = function(response) {
  1012. var result = _nodeOutput.get(0);
  1013. result.innerHTML = "<h3>Output:</h3>";
  1014. var features;
  1015. var contentType = response.getResponseHeader("Content-Type");
  1016. if (contentType == "application/wkt") {
  1017. features = new OpenLayers.Format.WKT().read(response.responseText);
  1018. } else if (contentType == "text/xml; subtype=wfs-collection/1.0") {
  1019. features = new OpenLayers.Format.WFST.v1_0_0().read(response.responseText);
  1020. }
  1021. if (features && (features instanceof OpenLayers.Feature.Vector || features.length)) {
  1022. _layer.addFeatures(features);
  1023. result.innerHTML += "The result should also be visible on the map.";
  1024. }
  1025. result.innerHTML += "<textarea>" + response.responseText + "</textarea>";
  1026. }
  1027. publ.updateSize = function() {
  1028. _map.updateSize();
  1029. };
  1030. publ.refresh = function(options) {
  1031. if (priv.options.debug) console.log('publ.refresh ... ', options);
  1032. _layer.refresh({force:true});
  1033. };
  1034. publ.zoomToExtent = function(extent) {
  1035. if (!extent) return;
  1036. var sourceProj = new OpenLayers.Projection("EPSG:4326");
  1037. var targetProj = _map.getProjectionObject();
  1038. var extentBounds = OpenLayers.Geometry.fromWKT(extent).transform(sourceProj, targetProj).getBounds();
  1039. _map.zoomToExtent(extentBounds);
  1040. };
  1041. publ.selectRecord = function(recordId, extent) {
  1042. if (priv.isSelectedRecordId()) {
  1043. if (priv.getSelectedRecordId() != recordId) {
  1044. if (priv.isSelectedFeature()) {
  1045. if (confirm('Aktualnie przypisany rekord to ' + priv.getSelectedRecordId() + ' czy zmienić na ' + recordId + '?')) {
  1046. priv.setSelectedRecordId(recordId);
  1047. priv.changeSelectedFeatureRecordId(recordId);
  1048. }
  1049. } else {
  1050. priv.setSelectedRecordId(recordId);
  1051. publ.zoomToExtent(extent);
  1052. }
  1053. } else {
  1054. publ.zoomToExtent(extent);
  1055. }
  1056. }
  1057. else {
  1058. priv.setSelectedRecordId(recordId);
  1059. publ.zoomToExtent(extent);
  1060. }
  1061. };
  1062. publ.init = function(options) {
  1063. if (priv.options.debug) console.log('TableAjaxMap initialization...', options);
  1064. //merge supplied options with defaults
  1065. $.extend(priv.options, defaults, options);
  1066. priv.init();
  1067. return publ;
  1068. };
  1069. return publ;
  1070. };
  1071. $.fn.TableAjaxMapUpdateSize = function(options) {
  1072. options = options || {};
  1073. return this.each(function() {
  1074. var tblAjaxMap = $(this).data('TableAjaxMap');
  1075. if (tblAjaxMap) {
  1076. tblAjaxMap.updateSize();
  1077. }
  1078. });
  1079. return this;
  1080. };
  1081. $.fn.TableAjaxMapRefresh = function(options) {
  1082. options = options || {};
  1083. return this.each(function() {
  1084. var tblAjaxMap = $(this).data('TableAjaxMap');
  1085. if (tblAjaxMap) {
  1086. tblAjaxMap.refresh(options);
  1087. }
  1088. });
  1089. return this;
  1090. };
  1091. $.fn.TableAjaxMapZoomToExtent = function(extent) {
  1092. if (!extent) return;
  1093. return this.each(function() {
  1094. var tblAjaxMap = $(this).data('TableAjaxMap');
  1095. if (tblAjaxMap) {
  1096. tblAjaxMap.zoomToExtent(extent);
  1097. }
  1098. });
  1099. return this;
  1100. };
  1101. $.fn.TableAjaxMapSelectRecord = function(recordId, extent) {
  1102. if (!recordId) return;
  1103. return this.each(function() {
  1104. var tblAjaxMap = $(this).data('TableAjaxMap');
  1105. if (tblAjaxMap) {
  1106. tblAjaxMap.selectRecord(recordId, extent);
  1107. }
  1108. });
  1109. return this;
  1110. };
  1111. $.fn.TableAjaxMap = function(options) {
  1112. options = options || {};
  1113. return this.each(function() {
  1114. options.id = this;
  1115. if (!$(this).data('TableAjaxMap')) {
  1116. $(this).data('TableAjaxMap', new TableAjaxMap().init(options));
  1117. }
  1118. });
  1119. return this;
  1120. };
  1121. }(jQuery));
  1122. </script>
  1123. <?php
  1124. }
  1125. public function ajaxTask($task) {
  1126. switch ($task) {
  1127. case 'PROXY': {
  1128. $this->sendAjaxProxy($_REQUEST);
  1129. break;
  1130. }
  1131. default:
  1132. //$this->sendAjaxData($_REQUEST);
  1133. }
  1134. }
  1135. public function sendAjaxProxy($args) {
  1136. $wpsServer = null;
  1137. $url = V::get('url', '', $args);
  1138. // 1. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DGetCapabilities
  1139. // 2. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DDescribeProcess%26VERSION%3D1.0.0%26IDENTIFIER%3Dpozdrawiam
  1140. header('Content-Type: application/xml; charset=utf-8');
  1141. $urlParts = parse_url($url);
  1142. $urlPath = V::get('path', '', $urlParts);
  1143. $urlQuery = array();
  1144. $urlQueryTmp = V::get('query', '', $urlParts);
  1145. $urlQueryTmp = explode('&', $urlQueryTmp);
  1146. foreach ($urlQueryTmp as $vQuery) {
  1147. $parts = explode('=', $vQuery, 2);
  1148. $urlQuery[$parts[0]] = $parts[1];
  1149. }
  1150. $urlPath = explode('/', trim($urlPath, "/ \n\t\r\0\x0B"));
  1151. if (count($urlPath) > 2) {// /wps/21176/BABIDOL_DXF_SHP
  1152. if ($urlPath[1] == '21176' && $urlPath[2] == 'BABIDOL_DXF_SHP') {
  1153. $tableId = $urlPath[1];
  1154. $userAcl = User::getAcl();
  1155. $userAcl->fetchGroups();
  1156. if (!$userAcl->hasTableAcl($tableId)) {
  1157. die('403 Forbidden');
  1158. }
  1159. $tblAcl = $userAcl->getTableAcl($tableId);
  1160. if (!$tblAcl) {
  1161. die('404 Not Found');
  1162. }
  1163. $tblAcl->init();
  1164. $wpsServer = new TableAjaxMapWpsServer($tblAcl);
  1165. }
  1166. }
  1167. if (!$wpsServer) {
  1168. $wpsServer = new TableAjaxMapWpsServer($this->_acl);
  1169. }
  1170. if ('WPS' == V::get('SERVICE', '', $urlQuery)) {
  1171. $req = V::get('REQUEST', '', $urlQuery);
  1172. $methodName = "{$req}Action";
  1173. if (method_exists($wpsServer, $methodName)) {
  1174. $wpsServer->$methodName($urlQuery);
  1175. }
  1176. }
  1177. else {
  1178. $wpsServer->parseXMLRequest();
  1179. }
  1180. exit;
  1181. }
  1182. }
  1183. class TableAjaxMapWfsAction {
  1184. private $_acl;
  1185. private $_zasobID;
  1186. public function __construct($acl) {
  1187. $this->_acl = $acl;
  1188. $this->_zasobID = $acl->getID();
  1189. }
  1190. /**
  1191. * example: MULTIPOLYGON(((2072016.74395199 7234076.79293037,2072016.74395199 7234115.01144451,2072131.3994944 7234115.01144451,2072131.3994944 7234076.79293037,2072016.74395199 7234076.79293037)))
  1192. */
  1193. public function generateGmlFromWKT($wkt) {
  1194. $gml = '';
  1195. $wktParts = explode('(', $wkt, 2);
  1196. ob_start();
  1197. switch ($wktParts[0]) {
  1198. case 'MULTIPOLYGON':
  1199. case 'POLYGON': {
  1200. $points = trim($wktParts[1], '() ');
  1201. $points = str_replace(',', "\n", $points);
  1202. ?>
  1203. <gml:boundedBy>
  1204. <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1205. <gml:lowerCorner>-180 -90</gml:lowerCorner>
  1206. <gml:upperCorner>180 90</gml:upperCorner>
  1207. </gml:Envelope>
  1208. </gml:boundedBy>
  1209. <og:the_geom>
  1210. <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1211. <gml:surfaceMember>
  1212. <gml:Polygon srsDimension="2">
  1213. <gml:exterior>
  1214. <gml:LinearRing srsDimension="2">
  1215. <gml:posList>
  1216. <?php echo $points; ?>
  1217. </gml:posList>
  1218. </gml:LinearRing>
  1219. </gml:exterior>
  1220. </gml:Polygon>
  1221. </gml:surfaceMember>
  1222. </gml:MultiSurface>
  1223. </og:the_geom>
  1224. <?php
  1225. }
  1226. break;
  1227. case 'POINT':
  1228. case 'MULTIPOINT': {
  1229. $points = trim($wktParts[1], '() ');
  1230. $points = str_replace(',', "\n", $points);
  1231. // <gml:pos>45.67 88.56</gml:pos>
  1232. // <gml:gml:coordinates>45.67, 88.56</gml:coordinates>
  1233. ?>
  1234. <gml:boundedBy>
  1235. <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1236. <gml:lowerCorner>-180 -90</gml:lowerCorner>
  1237. <gml:upperCorner>180 90</gml:upperCorner>
  1238. </gml:Envelope>
  1239. </gml:boundedBy>
  1240. <gml:Point srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1241. <gml:pos><?php echo $points; ?></gml:pos>
  1242. </gml:Point>
  1243. <?php
  1244. }
  1245. break;
  1246. case 'LINESTRING': {
  1247. $points = trim($wktParts[1], '() ');
  1248. $points = str_replace(',', "\n", $points);
  1249. ?>
  1250. <gml:boundedBy>
  1251. <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1252. <gml:lowerCorner>-180 -90</gml:lowerCorner>
  1253. <gml:upperCorner>180 90</gml:upperCorner>
  1254. </gml:Envelope>
  1255. </gml:boundedBy>
  1256. <gml:LineString srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1257. <gml:posList><?php echo $points; ?></gml:posList>
  1258. </gml:LineString>
  1259. <?php
  1260. }
  1261. break;
  1262. default:
  1263. ?>
  1264. <!-- UNKNOWN WKT:<?php echo $wkt; ?> -->
  1265. <?php
  1266. }
  1267. $gml = ob_get_contents();
  1268. ob_clean();
  1269. return $gml;
  1270. }
  1271. public function execute($args) {
  1272. /*
  1273. * Mapa odczytywanie punktów: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
  1274. *
  1275. * CI50:
  1276. 18.613243103027344 54.33614429135817
  1277. 18.613243103027344 54.33634445792519
  1278. 18.614273071289062 54.33634445792519
  1279. 18.614273071289062 54.33614429135817
  1280. */
  1281. Lib::loadClass('Data_Source');
  1282. $dataSource = new Data_Source($this->_acl->getDB());
  1283. $dataSource->setTable($this->_acl->getName());
  1284. $dataSource->addCol('ID');
  1285. $dataSource->addCol('the_geom');
  1286. $dataSource->setColTypes($this->_acl->getTypes());
  1287. $params = array();
  1288. $params['limit'] = 10000;
  1289. if (!empty($args['BBOX'])) {
  1290. $params['f_the_geom'] = 'BBOX:' . implode(',', $args['BBOX']);
  1291. }
  1292. $items = $dataSource->getItems($params);
  1293. $buildingsGml = array();
  1294. foreach ($items as $r) {
  1295. if (!empty($r->the_geom)) {
  1296. $buildingsGml[$r->ID] = $this->generateGmlFromWKT($r->the_geom);
  1297. }
  1298. }
  1299. /**
  1300. * <og:recordId><?php echo $kId; ?></og:recordId>
  1301. * <og:tblId><?php echo $tblId; ?></og:tblId>
  1302. *
  1303. * goes to js: @see priv.addWKTInput _layer.selectedFeatures[0]
  1304. *
  1305. * attributes: Object
  1306. recordId: "1130"
  1307. tblId: "16"
  1308. */
  1309. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1310. ?>
  1311. <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">
  1312. <gml:boundedBy>
  1313. <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
  1314. <gml:lowerCorner>-180 -90</gml:lowerCorner>
  1315. <gml:upperCorner>180 90</gml:upperCorner>
  1316. </gml:Envelope>
  1317. </gml:boundedBy>
  1318. <gml:featureMembers>
  1319. <?php foreach ($buildingsGml as $kId => $vGml) : ?>
  1320. <og:restricted gml:id="restricted.<?php echo $kId; ?>">
  1321. <?php echo $vGml; ?>
  1322. <og:recordId><?php echo $kId; ?></og:recordId>
  1323. <og:tblId><?php echo $this->_zasobID; ?></og:tblId>
  1324. </og:restricted>
  1325. <?php endforeach; ?>
  1326. </gml:featureMembers>
  1327. </wfs:FeatureCollection>
  1328. <?php
  1329. }
  1330. }
  1331. class WpsActionBase {
  1332. public $title = '';
  1333. public $description = '';
  1334. public $dataInputs = array();
  1335. public function execute($args) {
  1336. var_dump($args);
  1337. }
  1338. }
  1339. class WpsActionPrzypiszDoRekordu extends WpsActionBase {
  1340. public function __construct() {
  1341. $this->title = 'Przypisz';
  1342. $this->description = 'Przypisuje położenie do wybranego rekordu w tabeli.';
  1343. $this->dataInputs['geom'] = new stdClass();
  1344. $this->dataInputs['geom']->title = 'geom';
  1345. $this->dataInputs['geom']->description = 'Input geometry';
  1346. $this->dataInputs['geom']->type = 'geom';// CoomplexData
  1347. $this->dataInputs['idTable'] = new stdClass();
  1348. $this->dataInputs['idTable']->title = 'geom';
  1349. $this->dataInputs['idTable']->description = 'Table ID';
  1350. $this->dataInputs['idTable']->type = 'integer';// LiteralData: xs:integer
  1351. $this->dataInputs['idRecord'] = new stdClass();
  1352. $this->dataInputs['idRecord']->title = 'idRecord';
  1353. $this->dataInputs['idRecord']->description = 'Record ID';
  1354. $this->dataInputs['idRecord']->type = 'integer';// LiteralData: xs:integer
  1355. }
  1356. }
  1357. class TableAjaxMapWpsServer {
  1358. private $_fun;// config for identifiers
  1359. private $_wfsAction;
  1360. private $_zasobID;
  1361. private $_acl;
  1362. public function __construct($acl) {
  1363. $this->_fun['przypiszDoRekordu'] = new WpsActionPrzypiszDoRekordu();
  1364. $this->_acl = $acl;
  1365. $this->_zasobID = $acl->getID();
  1366. $this->_wfsAction = new TableAjaxMapWfsAction($this->_acl);
  1367. }
  1368. public function parseXMLRequest() {
  1369. $data = array();
  1370. $reqContent = file_get_contents('php://input');
  1371. $xml = new SimpleXMLElement($reqContent);
  1372. if ('GetFeature' == $xml->getName()) {
  1373. // TODO: parse xml and set query params
  1374. /*
  1375. <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">
  1376. <wfs:Query typeName="feature:restricted" srsName="EPSG:4326" xmlns:feature="http://opengeo.org">
  1377. <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
  1378. <ogc:BBOX>
  1379. <ogc:PropertyName>the_geom</ogc:PropertyName>
  1380. <gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
  1381. <gml:lowerCorner>17.226562502593 53.887024366231</gml:lowerCorner>
  1382. <gml:upperCorner>20.039062502593 54.847089981191</gml:upperCorner>
  1383. </gml:Envelope>
  1384. </ogc:BBOX>
  1385. </ogc:Filter>
  1386. </wfs:Query>
  1387. </wfs:GetFeature>
  1388. */
  1389. $corners = null;
  1390. $xmlTag = $xml->children("wfs", TRUE)->Query;
  1391. if (!empty($xmlTag)) {
  1392. $xmlTag = $xmlTag->children("ogc", TRUE)->Filter;
  1393. if (!empty($xmlTag)) {
  1394. $xmlTag = $xmlTag->BBOX;
  1395. if (!empty($xmlTag)) {
  1396. $xmlTag = $xmlTag->children("gml", TRUE)->Envelope;
  1397. if (!empty($xmlTag)) {
  1398. $corners = (object)array('lowerCorner' => (string)$xmlTag->lowerCorner, 'upperCorner' => (string)$xmlTag->upperCorner);
  1399. }
  1400. }
  1401. }
  1402. }
  1403. if ($corners) {
  1404. $lowerCorner = (string) $corners->lowerCorner;
  1405. $upperCorner = (string) $corners->upperCorner;
  1406. $lowerCorner = explode(" ", trim($lowerCorner));
  1407. $upperCorner = explode(" ", trim($upperCorner));
  1408. if (count($lowerCorner) == 2 && count($upperCorner) == 2) {
  1409. $points = array();
  1410. $points[] = $upperCorner[1];// top
  1411. $points[] = $upperCorner[0];// right
  1412. $points[] = $lowerCorner[1];// bottom
  1413. $points[] = $lowerCorner[0];// left
  1414. $isAllNumeric = true;
  1415. foreach ($points as $point) {
  1416. if (!is_numeric($point)) $isAllNumeric = false;
  1417. }
  1418. if ($isAllNumeric) {
  1419. $data['BBOX'] = $points;
  1420. }
  1421. }
  1422. } else {
  1423. // inna struktura xml'a
  1424. }
  1425. $this->_wfsAction->execute($data);
  1426. }
  1427. else if (isset($xml->children('ows', TRUE)->Identifier)) {
  1428. $identifier = (string)$xml->children('ows', TRUE)->Identifier;
  1429. if (array_key_exists($identifier, $this->_fun)) {
  1430. foreach ($xml->children('wps', TRUE)->DataInputs->children('wps', TRUE) as $input) {
  1431. $inputIdentifier = (string)$input->children('ows', TRUE)->Identifier;
  1432. if (array_key_exists($inputIdentifier, $this->_fun[$identifier]->dataInputs)) {
  1433. $inputType = (string)$this->_fun[$identifier]->dataInputs[$inputIdentifier]->type;
  1434. switch ($inputType) {
  1435. case 'integer':
  1436. $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->LiteralData;
  1437. break;
  1438. case 'geom':
  1439. $data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->ComplexData;
  1440. break;
  1441. default:
  1442. }
  1443. } else {
  1444. // brak zdefiniowanego inputa
  1445. }
  1446. }
  1447. $this->_fun['przypiszDoRekordu']->execute($data);
  1448. } else {
  1449. echo "TODO: brak zdefiniowanej funkcji '{$identifier}'";
  1450. var_dump($identifier);
  1451. }
  1452. }
  1453. else {
  1454. echo "TODO: '" . $xml->getName() . "' ...";
  1455. }
  1456. }
  1457. public function getCapabilitiesAction() {
  1458. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1459. ?>
  1460. <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">
  1461. <ows:ServiceIdentification>
  1462. <ows:Title>Prototype GeoServer WPS</ows:Title>
  1463. <ows:Abstract />
  1464. <ows:Keywords>
  1465. <ows:Keyword>wps</ows:Keyword>
  1466. <ows:Keyword>geoserver</ows:Keyword>
  1467. </ows:Keywords>
  1468. <ows:ServiceType>WPS</ows:ServiceType>
  1469. <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>
  1470. <ows:Fees>NONE</ows:Fees>
  1471. <ows:AccessConstraints>NONE</ows:AccessConstraints>
  1472. </ows:ServiceIdentification>
  1473. <ows:ServiceProvider>
  1474. <ows:ProviderName>GeoServer</ows:ProviderName>
  1475. <ows:ProviderSite />
  1476. <ows:ServiceContact />
  1477. </ows:ServiceProvider>
  1478. <ows:OperationsMetadata>
  1479. <ows:Operation name="GetCapabilities">
  1480. <ows:DCP>
  1481. <ows:HTTP>
  1482. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1483. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1484. </ows:HTTP>
  1485. </ows:DCP>
  1486. </ows:Operation>
  1487. <ows:Operation name="DescribeProcess">
  1488. <ows:DCP>
  1489. <ows:HTTP>
  1490. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1491. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1492. </ows:HTTP>
  1493. </ows:DCP>
  1494. </ows:Operation>
  1495. <ows:Operation name="Execute">
  1496. <ows:DCP>
  1497. <ows:HTTP>
  1498. <ows:Get xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1499. <ows:Post xlink:href="http://demo.opengeo.org:80/geoserver/wps" />
  1500. </ows:HTTP>
  1501. </ows:DCP>
  1502. </ows:Operation>
  1503. </ows:OperationsMetadata>
  1504. <wps:ProcessOfferings>
  1505. <?php foreach($this->_fun as $kFun => $vFun) : ?>
  1506. <wps:Process wps:processVersion="1.0.0">
  1507. <ows:Identifier><?php echo $kFun; ?></ows:Identifier>
  1508. <ows:Title><?php echo $vFun->title; ?></ows:Title>
  1509. <ows:Abstract><?php echo $vFun->description; ?></ows:Abstract>
  1510. </wps:Process>
  1511. <?php endforeach; ?>
  1512. </wps:ProcessOfferings>
  1513. <wps:Languages>
  1514. <wps:Default>
  1515. <ows:Language>en-US</ows:Language>
  1516. </wps:Default>
  1517. <wps:Supported>
  1518. <ows:Language>en-US</ows:Language>
  1519. </wps:Supported>
  1520. </wps:Languages>
  1521. </wps:Capabilities>
  1522. <?php
  1523. }
  1524. public function describeProcessAction($args) {
  1525. // TODO: xml z opiesem procese $args['IDENTIFIER']
  1526. /**
  1527. * should work like JTS:densify - geom field (map object) and integer field (record ID)
  1528. * 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
  1529. * http://demo.opengeo.org/geoserver/wps?SERVICE=WPS&REQUEST=DescribeProcess&VERSION=1.0.0&IDENTIFIER=JTS%3Adensify
  1530. */
  1531. echo '<?xml version="1.0" encoding="UTF-8"?>';
  1532. if (array_key_exists($args['IDENTIFIER'], $this->_fun)) {
  1533. $identifier = $this->_fun[$args['IDENTIFIER']];
  1534. ?>
  1535. <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">
  1536. <ProcessDescription wps:processVersion="1.0.0" statusSupported="true" storeSupported="true">
  1537. <ows:Identifier><?php echo $args['IDENTIFIER']; ?></ows:Identifier>
  1538. <ows:Title><?php echo $identifier->title; ?></ows:Title>
  1539. <ows:Abstract><?php echo $identifier->description; ?></ows:Abstract>
  1540. <DataInputs>
  1541. <?php foreach ($identifier->dataInputs as $kInput => $vInput) : ?>
  1542. <Input maxOccurs="1" minOccurs="1">
  1543. <ows:Identifier><?php echo $kInput; ?></ows:Identifier>
  1544. <ows:Title><?php echo $vInput->title; ?></ows:Title>
  1545. <ows:Abstract><?php echo $vInput->description; ?></ows:Abstract>
  1546. <?php if ($vInput->type == 'geom') : ?>
  1547. <ComplexData>
  1548. <Default>
  1549. <Format>
  1550. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1551. </Format>
  1552. </Default>
  1553. <Supported>
  1554. <Format>
  1555. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1556. </Format>
  1557. <Format>
  1558. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  1559. </Format>
  1560. <Format>
  1561. <MimeType>application/wkt</MimeType>
  1562. </Format>
  1563. <Format>
  1564. <MimeType>application/gml-3.1.1</MimeType>
  1565. </Format>
  1566. <Format>
  1567. <MimeType>application/gml-2.1.2</MimeType>
  1568. </Format>
  1569. </Supported>
  1570. </ComplexData>
  1571. <?php elseif ($vInput->type == 'integer') : ?>
  1572. <LiteralData>
  1573. <ows:DataType>xs:integer</ows:DataType>
  1574. <ows:AnyValue />
  1575. </LiteralData>
  1576. <?php else : ?>
  1577. <?php endif; ?>
  1578. </Input>
  1579. <?php endforeach; ?>
  1580. </DataInputs>
  1581. <ProcessOutputs>
  1582. <Output>
  1583. <ows:Identifier>result</ows:Identifier>
  1584. <ows:Title>result</ows:Title>
  1585. <ComplexOutput>
  1586. <Default>
  1587. <Format>
  1588. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1589. </Format>
  1590. </Default>
  1591. <Supported>
  1592. <Format>
  1593. <MimeType>text/xml; subtype=gml/3.1.1</MimeType>
  1594. </Format>
  1595. <Format>
  1596. <MimeType>text/xml; subtype=gml/2.1.2</MimeType>
  1597. </Format>
  1598. <Format>
  1599. <MimeType>application/wkt</MimeType>
  1600. </Format>
  1601. <Format>
  1602. <MimeType>application/gml-3.1.1</MimeType>
  1603. </Format>
  1604. <Format>
  1605. <MimeType>application/gml-2.1.2</MimeType>
  1606. </Format>
  1607. </Supported>
  1608. </ComplexOutput>
  1609. </Output>
  1610. </ProcessOutputs>
  1611. </ProcessDescription>
  1612. </wps:ProcessDescriptions>
  1613. <?php
  1614. } else {
  1615. echo 'TODO: brak funkcji';
  1616. }
  1617. }
  1618. }