[Dive4elements-commits] [PATCH 02 of 11] Added example config for river 'Elbe' and read the config in context factory

Wald Commits scm-commit at wald.intevation.org
Mon Dec 3 17:27:22 CET 2012


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1354550072 -3600
# Node ID 05c9902c761d051b50e2b3af2dab912b14c0f1ce
# Parent  e8c6fbed889b5229f28a56842f53444ac9f8b33f
Added example config for river 'Elbe' and read the config in context factory.

diff -r e8c6fbed889b -r 05c9902c761d flys-artifacts/doc/conf/conf.xml
--- 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>
diff -r e8c6fbed889b -r 05c9902c761d flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java
--- 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.
      *


More information about the Dive4elements-commits mailing list