Mercurial > dive4elements > gnv-client
changeset 975:5779220ebb80
Added functionality to read WMS-Capabilities-Documents
gnv/trunk@1145 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 01 Jun 2010 17:40:54 +0000 |
parents | a8e044224b16 |
children | d1ed5c51c0de |
files | gnv/ChangeLog gnv/src/main/webapp/WEB-INF/jsp/includes/display_map_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp gnv/src/main/webapp/scripts/olutils.js gnv/src/main/webapp/scripts/viewport.jsp |
diffstat | 5 files changed, 285 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Tue Jun 01 16:11:06 2010 +0000 +++ b/gnv/ChangeLog Tue Jun 01 17:40:54 2010 +0000 @@ -1,3 +1,27 @@ +2010-06-01 Tim Englich <tim.englich@intevation.de> + + Providing functionality to read an WMS-Capabilities-Documnet and list all + layers which are include. This is the first step to provide the requested + function to integrate external WMS-Layers. + + To read the XML-Documents it is required to integrate the proxy.cgi script + into the Apache Webserver. for this you have to copy the proxy.cgi script + to /usr/lib/cgi-bin. + + You might have to change the allowedHosts in this script. + + * src/main/webapp/WEB-INF/jsp/wmslayout.jsp: + Integrated link to JavaScript-file olutils.js + + * /src/main/webapp/scripts/olutils.js: + Integrate Utilities-javaScript-fiel from Demonstrator to provide + JavaScript-Functions for handling WMS-Capabilities-Requests. + * src/main/webapp/scripts/viewport.jsp: + Integrated JavaScript-Elements for WMS-Capabilities Request. + + * src/main/webapp/WEB-INF/jsp/includes/display_map_inc.jsp: + Integrated HTML-Elements for the WMS-Capabilities Request. + 2010-06-01 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/webapp/WEB-INF/config/templates/describe-ui-static.xsl:
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_map_inc.jsp Tue Jun 01 16:11:06 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_map_inc.jsp Tue Jun 01 17:40:54 2010 +0000 @@ -1,2 +1,8 @@ -<div id="tree"><!-- Just a Comment --></div> +<div id="cap"> + <div id="remoteinput"> + <div id="urlinput"><!-- Just a Comment --></div> + <div id="urlbutton"><!-- Just a Comment --></div> + </div> + <div id="capgrid"><!-- Just a Comment --></div> +</div> <div id="mapcontainer" style="width: 400px; height: 400px"><!-- Just a Comment --></div> \ No newline at end of file
--- a/gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp Tue Jun 01 16:11:06 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp Tue Jun 01 17:40:54 2010 +0000 @@ -33,6 +33,7 @@ <script type="text/javascript" src="scripts/ext/ext-2.3.0/ext-all.js"></script> <script type="text/javascript" src="scripts/openlayers/OpenLayers-2.9/OpenLayers.js"></script> <script type="text/javascript" src="scripts/geoext/geoext-0.6/script/GeoExt.js"></script> + <script type="text/javascript" src="scripts/olutils.js"></script> <script type="text/javascript" src="<%=response.encodeURL("scripts/layers.jsp?uid="+System.currentTimeMillis())%>"></script> <script type="text/javascript" src="<%=response.encodeURL("scripts/viewport.jsp?uid="+System.currentTimeMillis())%>"></script>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/scripts/olutils.js Tue Jun 01 17:40:54 2010 +0000 @@ -0,0 +1,191 @@ +function handleMeasurements(event) { + var geometry = event.geometry; + var units = event.units; + var order = event.order; + var measure = event.measure; + var element = document.getElementById('measurements'); + + var out = ""; + if(order == 1) { + out += "L\u00e4nge: " + measure.toFixed(3) + " " + units; + } else { + out += "Fl\u00e4che: " + measure.toFixed(3) + " " + units + "<sup>2</sup>"; + } + + element.innerHTML=out; +}; + + + +function readWMC(merge) { + var layers = mapPanel.layers; + map = mapPanel.map; + + var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}}); + var text = document.getElementById("wmc").value; + + merge = true; + if(merge) { + try { + map = format.read(text, {map: map}); + } catch(err) { + document.getElementById("wmc").value = err; + } + } else { + map.destroy(); + try { + var jsonFormat = new OpenLayers.Format.JSON(); + var mapOptions = jsonFormat.read(); + map = format.read(text, {map: mapOptions}); + } catch(err) { + document.getElementById("wmc").value = err; + } + } + + // create MapPanel + mapPanel = new GeoExt.MapPanel({ + border: true, + title: "Karte", + region: "center", + map: map, + zoom: 1, + layers: map.layers + }); +} + + +function writeWMC(merge) { + var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}}); + + try { + var text = format.write(map); + document.getElementById("wmc").value = text; + } catch(err) { + document.getElementById("wmc").value = err; + } +} + + + +function toggleGetFeatureInfo(evt) { + if (infoActive) { + infoControls.click.deactivate(); + infoActive = false; + } + else { + infoControls.click.activate(); + infoActive = true; + } +} + + +function showInfo(evt) { +} + + +function addLayer() { + var record = grid.getSelectionModel().getSelected(); + + if (record) { + var copy = record.copy(); + copy.set("layer", record.get("layer")); + copy.get("layer").mergeNewParams({ + format: "image/png", + transparent: true + }); + + mapPanel.layers.add(copy); + mapPanel.map.zoomToExtent(OpenLayers.Bounds.fromArray(copy.get("llbbox"))); + } +} + + +// this is just copied from OpenLayers.Util +function urlAppend(url, paramStr) { + var newUrl = url; + if(paramStr) { + var parts = (url + " ").split(/[?&]/); + newUrl += (parts.pop() === " " ? + paramStr : + parts.length ? "&" + paramStr : "?" + paramStr); + } + return newUrl; +} + + +function updateCapabilities() { + var ele = Ext.Element.get('capfield'); + + var url = ele.getValue(); + var service = "SERVICE=WMS"; + var request = "REQUEST=GetCapabilities"; + url = urlAppend(url, service); + url = urlAppend(url, request); + + store = new GeoExt.data.WMSCapabilitiesStore({ + url: url + }); + store.load(); + + grid.destroy(); + grid = new Ext.grid.GridPanel({ + id: 'wmsgrid', + collapsible: false, + split: false, + border: true, + height: 440, + //autoHeight: true, don't use autoHeight, because the component doesn't + //take care on the 'addLayer' button at the bottom + store: store, + cm: new Ext.grid.ColumnModel([ + { + header: 'Name', + dataIndex: 'name', + sortable: true + }, + { + id: 'title', + header: 'Title', + dataIndex: 'title', + sortable: true + }]), + renderTo: 'capgrid', + bbar: [{ + text: 'Add Layer', + handler: addLayer + }] + }); +} + + +function editFeature(e) { + var feature = e.feature; + + // TODO SET FEATURE ATTRIBUTES + //feature.attributes['lawa'] = 999; + //feature.attributes['lawa_id'] = 999; + //feature.attributes['w_gwk_lawa'] = 999; + //feature.attributes['w_wrrl'] = 999; + //feature.attributes['length_fee'] = 999; +} + +function updateControls() { + var controls = panel.controls; + + controls.remove(drawPointControl); + controls.remove(drawPathControl); + controls.remove(drawPolygonControl); + + panel.destroy(); + panel = new OpenLayers.Control.Panel(); + panel.addControls(controls); + + if (points.getVisibility()) + panel.addControls(drawPointControl); + if (lines.getVisibility()) + panel.addControls(drawPathControl); + if (polygons.getVisibility()) + panel.addControls(drawPolygonControl); + + map.addControl(panel); +}
--- a/gnv/src/main/webapp/scripts/viewport.jsp Tue Jun 01 16:11:06 2010 +0000 +++ b/gnv/src/main/webapp/scripts/viewport.jsp Tue Jun 01 17:40:54 2010 +0000 @@ -99,7 +99,67 @@ }); - // map.setCenter(INITIAL_CENTER); + map.setCenter(INITIAL_CENTER); + + store = new GeoExt.data.WMSCapabilitiesStore({ + }); + store.load(); + + grid = new Ext.grid.GridPanel({ + id: 'wmsgrid', + collapsible: false, + split: false, + border: true, + //height: 400, + autoHeight: true, + store: store, + cm: new Ext.grid.ColumnModel([ + { + header: 'Name', + dataIndex: 'name', + sortable: true + }, + { + id: 'title', + header: 'Title', + dataIndex: 'title', + sortable: true + }]), + renderTo: 'capgrid', + bbar: [{ + text: 'Add Layer', + handler: addLayer + }] + }); + var cap = new Ext.Panel({ + id: 'wmspanel', + border: true, + region: 'east', + title: 'WMS Capabilities', + collapsible: false, + split: false, + contentEl: 'cap', + height: 400 + }); + + var capfield = new Ext.form.TextField({ + id: 'capfield', + region: 'east', + width: '100%', + renderTo: 'urlinput' + }); + + var capbutton = new Ext.Button({ + id: 'capbutton', + region: 'west', + handler: updateCapabilities, + text: 'Lade', + tooltip: 'Lade GetCapabilities Dokument', + renderTo: 'urlbutton' + }); + + + /* --------------------------- Layer Tree ----------------------------------- */ @@ -182,6 +242,7 @@ }, items: [ tree, + cap, legendPanel ] }