annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearMetrics.java @ 745:d194939ecbaf

Improvement: Values of Type Geometry which are Points will be prepared as Regions for DB-Query. gnv-artifacts/trunk@785 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 16 Mar 2010 12:53:37 +0000
parents aec85d00d82c
children 6cff63d0c434
rev   line source
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.math;
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
3 import com.vividsolutions.jts.geom.Coordinate;
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 /**
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 * @author Sascha L. Teichmann
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 */
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 public final class LinearMetrics
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 implements Metrics
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 {
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 public static final Metrics INSTANCE =
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 new LinearMetrics();
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 public static final class LinearInterpolator
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 implements Interpolator
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 {
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 private double mx;
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 private double bx;
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 private double my;
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 private double by;
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
22 public LinearInterpolator(Coordinate p1, Coordinate p2) {
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 /*
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 I) p1.x = 0*m + bx
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 II) p2.x = 1*m + bx
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 bx = p1.x
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 p2.x = m + p1.x
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 mx = p2.x - p1.x
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 */
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
35 bx = p1.x;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
36 mx = p2.x - bx;
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
38 by = p1.y;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
39 my = p2.y - by;
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 }
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
42 public void interpolate(double t, Coordinate v) {
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
43 v.x = t*mx + bx;
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
44 v.y = t*my + by;
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 } // class LinearInterpolator
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 private LinearMetrics() {
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
51 public double distance(Coordinate p1, Coordinate p2) {
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 return p1.distance(p2);
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54
361
aec85d00d82c Added code to do 2D interpolations along a digitied track on the map.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 360
diff changeset
55 public Interpolator getInterpolator(Coordinate p1, Coordinate p2) {
360
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 return new LinearInterpolator(p1, p2);
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 }
ee760729f6b8 Added mapping from linear diagram space to 2D map coordinates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org