Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/AreaInterpolation.java @ 482:64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
gnv-artifacts/trunk@557 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 17 Jan 2010 21:26:21 +0000 |
parents | d47b478e662b |
children | 6e8364e766fa |
comparison
equal
deleted
inserted
replaced
481:20dde2b6f1b5 | 482:64e65daa65e9 |
---|---|
47 List<? extends Point2d> points, | 47 List<? extends Point2d> points, |
48 Envelope boundingBox, | 48 Envelope boundingBox, |
49 Dimension samples, | 49 Dimension samples, |
50 XYDepth depth | 50 XYDepth depth |
51 ) { | 51 ) { |
52 boolean debug = log.isDebugEnabled(); | |
53 | |
52 if (points == null || points.isEmpty()) { | 54 if (points == null || points.isEmpty()) { |
55 if (debug) { | |
56 log.debug("no points to interpolate"); | |
57 } | |
53 return false; | 58 return false; |
54 } | 59 } |
55 | 60 |
56 double [] buffer = Interpolation2D.calculateBuffer(points); | 61 double [] buffer = Interpolation2D.calculateBuffer(points); |
57 double dxMax = buffer[0]; | 62 double dxMax = buffer[0]; |
68 int H = samples.height; | 73 int H = samples.height; |
69 | 74 |
70 double cellWidth = boundingBox.getWidth() / W; | 75 double cellWidth = boundingBox.getWidth() / W; |
71 double cellHeight = boundingBox.getHeight() / H; | 76 double cellHeight = boundingBox.getHeight() / H; |
72 | 77 |
78 if (debug) { | |
79 log.debug("width: " + boundingBox.getWidth()); | |
80 log.debug("height: " + boundingBox.getHeight()); | |
81 log.debug("sample width: " + W); | |
82 log.debug("sample height: " + H); | |
83 log.debug("cell width: " + cellWidth); | |
84 log.debug("cell height: " + cellHeight); | |
85 log.debug("buffer x: " + dxMax); | |
86 log.debug("buffer y: " + dyMax); | |
87 } | |
88 | |
73 Envelope queryBuffer = new Envelope(); | 89 Envelope queryBuffer = new Envelope(); |
74 Point2d [] neighbors = new Point2d[4]; | 90 Point2d [] neighbors = new Point2d[4]; |
75 Coordinate center = new Coordinate(); | 91 Coordinate center = new Coordinate(); |
76 L1Comparator invL1 = new L1Comparator(center); | 92 L1Comparator invL1 = new L1Comparator(center); |
77 | 93 |
78 double [] raster = new double[W*H]; | 94 double [] raster = new double[W*H]; |
79 Arrays.fill(raster, Double.NaN); | 95 Arrays.fill(raster, Double.NaN); |
80 | 96 |
97 double minX = boundingBox.getMinX(); | |
98 double minY = boundingBox.getMinY(); | |
99 | |
81 int row = 0; | 100 int row = 0; |
82 for (int j = 0; j < H; ++j, row += W) { | 101 for (int j = 0; j < H; ++j, row += W) { |
83 double y = j*cellHeight + 0.5d*cellHeight; | 102 double y = j*cellHeight + 0.5d*cellHeight + minY; |
84 double x = 0.5d*cellWidth; | 103 double x = 0.5d*cellWidth + minX; |
85 for (int i = 0; i < W; ++i, x += cellWidth) { | 104 for (int i = 0; i < W; ++i, x += cellWidth) { |
86 queryBuffer.init( | 105 queryBuffer.init( |
87 x - dxMax, x + dxMax, | 106 x - dxMax, x + dxMax, |
88 y - dyMax, y + dyMax); | 107 y - dyMax, y + dyMax); |
89 | 108 |
90 List potential = spatialIndex.query(queryBuffer); | 109 List potential = spatialIndex.query(queryBuffer); |
91 | 110 |
92 if (potential.isEmpty()) { | 111 if (potential.size() < 4) { |
93 continue; | 112 continue; |
94 } | 113 } |
95 | 114 |
96 center.x = x; center.y = y; | 115 center.x = x; center.y = y; |
97 Collections.sort(potential, invL1); | 116 Collections.sort(potential, invL1); |