@@ -154,14 +154,11 @@ public static SortedSet<CoordinateDistance> calcOrderedCoordinateDistances(
154
154
* @param lngA longitude of coordinate a
155
155
* @param latB latitude of coordinate b
156
156
* @param lngB longitude of coordinate b
157
- * @return The distance between both coordinates in {@link
158
- * edu.ie3.util.quantities.PowerSystemUnits#KILOMETRE}
157
+ * @return The distance between both coordinates as a {@link Length}
159
158
*/
160
159
public static ComparableQuantity <Length > calcHaversine (
161
160
double latA , double lngA , double latB , double lngB ) {
162
161
163
- // average radius of the earth in km
164
- ComparableQuantity <Length > r = EARTH_RADIUS .to (KILOMETRE );
165
162
ComparableQuantity <Angle > dLat = Quantities .getQuantity (toRadians (latB - latA ), RADIAN );
166
163
ComparableQuantity <Angle > dLon = Quantities .getQuantity (toRadians (lngB - lngA ), RADIAN );
167
164
double a =
@@ -171,7 +168,7 @@ public static ComparableQuantity<Length> calcHaversine(
171
168
* sin (dLon .getValue ().doubleValue () / 2 )
172
169
* sin (dLon .getValue ().doubleValue () / 2 );
173
170
double c = 2 * atan2 (sqrt (a ), sqrt (1 - a ));
174
- return r .multiply (c );
171
+ return EARTH_RADIUS .multiply (c );
175
172
}
176
173
177
174
/**
@@ -207,7 +204,7 @@ public static ComparableQuantity<Length> totalLengthOfLineString(LineString line
207
204
* @return the length of the linestring as a quantity
208
205
*/
209
206
public static ComparableQuantity <Length > calcHaversine (LineString lineString ) {
210
- ComparableQuantity <Length > y = Quantities .getQuantity (0 , KILOMETRE );
207
+ ComparableQuantity <Length > y = Quantities .getQuantity (0 , METRE );
211
208
for (int i = 0 ; i < lineString .getNumPoints () - 1 ; i ++) {
212
209
y = y .add (calcHaversine (lineString .getCoordinateN (i ), lineString .getCoordinateN (i + 1 )));
213
210
}
0 commit comments