changeset 2650:a6fa128e4654

Add method to calculate length of water lines. flys-artifacts/trunk@4311 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 Apr 2012 13:38:56 +0000
parents 6f5fc3de0d48
children 9e9eb9d97548
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Apr 26 10:45:25 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Apr 26 13:38:56 2012 +0000
@@ -1,3 +1,8 @@
+2012-04-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/geom/Lines.java:
+	  Add method to calculate length of water lines.
+
 2012-04-26	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Most of issue454: Label waterlevels.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Thu Apr 26 10:45:25 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Thu Apr 26 13:38:56 2012 +0000
@@ -24,6 +24,16 @@
     protected Lines() {
     }
 
+    public static double length(List<Line2D> lines) {
+        double sum = 0d;
+        for (Line2D line: lines) {
+            double xDiff = line.getX1() - line.getX2();
+            double yDiff = line.getY1() - line.getY2();
+            sum += Math.sqrt(xDiff*xDiff + yDiff*yDiff);
+        }
+        return sum;
+    }
+
     public static List<Line2D> fillWater(List<Point2D> points, double waterLevel) {
 
         boolean debug = log.isDebugEnabled();

http://dive4elements.wald.intevation.org