From c9537fa61c07d58bccb24c9e387f09c4799a4196 Mon Sep 17 00:00:00 2001 From: Damien alias Dough Date: Sat, 3 Sep 2016 09:35:29 +0200 Subject: 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. --- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/org/traccar/protocol') 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 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; -- cgit v1.2.3 From f7d2f360323074081a560b168e6ddf0a875d2f38 Mon Sep 17 00:00:00 2001 From: Damien alias Dough Date: Sun, 4 Sep 2016 09:59:05 +0200 Subject: Using array instead of List to split location --- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 1d4dc898a..b9a519b21 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -106,9 +106,9 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(Double.parseDouble(value)); break; case "location": - List location = Arrays.asList(value.split(",")); - position.setLatitude(Double.parseDouble(location.get(0))); - position.setLongitude(Double.parseDouble(location.get(1))); + String[] location = value.split(","); + position.setLatitude(Double.parseDouble(location[0])); + position.setLongitude(Double.parseDouble(location[1])); break; case "speed": position.setSpeed(Double.parseDouble(value)); -- cgit v1.2.3 From d8166cc1b1db9fca92b801804831dc8c20ab7415 Mon Sep 17 00:00:00 2001 From: Damien alias Dough Date: Sun, 4 Sep 2016 10:04:11 +0200 Subject: Clean unused import Arrays in OsmAndProtocolDecoder --- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index b9a519b21..eddfb592c 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -32,7 +32,6 @@ 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; -- cgit v1.2.3