Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java @ 808:2e951160c43d
Finished the javadoc of the math package.
gnv-artifacts/trunk@890 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 08 Apr 2010 16:35:02 +0000 |
parents | 6cff63d0c434 |
children | 43f3c0cd60f2 |
comparison
equal
deleted
inserted
replaced
807:a645bd23c1c8 | 808:2e951160c43d |
---|---|
13 import java.util.List; | 13 import java.util.List; |
14 | 14 |
15 import org.apache.log4j.Logger; | 15 import org.apache.log4j.Logger; |
16 | 16 |
17 /** | 17 /** |
18 * Interpolates parameter values along a given line string from surface | |
19 * to the sea ground to generate "Profilschnitte". | |
20 * | |
18 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | 21 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
19 */ | 22 */ |
20 public class Interpolation3D | 23 public class Interpolation3D |
21 implements Serializable | 24 implements Serializable |
22 { | 25 { |
23 private static Logger log = Logger.getLogger(Interpolation3D.class); | 26 private static Logger log = Logger.getLogger(Interpolation3D.class); |
24 | 27 |
28 /** | |
29 * The default width of the interpolation: {@value} | |
30 */ | |
25 public static final int DEFAULT_WIDTH = 1024; | 31 public static final int DEFAULT_WIDTH = 1024; |
32 | |
33 /** | |
34 * The default height of the interpolation: {@value} | |
35 */ | |
26 public static final int DEFAULT_HEIGHT = 768; | 36 public static final int DEFAULT_HEIGHT = 768; |
27 | 37 |
38 /** | |
39 * Epsilon for numerical stability. | |
40 */ | |
28 public static final double EPS = 1e-6d; | 41 public static final double EPS = 1e-6d; |
29 | 42 |
43 /** | |
44 * The width of the interpolation. | |
45 */ | |
30 protected int width; | 46 protected int width; |
47 | |
48 /** | |
49 * The height of the interpolation. | |
50 */ | |
31 protected int height; | 51 protected int height; |
32 | 52 |
53 /** | |
54 * The cell width of the interpolation in world units. | |
55 */ | |
33 protected double cellWidth; | 56 protected double cellWidth; |
57 | |
58 /** | |
59 * The cell height of the interpolation in world units. | |
60 */ | |
34 protected double cellHeight; | 61 protected double cellHeight; |
35 | 62 |
63 /** | |
64 * The generated raster. | |
65 */ | |
36 protected double [] raster; | 66 protected double [] raster; |
67 | |
68 /** | |
69 * The sea ground depth along the line string. | |
70 */ | |
37 protected double [] depths; | 71 protected double [] depths; |
38 | 72 |
73 /** | |
74 * Default constructor. | |
75 */ | |
39 public Interpolation3D() { | 76 public Interpolation3D() { |
40 this(DEFAULT_WIDTH, DEFAULT_HEIGHT); | 77 this(DEFAULT_WIDTH, DEFAULT_HEIGHT); |
41 } | 78 } |
42 | 79 |
80 /** | |
81 * Constructor to create a Interpolation3D with a given size. | |
82 * @param size The size of the interpolation. | |
83 */ | |
43 public Interpolation3D(Dimension size) { | 84 public Interpolation3D(Dimension size) { |
44 this(size.width, size.height); | 85 this(size.width, size.height); |
45 } | 86 } |
46 | 87 |
88 /** | |
89 * Constructor to create a Interpolation3D with a given size. | |
90 * @param width The width of the interpolation. | |
91 * @param height the height of the interpolation. | |
92 */ | |
47 public Interpolation3D(int width, int height) { | 93 public Interpolation3D(int width, int height) { |
48 this.width = width; | 94 this.width = width; |
49 this.height = height; | 95 this.height = height; |
50 } | 96 } |
51 | 97 |
98 /** | |
99 * Returns the raster height of the interpolation. | |
100 * @return The raster height of the interpolation. | |
101 */ | |
52 public int getHeight() { | 102 public int getHeight() { |
53 return height; | 103 return height; |
54 } | 104 } |
55 | 105 |
106 /** | |
107 * Returns the raster width of the interpolation. | |
108 * @return The raster width of the interpolation. | |
109 */ | |
56 public int getWidth() { | 110 public int getWidth() { |
57 return width; | 111 return width; |
58 } | 112 } |
59 | 113 |
114 /** | |
115 * Returns the cell width of the interpolation in world units. | |
116 * @return The cell width of the interpolation in world units. | |
117 */ | |
60 public double getCellWidth() { | 118 public double getCellWidth() { |
61 return cellWidth; | 119 return cellWidth; |
62 } | 120 } |
63 | 121 |
122 /** | |
123 * Returns the cell height of the interpolation in world units. | |
124 * @return The cell height of the interpolation in world units. | |
125 */ | |
64 public double getCellHeight() { | 126 public double getCellHeight() { |
65 return cellHeight; | 127 return cellHeight; |
66 } | 128 } |
67 | 129 |
130 /** | |
131 * Returns the generated raster. | |
132 * @return The generated raster. | |
133 */ | |
68 public double [] getRaster() { | 134 public double [] getRaster() { |
69 return raster; | 135 return raster; |
70 } | 136 } |
71 | 137 |
138 /** | |
139 * Returns the depths along the line string path. | |
140 * @return The depth along the line string path. | |
141 */ | |
72 public double [] getDepths() { | 142 public double [] getDepths() { |
73 return depths; | 143 return depths; |
74 } | 144 } |
75 | 145 |
146 /** | |
147 * Returns the deepest depth along the line string path. | |
148 * @return The deepest depth along the line string path. | |
149 */ | |
76 public double getMaxDepth() { | 150 public double getMaxDepth() { |
77 double maxDepth = Double.MAX_VALUE; | 151 double maxDepth = Double.MAX_VALUE; |
78 for (int i = depths!=null?depths.length-1:0; i >= 0; --i) { | 152 for (int i = depths!=null?depths.length-1:0; i >= 0; --i) { |
79 double d = depths[i]; | 153 double d = depths[i]; |
80 if (!Double.isNaN(d) && d < maxDepth) { | 154 if (!Double.isNaN(d) && d < maxDepth) { |
82 } | 156 } |
83 } | 157 } |
84 return maxDepth; | 158 return maxDepth; |
85 } | 159 } |
86 | 160 |
161 /** | |
162 * Interpolates parameters along a given line string path from the surface | |
163 * to the sea ground. | |
164 * @param path The line string path. | |
165 * @param points The sample points. | |
166 * @param from Start point in scalar terms of the line string. | |
167 * @param to End point in scalar terms of the line string. | |
168 * @param metrics The used metric. | |
169 * @param xyDepth The callback to query the depth at a given point. | |
170 * @return true if the interpolation succeeds, else false. | |
171 */ | |
87 public boolean interpolate( | 172 public boolean interpolate( |
88 List<? extends Coordinate> path, | 173 List<? extends Coordinate> path, |
89 List<? extends XYColumn> points, | 174 List<? extends XYColumn> points, |
90 double from, | 175 double from, |
91 double to, | 176 double to, |