diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java @ 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 a7def20539fb
children 9d2a06c3a134
line wrap: on
line diff
--- 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