comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/DistanceCalculator.java @ 806:2cea76f1112e

Added Javadoc in utils package. gnv-artifacts/trunk@888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Apr 2010 13:10:39 +0000
parents c4156275c1e1
children a645bd23c1c8
comparison
equal deleted inserted replaced
805:bb7afd783321 806:2cea76f1112e
4 import com.vividsolutions.jts.geom.Point; 4 import com.vividsolutions.jts.geom.Point;
5 5
6 import java.util.List; 6 import java.util.List;
7 7
8 /** 8 /**
9 * A helper class to calculate distances between points and coordinates.
10 *
9 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> 11 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
10 * 12 *
11 */ 13 */
12 public class DistanceCalculator { 14 public class DistanceCalculator {
13 15
19 * Constructor 21 * Constructor
20 */ 22 */
21 public DistanceCalculator() { 23 public DistanceCalculator() {
22 } 24 }
23 25
26
27 /**
28 * Calculates the distance between two points.
29 *
30 * @param p1 First point.
31 * @param p2 Second point.
32 * @return the distance.
33 */
24 public static double calculateDistance(Point p1, Point p2){ 34 public static double calculateDistance(Point p1, Point p2){
25 return calculateDistance(p1.getCoordinate(), p2.getCoordinate()); 35 return calculateDistance(p1.getCoordinate(), p2.getCoordinate());
26 } 36 }
27 37
38
39 /**
40 * Calculates the distance between two coordinates.
41 *
42 * @param p1 First coordinate.
43 * @param p2 Second coordinate.
44 * @return the distance.
45 */
28 public static double calculateDistance(Coordinate p1, Coordinate p2){ 46 public static double calculateDistance(Coordinate p1, Coordinate p2){
29 double resultValue = 0.0; 47 double resultValue = 0.0;
30 48
31 double b1 = p1.y; 49 double b1 = p1.y;
32 double b2 = p2.y; 50 double b2 = p2.y;
64 (Math.sin(G) * Math.sin(G)))); 82 (Math.sin(G) * Math.sin(G))));
65 83
66 return resultValue; 84 return resultValue;
67 } 85 }
68 86
87 /**
88 * Calculates the length of a path specified by coordinates in <i>path</i>.
89 *
90 * @param path A list of coordinates.
91 * @return the length of the given path.
92 */
69 public static final double calculateDistance(List<Coordinate> path) { 93 public static final double calculateDistance(List<Coordinate> path) {
70 int N = path.size(); 94 int N = path.size();
71 if (N < 2) { 95 if (N < 2) {
72 return 0d; 96 return 0d;
73 } 97 }
77 } 101 }
78 return sum; 102 return sum;
79 } 103 }
80 104
81 } 105 }
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org