changeset 2681:b94b367d8b4d

Minor refactoring, docs. flys-artifacts/trunk@4379 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 10 May 2012 09:44:31 +0000
parents c0fbff11d287
children 0795c296f718
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu May 10 09:40:39 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu May 10 09:44:31 2012 +0000
@@ -1,3 +1,8 @@
+2012-05-10  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/geom/Lines.java:
+	  Minor refactoring, doc.
+
 2012-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/mapserver/layer.vm: Added a 'PROJECTION' section.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Thu May 10 09:40:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java	Thu May 10 09:44:31 2012 +0000
@@ -24,6 +24,8 @@
 
     public static enum Mode { UNDEF, WET, DRY };
 
+
+    /** Never instantiate Lines, use static functions instead. */
     protected Lines() {
     }
 
@@ -47,6 +49,7 @@
 
     /**
      * Calculate the 'length' of the given lines.
+     * @param lines lines of which to calculate length.
      */
     public static double length(List<Line2D> lines) {
         double sum = 0d;
@@ -333,6 +336,17 @@
     }
 
 
+    /** Return length of a single line. */
+    public static double lineLength(Line2D line) {
+        double xDiff = line.getX1() - line.getX2();
+        double yDiff = line.getY1() - line.getY2();
+        return Math.sqrt(xDiff*xDiff + yDiff*yDiff);
+    }
+
+
+    /**
+     * @param points the riverbed.
+     */
     public static LineData createWaterLines(
         List<Point2D> points,
         double        waterlevel
@@ -354,9 +368,7 @@
             lys.add(p2.getY());
 
             // Length calculation.
-            double xDiff = line.getX1() - line.getX2();
-            double yDiff = line.getY1() - line.getY2();
-            linesLength += Math.sqrt(xDiff*xDiff + yDiff*yDiff);
+            linesLength += lineLength(line);
 
             if (iter.hasNext()) {
                 lxs.add(Double.NaN);

http://dive4elements.wald.intevation.org