From d97f71973d3e0dd3571a05f8a938813795f5aced Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 11 Oct 2013 23:32:43 +1300 Subject: Support SendLocation app --- src/org/traccar/protocol/OsmAndProtocolDecoder.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/org/traccar') 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()); -- cgit v1.2.3