@@ -154,14 +154,11 @@ public static SortedSet<CoordinateDistance> calcOrderedCoordinateDistances(
154154 * @param lngA longitude of coordinate a
155155 * @param latB latitude of coordinate b
156156 * @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}
159158 */
160159 public static ComparableQuantity <Length > calcHaversine (
161160 double latA , double lngA , double latB , double lngB ) {
162161
163- // average radius of the earth in km
164- ComparableQuantity <Length > r = EARTH_RADIUS .to (KILOMETRE );
165162 ComparableQuantity <Angle > dLat = Quantities .getQuantity (toRadians (latB - latA ), RADIAN );
166163 ComparableQuantity <Angle > dLon = Quantities .getQuantity (toRadians (lngB - lngA ), RADIAN );
167164 double a =
@@ -171,7 +168,7 @@ public static ComparableQuantity<Length> calcHaversine(
171168 * sin (dLon .getValue ().doubleValue () / 2 )
172169 * sin (dLon .getValue ().doubleValue () / 2 );
173170 double c = 2 * atan2 (sqrt (a ), sqrt (1 - a ));
174- return r .multiply (c );
171+ return EARTH_RADIUS .multiply (c );
175172 }
176173
177174 /**
@@ -207,7 +204,7 @@ public static ComparableQuantity<Length> totalLengthOfLineString(LineString line
207204 * @return the length of the linestring as a quantity
208205 */
209206 public static ComparableQuantity <Length > calcHaversine (LineString lineString ) {
210- ComparableQuantity <Length > y = Quantities .getQuantity (0 , KILOMETRE );
207+ ComparableQuantity <Length > y = Quantities .getQuantity (0 , METRE );
211208 for (int i = 0 ; i < lineString .getNumPoints () - 1 ; i ++) {
212209 y = y .add (calcHaversine (lineString .getCoordinateN (i ), lineString .getCoordinateN (i + 1 )));
213210 }
0 commit comments