changeset 1418:750a53950e9f

The WMSLayerTree displays WMS layers that support a given SRS only. flys-client/trunk@3326 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 28 Nov 2011 16:27:36 +0000
parents 42d6cf6e10b7
children 3f15d9c22d53
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/WMSLayersTree.java flys-client/src/main/java/de/intevation/flys/client/shared/model/WMSLayer.java
diffstat 5 files changed, 73 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Nov 28 15:55:26 2011 +0000
+++ b/flys-client/ChangeLog	Mon Nov 28 16:27:36 2011 +0000
@@ -1,3 +1,21 @@
+2011-11-28  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/shared/model/WMSLayer.java: Added
+	  a method supportsSrs(String srs) that determines, if the WMS layer
+	  supports a given SRS. The 'srs' parameter needs to start with "EPSG:",
+	  otherwise this prefix is appended automatically.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java:
+	  Create the ExternalWMSWindow with the SRS definition of FloodMap.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java:
+	  Added a new constructor that takes a SRS. This srs is used to instantiate
+	  the WMSLayersTree.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/WMSLayersTree.java:
+	  Added a new constructor that takes a SRS. If a SRS is specified, this tree
+	  only displays layers that support the specified SRS.
+
 2011-11-28  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/CapabilitiesParser.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 28 15:55:26 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 28 16:27:36 2011 +0000
@@ -41,6 +41,8 @@
 
     protected Capabilities capabilites;
 
+    protected String srs;
+
     protected String url;
 
     protected LayerLoader loader;
@@ -52,6 +54,12 @@
     }
 
 
+    public ExternalWMSWindow(LayerLoader loader, String srs) {
+        this(loader);
+        this.srs = srs;
+    }
+
+
     protected void setUrl(String url) {
         this.url = url;
     }
@@ -225,7 +233,7 @@
     protected Layout createLayersPanel() {
         setTitle(MSG.addwmsLayerTitle());
 
-        final WMSLayersTree tree = new WMSLayersTree(capabilites);
+        final WMSLayersTree tree = new WMSLayersTree(capabilites, srs);
 
         ClickHandler backHandler = new ClickHandler() {
             @Override
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Mon Nov 28 15:55:26 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Mon Nov 28 16:27:36 2011 +0000
@@ -522,10 +522,12 @@
 
 
     protected ImgButton createWMSControl() {
+        final String srs = floodMap.getRiverProjection();
+
         ImgButton add = createButton(MSG.addWMS(), new ClickHandler() {
             public void onClick(ClickEvent event) {
                 MapOutputTab ot = (MapOutputTab) getOutputTab();
-                new ExternalWMSWindow(ot).start();
+                new ExternalWMSWindow(ot, srs).start();
             }
         });
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/WMSLayersTree.java	Mon Nov 28 15:55:26 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/WMSLayersTree.java	Mon Nov 28 16:27:36 2011 +0000
@@ -3,6 +3,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import com.google.gwt.core.client.GWT;
+
 import com.smartgwt.client.types.TreeModelType;
 import com.smartgwt.client.widgets.tree.Tree;
 import com.smartgwt.client.widgets.tree.TreeGrid;
@@ -37,6 +39,8 @@
 
 
     protected Capabilities capabilites;
+    protected String       srs;
+
 
     public WMSLayersTree(Capabilities capabilites) {
         super();
@@ -46,6 +50,16 @@
     }
 
 
+    public WMSLayersTree(Capabilities capabilites, String srs) {
+        super();
+
+        this.capabilites = capabilites;
+        this.srs         = srs;
+
+        initTree();
+    }
+
+
     protected void initTree() {
         setLoadDataOnDemand(false);
         setWidth100();
@@ -80,20 +94,29 @@
 
         for (WMSLayer layer: layers) {
             WMSLayerNode tn = buildTreeNode(layer);
-            TreeNode[] tns  = buildTree(layer.getLayers());
 
-            if (tns != null && tns.length > 0) {
-                tn.setAttribute("children-nodes", tns);
+            if (tn != null) {
+                TreeNode[] tns  = buildTree(layer.getLayers());
+
+                if (tns != null && tns.length > 0) {
+                    tn.setAttribute("children-nodes", tns);
+                }
+
+                layerNodes.add(tn);
             }
-
-            layerNodes.add(tn);
         }
 
         return (TreeNode[]) layerNodes.toArray(new TreeNode[layerNodes.size()]);
     }
 
 
-    protected static WMSLayerNode buildTreeNode(WMSLayer wms) {
-        return new WMSLayerNode(wms);
+    protected WMSLayerNode buildTreeNode(WMSLayer wms) {
+        if (srs != null && srs.length() > 0) {
+            return wms.supportsSrs(srs) ? new WMSLayerNode(wms) : null;
+        }
+        else {
+            GWT.log("No target SRS specified.");
+            return new WMSLayerNode(wms);
+        }
     }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/WMSLayer.java	Mon Nov 28 15:55:26 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/WMSLayer.java	Mon Nov 28 16:27:36 2011 +0000
@@ -64,5 +64,18 @@
     public List<WMSLayer> getLayers() {
         return layers;
     }
+
+
+    public boolean supportsSrs(String srs) {
+        if (this.srs == null || this.srs.size() == 0) {
+            return true;
+        }
+
+        if (!srs.startsWith("EPSG:")) {
+            srs = "EPSG:" + srs;
+        }
+
+        return this.srs.contains(srs);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org