# HG changeset patch # User Sascha L. Teichmann # Date 1335447536 0 # Node ID a6fa128e465402b198a990c371f5735f9a6607e1 # Parent 6f5fc3de0d4861d0a904070c1bdc4f10044428ea Add method to calculate length of water lines. flys-artifacts/trunk@4311 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6f5fc3de0d48 -r a6fa128e4654 flys-artifacts/ChangeLog --- 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 + + * src/main/java/de/intevation/flys/artifacts/geom/Lines.java: + Add method to calculate length of water lines. + 2012-04-26 Felix Wolfsteller Most of issue454: Label waterlevels. diff -r 6f5fc3de0d48 -r a6fa128e4654 flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java --- 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 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 fillWater(List points, double waterLevel) { boolean debug = log.isDebugEnabled();