aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-10-11 23:32:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-10-11 23:32:43 +1300
commitd97f71973d3e0dd3571a05f8a938813795f5aced (patch)
tree738e552031a06310123bac14be040a42d9e30f9e
parent6f177f5ceb8c8ce9af7be71effd1855dc764507a (diff)
downloadtraccar-server-d97f71973d3e0dd3571a05f8a938813795f5aced.tar.gz
traccar-server-d97f71973d3e0dd3571a05f8a938813795f5aced.tar.bz2
traccar-server-d97f71973d3e0dd3571a05f8a938813795f5aced.zip
Support SendLocation app
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java16
-rw-r--r--test/org/traccar/protocol/OsmAndProtocolDecoderTest.java3
2 files changed, 17 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index dba5e003b..50903f52a 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -53,7 +53,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("osmand");
// Identification
- String id = params.get("id").get(0);
+ String id = params.get(params.containsKey("id") ? "id" : "deviceid").get(0);
try {
position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
} catch(Exception error) {
@@ -62,7 +62,11 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
// Decode position
position.setValid(true);
- position.setTime(new Date(Long.valueOf(params.get("timestamp").get(0)) * 1000));
+ if (params.containsKey("timestamp")) {
+ position.setTime(new Date(Long.valueOf(params.get("timestamp").get(0)) * 1000));
+ } else {
+ position.setTime(new Date());
+ }
position.setLatitude(Double.valueOf(params.get("lat").get(0)));
position.setLongitude(Double.valueOf(params.get("lon").get(0)));
@@ -74,6 +78,8 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
}
if (params.containsKey("bearing")) {
position.setCourse(Double.valueOf(params.get("bearing").get(0)));
+ } else if (params.containsKey("heading")) {
+ position.setCourse(Double.valueOf(params.get("heading").get(0)));
} else {
position.setCourse(0.0);
}
@@ -85,6 +91,12 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
if (params.containsKey("hdop")) {
extendedInfo.set("hdop", params.get("hdop").get(0));
}
+ if (params.containsKey("vacc")) {
+ extendedInfo.set("vacc", params.get("vacc").get(0));
+ }
+ if (params.containsKey("hacc")) {
+ extendedInfo.set("hacc", params.get("hacc").get(0));
+ }
position.setExtendedInfo(extendedInfo.toString());
diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
index 9fb44b2ff..2a5b1baf0 100644
--- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
@@ -19,6 +19,9 @@ public class OsmAndProtocolDecoderTest {
assertNotNull(decoder.decode(null, null, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
"/?id=123456&timestamp=1377177267&lat=60.0&lon=30.0")));
+
+ assertNotNull(decoder.decode(null, null, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
+ "/?lat=60.0&lon=30.0&speed=0.0&heading=0.0&vacc=0&hacc=0&altitude=0&deviceid=123456")));
}