Mercurial > dive4elements > river
changeset 958:ae198bef4ba0
Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
flys-artifacts/trunk@2377 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Jul 20 15:06:16 2011 +0000 @@ -1,3 +1,34 @@ +2011-07-20 Ingo Weinzierl <ingo@intevation.de> + + * doc/conf/conf.xml: Added wms configurations for Saar, Mosel and Elbe. + Each river supported by FLYS requires such a WMS configuration. A WMS + should contain layers for the river axis, buildings, kilometer labels + and maybe a background layer as well. + + * src/main/java/de/intevation/flys/artifacts/context/FLYSContext.java: + Added key that is used to store a map of WMS URLs - for each river a + WMS URL. + + * src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java: + Parse the river WMS from global configuration. + + * src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java: + Create WMSLayerFacets with URLs based on the river and the river wms + configuration stored in the FLYSContext. + + * src/main/java/de/intevation/flys/artifacts/WMSBackgroundArtifact.java, + src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java: + Adapted the initialize() signature and the method call of computeInit() + which requires a FLYSContext to retrieve the river WMS configurations. + + * src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java, + src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: + Added the context object parameter to the computeInit() method. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Call + initialize() with the context object - which is a FLYSContext or a + CallContext. + 2011-07-20 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/services/meta/App.java:
--- a/flys-artifacts/doc/conf/conf.xml Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Wed Jul 20 15:06:16 2011 +0000 @@ -96,6 +96,9 @@ <!-- the WMS layer that is displayed as background layer in floodmaps. --> <floodmap> <background-layer url="http://vmap0.tiles.osgeo.org/wms/vmap0" layer="basic"/> + <river-wms river="Saar" url="http://flys-devel.intevation.de/cgi-bin/saar-wms"/> + <river-wms river="Mosel" url="http://flys-devel.intevation.de/cgi-bin/mosel-wms"/> + <river-wms river="Elbe" url="http://flys-devel.intevation.de/cgi-bin/elbe-wms"/> </floodmap> <rest-server>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Wed Jul 20 15:06:16 2011 +0000 @@ -1289,7 +1289,7 @@ res = state.computeAdvance(this, key, context, fs, old); break; case INIT: - res = state.computeInit(this, key, context.getMeta(), fs); + res = state.computeInit(this, key, context, context.getMeta(), fs); default: res = null; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java Wed Jul 20 15:06:16 2011 +0000 @@ -39,7 +39,7 @@ // TODO Add CallMeta DefaultState state = (DefaultState) getCurrentState(context); - state.computeInit(this, hash(), meta, fs); + state.computeInit(this, hash(), context, meta, fs); if (!fs.isEmpty()) { facets.put(getCurrentStateId(), fs);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBackgroundArtifact.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBackgroundArtifact.java Wed Jul 20 15:06:16 2011 +0000 @@ -36,7 +36,7 @@ // TODO Add CallMeta DefaultState state = (DefaultState) getCurrentState(context); - state.computeInit(this, hash(), meta, fs); + state.computeInit(this, hash(), context, meta, fs); if (!fs.isEmpty()) { facets.put(getCurrentStateId(), fs);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContext.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContext.java Wed Jul 20 15:06:16 2011 +0000 @@ -38,6 +38,10 @@ public static final String THEME_MAPPING = "flys.themes.mapping.map"; + /** The key that is used to store a map of WMS urls for each river.*/ + public static final String RIVER_WMS = + "flys.floodmap.river.wms"; + /** * The default constructor.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java Wed Jul 20 15:06:16 2011 +0000 @@ -73,6 +73,9 @@ public static final String XPATH_THEME_MAPPINGS = "/themes/mappings/mapping"; + public static final String XPATH_RIVER_WMS = + "/artifact-database/floodmap/river-wms"; + /** * Creates a new FLYSArtifactContext object and initialize all * components required by the application. @@ -88,6 +91,7 @@ configureOutGenerators(config, context); configureThemes(config, context); configureThemesMappings(config, context); + configureRiverWMS(config, context); return context; } @@ -360,5 +364,30 @@ context.put(FLYSContext.THEME_MAPPING, mapping); } + + + protected void configureRiverWMS(Document cfg, FLYSContext context) { + Map<String, String> riverWMS = new HashMap<String, String>(); + + NodeList rivers = (NodeList) XMLUtils.xpath( + cfg, XPATH_RIVER_WMS, XPathConstants.NODESET); + + int num = rivers != null ? rivers.getLength() : 0; + + for (int i = 0; i < num; i++) { + Element e = (Element) rivers.item(i); + + String river = e.getAttribute("river"); + String url = e.getAttribute("url"); + + if (river != null && url != null) { + riverWMS.put(river, url); + } + } + + logger.debug("Found " + riverWMS.size() + " river WMS."); + + context.put(FLYSContext.RIVER_WMS, riverWMS); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Wed Jul 20 15:06:16 2011 +0000 @@ -287,6 +287,7 @@ public Object computeInit( FLYSArtifact artifact, String hash, + Object context, CallMeta meta, List<Facet> facets) {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java Wed Jul 20 15:06:16 2011 +0000 @@ -1,14 +1,17 @@ package de.intevation.flys.artifacts.states; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; +import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.context.FLYSContext; import de.intevation.flys.artifacts.model.WMSLayerFacet; import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.artifacts.states.DefaultState.ComputeType; @@ -18,18 +21,43 @@ public static final String I18N_DESCRIPTION = "floodmap.riveraxis"; + public static final String WMS_LAYER_NAME = "riveraxis"; + private static final Logger logger = Logger.getLogger(RiverAxisState.class); + @Override public Object computeInit( FLYSArtifact artifact, String hash, + Object context, CallMeta meta, List<Facet> facets ) { logger.debug("RiverAxisState.computeInit()"); + FLYSContext flysContext = null; + + if (context instanceof FLYSContext) { + flysContext = (FLYSContext) context; + } + else { + flysContext = (FLYSContext) ((CallContext) context).globalContext(); + } + + Map<String, String> wms = (Map<String, String>) + flysContext.get(FLYSContext.RIVER_WMS); + + String river = artifact.getDataAsString("river"); + + if(river == null || river.length() == 0) { + logger.warn("No river found in the current parameterization."); + return null; + } + + String url = wms.get(river); + // TODO Add config for background layer WMSLayerFacet facet = new WMSLayerFacet( 0, @@ -37,9 +65,9 @@ Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION), ComputeType.INIT, getID(), hash, - "http://denmark.atlas/cgi-bin/flys-wms"); // TODO add correct WMS URL + url); - facet.addLayer("riveraxis"); + facet.addLayer(WMS_LAYER_NAME); // TODO determine extent based on the given geometry facet.setExtent("6.5 49.1 7.0 49.7");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java Wed Jul 20 14:59:25 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java Wed Jul 20 15:06:16 2011 +0000 @@ -51,6 +51,7 @@ public Object computeInit( FLYSArtifact artifact, String hash, + Object context, CallMeta meta, List<Facet> facets ) {