Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java @ 5686:efe1ab205a95
Inlcude years in error messages about sed.load, to avoid it interpreted as km.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 12 Apr 2013 16:53:17 +0200 |
parents | ed07dd55f487 |
children |
rev | line source |
---|---|
3227
ed07dd55f487
Fixed various bugs (package declarations, moved classes to correct places).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2688
diff
changeset
|
1 package de.intevation.flys.artifacts.geom; |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
1651
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
3 import java.util.ArrayList; |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 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
|
5 import java.util.Iterator; |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.awt.geom.Point2D; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import java.awt.geom.Line2D; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.artifacts.math.Linear; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
12 import org.apache.log4j.Logger; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
13 |
1651
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
14 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
|
15 |
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
|
16 /** |
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
|
17 * 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
|
18 */ |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 public class Lines |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
21 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
|
22 |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 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
|
24 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 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
|
26 |
2681
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
27 |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
28 /** 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
|
29 protected Lines() { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
32 |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
33 /** |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
34 * Calculate area of polygon with four vertices. |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
35 * @return area of polygon with four vertices. |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
36 */ |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 double area = 0d; |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
41 for (int i=0; i <4; i++) { |
2688
99350b06a780
Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2687
diff
changeset
|
42 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
|
43 } |
2688
99350b06a780
Improved middle height calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2687
diff
changeset
|
44 return Math.abs(area * 0.5d); |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
45 } |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
46 |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
47 |
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
|
48 /** |
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
|
49 * Calculate the 'length' of the given lines. |
2681
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
50 * @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
|
51 */ |
2650
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
52 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
|
53 double sum = 0d; |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
54 for (Line2D line: lines) { |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 } |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
59 return sum; |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
60 } |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
61 |
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
|
62 |
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
|
63 /** 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
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 } |
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 |
2679
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
74 /** |
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
75 * 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
|
76 * 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
|
77 * is distributed horizontally equally. |
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
78 * @param points the points describing the river bed. |
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
79 * @param waterLevel the height of the horizontal water line. |
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
80 * @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
|
81 * calculated area between water surface and river bed. |
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
82 */ |
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
|
83 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
|
84 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
85 boolean debug = log.isDebugEnabled(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
86 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
87 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
88 log.debug("fillWater"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
89 log.debug("----------------------------"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 List<Line2D> result = new ArrayList(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 int N = points.size(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 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
|
97 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
|
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 if (N == 1) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 Point2D p = points.get(0); |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
102 // 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
|
103 if (waterLevel > p.getY()) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 result.add(new Line2D.Double( |
934
d0f3fea20f01
Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
933
diff
changeset
|
105 p.getX(), waterLevel, |
d0f3fea20f01
Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
933
diff
changeset
|
106 p.getX(), waterLevel)); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 } |
2679
22c8a9b4de31
Minimal doc, TODO.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2674
diff
changeset
|
108 // 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
|
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 double minX = Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 double minY = Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 double maxX = -Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 double maxY = -Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 // 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
|
118 // the original index order is preserved. |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
119 for (Point2D p: points) { |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 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
|
121 if (x < minX) minX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 if (x > maxX) maxX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 if (y < minY) minY = y; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 if (y > maxY) maxY = y; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 if (waterLevel > maxY) { // water floods profile |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
133 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
|
134 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
|
135 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
|
136 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
138 // 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
|
139 Mode mode = Mode.UNDEF; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
141 double startX = minX; |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
143 double area = 0d; |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
144 // Walking along the profile. |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 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
|
146 Point2D p1 = points.get(i-1); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
147 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
|
148 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
149 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
|
150 // completely under water |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
151 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
152 log.debug("under water: " + p1 + " " + p2); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
153 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
154 if (mode != Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
155 startX = p1.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
156 mode = Mode.WET; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
157 } |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
158 area += area(p1, p2, |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
159 new Point2D.Double(p2.getX(), waterLevel), |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
160 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
|
161 continue; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
164 // TODO trigger area calculation |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
165 if (p1.getY() > waterLevel && p2.getY() > waterLevel) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
166 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
167 log.debug("over water: " + p1 + " " + p2); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
168 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 // completely over water |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 if (mode == Mode.WET) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
171 log.debug("over/wet"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 p1.getX(), waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 continue; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
180 // TODO trigger area calculation |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 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
|
182 // vertical line |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 switch (mode) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 case WET: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
185 log.debug("vertical/wet"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 p1.getX(), waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 case DRY: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
192 log.debug("vertical/dry"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 startX = p2.getX(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 default: // UNDEF |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
197 log.debug("vertical/undef"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 if (p2.getY() < waterLevel) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 startX = p2.getX(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 else { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 continue; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
209 // check if waterlevel directly hits the vertices; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
210 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
211 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
|
212 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
|
213 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
214 // TODO trigger area calculation |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
215 if (p1W || p2W) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
216 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
217 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
|
218 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
219 if (p1W && p2W) { // parallel to water -> dry |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
220 log.debug("water hits both vertices"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
221 if (mode == Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
222 result.add(new Line2D.Double( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
223 startX, waterLevel, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
224 p1.getX(), waterLevel)); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
225 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
226 mode = Mode.DRY; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
227 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
228 else if (p1W) { // p1 == waterlevel |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
229 log.debug("water hits first vertex"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
230 if (p2.getY() > waterLevel) { // --> dry |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
231 if (mode == Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
232 result.add(new Line2D.Double( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
233 startX, waterLevel, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
234 p1.getX(), waterLevel)); |
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 mode = Mode.DRY; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
237 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
238 else { // --> wet |
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 startX = p1.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
241 mode = Mode.WET; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
242 } |
2687
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
243 area += area(p1, p2, |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
244 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
|
245 new Point2D.Double(p2.getX(), waterLevel)); |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
246 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
247 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
248 else { // p2 == waterlevel |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
249 log.debug("water hits second vertex"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
250 if (p1.getY() > waterLevel) { // --> wet |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
251 if (mode != Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
252 startX = p2.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
253 mode = Mode.WET; |
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 { // --> dry |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
257 if (mode == Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
258 result.add(new Line2D.Double( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
259 startX, waterLevel, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
260 p2.getX(), waterLevel)); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
261 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
262 mode = Mode.DRY; |
2687
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
263 area += area(p1, p2, |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
264 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
|
265 new Point2D.Double(p1.getX(), waterLevel)); |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
266 } |
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 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
269 log.debug("mode is now: " + mode); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
270 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
271 continue; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
272 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
273 |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
274 // TODO trigger area calculation |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
275 // intersection case |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
276 double x = Linear.linear( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
277 waterLevel, |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
278 p1.getY(), p2.getY(), |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
279 p1.getX(), p2.getX()); |
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("intersection p1:" + p1); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
283 log.debug("intersection p2:" + p2); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
284 log.debug("intersection at x: " + x); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
285 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
286 |
2687
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
287 // 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
|
288 if (p1.getY() > waterLevel) { |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
289 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
|
290 p2, |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
291 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
|
292 new Point2D.Double(x, waterLevel)); |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
293 } |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
294 else { |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
295 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
|
296 p1, |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
297 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
|
298 new Point2D.Double(x, waterLevel)); |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
299 } |
dc67ddd4a34c
Progressed area calculation while line computation a bit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2681
diff
changeset
|
300 |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
301 switch (mode) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
302 case WET: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
303 log.debug("intersect/wet"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
304 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
305 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
306 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
307 x, waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
308 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
309 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
310 case DRY: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
311 log.debug("intersect/dry"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
312 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
313 startX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
314 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
315 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
316 default: // UNDEF |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
317 log.debug("intersect/undef"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
318 if (p2.getY() > waterLevel) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
319 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
|
320 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
321 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
322 p1.getX(), waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
323 x, waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
324 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
325 else { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
326 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
327 startX = x; |
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 } // switch mode |
934
d0f3fea20f01
Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
933
diff
changeset
|
330 } // 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
|
331 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
332 if (mode == Mode.WET) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
333 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
334 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 maxX, waterLevel)); |
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 |
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
|
338 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
|
339 } |
1651
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
340 |
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
|
341 |
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
|
342 /** |
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
|
343 * 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
|
344 */ |
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
|
345 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
|
346 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
|
347 public double width; |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
348 public double area; |
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
349 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
|
350 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
|
351 this.width = width; |
2673
0143b44631cc
Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2652
diff
changeset
|
352 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
|
353 } |
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 |
2681
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
357 /** Return length of a single line. */ |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
358 public static double lineLength(Line2D line) { |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
359 double xDiff = line.getX1() - line.getX2(); |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
360 double yDiff = line.getY1() - line.getY2(); |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
361 return Math.sqrt(xDiff*xDiff + yDiff*yDiff); |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
362 } |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
363 |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
364 |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
365 /** |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
366 * @param points the riverbed. |
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
367 */ |
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
|
368 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
|
369 List<Point2D> points, |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
370 double waterlevel |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
371 ) { |
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
|
372 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
|
373 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
|
374 |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 |
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 // Length calculation. |
2681
b94b367d8b4d
Minor refactoring, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2679
diff
changeset
|
389 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
|
390 |
1651
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
391 if (iter.hasNext()) { |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
392 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
|
393 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
|
394 } |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
395 } |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
396 |
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
|
397 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
|
398 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
|
399 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
|
400 ); |
1651
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
401 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
402 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
403 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |