annotate artifacts/src/main/java/org/dive4elements/river/artifacts/geom/Lines.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents af13ceeba52a
children 0a5239a1e46e
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 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
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
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
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) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
46 double[] x = new double[] {
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
47 p1.getX(), p2.getX(), p3.getX(), p4.getX(), p1.getX() };
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
48 double[] y = new double[] {
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
49 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
50 double area = 0d;
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
51 for (int i=0; i <4; i++) {
2688
99350b06a780 Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2687
diff changeset
52 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
53 }
2688
99350b06a780 Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2687
diff changeset
54 return Math.abs(area * 0.5d);
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
55 }
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
56
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
57
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
58 /**
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 * Calculate the 'length' of the given lines.
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
60 * @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
61 */
2650
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
62 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
63 double sum = 0d;
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
64 for (Line2D line: lines) {
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
65 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
66 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
67 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
68 }
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
69 return sum;
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
70 }
a6fa128e4654 Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1651
diff changeset
71
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
72
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 /** 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
74 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
75 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
76 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
77 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
78 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
79 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
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 }
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
82
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
83
2679
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
84 /**
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
85 * 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
86 * 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
87 * is distributed horizontally equally.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
88 * @param points the points describing the river bed.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
89 * @param waterLevel the height of the horizontal water line.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
90 * @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
91 * calculated area between water surface and river bed.
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
92 */
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
93 public static ListWithArea fillWater(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
94 List<Point2D> points,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
95 double waterLevel
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
96 ) {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
97 boolean debug = log.isDebugEnabled();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
98
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
99 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
100 log.debug("fillWater");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
101 log.debug("----------------------------");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 }
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 List<Line2D> result = new ArrayList();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 int N = points.size();
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 == 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
109 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
110 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 if (N == 1) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 Point2D p = points.get(0);
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
114 // 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
115 if (waterLevel > p.getY()) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 result.add(new Line2D.Double(
934
d0f3fea20f01 Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 933
diff changeset
117 p.getX(), waterLevel,
d0f3fea20f01 Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 933
diff changeset
118 p.getX(), waterLevel));
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 }
2679
22c8a9b4de31 Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2674
diff changeset
120 // 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
121 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
122 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 double minX = Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 double minY = Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 double maxX = -Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 double maxY = -Double.MAX_VALUE;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 // 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
130 // the original index order is preserved.
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
131 for (Point2D p: points) {
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 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
133 if (x < minX) minX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 if (x > maxX) maxX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 if (y < minY) minY = y;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 if (y > maxY) maxY = y;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 }
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 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
140 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
141 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
142 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 if (waterLevel > maxY) { // water floods profile
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
145 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
146 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
147 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
148 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
150 // 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
151 Mode mode = Mode.UNDEF;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
153 double startX = minX;
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
155 double area = 0d;
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
156 // Walking along the profile.
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 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
158 Point2D p1 = points.get(i-1);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
159 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
160
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
161 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
162 // completely under water
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
163 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
164 log.debug("under water: " + p1 + " " + p2);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
165 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
166 if (mode != Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
167 startX = p1.getX();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
168 mode = Mode.WET;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
169 }
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
170 area += area(p1, p2,
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
171 new Point2D.Double(p2.getX(), waterLevel),
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
172 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
173 continue;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
174 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
175
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
176 // TODO trigger area calculation
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
177 if (p1.getY() > waterLevel && p2.getY() > waterLevel) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
178 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
179 log.debug("over water: " + p1 + " " + p2);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
180 }
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 // completely over water
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 if (mode == Mode.WET) {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
183 log.debug("over/wet");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 p1.getX(), waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 continue;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
191
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
192 // TODO trigger area calculation
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 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
194 // vertical line
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 switch (mode) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 case WET:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
197 log.debug("vertical/wet");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201 p1.getX(), waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 case DRY:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
204 log.debug("vertical/dry");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 startX = p2.getX();
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 default: // UNDEF
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
209 log.debug("vertical/undef");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 if (p2.getY() < waterLevel) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 startX = p2.getX();
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 else {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218 continue;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
221 // check if waterlevel directly hits the vertices;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
222
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
223 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
224 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
225
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
226 // TODO trigger area calculation
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
227 if (p1W || p2W) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
228 if (debug) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
229 log.debug("water hits vertex: "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
230 + p1 + " " + p2 + " " + mode);
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
231 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
232 if (p1W && p2W) { // parallel to water -> dry
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
233 log.debug("water hits both vertices");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
234 if (mode == Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
235 result.add(new Line2D.Double(
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
236 startX, waterLevel,
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
237 p1.getX(), waterLevel));
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
238 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
239 mode = Mode.DRY;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
240 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
241 else if (p1W) { // p1 == waterlevel
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
242 log.debug("water hits first vertex");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
243 if (p2.getY() > waterLevel) { // --> dry
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
244 if (mode == Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
245 result.add(new Line2D.Double(
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
246 startX, waterLevel,
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
247 p1.getX(), waterLevel));
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
248 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
249 mode = Mode.DRY;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
250 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
251 else { // --> wet
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
252 if (mode != Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
253 startX = p1.getX();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
254 mode = Mode.WET;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
255 }
2687
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
256 area += area(p1, p2,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
257 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
258 new Point2D.Double(p2.getX(), waterLevel));
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
259 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
260 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
261 else { // p2 == waterlevel
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
262 log.debug("water hits second vertex");
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
263 if (p1.getY() > waterLevel) { // --> wet
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
264 if (mode != Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
265 startX = p2.getX();
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
266 mode = Mode.WET;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
267 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
268 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
269 else { // --> dry
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
270 if (mode == Mode.WET) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
271 result.add(new Line2D.Double(
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
272 startX, waterLevel,
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
273 p2.getX(), waterLevel));
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 mode = Mode.DRY;
2687
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
276 area += area(p1, p2,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
277 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
278 new Point2D.Double(p1.getX(), waterLevel));
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
279 }
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 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
282 log.debug("mode is now: " + mode);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
283 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
284 continue;
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
285 }
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
286
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
287 // TODO trigger area calculation
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
288 // intersection case
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
289 double x = Linear.linear(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
290 waterLevel,
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
291 p1.getY(), p2.getY(),
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
292 p1.getX(), p2.getX());
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
293
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
294 if (debug) {
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
295 log.debug("intersection p1:" + p1);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
296 log.debug("intersection p2:" + p2);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
297 log.debug("intersection at x: " + x);
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
298 }
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
299
2687
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
300 // 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
301 if (p1.getY() > waterLevel) {
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
302 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
303 p2,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
304 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
305 new Point2D.Double(x, waterLevel));
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
306 }
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
307 else {
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
308 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
309 p1,
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
310 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
311 new Point2D.Double(x, waterLevel));
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
312 }
dc67ddd4a34c Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2681
diff changeset
313
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
314 switch (mode) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
315 case WET:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
316 log.debug("intersect/wet");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
317 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
318 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
319 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
320 x, waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
321 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
322
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
323 case DRY:
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
324 log.debug("intersect/dry");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
325 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
326 startX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
327 break;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
328
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
329 default: // UNDEF
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
330 log.debug("intersect/undef");
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331 if (p2.getY() > waterLevel) {
938
bd3683453928 Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 934
diff changeset
332 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
333 mode = Mode.DRY;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 p1.getX(), waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
336 x, waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
337 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
338 else {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339 mode = Mode.WET;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 startX = x;
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342 } // switch mode
934
d0f3fea20f01 Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 933
diff changeset
343 } // 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
344
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
345 if (mode == Mode.WET) {
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
346 result.add(new Line2D.Double(
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347 startX, waterLevel,
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
348 maxX, waterLevel));
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
349 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
350
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
351 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
352 }
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
353
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
354
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 /**
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
356 * 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
357 */
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 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
359 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
360 public double width;
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
361 public double area;
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
362 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
363 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
364 this.width = width;
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
365 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
366 }
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
367 }
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
368
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
369
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
370 /** Return length of a single line. */
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
371 public static double lineLength(Line2D line) {
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
372 double xDiff = line.getX1() - line.getX2();
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
373 double yDiff = line.getY1() - line.getY2();
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
374 return Math.sqrt(xDiff*xDiff + yDiff*yDiff);
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
375 }
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
376
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
377
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
378 /**
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
379 * @param points the riverbed.
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
380 */
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
381 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
382 List<Point2D> points,
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
383 double waterlevel
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
384 ) {
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
385 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
386 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
387
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
388 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
389 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
390 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
391
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
392 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
393 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
394 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
395 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
396 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
397 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
398 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
399 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
400
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
401 // Length calculation.
2681
b94b367d8b4d Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2679
diff changeset
402 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
403
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
404 if (iter.hasNext()) {
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
405 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
406 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
407 }
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
408 }
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
409
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
410 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
411 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
412 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
413 );
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 938
diff changeset
414 }
933
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
415 }
34136924661b Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
416 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org