diff options
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r-- | src/org/traccar/helper/BitUtil.java | 4 | ||||
-rw-r--r-- | src/org/traccar/helper/Checksum.java | 2 | ||||
-rw-r--r-- | src/org/traccar/helper/DistanceCalculator.java | 12 | ||||
-rw-r--r-- | src/org/traccar/helper/PatternUtil.java | 3 |
4 files changed, 11 insertions, 10 deletions
diff --git a/src/org/traccar/helper/BitUtil.java b/src/org/traccar/helper/BitUtil.java index e8a55c0a8..6dceb52d7 100644 --- a/src/org/traccar/helper/BitUtil.java +++ b/src/org/traccar/helper/BitUtil.java @@ -25,7 +25,7 @@ public class BitUtil { } public static int range(int number, int index) { - return (number >> index); + return number >> index; } public static int range(int number, int index, int length) { @@ -33,7 +33,7 @@ public class BitUtil { } public static long range(long number, int index) { - return (number >> index); + return number >> index; } public static long range(long number, int index, int length) { diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java index 69c9dd499..d3cec3880 100644 --- a/src/org/traccar/helper/Checksum.java +++ b/src/org/traccar/helper/Checksum.java @@ -168,7 +168,7 @@ public class Checksum { for (int i = 0; remain != 0; i++) { long digit = remain % 10; - if ((i % 2) == 0) { + if (i % 2 == 0) { digit *= 2; if (digit >= 10) { digit = 1 + (digit % 10); 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; } diff --git a/src/org/traccar/helper/PatternUtil.java b/src/org/traccar/helper/PatternUtil.java index e129a1438..4fa212200 100644 --- a/src/org/traccar/helper/PatternUtil.java +++ b/src/org/traccar/helper/PatternUtil.java @@ -31,7 +31,8 @@ public class PatternUtil { if (matcher.matches()) { match = pattern.substring(0, i); } - } catch (PatternSyntaxException e) { + } catch (PatternSyntaxException error) { + Log.warning(error); } } |