annotate artifacts/src/main/java/org/dive4elements/river/artifacts/geom/Lines.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children af13ceeba52a
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3227
diff changeset
9 package org.dive4elements.river.artifacts.geom;
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
11 import java.util.ArrayList;
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import java.util.List;
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
13 import java.util.Iterator;
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 import java.awt.geom.Point2D;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import java.awt.geom.Line2D;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3227
diff changeset
18 import org.dive4elements.river.artifacts.math.Linear;
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
20 import org.apache.log4j.Logger;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
21
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
22 import gnu.trove.TDoubleArrayList;
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
23
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
24 /**
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
25 * Utility to create lines (intersect water with cross-section etc).
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
26 */
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 public class Lines
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
29 private static Logger log = Logger.getLogger(Lines.class);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
30
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 public static final double EPSILON = 1e-4;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 public static enum Mode { UNDEF, WET, DRY };
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
35
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
36 /** Never instantiate Lines, use static functions instead. */
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 protected Lines() {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
40
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
41 /**
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
42 * Calculate area of polygon with four vertices.
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
43 * @return area of polygon with four vertices.
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
44 */
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
45 public static double area(Point2D p1, Point2D p2, Point2D p3, Point2D p4) {
2688
99350b06a780 Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2687
diff changeset
46 double[] x = new double[] {p1.getX(), p2.getX(), p3.getX(), p4.getX(), p1.getX() };
99350b06a780 Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2687
diff changeset
47 double[] y = new double[] {p1.getY(), p2.getY(), p3.getY(), p4.getY(), p1.getY() };
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
48 double area = 0d;
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
49 for (int i=0; i <4; i++) {
2688
99350b06a780 Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2687
diff changeset
50 area += (x[i] * y[i+1]) - (x[i+1] * y[i]);
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
51 }
2688
99350b06a780 Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2687
diff changeset
52 return Math.abs(area * 0.5d);
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
53 }
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
54
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
55
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
56 /**
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
57 * Calculate the 'length' of the given lines.
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
58 * @param lines lines of which to calculate length.
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
59 */
2650
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
60 public static double length(List<Line2D> lines) {
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
61 double sum = 0d;
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
62 for (Line2D line: lines) {
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
63 double xDiff = line.getX1() - line.getX2();
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
64 double yDiff = line.getY1() - line.getY2();
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
65 sum += Math.sqrt(xDiff*xDiff + yDiff*yDiff);
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
66 }
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
67 return sum;
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
68 }
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
69
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
70
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
71 /** List of lines and a double-precision area. */
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
72 private static class ListWithArea {
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
73 public List<Line2D> lines;
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
74 public double area;
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
75 public ListWithArea(List<Line2D> lines, double area) {
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
76 this.lines = lines;
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
77 this.area = area;
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
78 }
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
79 }
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
80
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
81
2679
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
82 /**
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
83 * For a cross section given as points and a waterlevel (in meters),
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
84 * create a set of lines that represent the water surface, assuming it
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
85 * is distributed horizontally equally.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
86 * @param points the points describing the river bed.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
87 * @param waterLevel the height of the horizontal water line.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
88 * @return A list of Lines representing the water surface and the
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
89 * calculated area between water surface and river bed.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
90 */
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
91 public static ListWithArea fillWater(List<Point2D> points, double waterLevel) {
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
93 boolean debug = log.isDebugEnabled();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
94
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
95 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
96 log.debug("fillWater");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
97 log.debug("----------------------------");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 List<Line2D> result = new ArrayList();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 int N = points.size();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 if (N == 0) {
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
105 return new ListWithArea(result, 0d);
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 if (N == 1) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 Point2D p = points.get(0);
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
110 // Only generate point if over profile
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 if (waterLevel > p.getY()) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 result.add(new Line2D.Double(
934
d0f3fea20f01 Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 933
diff changeset
113 p.getX(), waterLevel,
d0f3fea20f01 Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 933
diff changeset
114 p.getX(), waterLevel));
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 }
2679
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
116 // TODO continue calculating area.
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
117 return new ListWithArea(result, 0d);
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 double minX = Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 double minY = Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 double maxX = -Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 double maxY = -Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 // To ensure for sequences of equals x's that
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 // the original index order is preserved.
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
127 for (Point2D p: points) {
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 double x = p.getX(), y = p.getY();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 if (x < minX) minX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 if (x > maxX) maxX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 if (y < minY) minY = y;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 if (y > maxY) maxY = y;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 if (minY > waterLevel) { // profile completely over water level
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
136 log.debug("complete over water");
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
137 return new ListWithArea(result, 0d);
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 if (waterLevel > maxY) { // water floods profile
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
141 log.debug("complete under water");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 result.add(new Line2D.Double(minX, waterLevel, maxX, waterLevel));
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
143 return new ListWithArea(result, 0d);
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
146 // Water is sometimes above, sometimes under profile.
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 Mode mode = Mode.UNDEF;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
149 double startX = minX;
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
151 double area = 0d;
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
152 // Walking along the profile.
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 for (int i = 1; i < N; ++i) {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
154 Point2D p1 = points.get(i-1);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
155 Point2D p2 = points.get(i);
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
157 if (p1.getY() < waterLevel && p2.getY() < waterLevel) {
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 // completely under water
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
159 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
160 log.debug("under water: " + p1 + " " + p2);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
161 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
162 if (mode != Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
163 startX = p1.getX();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
164 mode = Mode.WET;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
165 }
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
166 area += area(p1, p2,
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
167 new Point2D.Double(p2.getX(), waterLevel),
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
168 new Point2D.Double(p1.getX(), waterLevel));
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 continue;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
171
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
172 // TODO trigger area calculation
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
173 if (p1.getY() > waterLevel && p2.getY() > waterLevel) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
174 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
175 log.debug("over water: " + p1 + " " + p2);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
176 }
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 // completely over water
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 if (mode == Mode.WET) {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
179 log.debug("over/wet");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 p1.getX(), waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 continue;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
188 // TODO trigger area calculation
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 if (Math.abs(p1.getX() - p2.getX()) < EPSILON) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190 // vertical line
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
191 switch (mode) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
192 case WET:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
193 log.debug("vertical/wet");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 p1.getX(), waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 case DRY:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
200 log.debug("vertical/dry");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 startX = p2.getX();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204 default: // UNDEF
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
205 log.debug("vertical/undef");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 if (p2.getY() < waterLevel) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 startX = p2.getX();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 else {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214 continue;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
217 // check if waterlevel directly hits the vertices;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
218
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
219 boolean p1W = Math.abs(waterLevel - p1.getY()) < EPSILON;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
220 boolean p2W = Math.abs(waterLevel - p2.getY()) < EPSILON;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
221
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
222 // TODO trigger area calculation
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
223 if (p1W || p2W) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
224 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
225 log.debug("water hits vertex: " + p1 + " " + p2 + " " + mode);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
226 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
227 if (p1W && p2W) { // parallel to water -> dry
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
228 log.debug("water hits both vertices");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
229 if (mode == Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
230 result.add(new Line2D.Double(
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
231 startX, waterLevel,
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
232 p1.getX(), waterLevel));
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
233 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
234 mode = Mode.DRY;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
235 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
236 else if (p1W) { // p1 == waterlevel
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
237 log.debug("water hits first vertex");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
238 if (p2.getY() > waterLevel) { // --> dry
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
239 if (mode == Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
240 result.add(new Line2D.Double(
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
241 startX, waterLevel,
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
242 p1.getX(), waterLevel));
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
243 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
244 mode = Mode.DRY;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
245 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
246 else { // --> wet
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
247 if (mode != Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
248 startX = p1.getX();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
249 mode = Mode.WET;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
250 }
2687
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
251 area += area(p1, p2,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
252 new Point2D.Double(p2.getX(), waterLevel),
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
253 new Point2D.Double(p2.getX(), waterLevel));
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
254 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
255 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
256 else { // p2 == waterlevel
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
257 log.debug("water hits second vertex");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
258 if (p1.getY() > waterLevel) { // --> wet
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
259 if (mode != Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
260 startX = p2.getX();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
261 mode = Mode.WET;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
262 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
263 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
264 else { // --> dry
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
265 if (mode == Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
266 result.add(new Line2D.Double(
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
267 startX, waterLevel,
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
268 p2.getX(), waterLevel));
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
269 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
270 mode = Mode.DRY;
2687
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
271 area += area(p1, p2,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
272 new Point2D.Double(p1.getX(), waterLevel),
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
273 new Point2D.Double(p1.getX(), waterLevel));
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
274 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
275 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
276 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
277 log.debug("mode is now: " + mode);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
278 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
279 continue;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
280 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
281
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
282 // TODO trigger area calculation
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
283 // intersection case
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
284 double x = Linear.linear(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
285 waterLevel,
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
286 p1.getY(), p2.getY(),
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
287 p1.getX(), p2.getX());
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
288
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
289 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
290 log.debug("intersection p1:" + p1);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
291 log.debug("intersection p2:" + p2);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
292 log.debug("intersection at x: " + x);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
293 }
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
294
2687
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
295 // Add area of that part of intersection that is 'wet'.
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
296 if (p1.getY() > waterLevel) {
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
297 area += area(new Point2D.Double(x, waterLevel),
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
298 p2,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
299 new Point2D.Double(p2.getX(), waterLevel),
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
300 new Point2D.Double(x, waterLevel));
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
301 }
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
302 else {
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
303 area += area(new Point2D.Double(x, waterLevel),
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
304 p1,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
305 new Point2D.Double(p1.getX(), waterLevel),
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
306 new Point2D.Double(x, waterLevel));
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
307 }
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
308
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
309 switch (mode) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
310 case WET:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
311 log.debug("intersect/wet");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
312 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
313 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
314 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
315 x, waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
316 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
317
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
318 case DRY:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
319 log.debug("intersect/dry");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
320 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
321 startX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
322 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
323
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
324 default: // UNDEF
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
325 log.debug("intersect/undef");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
326 if (p2.getY() > waterLevel) {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
327 log.debug("intersect/undef/over");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
328 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
329 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
330 p1.getX(), waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331 x, waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
332 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
333 else {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 startX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
336 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
337 } // switch mode
934
d0f3fea20f01 Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 933
diff changeset
338 } // for all points p[i] and p[i-1]
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 if (mode == Mode.WET) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
343 maxX, waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
344 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
345
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
346 return new ListWithArea(result, area);
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347 }
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
348
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
349
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
350 /**
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
351 * Class holding points that form lines and the calculated length.
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
352 */
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
353 public static class LineData {
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
354 public double [][] points;
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
355 public double width;
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
356 public double area;
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
357 public LineData(double[][] points, double width, double area) {
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
358 this.points = points;
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
359 this.width = width;
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
360 this.area = area;
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
361 }
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
362 }
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
363
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
364
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
365 /** Return length of a single line. */
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
366 public static double lineLength(Line2D line) {
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
367 double xDiff = line.getX1() - line.getX2();
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
368 double yDiff = line.getY1() - line.getY2();
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
369 return Math.sqrt(xDiff*xDiff + yDiff*yDiff);
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
370 }
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
371
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
372
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
373 /**
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
374 * @param points the riverbed.
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
375 */
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
376 public static LineData createWaterLines(
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
377 List<Point2D> points,
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
378 double waterlevel
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
379 ) {
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
380 ListWithArea listAndArea = fillWater(points, waterlevel);
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
381 List<Line2D> lines = listAndArea.lines;
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
382
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
383 TDoubleArrayList lxs = new TDoubleArrayList();
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
384 TDoubleArrayList lys = new TDoubleArrayList();
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
385 double linesLength = 0.0f;
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
386
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
387 for (Iterator<Line2D> iter = lines.iterator(); iter.hasNext();) {
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
388 Line2D line = iter.next();
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
389 Point2D p1 = line.getP1();
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
390 Point2D p2 = line.getP2();
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
391 lxs.add(p1.getX());
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
392 lys.add(p1.getY());
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
393 lxs.add(p2.getX());
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
394 lys.add(p2.getY());
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
395
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
396 // Length calculation.
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
397 linesLength += lineLength(line);
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
398
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
399 if (iter.hasNext()) {
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
400 lxs.add(Double.NaN);
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
401 lys.add(Double.NaN);
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
402 }
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
403 }
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
404
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
405 return new LineData(
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
406 new double [][] { lxs.toNativeArray(), lys.toNativeArray() },
2674
2be59d5b342c Added and respect theme prop whether or not to display (not yet calculated) middle height.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
407 linesLength, listAndArea.area
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2650
diff changeset
408 );
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
409 }
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
410 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
411 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org