TableAjaxMap.php 58 KB

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