diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-29 16:21:49 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-29 16:21:49 +0500 |
commit | eef6dcea77898d5a917b225cfc8260ed88309a34 (patch) | |
tree | 18a7d4e7153350b1366314b14a4383cb73af5895 /src/org | |
parent | 561915e44fdf630ac10fdc8e4a207e384ea59d9a (diff) | |
download | traccar-server-eef6dcea77898d5a917b225cfc8260ed88309a34.tar.gz traccar-server-eef6dcea77898d5a917b225cfc8260ed88309a34.tar.bz2 traccar-server-eef6dcea77898d5a917b225cfc8260ed88309a34.zip |
Implement osmand.speedUnits patameter
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 6f8513c41..222369f58 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,9 @@ import org.jboss.netty.handler.codec.http.HttpVersion; import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.joda.time.format.ISODateTimeFormat; import org.traccar.BaseProtocolDecoder; +import org.traccar.Context; import org.traccar.DeviceSession; +import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; @@ -38,8 +40,11 @@ import java.util.Map; public class OsmAndProtocolDecoder extends BaseProtocolDecoder { + private String speedUnits; + public OsmAndProtocolDecoder(OsmAndProtocol protocol) { super(protocol); + speedUnits = Context.getConfig().getString("osmand.speedUnits", "kn"); } private void sendResponse(Channel channel, HttpResponseStatus status) { @@ -110,7 +115,19 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(Double.parseDouble(location[1])); break; case "speed": - position.setSpeed(Double.parseDouble(value)); + switch (speedUnits) { + case "kph": + position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(value))); + break; + case "mps": + position.setSpeed(UnitsConverter.knotsFromMps(Double.parseDouble(value))); + break; + case "mph": + position.setSpeed(UnitsConverter.knotsFromMph(Double.parseDouble(value))); + break; + default: + position.setSpeed(Double.parseDouble(value)); + } break; case "bearing": case "heading": |