changeset 4619:05c9902c761d

Added example config for river 'Elbe' and read the config in context factory.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 03 Dec 2012 16:54:32 +0100 (2012-12-03)
parents e8c6fbed889b
children 4a30d1d62caf
files flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java
diffstat 2 files changed, 57 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/conf.xml	Mon Dec 03 16:53:22 2012 +0100
+++ b/flys-artifacts/doc/conf/conf.xml	Mon Dec 03 16:54:32 2012 +0100
@@ -393,4 +393,12 @@
             <configuration>${artifacts.config.dir}/themes.xml</configuration>
         </themes>
     </flys>
+
+    <options>
+        <zoom-scales>
+            <zoom-scale river="Elbe" range="50" radius="1" />
+            <zoom-scale river="Elbe" range="100" radius="5" />
+            <zoom-scale river="Elbe" range="500" radius="10" />
+        </zoom-scales>
+    </options>
 </artifact-database>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java	Mon Dec 03 16:53:22 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java	Mon Dec 03 16:54:32 2012 +0100
@@ -1,6 +1,7 @@
 package de.intevation.flys.artifacts.context;
 
 import java.io.File;
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -27,6 +28,7 @@
 import de.intevation.artifactdatabase.transition.TransitionEngine;
 
 import de.intevation.flys.artifacts.model.Module;
+import de.intevation.flys.artifacts.model.ZoomScale;
 import de.intevation.flys.artifacts.states.StateFactory;
 import de.intevation.flys.artifacts.transitions.TransitionFactory;
 import de.intevation.flys.themes.Theme;
@@ -84,6 +86,8 @@
 
     public static final String XPATH_MODULES = "/artifact-database/modules/module";
 
+    private static final String XPATH_ZOOM_SCALES = "/artifact-database/options/zoom-scales/zoom-scale";
+
     /**
      * Creates a new FLYSArtifactContext object and initialize all
      * components required by the application.
@@ -101,11 +105,56 @@
         configureThemesMappings(config, context);
         configureRiverWMS(config, context);
         configureModules(config, context);
+        configureZoomScales(config, context);
 
         return context;
     }
 
 
+    private void configureZoomScales(Document config, FLYSContext context) {
+        NodeList list = (NodeList)XMLUtils.xpath(
+            config,
+            XPATH_ZOOM_SCALES,
+            XPathConstants.NODESET);
+        ZoomScale scale = new ZoomScale();
+        for (int i = 0; i < list.getLength(); i++) {
+            Element element = (Element)list.item(i);
+            String river = "default";
+            double range = 0d;
+            double radius = 10d;
+            if (element.hasAttribute("river")) {
+                river = element.getAttribute("river");
+            }
+            if (!element.hasAttribute("range")) {
+                continue;
+            }
+            else {
+                String r = element.getAttribute("range");
+                try {
+                    range = Double.parseDouble(r);
+                }
+                catch (NumberFormatException nfe) {
+                    continue;
+                }
+            }
+            if (!element.hasAttribute("radius")) {
+                continue;
+            }
+            else {
+                String r = element.getAttribute("radius");
+                try {
+                    radius = Double.parseDouble(r);
+                }
+                catch (NumberFormatException nfe) {
+                    continue;
+                }
+            }
+            scale.addRange(river, range, radius);
+       }
+       context.put("zoomscale", scale);
+    }
+
+
     /**
      * This method initializes the transition configuration.
      *

http://dive4elements.wald.intevation.org