aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/BaseProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-30 00:08:52 +1200
committerGitHub <noreply@github.com>2017-08-30 00:08:52 +1200
commite3dfcf55262b60142a10458641f720aff3a0f6ad (patch)
tree22550a31fad86f044633af278c731173d63398eb /src/org/traccar/BaseProtocolDecoder.java
parent561915e44fdf630ac10fdc8e4a207e384ea59d9a (diff)
parent72d35d6c63ff80353eae1559d5c5d71c94d137bb (diff)
downloadtrackermap-server-e3dfcf55262b60142a10458641f720aff3a0f6ad.tar.gz
trackermap-server-e3dfcf55262b60142a10458641f720aff3a0f6ad.tar.bz2
trackermap-server-e3dfcf55262b60142a10458641f720aff3a0f6ad.zip
Merge pull request #3491 from Abyss777/osmand_speedunits
Make OsmAnd speed units configurable
Diffstat (limited to 'src/org/traccar/BaseProtocolDecoder.java')
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index cc16000f4..2d6286bf8 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -19,6 +19,7 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.socket.DatagramChannel;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.traccar.helper.Log;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.Device;
import org.traccar.model.Position;
@@ -66,6 +67,20 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
return protocol.getName();
}
+ protected double convertSpeed(double value, String defaultUnits) {
+ switch (Context.getConfig().getString(getProtocolName() + ".speed", defaultUnits)) {
+ case "kmh":
+ return UnitsConverter.knotsFromKph(value);
+ case "mps":
+ return UnitsConverter.knotsFromMps(value);
+ case "mph":
+ return UnitsConverter.knotsFromMph(value);
+ case "kn":
+ default:
+ return value;
+ }
+ }
+
private DeviceSession channelDeviceSession; // connection-based protocols
private Map<SocketAddress, DeviceSession> addressDeviceSessions = new HashMap<>(); // connectionless protocols