# HG changeset patch # User Tim Englich # Date 1275414054 0 # Node ID 5779220ebb80ed52987b59cb40877427b896a7bb # Parent a8e044224b16cc19af5fdc7510526b3c8dff5bfe Added functionality to read WMS-Capabilities-Documents gnv/trunk@1145 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r a8e044224b16 -r 5779220ebb80 gnv/ChangeLog --- 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 + + 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 * src/main/webapp/WEB-INF/config/templates/describe-ui-static.xsl: diff -r a8e044224b16 -r 5779220ebb80 gnv/src/main/webapp/WEB-INF/jsp/includes/display_map_inc.jsp --- 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 @@ -
+
+
+
+
+
+
+
\ No newline at end of file diff -r a8e044224b16 -r 5779220ebb80 gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp --- 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 @@ + diff -r a8e044224b16 -r 5779220ebb80 gnv/src/main/webapp/scripts/olutils.js --- /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 + "2"; + } + + 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); +} diff -r a8e044224b16 -r 5779220ebb80 gnv/src/main/webapp/scripts/viewport.jsp --- 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 ] }