Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearToMap.java @ 824:7e5995c47125
Added more Javadoc.
gnv-artifacts/trunk@913 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 13 Apr 2010 08:49:42 +0000 |
parents | bb7afd783321 |
children | f953c9a559d8 |
rev | line source |
---|---|
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.math; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
3 import com.vividsolutions.jts.geom.Coordinate; |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
5 import java.util.Iterator; |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.util.List; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.util.NoSuchElementException; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 /** |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
10 * Given a list of line segments instances of this class are able |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
11 * to span a metric system between a start and an end point |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
12 * represented as scalar values to 2D coordinate on the |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
13 * course of the segments. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
14 * |
798
6cff63d0c434
Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
15 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 */ |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public class LinearToMap |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 { |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
19 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
20 * Represents a segment of the line string. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
21 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 public static final class Range { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 private Range next; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 private double from; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 private double to; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 private double b; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
29 private Coordinate p1; |
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
30 private Coordinate p2; |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 private Interpolator interpolator; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
34 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
35 * Default constructor. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
36 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public Range() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
40 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
41 * Constructor to create a segment that maps |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
42 * a coordinate pair to two scalar values. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
43 * Interpolations inside this segment are done with |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
44 * a given interpolator. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
45 * @param from Start point of the segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
46 * @param to End point of the segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
47 * @param interpolator The interpolator. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
48 * @param p1 The scalar value mapped to the start point. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
49 * @param p2 The scalar value mappend to the end point. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
50 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 public Range( |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
361
diff
changeset
|
52 double from, |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 double to, |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 Interpolator interpolator, |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
55 Coordinate p1, |
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
56 Coordinate p2 |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 ) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 this.from = from; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 this.to = to; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 this.interpolator = interpolator; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 this.p1 = p1; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 this.p2 = p2; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 b = from == to |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 ? 0d |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 : 1.0d/(to - from); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
69 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
70 * Interpolated a coordinate on the segment given a scalar value |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
71 * between the start and end point of the range. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
72 * @param x The scalar value. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
73 * @param v The interpolated value is stored here. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
74 */ |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
75 public void eval(double x, Coordinate v) { |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 interpolator.interpolate((x - from)*b, v); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
79 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
80 * Checks if a given value is inside this segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
81 * @param x The value to test |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
82 * @return true if inside, else false. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
83 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 public boolean inside(double x) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 return x >= from && x <= to; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
88 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
89 * Returns the start point of this segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
90 * @return The start point. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
91 */ |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
92 public Coordinate startPoint() { |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 return p1; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
96 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
97 * Return the end point of this segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
98 * @return The end point. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
99 */ |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
100 public Coordinate endPoint() { |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 return p2; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 } // class Range |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
105 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
106 * The head of the internal range list. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
107 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 protected Range head; |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
109 |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
110 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
111 * The last accessed segment. Used to accelerate |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
112 * the access of the right segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
113 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 protected Range last; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
116 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
117 * Default constructor. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
118 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 public LinearToMap() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
122 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
123 * Constructor to create a LinearToMap that maps |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
124 * given scalar values to coordinates of a given |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
125 * list of line segments. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
126 * @param path The list of line segments. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
127 * @param from The start value mapped to the start point |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
128 * of the first line segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
129 * @param to The end value mapped to the end point of |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
130 * the last line segment. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
131 * @param metrics The metric used to span the 2D space. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
132 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 public LinearToMap( |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
361
diff
changeset
|
134 List<? extends Coordinate> path, |
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
361
diff
changeset
|
135 double from, |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
136 double to, |
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
137 Metrics metrics |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 ) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 double diagramLength = Math.abs(to - from); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 double worldLength = length(path, metrics); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 double rangeStart = from; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 Range last = null; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 for (int i = 1, N = path.size(); i < N; ++i) { |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
148 Coordinate p1 = path.get(i-1); |
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
149 Coordinate p2 = path.get(i); |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 double segmentLength = metrics.distance(p1, p2); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 double relativeLength = segmentLength / worldLength; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 double rangeLength = diagramLength * relativeLength; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 double rangeEnd = rangeStart + rangeLength; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 Range range = new Range( |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 rangeStart, rangeEnd, |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 metrics.getInterpolator(p1, p2), |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 p1, p2); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 if (last == null) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 last = head = range; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 else { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 last.next = range; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 last = range; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 rangeStart = rangeEnd; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
174 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
175 * Returns a segment on which a given value is found. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
176 * @param diagramX The value. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
177 * @return The segment or null if no matching segment was found. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
178 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 protected Range locateRange(double diagramX) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 if (last != null && last.inside(diagramX)) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 return last; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 Range current = head; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 while (current != null) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 if (current.inside(diagramX)) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 return last = current; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 current = current.next; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 return null; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
196 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
197 * Interpolates a coordinate at a given scalar position. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
198 * @param diagramX The scalar position. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
199 * @param v The interpolated coordinate is stored here. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
200 * @return true if the scalar position is inside the |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
201 * spanned range of the line string, else false. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
202 */ |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
203 public boolean locate(double diagramX, Coordinate v) { |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 Range range = locateRange(diagramX); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 if (range == null) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 return false; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 range.eval(diagramX, v); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 return true; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
212 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
213 * Returns the length of a given line string using |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
214 * a given metric. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
215 * @param path The line string. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
216 * @param metrics The used metric. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
217 * @return The length of the line string. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
218 */ |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
219 public static double length( |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
361
diff
changeset
|
220 List<? extends Coordinate> path, |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
221 Metrics metrics |
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
222 ) { |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 double sum = 0d; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 for (int i = path.size()-1; i >= 1; --i) { |
361
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
225 Coordinate p1 = path.get(i); |
aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
360
diff
changeset
|
226 Coordinate p2 = path.get(i-1); |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 sum += metrics.distance(p1, p2); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
229 return sum; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
231 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
232 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
233 * Return the number of segments in this map. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
234 * @return the number of segments. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
235 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
236 public int numRanges() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 int count = 0; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 Range current = head; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 while (current != null) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
240 ++count; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 current = current.next; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 return count; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 |
805
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
246 /** |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
247 * Returns an iterator over all segments of this map. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
248 * @return The iterator. |
bb7afd783321
Removed trailing whitespace. Added more javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
798
diff
changeset
|
249 */ |
360
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 public Iterator ranges() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 return new Iterator() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
253 Range current = head; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 public boolean hasNext() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 return current != null; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 public Object next() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 if (!hasNext()) { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 throw new NoSuchElementException(); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 Range x = current; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 current = current.next; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
265 return x; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
266 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
267 |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
268 public void remove() { |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
269 throw new UnsupportedOperationException(); |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
270 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
271 }; |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
272 } |
ee760729f6b8
Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
273 } |
798
6cff63d0c434
Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
274 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |