changeset 2688:99350b06a780

Improved middle height calculations. flys-artifacts/trunk@4389 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 11 May 2012 08:45:11 +0000
parents dc67ddd4a34c
children 3ab7b593c6e5
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java
diffstat 3 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri May 11 07:24:12 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri May 11 08:45:11 2012 +0000
@@ -1,3 +1,14 @@
+2012-05-11  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Improved middle height calculations for waterlevels.
+
+	* src/main/java/de/intevation/flys/artifacts/geom/Lines.java
+	 (area): Improved or even corrected area calculation.
+
+	* src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java:
+	  Corrected middle height calculated, have a very verbose label for
+          the time being.
+
 2012-05-11  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Somewhat improve area calculation during line computation.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Fri May 11 07:24:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Fri May 11 08:45:11 2012 +0000
@@ -35,15 +35,13 @@
      * @return area of polygon with four vertices.
      */
     public static double area(Point2D p1, Point2D p2, Point2D p3, Point2D p4) {
-        double[] x = new double[] {p1.getX(), p2.getX(), p3.getX(), p4.getX() };
-        double[] y = new double[] {p1.getY(), p2.getY(), p3.getY(), p4.getY() };
+        double[] x = new double[] {p1.getX(), p2.getX(), p3.getX(), p4.getX(), p1.getX() };
+        double[] y = new double[] {p1.getY(), p2.getY(), p3.getY(), p4.getY(), p1.getY() };
         double area = 0d;
-        int j = 3;
         for (int i=0; i <4; i++) {
-            area += (x[j] + x[i]) * (y[j] - y[i]);
-            j = i;
+            area += (x[i] * y[i+1]) - (x[i+1] * y[i]);
         }
-        return area * 0.5d;
+        return Math.abs(area * 0.5d);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Fri May 11 07:24:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/CrossSectionGenerator.java	Fri May 11 08:45:11 2012 +0000
@@ -236,9 +236,8 @@
             && 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");    
+        if (ThemeUtil.parseShowMiddleHeight(theme) && lines.width != 0) {
+            series.setLabel(series.getLabel() + ",H=" + lines.area / lines.width + "m : " + lines.area + "/" + lines.width);    
         }
         // TODO Missing: "mittlere hoehe" (and area but this geos to
         //                                 the area theme).

http://dive4elements.wald.intevation.org