Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/geom/Lines.java @ 2651:9e9eb9d97548
Initial transition configuration and artifact/state stubs for fixation
analysis.
flys-artifacts/trunk@4312 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 26 Apr 2012 15:08:51 +0000 |
parents | a6fa128e4654 |
children | 9d2a06c3a134 |
rev | line source |
---|---|
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
1 package de.intevation.flys.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 |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public class Lines |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
18 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
|
19 |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 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
|
21 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 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
|
23 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 protected Lines() { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
2650
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
27 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
|
28 double sum = 0d; |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
29 for (Line2D line: lines) { |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 } |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
34 return sum; |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
35 } |
a6fa128e4654
Add method to calculate length of water lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1651
diff
changeset
|
36 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
37 public static List<Line2D> 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
|
38 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
39 boolean debug = log.isDebugEnabled(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
40 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
41 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
42 log.debug("fillWater"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
43 log.debug("----------------------------"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 List<Line2D> result = new ArrayList(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 int N = points.size(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 if (N == 0) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 return result; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 if (N == 1) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 Point2D p = points.get(0); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 // Only generate point if over water |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 if (waterLevel > p.getY()) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 result.add(new Line2D.Double( |
934
d0f3fea20f01
Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
933
diff
changeset
|
59 p.getX(), waterLevel, |
d0f3fea20f01
Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
933
diff
changeset
|
60 p.getX(), waterLevel)); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 return result; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 double minX = Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 double minY = Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 double maxX = -Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 double maxY = -Double.MAX_VALUE; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 // 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
|
71 // the original index order is preserved. |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
72 for (Point2D p: points) { |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 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
|
74 if (x < minX) minX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 if (x > maxX) maxX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 if (y < minY) minY = y; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 if (y > maxY) maxY = y; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 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
|
81 log.debug("complete over water"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 return result; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 if (waterLevel > maxY) { // water floods profile |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
86 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
|
87 result.add(new Line2D.Double(minX, waterLevel, maxX, waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 return result; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 } |
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 Mode mode = Mode.UNDEF; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
93 double startX = minX; |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 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
|
96 Point2D p1 = points.get(i-1); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
97 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
|
98 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
99 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
|
100 // completely under water |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
101 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
102 log.debug("under water: " + p1 + " " + p2); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
103 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
104 if (mode != Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
105 startX = p1.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
106 mode = Mode.WET; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
107 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 continue; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
111 if (p1.getY() > waterLevel && p2.getY() > waterLevel) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
112 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
113 log.debug("over water: " + p1 + " " + p2); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
114 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 // completely over water |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 if (mode == Mode.WET) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
117 log.debug("over/wet"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 p1.getX(), waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 continue; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 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
|
127 // vertical line |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 switch (mode) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 case WET: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
130 log.debug("vertical/wet"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 p1.getX(), waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 case DRY: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
137 log.debug("vertical/dry"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 startX = p2.getX(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 default: // UNDEF |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
142 log.debug("vertical/undef"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 if (p2.getY() < waterLevel) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 startX = p2.getX(); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 else { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 continue; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
154 // check if waterlevel directly hits the vertices; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
155 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
156 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
|
157 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
|
158 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
159 if (p1W || p2W) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
160 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
161 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
|
162 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
163 if (p1W && p2W) { // parallel to water -> dry |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
164 log.debug("water hits both vertices"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
165 if (mode == Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
166 result.add(new Line2D.Double( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
167 startX, waterLevel, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
168 p1.getX(), waterLevel)); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
169 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
170 mode = Mode.DRY; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
171 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
172 else if (p1W) { // p1 == waterlevel |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
173 log.debug("water hits first vertex"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
174 if (p2.getY() > waterLevel) { // --> dry |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
175 if (mode == Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
176 result.add(new Line2D.Double( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
177 startX, waterLevel, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
178 p1.getX(), waterLevel)); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
179 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
180 mode = Mode.DRY; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
181 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
182 else { // --> wet |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
183 if (mode != Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
184 startX = p1.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
185 mode = Mode.WET; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
186 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
187 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
188 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
189 else { // p2 == waterlevel |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
190 log.debug("water hits second vertex"); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
191 if (p1.getY() > waterLevel) { // --> wet |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
192 if (mode != Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
193 startX = p2.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
194 mode = Mode.WET; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
195 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
196 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
197 else { // --> dry |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
198 if (mode == Mode.WET) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
199 result.add(new Line2D.Double( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
200 startX, waterLevel, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
201 p2.getX(), waterLevel)); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
202 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
203 mode = Mode.DRY; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
204 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
205 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
206 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
207 log.debug("mode is now: " + mode); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
208 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
209 continue; |
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 |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 // intersection case |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 double x = Linear.linear( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 waterLevel, |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
215 p1.getY(), p2.getY(), |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
216 p1.getX(), p2.getX()); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
217 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
218 if (debug) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
219 log.debug("intersection p1:" + p1); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
220 log.debug("intersection p2:" + p2); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
221 log.debug("intersection at x: " + x); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
222 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 switch (mode) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 case WET: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
226 log.debug("intersect/wet"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
229 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 x, waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
231 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
232 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
233 case DRY: |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
234 log.debug("intersect/dry"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
235 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
236 startX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 break; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 default: // UNDEF |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
240 log.debug("intersect/undef"); |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 if (p2.getY() > waterLevel) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
934
diff
changeset
|
242 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
|
243 mode = Mode.DRY; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 p1.getX(), waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 x, waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 else { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 mode = Mode.WET; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 startX = x; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 } // switch mode |
934
d0f3fea20f01
Fixed corner case.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
933
diff
changeset
|
253 } // 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
|
254 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 if (mode == Mode.WET) { |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 result.add(new Line2D.Double( |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 startX, waterLevel, |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 maxX, waterLevel)); |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 return result; |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 } |
1651
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
263 |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
264 public static double [][] createWaterLines( |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
265 List<Point2D> points, |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
266 double waterlevel |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
267 ) { |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
268 List<Line2D> lines = fillWater(points, waterlevel); |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
269 |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
270 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
|
271 TDoubleArrayList lys = new TDoubleArrayList(); |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
272 |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
273 for (Iterator<Line2D> iter = lines.iterator(); iter.hasNext();) { |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
274 Line2D l = iter.next(); |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
275 Point2D p1 = l.getP1(); |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
276 Point2D p2 = l.getP2(); |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 lys.add(p2.getY()); |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
281 if (iter.hasNext()) { |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
282 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
|
283 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
|
284 } |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
285 } |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
286 |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
287 return new double [][] { lxs.toNativeArray(), lys.toNativeArray() }; |
a7def20539fb
flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
938
diff
changeset
|
288 } |
933
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
289 } |
34136924661b
Generate water level lines for given cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
290 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |