diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-29 17:06:14 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-29 17:06:14 +0500 |
commit | 72d35d6c63ff80353eae1559d5c5d71c94d137bb (patch) | |
tree | 22550a31fad86f044633af278c731173d63398eb /src/org/traccar/BaseProtocolDecoder.java | |
parent | eef6dcea77898d5a917b225cfc8260ed88309a34 (diff) | |
download | trackermap-server-72d35d6c63ff80353eae1559d5c5d71c94d137bb.tar.gz trackermap-server-72d35d6c63ff80353eae1559d5c5d71c94d137bb.tar.bz2 trackermap-server-72d35d6c63ff80353eae1559d5c5d71c94d137bb.zip |
Move common speed converting code to BaseProtocolDecoder
Diffstat (limited to 'src/org/traccar/BaseProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/BaseProtocolDecoder.java | 15 |
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 |