annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/Point2d.java @ 1043:d955571cdf2a

Added queries for Meshes using Vectorvalues for TimeSeries. gnv-artifacts/trunk@1115 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 21 May 2010 08:28:49 +0000
parents 6cff63d0c434
children f953c9a559d8
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
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
3 import com.vividsolutions.jts.geom.Coordinate;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
4 import com.vividsolutions.jts.geom.Envelope;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
5
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
6 import java.util.Comparator;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
8 import org.apache.log4j.Logger;
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
9
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 /**
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
11 * Point which besides the x, y, z coodinates has an index i, j pair
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
12 * to model neighborhood.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
13 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
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 class Point2d
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 extends 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
17 {
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
18 private static Logger log = Logger.getLogger(Point2d.class);
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
19
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
20 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
21 * Numerical tolerance epsilon: {@value}
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
22 */
365
f66088a43ecc Added horizontal crossprofile charts to chart pallet. Fixed some bugs before interpolation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 361
diff changeset
23 public static final double EPSILON = 1e-3d;
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
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
25 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
26 * Compares two Point2ds by their x coordinates
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
27 */
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
28 public static final Comparator X_COMPARATOR = new Comparator() {
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 public int compare(Object a, Object 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
30 double xa = ((Coordinate)a).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
31 double xb = ((Coordinate)b).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
32 if (xa < xb) return -1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 if (xa > xb) return +1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 return 0;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 };
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
38 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
39 * Compares two Point2ds by their y coordinates.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
40 */
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
41 public static final Comparator Y_COMPARATOR = new Comparator() {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 public int compare(Object a, Object 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
43 double ya = ((Coordinate)a).y;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 double yb = ((Coordinate)b).y;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 if (ya < yb) return -1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 if (ya > yb) return +1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 return 0;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
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 };
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
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
51 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
52 * The i index of this Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
53 */
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
54 public int i;
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
55 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
56 * The j index of this Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
57 */
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
58 public int j;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
60 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
61 * Default constructor.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
62 */
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
63 public Point2d() {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
66 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
67 * Constructor setting x and y coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
68 * @param x The x coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
69 * @param y The y coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
70 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
71 public Point2d(double x, double y) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
72 super(x, y);
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
73 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
74
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
75 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
76 * Constructor setting x, y and i, j.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
77 * @param x The x coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
78 * @param y The y coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
79 * @param i The i index.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
80 * @param j The j index.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
81 */
431
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 365
diff changeset
82 public Point2d(double x, double y, int i, int j) {
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 365
diff changeset
83 super(x, y);
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 365
diff changeset
84 this.i = i;
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 365
diff changeset
85 this.j = j;
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 365
diff changeset
86 }
422275fc9927 Refactored the XYColumn and Point2d code a bit to be more reusable in 3D.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 365
diff changeset
87
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
88 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
89 * Constructor setting x, y, z and i, j.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
90 * @param x The x coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
91 * @param y The y coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
92 * @param z The z coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
93 * @param i The i index.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
94 * @param j The j index.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
95 */
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
96 public Point2d(double x, double y, double z, int i, int j) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 super(x, y, z);
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 this.i = i;
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 this.j = j;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
102 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
103 * Calculates the L1 distance to another Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
104 * @param other The other Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
105 * @return The L1 distance.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
106 */
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
107 public double L1(Point2d other) {
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
108 return L1Comparator.L1(this, other);
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
109 }
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
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
111 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
112 * Creates an envelope around this Point2d with
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
113 * the numerical tolerance of {@link #EPSILON}.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
114 * @return The envelope.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
115 */
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
116 public Envelope 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
117 return envelope(EPSILON);
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
120 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
121 *Creates an envelope around this Point2d with
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
122 * a given tolerance.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
123 * @param epsilon The tolerance in all directions.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
124 * @return The envelope.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
125 */
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 public Envelope envelope(double epsilon) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 return new 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
128 x-epsilon, x+epsilon,
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 y-epsilon, y+epsilon);
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
132 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
133 * Given this and another Point2d it looks if there is
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
134 * a gap between the in points in i index direction.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
135 * @param other The other Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
136 * @return true if there is is a gap, else false.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
137 */
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
138 public boolean hasIGap(Point2d other) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 return Math.abs(i - other.i) > 1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 }
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
142 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
143 * Given this and another Point2d it looks if there is
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
144 * a gap between the in points in j index direction.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
145 * @param other The other Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
146 * @return true if there is is a gap, else false.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
147 */
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
148 public boolean hasJGap(Point2d other) {
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 return Math.abs(j - other.j) > 1;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 }
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
151
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
152 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
153 * Given this and another Point2d a new Point2d is
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
154 * created via {@link #newPoint() }. The x, y coordinate
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
155 * of the new point is on the line of this and the other
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
156 * given point at a given scaling point.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
157 * @param t The scaling factor.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
158 * @param other The other point.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
159 * @return The new Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
160 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
161 public Point2d extrapolate(double t, Point2d other) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
162 if (other == null) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
163 return null;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
164 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
165 Point2d p = newPoint();
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
166 p.x = t*(other.x - x) + x;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
167 p.y = t*(other.y - y) + y;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
168 return p;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
169 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
170
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
171 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
172 * Creates a new Point2d or an instance of a subclass.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
173 * Override this in subclasses.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
174 * @return The new Point2d.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
175 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
176 public Point2d newPoint() {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
177 return new Point2d(0d, 0d);
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
178 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
179
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
180 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
181 * Creates a new Point2d or an instance of a subclass
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
182 * at a given coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
183 * Override this in subclasses.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
184 * @param x The x coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
185 * @param y The y coordinate.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
186 * @return The new point.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
187 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
188 public Point2d newPoint(double x, double y) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
189 return new Point2d(x, y);
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
190 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
191
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
192 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
193 * Sets the z value to the inverse distance weighting (IDW) value
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
194 * of the z values of a set of given points.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
195 * @param ps The points from wich the z values are taken
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
196 * to calculate the IDW.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
197 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
198 public void inverseDistanceWeighting(Point2d [] ps) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
199
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
200 double sum = 0d;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
201
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
202 double [] d = new double[ps.length];
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
203
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
204 for (int i = 0; i < ps.length; ++i) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
205 Point2d p = ps[i];
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
206 if (p != null) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
207 double di = distance(p);
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
208 if (di < 1e-5d) { z = p.z; return; }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
209 di = 1d/di;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
210 d[i] = di;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
211 sum += di;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
212 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
213 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
214
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
215 if (sum == 0d) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
216 return;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
217 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
218
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
219 double v = 0d;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
220
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
221 for (int i = 0; i < ps.length; ++i) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
222 Point2d p = ps[i];
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
223 if (p != null) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
224 v += p.z*d[i];
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
225 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
226 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
227 z = v/sum;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
228 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
229
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
230 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
231 * Creates a new point via {@link #newPoint() } with the
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
232 * x,y coordinates of the center of a given set of
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
233 * coordinates.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
234 * @param ps The points from which the x,y coordinates are
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
235 * taken to calculate the center.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
236 * @return The new center point.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
237 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
238 public static Point2d average(Point2d [] ps) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
239
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
240 Point2d p = null;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
241 int count = 0;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
242
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
243 for (int i = 0; i < ps.length; ++i) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
244 Point2d t = ps[i];
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
245 if (t != null) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
246 ++count;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
247 if (p == null) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
248 p = t.newPoint(t.x, t.y);
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
249 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
250 else {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
251 p.x += t.x;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
252 p.y += t.y;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
253 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
254 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
255 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
256
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
257 if (p != null) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
258 double s = 1d/count;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
259 p.x *= s;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
260 p.y *= s;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
261 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
262
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
263 return p;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
264 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
265
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
266 /**
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
267 * Checks if this Point2d is near to at least one point
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
268 * out of a given set of points. Near is defined by an
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
269 * euclidian distance small than {@link #EPSILON}.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
270 * @param ps The set of points to be tested.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
271 * @return true if this Point2d is near to one of the given
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
272 * points, else false.
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
273 */
593
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
274 public boolean near(Point2d [] ps) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
275
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
276 for (int i = 0; i < ps.length; ++i) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
277 Point2d p = ps[i];
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
278 if (p != null && distance(p) > EPSILON) {
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
279 return false;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
280 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
281 }
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
282
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
283 return true;
b248531fa20b Added experimental support for extrapolation in "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 431
diff changeset
284 }
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
285 }
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
286 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org