annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation2D.java @ 525:0eba2f032e0d

Set serverRoundtripInterval to 5 seconds and serverInactiveInterval to 5 minutes. gnv-artifacts/trunk@620 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 25 Jan 2010 13:48:52 +0000
parents 4e347624ee7c
children 44415ae01ddb
rev   line source
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.math;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import com.vividsolutions.jts.geom.Coordinate;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import com.vividsolutions.jts.geom.Envelope;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
6 import com.vividsolutions.jts.index.strtree.STRtree;
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
7
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
8 import java.util.List;
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
9
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
10 import org.apache.log4j.Logger;
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
11
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 /**
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
13 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 */
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 public final class Interpolation2D
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 {
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
17 private static Logger log = Logger.getLogger(Interpolation2D.class);
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
18
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
19 public static final int CULL_POINT_THRESHOLD = Integer.getInteger(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
20 "gnv.interpolation2d.cull.point.threshold", 1000);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
21
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
22 public static final double EPS = 1e-6d;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
23
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 public interface Consumer {
416
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
25 void interpolated(Coordinate point, boolean success);
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 } // interface Consumer
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 private Interpolation2D() {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
31 public static Envelope pathBoundingBox(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
32 List<? extends Coordinate> path,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
33 double extra
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
34 ) {
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
35 int N = path.size();
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
36 Envelope area = new Envelope(path.get(N-1));
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
37
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
38 for (int i = N-2; i >= 0; --i) {
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
39 area.expandToInclude(path.get(i));
501
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
40 }
70adafe2b9d5 Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
41
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
42 area.expandBy(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
43 extra*area.getWidth(),
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
44 extra*area.getHeight());
431
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 416
diff changeset
45
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
46 return area;
431
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 416
diff changeset
47 }
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 416
diff changeset
48
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 public static void interpolate(
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 List<? extends Coordinate> path,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 List<? extends Point2d> points,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 double from,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 double to,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 int steps,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 Metrics metrics,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 Consumer consumer
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 ) {
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
58 boolean debug = log.isDebugEnabled();
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
59
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 int N = path.size();
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 int M = points.size();
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
63 if (debug) {
416
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
64 log.debug("Size of path: " + N);
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
65 log.debug("Size of points: " + M);
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
66 }
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
67
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 if (M < 1 || N < 2) { // nothing to do
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 return;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
71
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
72 Envelope relevantArea = M > CULL_POINT_THRESHOLD
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
73 ? pathBoundingBox(path, 0.05d)
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
74 : null;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
75
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
76 List<GridCell> cells = GridCell.pointsToGridCells(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
77 points, relevantArea);
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
78
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
79 if (cells.isEmpty()) {
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
80 log.warn("no cells found");
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
81 return;
416
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
82 }
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 // put into spatial index to speed up finding neighbors.
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
85 STRtree spatialIndex = new STRtree();
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
87 for (GridCell cell: cells) {
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
88 spatialIndex.insert(cell.getEnvelope(), cell);
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 LinearToMap linearToMap = new LinearToMap(
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 path, from, to, metrics);
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 double dP = (to - from)/steps;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
96 Coordinate center = new Coordinate();
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
97 Envelope queryBuffer = new Envelope();
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
98 GridCell.CellFinder finder = new GridCell.CellFinder();
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
100 int missedInterpolations = 0;
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
101 int interpolations = 0;
474
ab29e4ff2fda Added area interpolation needed for "Horizontalschnitt"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 445
diff changeset
102
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
103 for (double p = from; p <= to; p += dP) {
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 if (!linearToMap.locate(p, center)) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 continue;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 queryBuffer.init(
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
108 center.x - EPS, center.x + EPS,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
109 center.y - EPS, center.y + EPS);
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
111 finder.prepare(center);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
112 spatialIndex.query(queryBuffer, finder);
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
114 GridCell found = finder.found;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
115
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
116 if (found == null) {
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
117 consumer.interpolated(center, false);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
118 ++missedInterpolations;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
119 continue;
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
122 Point2d n0 = found.p1;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
123 Point2d n1 = found.p2;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
124 Point2d n2 = found.p3;
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
125 Point2d n3 = found.p4;
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126
519
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
127 double z1 = interpolate(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
128 n0.x, n0.z,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
129 n1.x, n1.z,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
130 center.x);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
131 double z2 = interpolate(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
132 n2.x, n2.z,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
133 n3.x, n3.z,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
134 center.x);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
135 double y1 = interpolate(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
136 n0.x, n0.y,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
137 n1.x, n1.y,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
138 center.x);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
139 double y2 = interpolate(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
140 n2.x, n2.y,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
141 n3.x, n3.y,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
142 center.x);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
143 center.z = interpolate(
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
144 y1, z1,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
145 y2, z2,
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
146 center.y);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
147 consumer.interpolated(center, true);
4e347624ee7c Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 514
diff changeset
148 ++interpolations;
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 }
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
150
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
151 if (debug) {
416
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
152 log.debug("interpolations: " +
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
153 interpolations + " / " + missedInterpolations);
04a242c67fe6 Added support of gap detection in horizontalcrossprofile charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 366
diff changeset
154 }
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 public static final double interpolate(
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 double x1, double y1,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 double x2, double y2,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 double x
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 ) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 if (x2 == x1) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 return (y1 + y2)*0.5d;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 double m = (y2-y1)/(x2-x1);
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 double b = y1 - m*x1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 return m*x + b;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org