comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java @ 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 22c8a9b4de31
children dc67ddd4a34c
comparison
equal deleted inserted replaced
2680:c0fbff11d287 2681:b94b367d8b4d
22 22
23 public static final double EPSILON = 1e-4; 23 public static final double EPSILON = 1e-4;
24 24
25 public static enum Mode { UNDEF, WET, DRY }; 25 public static enum Mode { UNDEF, WET, DRY };
26 26
27
28 /** Never instantiate Lines, use static functions instead. */
27 protected Lines() { 29 protected Lines() {
28 } 30 }
29 31
30 32
31 /** 33 /**
45 } 47 }
46 48
47 49
48 /** 50 /**
49 * Calculate the 'length' of the given lines. 51 * Calculate the 'length' of the given lines.
52 * @param lines lines of which to calculate length.
50 */ 53 */
51 public static double length(List<Line2D> lines) { 54 public static double length(List<Line2D> lines) {
52 double sum = 0d; 55 double sum = 0d;
53 for (Line2D line: lines) { 56 for (Line2D line: lines) {
54 double xDiff = line.getX1() - line.getX2(); 57 double xDiff = line.getX1() - line.getX2();
331 this.area = area; 334 this.area = area;
332 } 335 }
333 } 336 }
334 337
335 338
339 /** Return length of a single line. */
340 public static double lineLength(Line2D line) {
341 double xDiff = line.getX1() - line.getX2();
342 double yDiff = line.getY1() - line.getY2();
343 return Math.sqrt(xDiff*xDiff + yDiff*yDiff);
344 }
345
346
347 /**
348 * @param points the riverbed.
349 */
336 public static LineData createWaterLines( 350 public static LineData createWaterLines(
337 List<Point2D> points, 351 List<Point2D> points,
338 double waterlevel 352 double waterlevel
339 ) { 353 ) {
340 ListWithArea listAndArea = fillWater(points, waterlevel); 354 ListWithArea listAndArea = fillWater(points, waterlevel);
352 lys.add(p1.getY()); 366 lys.add(p1.getY());
353 lxs.add(p2.getX()); 367 lxs.add(p2.getX());
354 lys.add(p2.getY()); 368 lys.add(p2.getY());
355 369
356 // Length calculation. 370 // Length calculation.
357 double xDiff = line.getX1() - line.getX2(); 371 linesLength += lineLength(line);
358 double yDiff = line.getY1() - line.getY2();
359 linesLength += Math.sqrt(xDiff*xDiff + yDiff*yDiff);
360 372
361 if (iter.hasNext()) { 373 if (iter.hasNext()) {
362 lxs.add(Double.NaN); 374 lxs.add(Double.NaN);
363 lys.add(Double.NaN); 375 lys.add(Double.NaN);
364 } 376 }

http://dive4elements.wald.intevation.org