diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-08 15:08:33 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-08 15:08:33 +1300 |
commit | eb4ee7a9d4d0f132546b164c3483d62eb9e9f0db (patch) | |
tree | 29bc56f0f67cd49bac31a50e415c614ed4b1c5dc /src/org/traccar/helper/DistanceCalculator.java | |
parent | 320d41863864485c5675c9bf8332ff0845e5e812 (diff) | |
download | trackermap-server-eb4ee7a9d4d0f132546b164c3483d62eb9e9f0db.tar.gz trackermap-server-eb4ee7a9d4d0f132546b164c3483d62eb9e9f0db.tar.bz2 trackermap-server-eb4ee7a9d4d0f132546b164c3483d62eb9e9f0db.zip |
Clean up reported PMD issues
Diffstat (limited to 'src/org/traccar/helper/DistanceCalculator.java')
-rw-r--r-- | src/org/traccar/helper/DistanceCalculator.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/org/traccar/helper/DistanceCalculator.java b/src/org/traccar/helper/DistanceCalculator.java index 072f3d7a8..7ba5044bc 100644 --- a/src/org/traccar/helper/DistanceCalculator.java +++ b/src/org/traccar/helper/DistanceCalculator.java @@ -17,16 +17,16 @@ package org.traccar.helper; public class DistanceCalculator { - private static final double equatorialEarthRadius = 6378.1370D; - private static final double deg2rad = (Math.PI / 180); + private static final double EQUATORIAL_EARTH_RADIUS = 6378.1370; + private static final double DEG_TO_RAD = Math.PI / 180; public static double distance(double lat1, double lon1, double lat2, double lon2) { - double dlong = (lon2 - lon1) * deg2rad; - double dlat = (lat2 - lat1) * deg2rad; + double dlong = (lon2 - lon1) * DEG_TO_RAD; + double dlat = (lat2 - lat1) * DEG_TO_RAD; double a = Math.pow(Math.sin(dlat / 2), 2) + - Math.cos(lat1 * deg2rad) * Math.cos(lat2 * deg2rad) * Math.pow(Math.sin(dlong / 2), 2); + Math.cos(lat1 * DEG_TO_RAD) * Math.cos(lat2 * DEG_TO_RAD) * Math.pow(Math.sin(dlong / 2), 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - double d = equatorialEarthRadius * c; + double d = EQUATORIAL_EARTH_RADIUS * c; return d * 1000; } |