changeset 9483:992c188b7330

wms uinfo.inundation
author gernotbelger
date Thu, 13 Sep 2018 18:22:05 +0200 (2018-09-13)
parents e5cb5efbc43e
children c81cf7e2a770
files artifacts/doc/conf/modules/wms_uedauern_jahre_Beispielfluss.tsv artifacts/doc/conf/modules/wms_uedauern_jahre_Rhein.tsv artifacts/doc/conf/modules/wms_uedauern_mittel_Beispielfluss.tsv artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapThemePanel.java
diffstat 6 files changed, 358 insertions(+), 421 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/modules/wms_uedauern_jahre_Beispielfluss.tsv	Thu Sep 13 18:22:05 2018 +0200
@@ -0,0 +1,13 @@
+# Konfigurationsdatei für die in der Berechnungsart UINFO-Überflutungsdauern auszugebenden URLs		
+# Je Gewässer ist zwingend eine Datei mit Namen 'wms_uedauern_jahre_<Gewässername>.tsv' anzulegen. Groß-/Kleinschriebung beim Gewässernamen ist zu beachten!			
+ 
+# Die Datei definiert für beliebig viele Layer individuell konfigurierbare Bezeichnungen und URLs.		
+# Pro Layer ist eine Zeile folgender Form anzulegen:			
+#<Layer-Name><Tab><Label><Tab><WMS-URL>			
+ 
+# Änderungen werden erst nach einem Neustart des Servers wirksam.			
+
+1991	1	https://geoportal.bafg.de/arcgis3/services/Flut3/Elbe_1990_1999/MapServer/WMSServer
+1992	2	https://geoportal.bafg.de/arcgis3/services/Flut3/Elbe_1990_1999/MapServer/WMSServer
+1993	3	https://geoportal.bafg.de/arcgis3/services/Flut3/Elbe_1990_1999/MapServer/WMSServer
+1994	4	https://geoportal.bafg.de/arcgis3/services/Flut3/Elbe_1990_1999/MapServer/WMSServer
\ No newline at end of file
--- a/artifacts/doc/conf/modules/wms_uedauern_jahre_Rhein.tsv	Wed Sep 12 12:50:28 2018 +0200
+++ b/artifacts/doc/conf/modules/wms_uedauern_jahre_Rhein.tsv	Thu Sep 13 18:22:05 2018 +0200
@@ -7,7 +7,7 @@
  
 # Änderungen werden erst nach einem Neustart des Servers wirksam.			
 
-1991	0	https://geoportal.bafg.de/arcgis3/services/U2_Flut3/Elbe_Flut3_1991_2001/MapServer/WMSServer
-1992	1	https://geoportal.bafg.de/arcgis3/services/U2_Flut3/Elbe_Flut3_1991_2001/MapServer/WMSServer
-1993	2	https://geoportal.bafg.de/arcgis3/services/U2_Flut3/Elbe_Flut3_1991_2001/MapServer/WMSServer
-1994	3	https://geoportal.bafg.de/arcgis3/services/U2_Flut3/Elbe_Flut3_1991_2001/MapServer/WMSServer
\ No newline at end of file
+1991	1	https://geoportal.bafg.de/arcgis3/services/Flut3/Rhein_1990_1999/MapServer/WMSServer
+1992	2	https://geoportal.bafg.de/arcgis3/services/Flut3/Rhein_1990_1999/MapServer/WMSServer
+1993	3	https://geoportal.bafg.de/arcgis3/services/Flut3/Rhein_1990_1999/MapServer/WMSServer
+1994	4	https://geoportal.bafg.de/arcgis3/services/Flut3/Rhein_1990_1999/MapServer/WMSServer
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/modules/wms_uedauern_mittel_Beispielfluss.tsv	Thu Sep 13 18:22:05 2018 +0200
@@ -0,0 +1,11 @@
+# Konfigurationsdatei für die in der Berechnungsart UINFO-Überflutungsdauern auszugebenden URLs		
+# Je Gewässer ist zwingend eine Datei mit Namen 'wms_uedauern_mittel_<Gewässername>.tsv' anzulegen. Groß-/Kleinschriebung beim Gewässernamen ist zu beachten!			
+ 
+# Die Datei definiert für beliebig viele Layer individuell konfigurierbare Bezeichnungen und URLs.		
+# Pro Layer ist eine Zeile folgender Form anzulegen:			
+#<Layer-Name><Tab><Label><Tab><WMS-URL>			
+ 
+# Änderungen werden erst nach einem Neustart des Servers wirksam.			
+
+Langjähriges Mittel (1989-2001)	0	www.das-ist-ein-test.de
+Langjähriges Mittel (1888-1999)	1	www.das-ist-ein-test.de
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java	Wed Sep 12 12:50:28 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java	Thu Sep 13 18:22:05 2018 +0200
@@ -97,7 +97,7 @@
             wmsFacet.addLayer(layer.getLayer());
 
             facets.add(wmsFacet);
-
+            // TODO:
             // wmsFacet.setExtent(getExtent(false));
             // wmsFacet.setOriginalExtent(getExtent(true));
             wmsFacet.setSrid(getSrid());
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java	Wed Sep 12 12:50:28 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java	Thu Sep 13 18:22:05 2018 +0200
@@ -8,19 +8,8 @@
 
 package org.dive4elements.river.client.client.ui.map;
 
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.AbsolutePanel;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.events.ParentMovedEvent;
-import com.smartgwt.client.widgets.events.ParentMovedHandler;
-import com.smartgwt.client.widgets.events.ResizedEvent;
-import com.smartgwt.client.widgets.events.ResizedHandler;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
-import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
+import java.util.HashMap;
+import java.util.List;
 
 import org.dive4elements.river.client.client.Config;
 import org.dive4elements.river.client.client.FLYSConstants;
@@ -52,10 +41,6 @@
 import org.dive4elements.river.client.shared.model.Theme;
 import org.dive4elements.river.client.shared.model.ThemeList;
 import org.dive4elements.river.client.shared.model.WMSLayer;
