changeset 1096:9f88cc54570c

Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state. flys-artifacts/trunk@2599 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 26 Aug 2011 15:01:20 +0000
parents f465785ed1ae
children 94df49614d92
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java
diffstat 2 files changed, 90 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Aug 26 14:58:35 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Aug 26 15:01:20 2011 +0000
@@ -1,3 +1,8 @@
+2011-08-26  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java:
+	  Set some WSPLGENJob parameters which are stored at FLYSArtifact.
+
 2011-08-26  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/FLYSUtils.java: New. This helper
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Aug 26 14:58:35 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Aug 26 15:01:20 2011 +0000
@@ -20,6 +20,7 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WSPLGENFacet;
 import de.intevation.flys.artifacts.model.WSPLGENJob;
+import de.intevation.flys.utils.FLYSUtils;
 
 
 public class FloodMapState
@@ -35,6 +36,8 @@
 
     public static final String WSPLGEN_PARAMETER_FILE = "wsplgen.par";
 
+    public static final int WSPLGEN_DEFAULT_OUTPUT = 0;
+
 
 
     @Override
@@ -131,7 +134,6 @@
     }
 
 
-
     protected WSPLGENJob prepareWSPLGENJob(
         FLYSArtifact artifact,
         File         artifactDir
@@ -141,6 +143,22 @@
         WSPLGENJob job = new WSPLGENJob();
         File  paraFile = new File(artifactDir, WSPLGEN_PARAMETER_FILE);
 
+        setOut(artifact, job);
+        setRange(artifact, job);
+        setDelta(artifact, job);
+        setGel(artifact, job);
+        setDist(artifact, job);
+
+        // TODO
+        // setDgm(artifact, job);    // SHP
+        // setPro(artifact, job);    // SHP
+        // setWsp(artifact, job);    // WSP
+        // setWspTag(artifact, job);
+        // setLine(artifact, job);   // SHP
+        // setAxis(artifact, job);   // SHP
+        // setArea(artifact, job);   // SHP
+        // setOutFile(artifact, job);
+
         try {
             job.toFile(paraFile);
 
@@ -155,5 +173,71 @@
 
         return null;
     }
+
+
+    protected void setOut(FLYSArtifact artifact, WSPLGENJob job) {
+        job.setOut(WSPLGEN_DEFAULT_OUTPUT);
+    }
+
+
+    protected void setRange(FLYSArtifact artifact, WSPLGENJob job) {
+        double[] range = FLYSUtils.getKmRange(artifact);
+
+        job.setStart(range[0]);
+        job.setEnd(range[1]);
+    }
+
+
+    protected void setDelta(FLYSArtifact artifact, WSPLGENJob job) {
+        String from = artifact.getDataAsString("diff_from");
+        String to   = artifact.getDataAsString("diff_to");
+        String diff = artifact.getDataAsString("diff_diff");
+
+        try {
+            job.setFrom(Double.parseDouble(from));
+        }
+        catch (NumberFormatException nfe) {
+        }
+
+        try {
+            job.setTo(Double.parseDouble(to));
+        }
+        catch (NumberFormatException nfe) {
+        }
+
+        try {
+            job.setDiff(Double.parseDouble(diff));
+        }
+        catch (NumberFormatException nfe) {
+        }
+    }
+
+
+    protected void setGel(FLYSArtifact artifact, WSPLGENJob job) {
+        String gel = artifact.getDataAsString("use_floodplain");
+
+        if (gel != null && gel.length() > 0) {
+            boolean use = Boolean.parseBoolean(gel);
+
+            if (use) {
+                job.setGel(WSPLGENJob.GEL_SPERRE);
+            }
+            else {
+                job.setGel(WSPLGENJob.GEL_NOSPERRE);
+            }
+        }
+    }
+
+
+    protected void setDist(FLYSArtifact artifact, WSPLGENJob job) {
+        String dist = artifact.getDataAsString("profile_distance");
+
+        try {
+            job.setDist(Double.parseDouble(dist));
+        }
+        catch (NumberFormatException nfe) {
+            // nothing to do here
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org