Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java @ 521:1bf058f1a2d1
Generate seabed polygon to "Profilschnitte".
gnv-artifacts/trunk@615 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 24 Jan 2010 20:24:03 +0000 |
parents | 4e347624ee7c |
children | 44415ae01ddb |
comparison
equal
deleted
inserted
replaced
520:a8f6ca59b26e | 521:1bf058f1a2d1 |
---|---|
31 public static final double EPS = 1e-6d; | 31 public static final double EPS = 1e-6d; |
32 | 32 |
33 protected int width; | 33 protected int width; |
34 protected int height; | 34 protected int height; |
35 | 35 |
36 protected double cellWidth; | |
37 protected double cellHeight; | |
38 | |
36 protected double [] raster; | 39 protected double [] raster; |
37 protected double [] depths; | 40 protected double [] depths; |
38 | 41 |
39 public Interpolation3D() { | 42 public Interpolation3D() { |
40 this(DEFAULT_WIDTH, DEFAULT_HEIGHT); | 43 this(DEFAULT_WIDTH, DEFAULT_HEIGHT); |
53 return height; | 56 return height; |
54 } | 57 } |
55 | 58 |
56 public int getWidth() { | 59 public int getWidth() { |
57 return width; | 60 return width; |
61 } | |
62 | |
63 public double getCellWidth() { | |
64 return cellWidth; | |
65 } | |
66 | |
67 public double getCellHeight() { | |
68 return cellHeight; | |
58 } | 69 } |
59 | 70 |
60 public double [] getRaster() { | 71 public double [] getRaster() { |
61 return raster; | 72 return raster; |
62 } | 73 } |
158 GridCell.CellFinder finder = new GridCell.CellFinder(); | 169 GridCell.CellFinder finder = new GridCell.CellFinder(); |
159 | 170 |
160 i = 0; | 171 i = 0; |
161 for (double p = cellWidth*0.5; i < depths.length; ++i, p += cellWidth) { | 172 for (double p = cellWidth*0.5; i < depths.length; ++i, p += cellWidth) { |
162 double depth = depths[i]; | 173 double depth = depths[i]; |
163 if (Double.isNaN(depth)) { | 174 if (Double.isNaN(depth) || depth >= 0d) { |
164 continue; | 175 continue; |
165 } | 176 } |
166 linearToMap.locate(p, center); | 177 linearToMap.locate(p, center); |
167 | 178 |
168 queryBuffer.init( | 179 queryBuffer.init( |
194 center.x); | 205 center.x); |
195 double y2 = Interpolation2D.interpolate( | 206 double y2 = Interpolation2D.interpolate( |
196 n2.x, n2.y, | 207 n2.x, n2.y, |
197 n3.x, n3.y, | 208 n3.x, n3.y, |
198 center.x); | 209 center.x); |
199 int j = i; | 210 double z = -cellHeight*0.5; |
200 for (double z = -cellHeight*0.5; | 211 for (int j = i; |
201 j < raster.length && z >= depth; | 212 j < raster.length && z >= depth; |
202 z -= cellHeight, j += width) { | 213 z -= cellHeight, j += width) { |
203 | 214 |
204 double v0 = n0.value(z); | 215 double v0 = n0.value(z); |
205 double v1 = n1.value(z); | 216 double v1 = n1.value(z); |
218 y1, z1, | 229 y1, z1, |
219 y2, z2, | 230 y2, z2, |
220 center.y); | 231 center.y); |
221 raster[j] = value; | 232 raster[j] = value; |
222 } | 233 } |
234 // XXX: Adjusted depth to create no gap | |
235 // between last value and ground. | |
236 depths[i] = z+0.5d*cellHeight; | |
223 } // down the x/y column | 237 } // down the x/y column |
224 } // all along the track | 238 } // all along the track |
225 | 239 |
226 this.depths = depths; | 240 this.depths = depths; |
227 this.raster = raster; | 241 this.raster = raster; |
242 this.cellWidth = cellWidth; | |
243 this.cellHeight = cellHeight; | |
228 | 244 |
229 return true; | 245 return true; |
230 } | 246 } |
231 } | 247 } |
232 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 248 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |