annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java @ 1116:2d393d79c097

Added author names. gnv-artifacts/trunk@1262 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 04 Nov 2010 21:46:58 +0000
parents f953c9a559d8
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 837
diff changeset
8
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.math;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import com.vividsolutions.jts.geom.Coordinate;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import com.vividsolutions.jts.geom.Envelope;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
14 import com.vividsolutions.jts.index.strtree.STRtree;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
15
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
16 import java.awt.Dimension;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
17
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
18 import java.io.Serializable;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
19
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
20 import java.util.Arrays;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
21 import java.util.List;
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 import org.apache.log4j.Logger;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
25 /**
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
26 * Interpolates parameter values along a given line string from surface
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
27 * to the sea ground to generate "Profilschnitte".
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
28 *
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: 778
diff changeset
29 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
30 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 public class Interpolation3D
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
32 implements Serializable
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 private static Logger log = Logger.getLogger(Interpolation3D.class);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
36 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
37 * The default width of the interpolation: {@value}
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
38 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 public static final int DEFAULT_WIDTH = 1024;
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
40
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
41 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
42 * The default height of the interpolation: {@value}
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
43 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 public static final int DEFAULT_HEIGHT = 768;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
46 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
47 * Epsilon for numerical stability.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
48 */
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
49 public static final double EPS = 1e-6d;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
50
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
51 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
52 * The width of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
53 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 protected int width;
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
55
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
56 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
57 * The height of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
58 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 protected int height;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
61 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
62 * The cell width of the interpolation in world units.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
63 */
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
64 protected double cellWidth;
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
65
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
66 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
67 * The cell height of the interpolation in world units.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
68 */
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
69 protected double cellHeight;
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
70
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
71 /**
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
72 * The coordinates of the interpolation.
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
73 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
74 protected Coordinate[] coordinates;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
75
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
76 /**
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
77 * The generated raster.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
78 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 protected double [] raster;
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
80
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
81 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
82 * The sea ground depth along the line string.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
83 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 protected double [] depths;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
86 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
87 * Default constructor.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
88 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 public Interpolation3D() {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 this(DEFAULT_WIDTH, DEFAULT_HEIGHT);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
93 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
94 * Constructor to create a Interpolation3D with a given size.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
95 * @param size The size of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
96 */
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
97 public Interpolation3D(Dimension size) {
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
98 this(size.width, size.height);
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
99 }
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
100
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
101 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
102 * Constructor to create a Interpolation3D with a given size.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
103 * @param width The width of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
104 * @param height the height of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
105 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 public Interpolation3D(int width, int height) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 this.width = width;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 this.height = height;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
111 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
112 * Returns the raster height of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
113 * @return The raster height of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
114 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 public int getHeight() {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 return height;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
119 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
120 * Returns the raster width of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
121 * @return The raster width of the interpolation.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
122 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 public int getWidth() {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 return width;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
127 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
128 * Returns the cell width of the interpolation in world units.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
129 * @return The cell width of the interpolation in world units.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
130 */
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
131 public double getCellWidth() {
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
132 return cellWidth;
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
133 }
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
134
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
135 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
136 * Returns the cell height of the interpolation in world units.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
137 * @return The cell height of the interpolation in world units.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
138 */
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
139 public double getCellHeight() {
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
140 return cellHeight;
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
141 }
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
142
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
143 /**
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
144 * Returns the coordinates used for the interpolation.
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
145 * @return the coordinates used for the interpolation.
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
146 */
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
147 public Coordinate[] getCoordinates() {
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
148 return coordinates;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
149 }
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
150
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
151 /**
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
152 * Returns the generated raster.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
153 * @return The generated raster.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
154 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 public double [] getRaster() {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 return raster;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
159 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
160 * Returns the depths along the line string path.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
161 * @return The depth along the line string path.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
162 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 public double [] getDepths() {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 return depths;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
167 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
168 * Returns the deepest depth along the line string path.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
169 * @return The deepest depth along the line string path.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
170 */
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
171 public double getMaxDepth() {
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
172 double maxDepth = Double.MAX_VALUE;
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
173 for (int i = depths!=null?depths.length-1:0; i >= 0; --i) {
446
f5a041000357 Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 445
diff changeset
174 double d = depths[i];
f5a041000357 Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 445
diff changeset
175 if (!Double.isNaN(d) && d < maxDepth) {
f5a041000357 Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 445
diff changeset
176 maxDepth = d;
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
177 }
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
178 }
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
179 return maxDepth;
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
180 }
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
181
808
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
182 /**
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
183 * Interpolates parameters along a given line string path from the surface
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
184 * to the sea ground.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
185 * @param path The line string path.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
186 * @param points The sample points.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
187 * @param from Start point in scalar terms of the line string.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
188 * @param to End point in scalar terms of the line string.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
189 * @param metrics The used metric.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
190 * @param xyDepth The callback to query the depth at a given point.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
191 * @return true if the interpolation succeeds, else false.
2e951160c43d Finished the javadoc of the math package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
192 */
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 public boolean interpolate(
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 List<? extends Coordinate> path,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 List<? extends XYColumn> points,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 double from,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 double to,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 Metrics metrics,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 XYDepth xyDepth
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 ) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201 boolean debug = log.isDebugEnabled();
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 int N = path.size();
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204 int M = points.size();
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 if (debug) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 log.debug("Size of path: " + N);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 log.debug("Size of points: " + M);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 if (M < 1 || N < 2) { // nothing to do
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 return false;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214
518
464e03bf786b Try to cull points from set of input points when generating "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 515
diff changeset
215 List<GridCell> cells = GridCell.pointsToGridCells(
528
44415ae01ddb Fixed issue gnv/issue159
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 521
diff changeset
216 points, Interpolation2D.relevantArea(path, points));
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
218 if (cells.isEmpty()) {
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
219 log.warn("no cells found");
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
220 return false;
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 // put into spatial index to speed up finding neighbors.
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
224 STRtree spatialIndex = new STRtree();
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
226 for (GridCell cell: cells) {
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
227 spatialIndex.insert(cell.getEnvelope(), cell);
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 LinearToMap linearToMap = new LinearToMap(
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231 path, from, to, metrics);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
232
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
233 double [] depths = new double[width];
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 Arrays.fill(depths, Double.NaN);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
236 Coordinate[] coordinates = new Coordinate[width];
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
237
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238 double cellWidth = (to - from)/width;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 double maxDepth = Double.MAX_VALUE;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
241
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242 int i = 0;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
243 Coordinate center = new Coordinate();
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244 for (double p = cellWidth*0.5; i < depths.length; ++i, p += cellWidth) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
245 if (linearToMap.locate(p, center)) {
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
246 coordinates[i] = (Coordinate) center.clone();
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 double depth = xyDepth.depth(center);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248 depths[i] = depth;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 if (depth < maxDepth) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 maxDepth = depth;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
252 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
253 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
254
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
255 if (maxDepth == Double.MAX_VALUE) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
256 log.warn("no depth found -> no interpolation");
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
257 return false;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
258 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
260 double cellHeight = Math.abs(maxDepth)/height;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 if (debug) {
445
f42ed4f10b79 Fixed some bugs and create "Profilschnitt" polygons via configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 434
diff changeset
263 log.debug("max depth found: " + maxDepth);
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 log.debug("cell size: " + cellWidth + " x " + cellHeight);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 double [] raster = new double[width*height];
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
268 Arrays.fill(raster, Double.NaN);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
269
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
270 Envelope queryBuffer = new Envelope();
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
271 GridCell.CellFinder finder = new GridCell.CellFinder();
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
272
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
273 i = 0;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
274 for (double p = cellWidth*0.5; i < depths.length; ++i, p += cellWidth) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 double depth = depths[i];
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
276 if (Double.isNaN(depth) || depth >= 0d) {
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
277 continue;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
278 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
279 linearToMap.locate(p, center);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
280
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
281 queryBuffer.init(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 528
diff changeset
282 center.x - EPS, center.x + EPS,
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
283 center.y - EPS, center.y + EPS);
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
284
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
285 finder.prepare(center);
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
286 spatialIndex.query(queryBuffer, finder);
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
287
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
288 GridCell found = finder.found;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
289
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
290 if (found == null) {
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
291 continue;
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
292 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
293
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
294 XYColumn n0 = (XYColumn)found.p1;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
295 XYColumn n1 = (XYColumn)found.p2;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
296 XYColumn n2 = (XYColumn)found.p3;
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
297 XYColumn n3 = (XYColumn)found.p4;
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
298
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
299 if (n0.prepare(xyDepth)
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
300 && n1.prepare(xyDepth)
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
301 && n2.prepare(xyDepth)
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
302 && n3.prepare(xyDepth)
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
303 ) {
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
304 double y1 = Interpolation2D.interpolate(
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
305 n0.x, n0.y,
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
306 n1.x, n1.y,
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
307 center.x);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
308 double y2 = Interpolation2D.interpolate(
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
309 n2.x, n2.y,
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
310 n3.x, n3.y,
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
311 center.x);
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
312 double z = -cellHeight*0.5;
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
313 for (int j = i;
453
537e663d6c0c vertical cross section: Fixed problem with running to max depth on every column in interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
314 j < raster.length && z >= depth;
537e663d6c0c vertical cross section: Fixed problem with running to max depth on every column in interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 446
diff changeset
315 z -= cellHeight, j += width) {
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
316
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
317 double v0 = n0.value(z);
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
318 double v1 = n1.value(z);
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
319 double v2 = n2.value(z);
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
320 double v3 = n3.value(z);
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
321
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
322 double z1 = Interpolation2D.interpolate(
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
323 n0.x, v0,
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
324 n1.x, v1,
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
325 center.x);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
326 double z2 = Interpolation2D.interpolate(
515
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
327 n2.x, v2,
234d9892e497 Fixed "Profilschnitte" for gnv/issue153.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
328 n3.x, v3,
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
329 center.x);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
330 double value = Interpolation2D.interpolate(
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331 y1, z1,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
332 y2, z2,
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
333 center.y);
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 raster[j] = value;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 528
diff changeset
336 // XXX: Adjusted depth to create no gap
521
1bf058f1a2d1 Generate seabed polygon to "Profilschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 519
diff changeset
337 // between last value and ground.
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 528
diff changeset
338 depths[i] = z+0.5d*cellHeight;
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339 } // down the x/y column
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 } // all along the track
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341
837
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
342 this.coordinates = coordinates;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
343 this.depths = depths;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
344 this.raster = raster;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
345 this.cellWidth = cellWidth;
43f3c0cd60f2 First implementation of an odv export of a 'Profilschnitt' (issue217).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 808
diff changeset
346 this.cellHeight = cellHeight;
434
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
348 return true;
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
349 }
0eed5749fd63 Implemented the raster interpolation for the 'Profilschnitt'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
350 }
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
351 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org