changeset 463:07672838fa5f

Make ground interpolation for vertical cross section configurable. gnv-artifacts/trunk@522 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 09 Jan 2010 16:58:53 +0000
parents 912797826099
children 70df44021a9f
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/conf.xml gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java
diffstat 6 files changed, 74 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Sat Jan 09 12:45:42 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Sat Jan 09 16:58:53 2010 +0000
@@ -1,3 +1,20 @@
+2010-01-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* doc/conf/conf.xml: Added configuration for vertical cross 
+	  section ground interpolation.
+
+	* src/main/java/de/intevation/gnv/math/QueriedXYDepth.java: Uses configured
+	  interpolation method now.
+
+	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java:
+	  Read configuration for vertical cross section ground interpolation.
+
+	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java:
+	  Added key and default for vertical cross section ground interpolation.
+
+	* src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java:
+	  Forwards vertical cross section ground interpolation to QueriedXYDepth.
+
 2010-01-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java:
--- a/gnv-artifacts/doc/conf/conf.xml	Sat Jan 09 12:45:42 2010 +0000
+++ b/gnv-artifacts/doc/conf/conf.xml	Sat Jan 09 16:58:53 2010 +0000
@@ -419,6 +419,7 @@
         <vertical-cross-section>
             <!-- This section configures the "Profilschnitt" -->
             <samples width="1024" height="768"/>
+            <ground interpolation="bilinear" />
             <!--
             <filters>
                 <filter factory="de.intevation.gnv.raster.KernelFilter$GaussFactory" 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java	Sat Jan 09 12:45:42 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java	Sat Jan 09 16:58:53 2010 +0000
@@ -44,6 +44,12 @@
     public static final String VERTICAL_CROSS_SECTION_FILTER_FACTORIES_KEY =
         "gnv.vertical.cross.section.filter.factories";
 
+    public static final String VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY =
+        "gnv.vertical.cross.section.ground.interpolation";
+
+    public static final String DEFAULT_VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION =
+        "bilinear";
+
     public GNVArtifactContext() {
         super();
         log.debug("GNVArtifactContext.Constructor");
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Sat Jan 09 12:45:42 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Sat Jan 09 16:58:53 2010 +0000
@@ -78,6 +78,9 @@
     public final static String VERTICAL_CROSS_SECTION_FILTERS =
         "/artifact-database/gnv/vertical-cross-section/filters/filter";
 
+    public final static String VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION =
+        "/artifact-database/gnv/vertical-cross-section/ground/@interpolation";
+
     /**
      * Constructor
      */
@@ -149,6 +152,30 @@
         log.info("configuration of vertical cross section");
         configureVerticalCrossSectionSamples(config, context);
         configureVerticalCrossSectionFilters(config, context);
+        configureVerticalCrossSectionGroundInterpolation(config, context);
+    }
+
+    protected void configureVerticalCrossSectionGroundInterpolation(
+        Document           config,
+        GNVArtifactContext context
+    ) {
+        log.info("configuration of vertical cross section ground interpolation");
+        String interpolation = Config.getStringXPath(
+            config,
+            VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION);
+
+        if (interpolation == null 
+        || (interpolation = interpolation.trim()).length() == 0) {
+            interpolation = GNVArtifactContext
+                .DEFAULT_VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION;
+        }
+
+        log.info("ground interpolation: " + interpolation);
+
+        context.put(
+            GNVArtifactContext
+                .VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY,
+            interpolation);
     }
 
     protected void configureVerticalCrossSectionFilters(
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Sat Jan 09 12:45:42 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Sat Jan 09 16:58:53 2010 +0000
@@ -39,11 +39,15 @@
     private ArrayList<SoftReference<RasterObject>> rasterData;
 
     private RasterObject last;
+
+    private int interpolation;
     
-    /**
-     * Constructor
-     */
     public QueriedXYDepth() {
+        this(RasterObject.BILINEAR);
+    }
+
+    public QueriedXYDepth(int interpolation) {
+        this.interpolation = interpolation;
         rasterData    = new ArrayList<SoftReference<RasterObject>>();
         queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor();
     }
@@ -71,11 +75,11 @@
             }
         }
         return ro != null
-            ? ro.getValue(coordinate)
+            ? ro.getValue(coordinate, interpolation)
             : Double.NaN; 
     }
     
-    private RasterObject getRasterObject(Coordinate coordinate){
+    private RasterObject getRasterObject(Coordinate coordinate) {
         if (last != null && last.contains(coordinate)) {
             return last;
         }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Sat Jan 09 12:45:42 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Sat Jan 09 16:58:53 2010 +0000
@@ -84,6 +84,8 @@
 import de.intevation.gnv.jfreechart.PolygonDataset;
 import de.intevation.gnv.jfreechart.PolygonSeries;
 
+import de.intevation.gnv.geobackend.sde.datasources.RasterObject;
+
 /**
  * @author Tim Englich         (tim.englich@intevation.de)
  * @author Ingo Weinzierl      (iweinzierl@intevation.de)
@@ -182,6 +184,16 @@
         return obj;
     }
 
+    private static int getGroundInterpolation(CallContext callContext) {
+        GNVArtifactContext context = 
+            (GNVArtifactContext)callContext.globalContext();
+
+        String interpolation = (String)context.get(
+            GNVArtifactContext.VERTICAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY);
+
+        return RasterObject.getInterpolationType(interpolation);
+    }
+
     private static Dimension getRasterSize(CallContext callContext) {
         GNVArtifactContext context = 
             (GNVArtifactContext)callContext.globalContext();
@@ -265,8 +277,8 @@
             0d,
             distance,
             LinearMetrics.INSTANCE,
-            new QueriedXYDepth());
-            //new ConstantXYDepth(-75d)); // TODO: Use DEM here!!
+            new QueriedXYDepth(
+                getGroundInterpolation(callContext)));
 
         if (!success) {
             log.warn("interpolation failed");

http://dive4elements.wald.intevation.org