changeset 2687:dc67ddd4a34c

Progressed area calculation while line computation a bit. flys-artifacts/trunk@4388 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 11 May 2012 07:24:12 +0000
parents 6fda6ec9e426
children 99350b06a780
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri May 11 07:11:01 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri May 11 07:24:12 2012 +0000
@@ -1,3 +1,11 @@
+2012-05-11  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Somewhat improve area calculation during line computation.
+	Still faulty.
+
+	* src/main/java/de/intevation/flys/artifacts/geom/Lines.java
+	 (fillWater): Piecewise calculate area in more cases.
+
 2012-05-11  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Tackle water-through-mountain issue that exists since r4099.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Fri May 11 07:11:01 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Fri May 11 07:24:12 2012 +0000
@@ -242,6 +242,9 @@
                             startX = p1.getX();
                             mode = Mode.WET;
                         }
+                        area += area(p1, p2,
+                            new Point2D.Double(p2.getX(), waterLevel),
+                            new Point2D.Double(p2.getX(), waterLevel));
                     }
                 }
                 else { // p2 == waterlevel
@@ -259,6 +262,9 @@
                                 p2.getX(), waterLevel));
                         }
                         mode = Mode.DRY;
+                        area += area(p1, p2,
+                            new Point2D.Double(p1.getX(), waterLevel),
+                            new Point2D.Double(p1.getX(), waterLevel));
                     }
                 }
                 if (debug) {
@@ -280,6 +286,20 @@
                 log.debug("intersection at x: " + x);
             }
 
+            // Add area of that part of intersection that is 'wet'.
+            if (p1.getY() > waterLevel) {
+                area += area(new Point2D.Double(x, waterLevel),
+                             p2,
+                             new Point2D.Double(p2.getX(), waterLevel),
+                             new Point2D.Double(x, waterLevel));
+            }
+            else {
+                area += area(new Point2D.Double(x, waterLevel),
+                             p1,
+                             new Point2D.Double(p1.getX(), waterLevel),
+                             new Point2D.Double(x, waterLevel));
+            }
+
             switch (mode) {
                 case WET:
                     log.debug("intersect/wet");

http://dive4elements.wald.intevation.org