-
-import java.util.HashMap;
-import java.util.List;
-
 import org.gwtopenmaps.openlayers.client.Bounds;
 import org.gwtopenmaps.openlayers.client.Map;
 import org.gwtopenmaps.openlayers.client.MapWidget;
@@ -70,11 +55,21 @@
 import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
 import org.gwtopenmaps.openlayers.client.layer.WMSParams;
 
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.ParentMovedEvent;
+import com.smartgwt.client.widgets.events.ParentMovedHandler;
+import com.smartgwt.client.widgets.events.ResizedEvent;
+import com.smartgwt.client.widgets.events.ResizedHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
+import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
 
-public class MapOutputTab
-extends      OutputTab
-implements   RedrawRequestHandler, ExternalWMSWindow.LayerLoader,
-             TabSelectedHandler, OutputParameterChangeHandler {
+public class MapOutputTab extends OutputTab implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader, TabSelectedHandler, OutputParameterChangeHandler {
 
     public static final String DEFAULT_SRID = "4326";
 
@@ -84,179 +79,151 @@
 
     public static final String EXTERNAL_WMS_FACTORY = "externalwmsfactory";
 
+    protected StepForwardServiceAsync feedService = GWT.create(StepForwardService.class);
 
-    protected StepForwardServiceAsync feedService =
-        GWT.create(StepForwardService.class);
-
-    protected MapOutputServiceAsync mapService =
-        GWT.create(MapOutputService.class);
+    protected MapOutputServiceAsync mapService = GWT.create(MapOutputService.class);
 
     /** Service handle to clone and add artifacts to collection. */
-    protected LoadArtifactServiceAsync loadArtifactService =
-        GWT.create(LoadArtifactService.class);
+    protected LoadArtifactServiceAsync loadArtifactService = GWT.create(LoadArtifactService.class);
 
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
     protected MapToolbar controlPanel;
     protected ThemePanel themePanel;
-    protected Canvas     themePanelCanvas;
-    protected MapWidget     mapPanel;
+    protected Canvas themePanelCanvas;
+    protected MapWidget mapPanel;
     protected Canvas mapPanelCanvas;
     protected VLayout rootLayout = new VLayout();
     protected AbsolutePanel absPan = new AbsolutePanel();
     protected FloodMap floodMap;
-    protected java.util.Map<String, String> wmsUrls =
-        new HashMap<String, String>();
-
 
-    public MapOutputTab(
-        String         title,
-        Collection     collection,
-        OutputMode     mode,
-        CollectionView collectionView
-    ){
+    private final java.util.Map<String, String> wmsUrls = new HashMap<String, String>();
+
+    public MapOutputTab(final String title, final Collection collection, final OutputMode mode, final CollectionView collectionView) {
         super(title, collection, collectionView, mode);
 
         collectionView.registerTabHandler(this);
 
-        mapService.doOut(collection, new AsyncCallback<MapConfig>() {
-                @Override
-                public void onFailure(Throwable caught) {
-                    GWT.log("MAP ERROR: " + caught.getMessage());
+        this.mapService.doOut(collection, new AsyncCallback<MapConfig>() {
+            @Override
+            public void onFailure(final Throwable caught) {
+                GWT.log("MAP ERROR: " + caught.getMessage());
+            }
+
+            @Override
+            public void onSuccess(final MapConfig c) {
+                GWT.log("MAP SUCCESS!");
+
+                final Bounds max = boundsFromString(c.getMaxExtent());
+                Bounds initial = boundsFromString(c.getInitialExtent());
+
+                if (initial == null) {
+                    GWT.log("Warning: No initial extent set.");
+                    initial = max;
                 }
 
-                @Override
-                public void onSuccess(MapConfig c) {
-                    GWT.log("MAP SUCCESS!");
-
-                    Bounds max     = boundsFromString(c.getMaxExtent());
-                    Bounds initial = boundsFromString(c.getInitialExtent());
+                setFloodmap(new FloodMap(c.getSrid(), max, 640, 480));
 
-                    if (initial == null) {
-                        GWT.log("Warning: No initial extent set.");
-                        initial = max;
-                    }
-
-                    setFloodmap(new FloodMap(c.getSrid(), max, 640, 480));
+                initLayout();
+                initBarriers();
 
-                    initLayout();
-                    initBarriers();
-
-                    GWT.log("MAX EXTENT: " + max);
-                    GWT.log("ZOOM TO: " + initial);
-                    getMap().zoomToExtent(initial);
-                }
+                GWT.log("MAX EXTENT: " + max);
+                GWT.log("ZOOM TO: " + initial);
+                getMap().zoomToExtent(initial);
             }
-        );
+        });
     }
 
-
     protected void initLayout() {
-        rootLayout.setHeight100();
-        rootLayout.setWidth100();
-        rootLayout.setMembersMargin(2);
+        this.rootLayout.setHeight100();
+        this.rootLayout.setWidth100();
+        this.rootLayout.setMembersMargin(2);
 
-        HLayout hlayout = new HLayout();
+        final HLayout hlayout = new HLayout();
         hlayout.setMembersMargin(0);
 
         this.themePanelCanvas = createThemePanel();
 
-        controlPanel = createControlPanel();
-        mapPanel = floodMap.getMapWidget();
+        this.controlPanel = createControlPanel();
+        this.mapPanel = this.floodMap.getMapWidget();
 
-        rootLayout.addMember(controlPanel);
-        rootLayout.addMember(absPan);
-        absPan.setWidth("100%");
-        absPan.setHeight("100%");
-        absPan.add(themePanelCanvas);
-        absPan.add(mapPanel);
+        this.rootLayout.addMember(this.controlPanel);
+        this.rootLayout.addMember(this.absPan);
+        this.absPan.setWidth("100%");
+        this.absPan.setHeight("100%");
+        this.absPan.add(this.themePanelCanvas);
+        this.absPan.add(this.mapPanel);
 
-        rootLayout.addResizedHandler(new ResizedHandler() {
+        this.rootLayout.addResizedHandler(new ResizedHandler() {
             @Override
-            public void onResized(ResizedEvent e) {
+            public void onResized(final ResizedEvent e) {
                 doLayout();
             }
         });
 
-        rootLayout.addParentMovedHandler(new ParentMovedHandler() {
+        this.rootLayout.addParentMovedHandler(new ParentMovedHandler() {
             @Override
-            public void onParentMoved(ParentMovedEvent event) {
-                mapPanel.getMap().updateSize();
+            public void onParentMoved(final ParentMovedEvent event) {
+                MapOutputTab.this.mapPanel.getMap().updateSize();
             }
         });
 
-        setPane(rootLayout);
+        setPane(this.rootLayout);
     }
 
-
     protected void doLayout() {
-        if(!rootLayout.isVisible()) {
+        if (!this.rootLayout.isVisible()) {
             return;
         }
 
         // Manually set the height of the AbsolutePanel,
         // somehow this is necessary
-        absPan.setHeight(String.valueOf(
-                rootLayout.getHeight() - controlPanel.getHeight() - 2) + "px");
+        this.absPan.setHeight(String.valueOf(this.rootLayout.getHeight() - this.controlPanel.getHeight() - 2) + "px");
 
         // Calculate bounds of Map
-        int height = rootLayout.getHeight() -
-                controlPanel.getHeight() - 6;
-        int width  = controlPanel.getWidth() -
-            (themePanelCanvas.isVisible()
-                ? themePanelCanvas.getWidth() + 4
-                : 2);
+        final int height = this.rootLayout.getHeight() - this.controlPanel.getHeight() - 6;
+        final int width = this.controlPanel.getWidth() - (this.themePanelCanvas.isVisible() ? this.themePanelCanvas.getWidth() + 4 : 2);
 
         // Set size and position of Map
-        String w = String.valueOf(width) + "px";
-        String h = String.valueOf(height) + "px";
+        final String w = String.valueOf(width) + "px";
+        final String h = String.valueOf(height) + "px";
         GWT.log("width=" + w);
 
-        mapPanel.setSize(w, h);
-        mapPanel.getMap().updateSize();
-        if(themePanelCanvas.isVisible()) {
-            absPan.setWidgetPosition(
-                mapPanel, themePanelCanvas.getWidth() + 2, 0);
-        }
-        else {
-            absPan.setWidgetPosition(mapPanel, 0, 0);
+        this.mapPanel.setSize(w, h);
+        this.mapPanel.getMap().updateSize();
+        if (this.themePanelCanvas.isVisible()) {
+            this.absPan.setWidgetPosition(this.mapPanel, this.themePanelCanvas.getWidth() + 2, 0);
+        } else {
+            this.absPan.setWidgetPosition(this.mapPanel, 0, 0);
         }
 
         // Set bounds of ThemePanelCanvas
-        themePanelCanvas.setSize(
-            themePanelCanvas.getWidthAsString(),
-            String.valueOf(height + 2) + "px");
+        this.themePanelCanvas.setSize(this.themePanelCanvas.getWidthAsString(), String.valueOf(height + 2) + "px");
     }
 
-
     protected void initBarriers() {
-        Vector vector = floodMap.getBarrierLayer();
-        vector.addVectorFeatureAddedListener(
-            new VectorFeatureAddedListener() {
-                @Override
-                public void onFeatureAdded(FeatureAddedEvent e) {
-                    saveBarriers();
-                }
+        final Vector vector = this.floodMap.getBarrierLayer();
+        vector.addVectorFeatureAddedListener(new VectorFeatureAddedListener() {
+            @Override
+            public void onFeatureAdded(final FeatureAddedEvent e) {
+                saveBarriers();
             }
-        );
+        });
 
-        vector.addVectorFeatureRemovedListener(
-            new VectorFeatureRemovedListener() {
-                @Override
-                public void onFeatureRemoved(FeatureRemovedEvent e) {
-                    saveBarriers();
-                }
+        vector.addVectorFeatureRemovedListener(new VectorFeatureRemovedListener() {
+            @Override
+            public void onFeatureRemoved(final FeatureRemovedEvent e) {
+                saveBarriers();
             }
-        );
+        });
 
-
-        Artifact artifact = getArtifact();
+        final Artifact artifact = getArtifact();
 
         if (artifact == null) {
             return;
         }
 
-        ArtifactDescription desc = artifact.getArtifactDescription();
+        final ArtifactDescription desc = artifact.getArtifactDescription();
 
         String geojson = getGeoJSONFromStatic(desc);
         geojson = geojson != null ? geojson : getGeoJSONFromDynamic(desc);
@@ -266,128 +233,122 @@
             return;
         }
 
-        GeoJSON reader = new GeoJSON();
-        VectorFeature[] features = reader.read(geojson);
+        final GeoJSON reader = new GeoJSON();
+        final VectorFeature[] features = reader.read(geojson);
 
         vector.addFeatures(features);
     }
 
+    public void addLayer(final Theme newTheme) {
 
-    public void addLayer(Layer layer) {
-        FloodMap map = getFloodmap();
+        final Layer layer = createWMSLayer(newTheme);
+
+        final FloodMap map = getFloodmap();
 
         if (map != null) {
             GWT.log("Add new layer '" + layer.getName() + "' to map.");
             map.addLayer(layer);
             if (layer instanceof WMS) {
-                wmsUrls.put(layer.getName(),
-                    ((WMS)layer).getFullRequestString(new WMSParams(), null));
+                this.wmsUrls.put(layer.getName(), ((WMS) layer).getFullRequestString(new WMSParams(), null));
             }
         }
     }
 
-
-    public void removeLayer(String name) {
-        Map map = getMap();
+    public void removeLayer(final Theme theme) {
 
-        Layer[] layers = map.getLayers();
+        final String layerId = getLayerId(theme);
 
-        for (Layer layer: layers) {
-            if (name.equals(layer.getName())) {
+        final Map map = getMap();
+
+        final Layer[] layers = map.getLayers();
+
+        for (final Layer layer : layers) {
+            if (layerId.equals(layer.getName())) {
                 map.removeLayer(layer);
             }
         }
     }
 
-
     @Override
-    public void onRedrawRequest(RedrawRequestEvent event) {
-        mapService.doOut(collection, new AsyncCallback<MapConfig>() {
+    public void onRedrawRequest(final RedrawRequestEvent event) {
+        this.mapService.doOut(this.collection, new AsyncCallback<MapConfig>() {
             @Override
-            public void onFailure(Throwable caught) {
+            public void onFailure(final Throwable caught) {
                 GWT.log("MAP ERROR: " + caught.getMessage());
             }
 
             @Override
-            public void onSuccess(MapConfig c) {
+            public void onSuccess(final MapConfig c) {
                 GWT.log("We want to refresh the map now!");
-                themePanel.updateCollection();
+                MapOutputTab.this.themePanel.updateCollection();
                 getFloodmap().update();
             }
         });
     }
 
-
     @Override
-    public void load(List<WMSLayer> toLoad) {
+    public void load(final List<WMSLayer> toLoad) {
         GWT.log("The user wants to add " + toLoad.size() + " new WMS layers.");
 
-        int len = toLoad.size();
+        final int len = toLoad.size();
 
-        Recommendation[] recom = new Recommendation[len];
+        final Recommendation[] recom = new Recommendation[len];
 
         for (int i = 0; i < len; i++) {
-            WMSLayer w = toLoad.get(i);
+            final WMSLayer w = toLoad.get(i);
 
-            String ids = w.getServer() + ";" + w.getName() + ";" + w.getTitle();
+            final String ids = w.getServer() + ";" + w.getName() + ";" + w.getTitle();
             recom[i] = new Recommendation(EXTERNAL_WMS_FACTORY, ids);
         }
 
-        Collection c = getCollection();
-
-        Config config = Config.getInstance();
-        String locale = config.getLocale();
-
-        loadArtifactService.loadMany(c, recom, EXTERNAL_WMS_FACTORY, locale,
-            new AsyncCallback<Artifact[]>() {
+        final Collection c = getCollection();
 
-                @Override
-                public void onFailure(Throwable throwable) {
-                    SC.warn(MSG.getString(throwable.getMessage()));
-                }
+        final Config config = Config.getInstance();
+        final String locale = config.getLocale();
 
-                @Override
-                public void onSuccess(Artifact[] newArtifacts) {
-                    getThemePanel().updateCollection();
-                }
+        this.loadArtifactService.loadMany(c, recom, EXTERNAL_WMS_FACTORY, locale, new AsyncCallback<Artifact[]>() {
+
+            @Override
+            public void onFailure(final Throwable throwable) {
+                SC.warn(MapOutputTab.this.MSG.getString(throwable.getMessage()));
             }
-        );
+
+            @Override
+            public void onSuccess(final Artifact[] newArtifacts) {
+                getThemePanel().updateCollection();
+            }
+        });
     }
 
-
-    protected void setFloodmap(FloodMap floodMap) {
+    protected void setFloodmap(final FloodMap floodMap) {
         this.floodMap = floodMap;
     }
 
-
     protected FloodMap getFloodmap() {
-        return floodMap;
+        return this.floodMap;
     }
 
-
     protected Map getMap() {
-        return floodMap.getMap();
+        return this.floodMap.getMap();
     }
 
-
     protected ThemePanel getThemePanel() {
-        return themePanel;
+        return this.themePanel;
     }
 
-
-    protected String getGeoJSONFromDynamic(ArtifactDescription desc) {
-        DataList list = desc.getCurrentData();
+    protected String getGeoJSONFromDynamic(final ArtifactDescription desc) {
+        final DataList list = desc.getCurrentData();
 
         if (list == null) {
             return null;
         }
 
-        List<Data> datas = list.getAll();
-        for (Data data: datas) {
-            String key = data.getLabel();
+        final List<Data> datas = list.getAll();
+        for (final Data data : datas) {
+            final String key = data.getLabel();
 
             if (key != null && key.equals(BARRIERS_PARAMETER_KEY)) {
-                DataItem def = data.getDefault();
+                final DataItem def = data.getDefault();
 
                 if (def != null) {
                     return def.getStringValue();
@@ -398,32 +359,29 @@
         return null;
     }
 
-
-    protected String getGeoJSONFromStatic(ArtifactDescription desc) {
+    protected String getGeoJSONFromStatic(final ArtifactDescription desc) {
         // TODO Implement this method, if there are reachable states right after
         // the floodmap state - which is currently not the case.
         return null;
     }
 
-
     public ThemeList getThemeList() {
-        return collection.getThemeList(mode.getName());
+        return this.collection.getThemeList(this.mode.getName());
     }
 
-
     public String getSrid() {
-        ThemeList themeList = getThemeList();
+        final ThemeList themeList = getThemeList();
 
-        int num = themeList.getThemeCount();
+        final int num = themeList.getThemeCount();
 
         for (int i = 1; i <= num; i++) {
-            AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i);
+            final AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i);
 
             if (theme == null) {
                 continue;
             }
 
-            String srid = theme.getAttr("srid");
+            final String srid = theme.getAttr("srid");
 
             if (srid != null && srid.length() > 0) {
                 return srid;
@@ -433,63 +391,60 @@
         return DEFAULT_SRID;
     }
 
-
-    protected Bounds boundsFromString(String bounds) {
+    protected Bounds boundsFromString(final String bounds) {
         GWT.log("Create Bounds from String: '" + bounds + "'");
         if (bounds == null || bounds.length() == 0) {
             return null;
         }
 
-        String[] values = bounds.split(" ");
+        final String[] values = bounds.split(" ");
 
         if (values == null || values.length < 4) {
             return null;
         }
 
         try {
-            return new Bounds(
-                Double.valueOf(values[0]),
-                Double.valueOf(values[1]),
-                Double.valueOf(values[2]),
-                Double.valueOf(values[3]));
+            return new Bounds(Double.valueOf(values[0]), Double.valueOf(values[1]), Double.valueOf(values[2]), Double.valueOf(values[3]));
         }
-        catch (NumberFormatException nfe) {}
+        catch (final NumberFormatException nfe) {
+        }
 
         return null;
     }
 
-
-    public Layer createWMSLayer(Theme theme) {
+    private Layer createWMSLayer(final Theme theme) {
         if (!(theme instanceof AttributedTheme)) {
             return null;
         }
 
-        AttributedTheme at = (AttributedTheme) theme;
+        final AttributedTheme at = (AttributedTheme) theme;
 
-        String name      = at.getAttr("name");
-        String desc      = at.getAttr("description");
-        String url       = at.getAttr("url");
-        String layers    = at.getAttr("layers");
+        // final String desc = at.getAttr("description");
+        final String url = at.getAttr("url");
+        final String layers = at.getAttr("layers");
+
+        final String layerId = getLayerId(theme);
 
         if (url == null || layers == null) {
             return null;
         }
 
-        WMSParams params = new WMSParams();
+        final WMSParams params = new WMSParams();
         params.setLayers(layers);
         params.setFormat("image/png");
         params.setIsTransparent(true);
 
-        WMSOptions opts = new WMSOptions();
+        final WMSOptions opts = new WMSOptions();
+
         opts.setProjection("EPSG:" + getSrid());
         opts.setSingleTile(true);
         opts.setRatio(1);
         if (layers.equals("OSM-WMS-Dienst")) {
-            opts.setAttribution(MSG.attribution());
+            opts.setAttribution(this.MSG.attribution());
             opts.setSingleTile(true);
             opts.setTransitionEffect(TransitionEffect.RESIZE);
         }
-        WMS wms = new WMS(layers, url, params, opts);
+        final WMS wms = new WMS(layerId, url, params, opts);
         wms.setIsVisible(at.getActive() == 1);
         wms.setIsBaseLayer(false);
         // We can't set the full_url attribute here because map is not set
@@ -497,156 +452,145 @@
         return wms;
     }
 
+    private String getLayerId(final Theme theme) {
 
-    public java.util.Map<String, String> wmsUrls() {
-        return this.wmsUrls;
+        final AttributedTheme at = (AttributedTheme) theme;
+
+        final String name = at.getAttr("name");
+        final String layers = at.getAttr("layers");
+
+        return name + "_" + layers;
     }
 
-
     protected MapToolbar createControlPanel() {
-        return new MapToolbar(this, floodMap, false);
+        return new MapToolbar(this, this.floodMap, false);
     }
 
-
     protected Canvas createThemePanel() {
-        Canvas c = new Canvas();
+        final Canvas c = new Canvas();
         c.setMinWidth(300);
         c.setWidth(200);
         c.setHeight100();
         c.setCanDragResize(true);
         c.setBorder("1px solid black");
 
-        themePanel = new MapThemePanel(
-            this.getCollectionView(),
-            mode,
-            this,
-            new MapThemePanel.ActivateCallback() {
-                @Override
-                public void activate(Theme theme, boolean active) {
-                    fireActivateTheme(theme, active);
-                }
-            },
-            new MapThemePanel.ThemeMovedCallback() {
-                @Override
-                public void onThemeMoved(Theme theme, int oldIdx, int newIdx) {
-                    // this code synchronizes the ThemePanel and the OpenLayers
-                    // internal order of layers.
-                    AttributedTheme at = (AttributedTheme) theme;
-
-                    String    name = at.getAttr("layers");
-                    Map        map = getMap();
-                    Layer[] layers = map.getLayersByName(name);
+        this.themePanel = new MapThemePanel(this.getCollectionView(), this.mode, this, new MapThemePanel.ActivateCallback() {
+            @Override
+            public void activate(final Theme theme, final boolean active) {
+                fireActivateTheme(theme, active);
+            }
+        }, new MapThemePanel.ThemeMovedCallback() {
+            @Override
+            public void onThemeMoved(final Theme theme, final int oldIdx, final int newIdx) {
+                // this code synchronizes the ThemePanel and the OpenLayers
+                // internal order of layers.
+                final AttributedTheme at = (AttributedTheme) theme;
 
-                    if (layers == null || layers.length == 0) {
-                        GWT.log("Error: Cannot find layer '" + name + "'");
-                        return;
-                    }
+                final String layerId = getLayerId(theme);
 
-                    map.raiseLayer(layers[0], (newIdx-oldIdx)*-1);
-                    map.zoomTo(map.getZoom()-1);
-                    map.zoomTo(map.getZoom()+1);
+                final Map map = getMap();
+                final Layer[] layers = map.getLayersByName(layerId);
+
+                if (layers == null || layers.length == 0) {
+                    GWT.log("Error: Cannot find layer '" + layerId + "'");
+                    return;
                 }
-            },
-            new MapThemePanel.LayerZoomCallback() {
-                @Override
-                public void onLayerZoom(Theme theme, String extent) {
-                    Bounds zoomTo = boundsFromString(extent);
 
-                    if (zoomTo == null) {
-                        GWT.log("WARNING: No valid bounds for zooming found!");
-                        return;
-                    }
+                map.raiseLayer(layers[0], (newIdx - oldIdx) * -1);
+                map.zoomTo(map.getZoom() - 1);
+                map.zoomTo(map.getZoom() + 1);
+            }
+        }, new MapThemePanel.LayerZoomCallback() {
+            @Override
+            public void onLayerZoom(final Theme theme, final String extent) {
+                final Bounds zoomTo = boundsFromString(extent);
 
-                    getMap().zoomToExtent(zoomTo);
+                if (zoomTo == null) {
+                    GWT.log("WARNING: No valid bounds for zooming found!");
+                    return;
                 }
+
+                getMap().zoomToExtent(zoomTo);
             }
-        );
-        themePanel.addRedrawRequestHandler(this);
-        themePanel.addOutputParameterChangeHandler(this);
-        c.addChild(themePanel);
+        });
+        this.themePanel.addRedrawRequestHandler(this);
+        this.themePanel.addOutputParameterChangeHandler(this);
+        c.addChild(this.themePanel);
 
         return c;
     }
 
-
-    private void fireActivateTheme(Theme theme, boolean active) {
+    private void fireActivateTheme(final Theme theme, final boolean active) {
         activateTheme(theme, active);
     }
 
-
-    protected void activateTheme(Theme theme, boolean active) {
-        AttributedTheme at = (AttributedTheme) theme;
+    protected void activateTheme(final Theme theme, final boolean active) {
 
-        String name = at.getAttr("layers");
-        Layer layer = floodMap.getMap().getLayerByName(name);
+        final String layerId = getLayerId(theme);
 
-        GWT.log("Set visibility of '" + name + "': " + active);
+        final Layer layer = this.floodMap.getMap().getLayerByName(layerId);
+
+        GWT.log("Set visibility of '" + layerId + "': " + active);
 
         if (layer != null) {
             layer.setIsVisible(active);
         }
     }
 
-
     protected void saveBarriers() {
-        Vector layer = floodMap.getBarrierLayer();
-
-        GeoJSON format   = new GeoJSON();
-        String  features = format.write(layer.getFeatures());
-
-        DataItem item = new DefaultDataItem(
-            BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, features);
-
-        Data data = new DefaultData(
-            BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, "String",
-            new DataItem[] {item} );
+        final Vector layer = this.floodMap.getBarrierLayer();
 
-        Config config       = Config.getInstance();
-        String locale = config.getLocale();
+        final GeoJSON format = new GeoJSON();
+        final String features = format.write(layer.getFeatures());
 
-        feedService.go(locale, getArtifact(), new Data[] { data },
-            new AsyncCallback<Artifact>() {
-                @Override
-                public void onFailure(Throwable caught) {
-                    GWT.log("Could not save barrier geometries: " +
-                        caught.getMessage());
-                }
+        final DataItem item = new DefaultDataItem(BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, features);
 
-                @Override
-                public void onSuccess(Artifact artifact) {
-                    GWT.log("Successfully saved barrier geometries.");
-                }
+        final Data data = new DefaultData(BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, "String", new DataItem[] { item });
+
+        final Config config = Config.getInstance();
+        final String locale = config.getLocale();
+
+        this.feedService.go(locale, getArtifact(), new Data[] { data }, new AsyncCallback<Artifact>() {
+            @Override
+            public void onFailure(final Throwable caught) {
+                GWT.log("Could not save barrier geometries: " + caught.getMessage());
             }
-        );
+
+            @Override
+            public void onSuccess(final Artifact artifact) {
+                GWT.log("Successfully saved barrier geometries.");
+            }
+        });
     }
 
-
     @Override
-    public void onTabSelected(TabSelectedEvent tse) {
-        if(floodMap == null) {
+    public void onTabSelected(final TabSelectedEvent tse) {
+        if (this.floodMap == null) {
             return;
         }
-        if(this.equals(tse.getTab())) {
-            floodMap.activateScaleLine(true);
-        }
-        else {
-            controlPanel.activateMeasureControl(false);
-            floodMap.activateScaleLine(false);
+        if (this.equals(tse.getTab())) {
+            this.floodMap.activateScaleLine(true);
+        } else {
+            this.controlPanel.activateMeasureControl(false);
+            this.floodMap.activateScaleLine(false);
         }
     }
 
     public void toogleThemePanel() {
-        this.themePanelCanvas.setVisible(!themePanelCanvas.isVisible());
+        this.themePanelCanvas.setVisible(!this.themePanelCanvas.isVisible());
 
         // Trigger resize event handler
         doLayout();
     }
 
-
     @Override
-    public void onOutputParameterChanged(OutputParameterChangeEvent evt) {
+    public void onOutputParameterChanged(final OutputParameterChangeEvent evt) {
         GWT.log("OutputParameterChanged");
-        controlPanel.updateThemes(getThemePanel().getThemeList());
+        this.controlPanel.updateThemes(getThemePanel().getThemeList());
     }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+
+    public String getWMSUrl(final Theme theme) {
+        final String layerId = getLayerId(theme);
+        return this.wmsUrls.get(layerId);
+    }
+}
\ No newline at end of file
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapThemePanel.java	Wed Sep 12 12:50:28 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapThemePanel.java	Thu Sep 13 18:22:05 2018 +0200
@@ -8,8 +8,16 @@
 
 package org.dive4elements.river.client.client.ui.map;
 
+import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.ui.CollectionView;
+import org.dive4elements.river.client.client.ui.NoopThemeRecordHandler;
+import org.dive4elements.river.client.client.ui.ThemePanel;
+import org.dive4elements.river.client.shared.model.AttributedTheme;
+import org.dive4elements.river.client.shared.model.FacetRecord;
+import org.dive4elements.river.client.shared.model.OutputMode;
+import org.dive4elements.river.client.shared.model.Theme;
+
 import com.google.gwt.core.client.GWT;
-
 import com.smartgwt.client.types.ListGridFieldType;
 import com.smartgwt.client.util.BooleanCallback;
 import com.smartgwt.client.util.SC;
@@ -23,16 +31,6 @@
 import com.smartgwt.client.widgets.menu.events.ClickHandler;
 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
 
-import org.dive4elements.river.client.client.FLYSConstants;
-import org.dive4elements.river.client.client.ui.CollectionView;
-import org.dive4elements.river.client.client.ui.NoopThemeRecordHandler;
-import org.dive4elements.river.client.client.ui.ThemePanel;
-import org.dive4elements.river.client.shared.model.AttributedTheme;
-import org.dive4elements.river.client.shared.model.FacetRecord;
-import org.dive4elements.river.client.shared.model.OutputMode;
-import org.dive4elements.river.client.shared.model.Theme;
-
-
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -40,12 +38,10 @@
 
     public static final int CELL_HEIGHT = 25;
 
-
     public interface ActivateCallback {
         void activate(Theme theme, boolean activate);
     }
 
-
     public interface ThemeMovedCallback {
         void onThemeMoved(Theme theme, int oldIdx, int newIdx);
     }
@@ -54,39 +50,27 @@
         void onLayerZoom(Theme theme, String extent);
     }
 
-
-
-    private FLYSConstants MSG = GWT.create(FLYSConstants.class);
+    private final FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
-
-    protected ActivateCallback   activateCallback;
+    protected ActivateCallback activateCallback;
     protected ThemeMovedCallback themeMovedCallback;
-    protected LayerZoomCallback  layerZoomCallback;
+    protected LayerZoomCallback layerZoomCallback;
 
     protected ListGridRecord[] oldRecords;
 
-
     public static final String GRID_FIELD_ACTIVE = "active";
-    public static final String GRID_FIELD_NAME   = "name";
-
+    public static final String GRID_FIELD_NAME = "name";
 
     protected MapOutputTab mapOut;
 
-
-    public MapThemePanel(
-        CollectionView     view,
-        OutputMode         mode,
-        MapOutputTab       mapOut,
-        ActivateCallback   activateCallback,
-        ThemeMovedCallback themeMovedCallback,
-        LayerZoomCallback  layerZoomCallback
-    ) {
+    public MapThemePanel(final CollectionView view, final OutputMode mode, final MapOutputTab mapOut, final ActivateCallback activateCallback,
+            final ThemeMovedCallback themeMovedCallback, final LayerZoomCallback layerZoomCallback) {
         super(mode, view, new NoopThemeRecordHandler());
 
-        this.mapOut             = mapOut;
-        this.activateCallback   = activateCallback;
+        this.mapOut = mapOut;
+        this.activateCallback = activateCallback;
         this.themeMovedCallback = themeMovedCallback;
-        this.layerZoomCallback  = layerZoomCallback;
+        this.layerZoomCallback = layerZoomCallback;
 
         initGrid();
         initLayout();
@@ -94,74 +78,69 @@
         updateGrid();
     }
 
-
     protected void initLayout() {
         setWidth100();
         setHeight100();
 
-        VLayout layout = new VLayout();
+        final VLayout layout = new VLayout();
         layout.setWidth100();
         layout.setHeight100();
 
-        layout.addMember(list);
-        layout.addMember(navigation);
+        layout.addMember(this.list);
+        layout.addMember(this.navigation);
 
         addChild(layout);
     }
 
-
     protected void initGrid() {
-        list.setCanEdit(true);
-        list.setCanSort(false);
-        list.setShowRecordComponents(false);
-        list.setShowRecordComponentsByCell(true);
-        list.setShowHeader(true);
-        list.setShowHeaderContextMenu(false);
-        list.setCanReorderFields(false);
-        list.setWidth100();
-        list.setHeight100();
+        this.list.setCanEdit(true);
+        this.list.setCanSort(false);
+        this.list.setShowRecordComponents(false);
+        this.list.setShowRecordComponentsByCell(true);
+        this.list.setShowHeader(true);
+        this.list.setShowHeaderContextMenu(false);
+        this.list.setCanReorderFields(false);
+        this.list.setWidth100();
+        this.list.setHeight100();
 
-        list.addHeaderDoubleClickHandler(new HeaderDoubleClickHandler() {
+        this.list.addHeaderDoubleClickHandler(new HeaderDoubleClickHandler() {
             @Override
-            public void onHeaderDoubleClick(HeaderDoubleClickEvent event) {
+            public void onHeaderDoubleClick(final HeaderDoubleClickEvent event) {
                 // cancel the event.
                 return;
             }
         });
 
-        list.setCellHeight(CELL_HEIGHT);
-        list.setShowRecordComponents(true);
-        list.setShowRecordComponentsByCell(true);
-        list.setShowAllRecords(true);
+        this.list.setCellHeight(CELL_HEIGHT);
+        this.list.setShowRecordComponents(true);
+        this.list.setShowRecordComponentsByCell(true);
+        this.list.setShowAllRecords(true);
 
-        list.addEditCompleteHandler(this);
+        this.list.addEditCompleteHandler(this);
 
-        ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20);
+        final ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20);
         active.setType(ListGridFieldType.BOOLEAN);
         active.setCanDragResize(false);
 
-        ListGridField name = new ListGridField(
-            GRID_FIELD_NAME, MSG.chart_themepanel_header_themes());
+        final ListGridField name = new ListGridField(GRID_FIELD_NAME, this.MSG.chart_themepanel_header_themes());
         name.setType(ListGridFieldType.TEXT);
 
-        list.setFields(active, name);
+        this.list.setFields(active, name);
     }
 
-
     @Override
     protected void clearGrid() {
-        oldRecords = list.getRecords();
+        this.oldRecords = this.list.getRecords();
         super.clearGrid();
     }
 
-
     @Override
-    protected void addFacetRecord(FacetRecord rec) {
-        Theme newTheme = rec.getTheme();
-        boolean  isNew = true;
+    protected void addFacetRecord(final FacetRecord rec) {
+        final Theme newTheme = rec.getTheme();
+        boolean isNew = true;
 
-        for (ListGridRecord old: getOldRecords()) {
-            FacetRecord fr = (FacetRecord) old;
+        for (final ListGridRecord old : getOldRecords()) {
+            final FacetRecord fr = (FacetRecord) old;
 
             if (newTheme.equals(fr.getTheme())) {
                 isNew = false;
@@ -169,19 +148,17 @@
             }
         }
 
-        if (isNew && mapOut != null) {
-            mapOut.addLayer(mapOut.createWMSLayer(newTheme));
-        }
+        if (isNew && this.mapOut != null)
+            this.mapOut.addLayer(newTheme);
 
         super.addFacetRecord(rec);
     }
 
-
     @Override
     protected Menu getSingleContextMenu(final ListGridRecord[] records) {
-        Menu menu = super.getSingleContextMenu(records);
+        final Menu menu = super.getSingleContextMenu(records);
 
-        MenuItem layerZoom = createLayerZoomItem(records);
+        final MenuItem layerZoom = createLayerZoomItem(records);
         if (layerZoom != null) {
             menu.addItem(layerZoom);
         }
@@ -190,45 +167,42 @@
         return menu;
     }
 
-
     protected MenuItem createMapURLItem(final ListGridRecord[] records) {
-        final FacetRecord     fr = (FacetRecord) records[0];
-        final AttributedTheme at = (AttributedTheme) fr.getTheme();
+        final FacetRecord fr = (FacetRecord) records[0];
+        final Theme theme = fr.getTheme();
+        final AttributedTheme at = (AttributedTheme) theme;
 
-        MenuItem item = new MenuItem(MSG.wmsURLMenuItem());
+        final MenuItem item = new MenuItem(this.MSG.wmsURLMenuItem());
         item.addClickHandler(new ClickHandler() {
             @Override
-            public void onClick(MenuItemClickEvent evt) {
-                String url = getMapOutputTab().wmsUrls().get(
-                    at.getAttr("layers"));
-                SC.say(MSG.wmsURLBoxTitle(), url);
+            public void onClick(final MenuItemClickEvent evt) {
+                final String url = getMapOutputTab().getWMSUrl(theme);
+
+                SC.say(MapThemePanel.this.MSG.wmsURLBoxTitle(), url);
             }
         });
 
         return item;
     }
 
-
     @Override
     protected MenuItem createRemoveItem(final ListGridRecord[] records) {
-        MenuItem item = super.createRemoveItem(records);
+        final MenuItem item = super.createRemoveItem(records);
         item.addClickHandler(new ClickHandler() {
             @Override
-            public void onClick(MenuItemClickEvent evt) {
-                SC.ask(MSG.askThemeRemove(), new BooleanCallback() {
+            public void onClick(final MenuItemClickEvent evt) {
+                SC.ask(MapThemePanel.this.MSG.askThemeRemove(), new BooleanCallback() {
                     @Override
-                    public void execute(Boolean value) {
+                    public void execute(final Boolean value) {
                         if (value) {
-                            for (ListGridRecord record: records) {
-                                FacetRecord facet = (FacetRecord) record;
+                            for (final ListGridRecord record : records) {
+                                final FacetRecord facet = (FacetRecord) record;
 
-                                Theme theme = facet.getTheme();
+                                final Theme theme = facet.getTheme();
                                 theme.setVisible(0);
                                 theme.setActive(0);
 
-                                AttributedTheme at = (AttributedTheme) theme;
-                                getMapOutputTab().removeLayer(
-                                    at.getAttr("layers"));
+                                getMapOutputTab().removeLayer(theme);
                             }
 
                             updateCollection();
@@ -241,9 +215,8 @@
         return item;
     }
 
-
     protected MenuItem createLayerZoomItem(final ListGridRecord[] recs) {
-        final FacetRecord     fr = (FacetRecord) recs[0];
+        final FacetRecord fr = (FacetRecord) recs[0];
         final AttributedTheme at = (AttributedTheme) fr.getTheme();
 
         final String extent = at.getAttr("extent");
@@ -252,12 +225,12 @@
             return null;
         }
 
-        MenuItem zoom = new MenuItem(MSG.zoomToLayer());
+        final MenuItem zoom = new MenuItem(this.MSG.zoomToLayer());
         zoom.addClickHandler(new ClickHandler() {
             @Override
-            public void onClick(MenuItemClickEvent evt) {
-                if (layerZoomCallback != null) {
-                    layerZoomCallback.onLayerZoom(at, extent);
+            public void onClick(final MenuItemClickEvent evt) {
+                if (MapThemePanel.this.layerZoomCallback != null) {
+                    MapThemePanel.this.layerZoomCallback.onLayerZoom(at, extent);
                 }
             }
         });
@@ -267,39 +240,35 @@
 
     @Override
     public String getWidthAsString() {
-        if(!isVisible()) {
+        if (!isVisible()) {
             return "0";
-        }
-        else {
+        } else {
             return super.getWidthAsString();
         }
     }
 
     @Override
-    public void activateTheme(Theme theme, boolean active) {
-        if (activateCallback != null) {
-            activateCallback.activate(theme, active);
+    public void activateTheme(final Theme theme, final boolean active) {
+        if (this.activateCallback != null) {
+            this.activateCallback.activate(theme, active);
         }
 
         theme.setActive(active ? 1 : 0);
     }
 
-
     @Override
-    protected void fireThemeMoved(Theme theme, int oldIdx, int newIdx) {
-        if (themeMovedCallback != null) {
-            themeMovedCallback.onThemeMoved(theme, oldIdx, newIdx);
+    protected void fireThemeMoved(final Theme theme, final int oldIdx, final int newIdx) {
+        if (this.themeMovedCallback != null) {
+            this.themeMovedCallback.onThemeMoved(theme, oldIdx, newIdx);
         }
     }
 
-
     protected ListGridRecord[] getOldRecords() {
-        return oldRecords != null ? oldRecords : new ListGridRecord[0];
+        return this.oldRecords != null ? this.oldRecords : new ListGridRecord[0];
     }
 
-
     protected MapOutputTab getMapOutputTab() {
-        return mapOut;
+        return this.mapOut;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org