changeset 2674:2be59d5b342c

Added and respect theme prop whether or not to display (not yet calculated) middle height. flys-artifacts/trunk@4368 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 09 May 2012 20:05:46 +0000
parents 0143b44631cc
children 1d7231d5b8ad
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 5 files changed, 55 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed May 09 19:03:54 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed May 09 20:05:46 2012 +0000
@@ -1,3 +1,18 @@
+2012-05-08  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Display mittlere hoehe (which is not yet calculated).
+
+	* doc/conf/themes.xml: Added theme prop to display middlere hoehe or not.
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java:
+	  (parseShowMiddleHeight): New, parse the new theme prop.
+
+	* src/main/java/de/intevation/flys/artifacts/geom/Lines.java:
+	  (fillWater, ListWithArea): Return new type wich also contains area.
+
+	* src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java:
+	  Respect new theme prop and adjust label if set.
+
 2012-05-08  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Beginning of calculation of Mittlere Hoehe: area calculation.
--- a/flys-artifacts/doc/conf/themes.xml	Wed May 09 19:03:54 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Wed May 09 20:05:46 2012 +0000
@@ -587,6 +587,7 @@
             <field name="linesize"  type="int"   display="Liniendicke" default="1" hints="h"/>
             <field name="showwidth" type="boolean" display="Breite anzeigen" default="false"/>
             <field name="showlevel" type="boolean" display="Wasserstand anzeigen" default="false"/>
+            <field name="showmiddleheight" type="boolean" display="Wasserstand anzeigen" default="false"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Wed May 09 19:03:54 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Wed May 09 20:05:46 2012 +0000
@@ -58,7 +58,19 @@
         return sum;
     }
 
-    public static List<Line2D> fillWater(List<Point2D> points, double waterLevel) {
+
+    /** List of lines and a double-precision area. */
+    private static class ListWithArea {
+        public List<Line2D> lines;
+        public double area;
+        public ListWithArea(List<Line2D> lines, double area) {
+            this.lines = lines;
+            this.area = area;
+        }
+    }
+
+
+    public static ListWithArea fillWater(List<Point2D> points, double waterLevel) {
 
         boolean debug = log.isDebugEnabled();
 
@@ -72,7 +84,7 @@
         int N = points.size();
 
         if (N == 0) {
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         if (N == 1) {
@@ -83,7 +95,7 @@
                     p.getX(), waterLevel,
                     p.getX(), waterLevel));
             }
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         double minX =  Double.MAX_VALUE;
@@ -103,13 +115,13 @@
 
         if (minY > waterLevel) { // profile completely over water level
             log.debug("complete over water");
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         if (waterLevel > maxY) { // water floods profile
             log.debug("complete under water");
             result.add(new Line2D.Double(minX, waterLevel, maxX, waterLevel));
-            return result;
+            return new ListWithArea(result, 0d);
         }
 
         // Water is sometimes above, sometimes under profile.
@@ -292,7 +304,7 @@
                 maxX, waterLevel));
         }
 
-        return result;
+        return new ListWithArea(result, area);
     }
 
 
@@ -315,7 +327,8 @@
         List<Point2D> points,
         double        waterlevel
     ) {
-        List<Line2D> lines = fillWater(points, waterlevel);
+        ListWithArea listAndArea = fillWater(points, waterlevel);
+        List<Line2D> lines = listAndArea.lines;
 
         TDoubleArrayList lxs = new TDoubleArrayList();
         TDoubleArrayList lys = new TDoubleArrayList();
@@ -343,7 +356,7 @@
 
         return new LineData(
             new double [][] { lxs.toNativeArray(), lys.toNativeArray() },
-            linesLength, 0d
+            linesLength, listAndArea.area
             );
     }
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Wed May 09 19:03:54 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Wed May 09 20:05:46 2012 +0000
@@ -232,9 +232,14 @@
             // Do not modify.
             //series.setLabel(series.getLabel());
         }
-        if (ThemeUtil.parseShowLevel(theme) && lines.points.length >0 && lines.points[1].length > 0) {
+        if (ThemeUtil.parseShowLevel(theme) && lines.points.length >0
+            && lines.points[1].length > 0) {
             series.setLabel(series.getLabel() + ", W=" + lines.points[1][0] + "NN+m");
         }
+        if (ThemeUtil.parseShowMiddleHeight(theme) && lines.points.length >0
+            && lines.points[1].length > 0) {
+            series.setLabel(series.getLabel() + ",H=" + lines.area / lines.points[1][0] + "m");    
+        }
         // TODO Missing: "mittlere hoehe" (and area but this geos to
         //                                 the area theme).
         
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed May 09 19:03:54 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed May 09 20:05:46 2012 +0000
@@ -85,6 +85,9 @@
     public final static String XPATH_SHOW_AREA =
         "/theme/field[@name='showarea']/@default";
 
+    public final static String XPATH_SHOW_MIDDLE_HEIGHT =
+        "/theme/field[@name='showmiddleheight']/@default";
+
     public final static String XPATH_TEXT_COLOR =
         "/theme/field[@name='textcolor']/@default";
 
@@ -249,6 +252,15 @@
     }
 
     /**
+     * Parses the attribute 'showmiddleheight', defaults to false.
+     * @param theme The theme.
+     */
+    public static boolean parseShowMiddleHeight(Document theme) {
+        String show = XMLUtils.xpathString(theme, XPATH_SHOW_MIDDLE_HEIGHT, null);
+        return parseBoolean(show, false);
+    }
+
+    /**
      * Parses the attribute 'showarea', defaults to false.
      * @param theme The theme.
      */

http://dive4elements.wald.intevation.org