diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-25 03:33:36 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-25 03:33:36 +1200 |
commit | 43033e0bd19dc99d9e571881aadee3b0285f4574 (patch) | |
tree | 166d62dbab0554e5d21924c195a90ffceb34368b /src/org/traccar/helper | |
parent | 516d1f157a762c3bd54e0ffc2f3c71547d49773c (diff) | |
parent | d2e89a2c1aa8f787bc0a296f588295ad1a5f76f2 (diff) | |
download | trackermap-server-43033e0bd19dc99d9e571881aadee3b0285f4574.tar.gz trackermap-server-43033e0bd19dc99d9e571881aadee3b0285f4574.tar.bz2 trackermap-server-43033e0bd19dc99d9e571881aadee3b0285f4574.zip |
Merge pull request #2248 from Abyss777/convert_speed2
Convert speed units in mail notifications
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r-- | src/org/traccar/helper/UnitsConverter.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/org/traccar/helper/UnitsConverter.java b/src/org/traccar/helper/UnitsConverter.java index fe42d9ee2..4bc7348db 100644 --- a/src/org/traccar/helper/UnitsConverter.java +++ b/src/org/traccar/helper/UnitsConverter.java @@ -17,23 +17,36 @@ package org.traccar.helper; public final class UnitsConverter { + private static final double KNOTS_TO_KPH_RATIO = 0.539957; + private static final double KNOTS_TO_MPH_RATIO = 0.868976; + private static final double KNOTS_TO_MPS_RATIO = 1.94384; + private static final double KNOTS_TO_CPS_RATIO = 0.0194384449; + private UnitsConverter() { } public static double knotsFromKph(double value) { // km/h - return value * 0.539957; + return value * KNOTS_TO_KPH_RATIO; + } + + public static double kphFromKnots(double value) { + return value / KNOTS_TO_KPH_RATIO; } public static double knotsFromMph(double value) { - return value * 0.868976; + return value * KNOTS_TO_MPH_RATIO; + } + + public static double mphFromKnots(double value) { + return value / KNOTS_TO_MPH_RATIO; } public static double knotsFromMps(double value) { // m/s - return value * 1.94384; + return value * KNOTS_TO_MPS_RATIO; } public static double knotsFromCps(double value) { // cm/s - return value * 0.0194384449; + return value * KNOTS_TO_CPS_RATIO; } } |