diff gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java @ 472:d6a100d5f74a

Added configuration of directory of "Horizontalschnitt" shape files. gnv-artifacts/trunk@537 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 13 Jan 2010 18:58:26 +0000
parents 7ba4c7222265
children ab29e4ff2fda
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Tue Jan 12 17:41:59 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Wed Jan 13 18:58:26 2010 +0000
@@ -75,6 +75,9 @@
     public final static String HORIZONTAL_CROSS_SECTION_SAMPLES =
         "/artifact-database/gnv/horizontal-cross-section/samples/@number";
     
+    public final static String HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH =
+        "/artifact-database/gnv/horizontal-cross-section/result-shapefile-directory/@path";
+    
     public final static String VERTICAL_CROSS_SECTION_SAMPLES =
         "/artifact-database/gnv/vertical-cross-section/samples";
 
@@ -313,37 +316,79 @@
     }
     
     protected void configureHorizontalCrossSection(
-          Document           config,
-          GNVArtifactContext context
-      )
-      {
-          log.info("configuration of horizontal cross section");
-    
-          String numSamples = Config.getStringXPath(
-              config,
-              HORIZONTAL_CROSS_SECTION_SAMPLES);
-    
-          Integer samples =
-              GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_SAMPLES;
-    
-          if (numSamples == null) {
-              log.warn("No number of samples found.");
-          }
-          else {
-              try {
-                  samples = Integer.valueOf(numSamples);
-              }
-              catch (NumberFormatException nfe) {
-                  log.warn("Invalid integer for number of samples");
-              }
-          }
-    
-          log.info("# horizontal cross section profile samples: " + samples);
-    
-          context.put(
-              GNVArtifactContext.HORIZONTAL_CROSS_SECTION_SAMPLES_KEY,
-              samples);
-      }
+        Document           config,
+        GNVArtifactContext context
+    ) {
+        log.info("configuration of horizontal cross section");
+
+        configureHorizontalCrossSectionSamples(config, context);
+        configureHorizontalCrossSectionResultShapeFilePath(config, context);
+    }
+
+    protected void configureHorizontalCrossSectionResultShapeFilePath(
+        Document           config,
+        GNVArtifactContext context
+    )
+    {
+        log.info(
+            "configuration of horizontal cross section result shape file path");
+
+        File dir = 
+            GNVArtifactContext.
+            DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH;
+
+        String path = Config.getStringXPath(
+            config,
+            HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH);
+
+        if (path != null && (path = path.trim()).length() > 0) {
+            dir = new File(Config.replaceConfigDir(path));
+        }
+        else {
+            log.warn("No 'result-shapefile-directory' given");
+        }
+
+        log.info("writing shape files to '" 
+            + dir.getAbsolutePath() + "'");
+
+        context.put(
+            GNVArtifactContext
+                .HORIZONTAL_CROSS_SECTION_RESULT_SHAPEFILE_PATH_KEY,
+            dir);
+    }
+
+    protected void configureHorizontalCrossSectionSamples(
+        Document           config,
+        GNVArtifactContext context
+    )
+    {
+        log.info("configuration of horizontal cross section samples");
+        String numSamples = Config.getStringXPath(
+            config,
+            HORIZONTAL_CROSS_SECTION_SAMPLES);
+
+        Integer samples =
+            GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_SAMPLES;
+
+        if (numSamples == null) {
+            log.warn("No number of samples found.");
+        }
+        else {
+            try {
+                samples = Integer.valueOf(numSamples);
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("Invalid integer for number of samples");
+            }
+        }
+
+        log.info("# horizontal cross section profile samples: " + samples);
+
+        context.put(
+            GNVArtifactContext.HORIZONTAL_CROSS_SECTION_SAMPLES_KEY,
+            samples);
+    }
+
 
     protected void configureChartTemplate(
         Document           config,

http://dive4elements.wald.intevation.org