diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-13 03:51:37 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-13 02:51:37 +1300 |
commit | 96f2ddba048b064381cf9375514f7b9d84186218 (patch) | |
tree | a5a0b9022c905b8086bf162b7f9022b15722da3b | |
parent | 7844532ac883784c50ef7979a57d87ce35045006 (diff) | |
download | traccar-server-96f2ddba048b064381cf9375514f7b9d84186218.tar.gz traccar-server-96f2ddba048b064381cf9375514f7b9d84186218.tar.bz2 traccar-server-96f2ddba048b064381cf9375514f7b9d84186218.zip |
Add accuracy to OsmAnd protocol
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 3 | ||||
-rwxr-xr-x | tools/test-generator.py | 19 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index 5508cad92..382865e8f 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -119,6 +119,9 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { case "altitude": position.setAltitude(Double.parseDouble(value)); break; + case "accuracy": + position.setAccuracy(Double.parseDouble(value)); + break; case "hdop": position.set(Position.KEY_HDOP, Double.parseDouble(value)); break; diff --git a/tools/test-generator.py b/tools/test-generator.py index a23e2576e..1a50c5c61 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -33,13 +33,14 @@ for i in range(0, len(waypoints)): lon = lon1 + (lon2 - lon1) * j / count points.append((lat, lon)) -def send(conn, lat, lon, course, alarm, ignition, speed): - params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course)) +def send(conn, lat, lon, course, speed, alarm, ignition, accuracy): + params = (('id', id), ('timestamp', int(time.time())), ('lat', lat), ('lon', lon), ('bearing', course), ('speed', speed)) if alarm: params = params + (('alarm', 'sos'),) if ignition: params = params + (('ignition', 'true'),) - params = params + (('speed', speed),) + if ignition: + params = params + (('accuracy', accuracy),) conn.request('GET', '?' + urllib.urlencode(params)) conn.getresponse().read() @@ -59,12 +60,10 @@ conn = httplib.HTTPConnection(server) while True: (lat1, lon1) = points[index % len(points)] (lat2, lon2) = points[(index + 1) % len(points)] - alarm = ((index % 10) == 0) - ignition = ((index % len(points)) != 0) - if (index % len(points)) != 0: - speed = device_speed - else: - speed = 0 - send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm, ignition, speed) + speed = device_speed if (index % len(points)) != 0 else 0 + alarm = (index % 10) == 0 + ignition = (index % len(points)) != 0 + accuracy = 100 if (index % 10) == 0 else 0 + send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), speed, alarm, ignition, accuracy) time.sleep(period) index += 1 |