comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation2D.java @ 416:04a242c67fe6

Added support of gap detection in horizontalcrossprofile charts. gnv-artifacts/trunk@464 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 21 Dec 2009 13:49:49 +0000
parents 086e3af38b96
children 422275fc9927
comparison
equal deleted inserted replaced
375:b3ad3cb94855 416:04a242c67fe6
18 public final class Interpolation2D 18 public final class Interpolation2D
19 { 19 {
20 private static Logger log = Logger.getLogger(Interpolation2D.class); 20 private static Logger log = Logger.getLogger(Interpolation2D.class);
21 21
22 public interface Consumer { 22 public interface Consumer {
23 void interpolated(Coordinate point); 23 void interpolated(Coordinate point, boolean success);
24 } // interface Consumer 24 } // interface Consumer
25 25
26 private Interpolation2D() { 26 private Interpolation2D() {
27 } 27 }
28 28
36 Consumer consumer 36 Consumer consumer
37 ) { 37 ) {
38 int N = path.size(); 38 int N = path.size();
39 int M = points.size(); 39 int M = points.size();
40 40
41 log.debug("Size of path: " + N); 41 if (log.isDebugEnabled()) {
42 log.debug("Size of points: " + M); 42 log.debug("Size of path: " + N);
43 log.debug("Size of points: " + M);
44 }
43 45
44 if (M < 1 || N < 2) { // nothing to do 46 if (M < 1 || N < 2) { // nothing to do
45 return; 47 return;
46 } 48 }
47 49
68 dxMax = dx; 70 dxMax = dx;
69 } 71 }
70 } 72 }
71 } 73 }
72 74
73 dxMax = dxMax + 1e-5d; 75 dxMax += 1e-5d;
74 76
75 map.clear(); 77 map.clear();
76 78
77 for (int k = M-1; k >= 0; --k) { 79 for (int k = M-1; k >= 0; --k) {
78 Point2d p = points.get(k); 80 Point2d p = points.get(k);
95 dyMax = dy; 97 dyMax = dy;
96 } 98 }
97 } 99 }
98 } 100 }
99 101
100 dyMax = dyMax + 1e-5d; 102 dyMax += 1e-5d;
101 103
102 map = null; 104 map = null;
103 105
104 log.debug("buffer size: " + dxMax + " / " + dyMax); 106 if (log.isDebugEnabled()) {
107 log.debug("buffer size: " + dxMax + " / " + dyMax);
108 }
105 109
106 // put into spatial index to speed up finding neighbors. 110 // put into spatial index to speed up finding neighbors.
107 Quadtree spatialIndex = new Quadtree(); 111 Quadtree spatialIndex = new Quadtree();
108 112
109 for (int i = 0; i < M; ++i) { 113 for (int i = 0; i < M; ++i) {
185 center.x); 189 center.x);
186 center.z = interpolate( 190 center.z = interpolate(
187 y1, z1, 191 y1, z1,
188 y2, z2, 192 y2, z2,
189 center.y); 193 center.y);
190 consumer.interpolated(center); 194 consumer.interpolated(center, true);
191 ++interpolations; 195 ++interpolations;
192 } 196 }
193 else { 197 else {
198 consumer.interpolated(center, false);
194 ++missedInterpolations; 199 ++missedInterpolations;
195 } 200 }
196 } 201 }
197 202
198 log.debug("interpolations: " + interpolations + " / " + missedInterpolations); 203 if (log.isDebugEnabled()) {
204 log.debug("interpolations: " +
205 interpolations + " / " + missedInterpolations);
206 }
199 } 207 }
200 208
201 public static final double interpolate( 209 public static final double interpolate(
202 double x1, double y1, 210 double x1, double y1,
203 double x2, double y2, 211 double x2, double y2,

http://dive4elements.wald.intevation.org