diff options
author | Damien alias Dough <dough29@gmail.com> | 2016-09-03 09:35:29 +0200 |
---|---|---|
committer | Damien alias Dough <dough29@gmail.com> | 2016-09-03 09:35:29 +0200 |
commit | c9537fa61c07d58bccb24c9e387f09c4799a4196 (patch) | |
tree | 1d5fccf0c080e8a927fc53965d5f7081199792e0 | |
parent | 8ec8955876bbfaf9e2856ec50f2a011b1dee0eca (diff) | |
download | trackermap-server-c9537fa61c07d58bccb24c9e387f09c4799a4196.tar.gz trackermap-server-c9537fa61c07d58bccb24c9e387f09c4799a4196.tar.bz2 trackermap-server-c9537fa61c07d58bccb24c9e387f09c4799a4196.zip |
As exposed on forum thread - https://www.traccar.org/forums/topic/tracking-through-http-url-request/ - add location parameter to OsmAnd protocol for coma separated lat & lon.
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/OsmAndProtocolDecoderTest.java | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index c5884a4d0..1d4dc898a 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -32,6 +32,7 @@ import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; @@ -104,6 +105,11 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { case "lon": position.setLongitude(Double.parseDouble(value)); break; + case "location": + List<String> location = Arrays.asList(value.split(",")); + position.setLatitude(Double.parseDouble(location.get(0))); + position.setLongitude(Double.parseDouble(location.get(1))); + break; case "speed": position.setSpeed(Double.parseDouble(value)); break; diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java index 6ec885058..1dc89b251 100644 --- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java +++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java @@ -34,6 +34,9 @@ public class OsmAndProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, request( "/?id=861001000719969&lat=41.666667&lon=-0.883333&altitude=350.059479&speed=0.000000&batt=87")); + verifyPosition(decoder, request( + "/?id=123456×tamp=1377177267&location=60.0,30.0")); + } } |