annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/AreaInterpolation.java @ 539:0f454d8067ca

Reordered items in Changes a bit. gnv-artifacts/trunk@641 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 27 Jan 2010 15:03:16 +0000
parents 44415ae01ddb
children b248531fa20b
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 /**
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
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,
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 XYDepth depth
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 ) {
482
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
54 boolean debug = log.isDebugEnabled();
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
55
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 if (points == null || points.isEmpty()) {
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
57 log.warn("no points to interpolate");
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
58 return false;
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
59 }
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
60
517
96a1e92e7ed2 If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
61 List<GridCell> cells = GridCell.pointsToGridCells(
528
44415ae01ddb Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 517
diff changeset
62 points,
44415ae01ddb Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 517
diff changeset
63 Interpolation2D.relevantArea(
44415ae01ddb Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 517
diff changeset
64 boundingBox,
44415ae01ddb Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 517
diff changeset
65 points));
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
66
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
67 if (cells.isEmpty()) {
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
68 log.warn("no cells to interpolate");
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 return false;
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71
495
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
72 int W = samples.width;
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
73 int H = samples.height;
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
74
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
75 double cellWidth = boundingBox.getWidth() / W;
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
76 double cellHeight = boundingBox.getHeight() / H;
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
77
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
78 STRtree spatialIndex = new STRtree();
495
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 for (GridCell cell: cells) {
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
81 spatialIndex.insert(cell.getEnvelope(), cell);
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 }
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83
482
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
84 if (debug) {
495
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
85 log.debug("width: " + boundingBox.getWidth());
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
86 log.debug("height: " + boundingBox.getHeight());
482
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
87 log.debug("sample width: " + W);
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
88 log.debug("sample height: " + H);
495
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
89 log.debug("cell width: " + cellWidth);
6e8364e766fa Generate JTS geometries of "Horizontalschnitte" correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
90 log.debug("cell height: " + cellHeight);
482
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
91 }
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
92
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
93 Envelope queryBuffer = new Envelope();
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
94 Coordinate center = new Coordinate();
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
95 GridCell.CellFinder finder = new GridCell.CellFinder();
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 double [] raster = new double[W*H];
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 Arrays.fill(raster, Double.NaN);
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
482
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
100 double minX = boundingBox.getMinX();
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
101 double minY = boundingBox.getMinY();
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
102
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
103 long startTime = System.currentTimeMillis();
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
104
517
96a1e92e7ed2 If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
105 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
106 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
107
482
64e65daa65e9 Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 479
diff changeset
108 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
109 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
110
96a1e92e7ed2 If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
111 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
112
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
113 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
114 center.x = x; center.y = y;
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
115 finder.prepare(center);
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
116 spatialIndex.query(queryBuffer, finder);
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
118 GridCell found = finder.found;
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
119
517
96a1e92e7ed2 If the number of data points to generate a "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
120 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
121 continue;
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 }
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
124 double z1 = Interpolation2D.interpolate(
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
125 found.p1.x, found.p1.z,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
126 found.p2.x, found.p2.z,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
127 center.x);
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
128 double z2 = Interpolation2D.interpolate(
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
129 found.p3.x, found.p3.z,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
130 found.p4.x, found.p4.z,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
131 center.x);
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
132 double y1 = Interpolation2D.interpolate(
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
133 found.p1.x, found.p1.y,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
134 found.p2.x, found.p2.y,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
135 center.x);
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
136 double y2 = Interpolation2D.interpolate(
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
137 found.p3.x, found.p3.y,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
138 found.p4.x, found.p4.y,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
139 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
140 raster[pos] = Interpolation2D.interpolate(
514
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
141 y1, z1,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
142 y2, z2,
d9d933e06875 Fixed gnv/issue153
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
143 center.y);
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 }
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 }
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
147 long stopTime = System.currentTimeMillis();
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
148
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
149 if (debug) {
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
150 log.debug("interpolation took: " + (stopTime - startTime)/1000f + " secs");
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
151 }
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
152
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 this.raster = raster;
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 this.width = W;
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 this.height = H;
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 return true;
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 }
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org