Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/AreaInterpolation.java @ 799:feeaf5aec552
ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
gnv-artifacts/trunk@881 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 06 Apr 2010 11:56:53 +0000 |
parents | c4156275c1e1 |
children | d766fe2d917a |
rev | line source |
---|---|
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.math; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import com.vividsolutions.jts.geom.Coordinate; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import com.vividsolutions.jts.geom.Envelope; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
6 import com.vividsolutions.jts.index.strtree.STRtree; |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
479
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
8 import java.awt.Dimension; |
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
9 |
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
10 import java.io.Serializable; |
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
11 |
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
12 import java.util.Arrays; |
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
13 import java.util.List; |
d47b478e662b
Cleaned up imports
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
474
diff
changeset
|
14 |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 /** |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
593
diff
changeset
|
18 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 */ |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 public class AreaInterpolation |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 implements Serializable |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 { |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 private static Logger log = Logger.getLogger(AreaInterpolation.class); |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 protected double [] raster; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 protected int width; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 protected int height; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 public AreaInterpolation() { |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 public int getWidth() { |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 return width; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public int getHeight() { |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 return height; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 public double [] getRaster() { |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 return raster; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
45 public static final double EPS = 1e-6d; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
46 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
47 |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 public boolean interpolate( |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 List<? extends Point2d> points, |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 Envelope boundingBox, |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 Dimension samples, |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
528
diff
changeset
|
52 XYDepth depth, |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
528
diff
changeset
|
53 int extrapolationRounds |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 ) { |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
55 boolean debug = log.isDebugEnabled(); |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
56 |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 if (points == null || points.isEmpty()) { |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
58 log.warn("no points to interpolate"); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
59 return false; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
60 } |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
61 |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
62 List<GridCell> cells = GridCell.pointsToGridCells( |
528
44415ae01ddb
Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
63 points, |
44415ae01ddb
Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
64 Interpolation2D.relevantArea( |
44415ae01ddb
Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
517
diff
changeset
|
65 boundingBox, |
593
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
528
diff
changeset
|
66 points), |
b248531fa20b
Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
528
diff
changeset
|
67 extrapolationRounds); |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
68 |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
69 if (cells.isEmpty()) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
70 log.warn("no cells to interpolate"); |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 return false; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
495
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
74 int W = samples.width; |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
75 int H = samples.height; |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
76 |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
77 double cellWidth = boundingBox.getWidth() / W; |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
78 double cellHeight = boundingBox.getHeight() / H; |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
79 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
80 STRtree spatialIndex = new STRtree(); |
495
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
81 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
82 for (GridCell cell: cells) { |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
83 spatialIndex.insert(cell.getEnvelope(), cell); |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
86 if (debug) { |
495
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
87 log.debug("width: " + boundingBox.getWidth()); |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
88 log.debug("height: " + boundingBox.getHeight()); |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
89 log.debug("sample width: " + W); |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
90 log.debug("sample height: " + H); |
495
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
91 log.debug("cell width: " + cellWidth); |
6e8364e766fa
Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
482
diff
changeset
|
92 log.debug("cell height: " + cellHeight); |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
93 } |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
94 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
95 Envelope queryBuffer = new Envelope(); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
96 Coordinate center = new Coordinate(); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
97 GridCell.CellFinder finder = new GridCell.CellFinder(); |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 double [] raster = new double[W*H]; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 Arrays.fill(raster, Double.NaN); |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
102 double minX = boundingBox.getMinX(); |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
103 double minY = boundingBox.getMinY(); |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
104 |
501
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
105 long startTime = System.currentTimeMillis(); |
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
106 |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
107 int pos = 0; |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
108 for (int j = 0; j < H; ++j) { |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
109 |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
110 double y = j*cellHeight + 0.5d*cellHeight + minY; |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
479
diff
changeset
|
111 double x = 0.5d*cellWidth + minX; |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
112 |
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
113 for (int end = pos + W; pos < end; ++pos, x += cellWidth) { |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
115 queryBuffer.init(x - EPS, x + EPS, y - EPS, y + EPS); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
116 center.x = x; center.y = y; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
117 finder.prepare(center); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
118 spatialIndex.query(queryBuffer, finder); |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
120 GridCell found = finder.found; |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
121 |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
122 if (found == null || depth.depth(center) > 0d) { |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 continue; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
126 double z1 = Interpolation2D.interpolate( |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
127 found.p1.x, found.p1.z, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
128 found.p2.x, found.p2.z, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
129 center.x); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
130 double z2 = Interpolation2D.interpolate( |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
131 found.p3.x, found.p3.z, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
132 found.p4.x, found.p4.z, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
133 center.x); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
134 double y1 = Interpolation2D.interpolate( |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
135 found.p1.x, found.p1.y, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
136 found.p2.x, found.p2.y, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
137 center.x); |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
138 double y2 = Interpolation2D.interpolate( |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
139 found.p3.x, found.p3.y, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
140 found.p4.x, found.p4.y, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
141 center.x); |
517
96a1e92e7ed2
If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
514
diff
changeset
|
142 raster[pos] = Interpolation2D.interpolate( |
514
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
143 y1, z1, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
144 y2, z2, |
d9d933e06875
Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
145 center.y); |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 |
501
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
149 long stopTime = System.currentTimeMillis(); |
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
150 |
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
151 if (debug) { |
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
152 log.debug("interpolation took: " + (stopTime - startTime)/1000f + " secs"); |
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
153 } |
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
154 |
474
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 this.raster = raster; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 this.width = W; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 this.height = H; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 return true; |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 } |
ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |