[Dive4elements-commits] [PATCH] Add a configurable path prefix to relative DGM path to allways have an absolute path

Wald Commits scm-commit at wald.intevation.org
Fri Mar 1 10:36:11 CET 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1362130538 -3600
# Node ID b26465581abf9bf83ab5357de474680b4c027ba1
# Parent  240ff7aeb6de8c9058784ed80b196ae9ab9638e5
Add a configurable path prefix to relative DGM path to allways have an absolute path.

diff -r 240ff7aeb6de -r b26465581abf flys-artifacts/doc/conf/conf.xml
--- a/flys-artifacts/doc/conf/conf.xml	Fri Mar 01 10:04:57 2013 +0100
+++ b/flys-artifacts/doc/conf/conf.xml	Fri Mar 01 10:35:38 2013 +0100
@@ -394,9 +394,14 @@
             <zoom-scale river="Elbe" range="100" radius="5" />
             <zoom-scale river="Elbe" range="500" radius="10" />
         </zoom-scales>
+
         <minfo-sq>
             <!-- valid names: grubbs or std-dev -->
             <outlier-method name="grubbs"/>
         </minfo-sq>
+
+        <dgm-path>
+          /path/to/rivers/
+        </dgm-path>
     </options>
 </artifact-database>
diff -r 240ff7aeb6de -r b26465581abf 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	Fri Mar 01 10:04:57 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java	Fri Mar 01 10:35:38 2013 +0100
@@ -83,6 +83,9 @@
 
     private static final String XPATH_ZOOM_SCALES = "/artifact-database/options/zoom-scales/zoom-scale";
 
+    private static final String XPATH_DGM_PATH = "/artifact-database/options/dgm-path/text()";
+
+
     /**
      * Creates a new FLYSArtifactContext object and initialize all
      * components required by the application.
@@ -102,11 +105,22 @@
         configureFloodmapWMS(config, context);
         configureModules(config, context);
         configureZoomScales(config, context);
+        configureDGMPath(config, context);
 
         return context;
     }
 
 
+    private void configureDGMPath(Document config, FLYSContext context) {
+        String dgmPath = (String) XMLUtils.xpath(
+            config,
+            XPATH_DGM_PATH,
+            XPathConstants.STRING);
+
+        context.put("dgm-path", dgmPath);
+    }
+
+
     protected void configureZoomScales(Document config, FLYSContext context) {
         NodeList list = (NodeList)XMLUtils.xpath(
             config,
diff -r 240ff7aeb6de -r b26465581abf flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Mar 01 10:04:57 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Mar 01 10:35:38 2013 +0100
@@ -10,6 +10,7 @@
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.GlobalContext;
+import de.intevation.artifacts.common.utils.Config;
 import de.intevation.artifacts.common.utils.FileTools;
 import de.intevation.flys.artifacts.access.RangeAccess;
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -43,6 +44,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.naming.Context;
+
 import org.apache.log4j.Logger;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.FeatureCollections;
@@ -307,7 +310,7 @@
         setUserShape(artifact, facetCreator, artifactDir, job);
         setAxis(artifact, artifactDir, job);
         setPro(artifact, artifactDir, job);
-        setDgm(artifact, job);
+        setDgm(artifact, job, context);
         setArea(artifact, artifactDir, job);
         setOutFile(artifact, job);
         setWsp(artifact, context, artifactDir, job);    // WSP
@@ -691,7 +694,11 @@
     }
 
 
-    protected void setDgm(FLYSArtifact artifact, WSPLGENJob job) {
+    protected void setDgm(
+        FLYSArtifact artifact,
+        WSPLGENJob job,
+        CallContext context
+    ) {
         String dgm_id = artifact.getDataAsString("dgm");
 
         int id = -1;
@@ -708,7 +715,15 @@
             return;
         }
 
-        job.setDgm(dgm.getPath());
+        File dgmPath = new File (dgm.getPath());
+        if (dgmPath.isAbsolute()) {
+            job.setDgm(dgm.getPath());
+        }
+        else {
+            FLYSContext fc = (FLYSContext)context.globalContext();
+            String prefix = (String) fc.get("dgm-path");
+            job.setDgm(prefix.trim() + dgm.getPath().trim());
+        }
     }
 
 


More information about the Dive4elements-commits mailing list