diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-05 12:15:21 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-05 12:15:21 +1200 |
commit | b16f2be8393581cd516bf8b6c3d188cd6073a80c (patch) | |
tree | a471007c7a401cb08b57e520172c4d52f9ad1625 | |
parent | 5311269628c2c38ccf349e68549aa91fdef80c1a (diff) | |
download | traccar-server-b16f2be8393581cd516bf8b6c3d188cd6073a80c.tar.gz traccar-server-b16f2be8393581cd516bf8b6c3d188cd6073a80c.tar.bz2 traccar-server-b16f2be8393581cd516bf8b6c3d188cd6073a80c.zip |
Allow empty degrees value
-rw-r--r-- | src/org/traccar/protocol/V680ProtocolDecoder.java | 10 | ||||
-rw-r--r-- | test/org/traccar/protocol/V680ProtocolDecoderTest.java | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java index 81fd393e0..95f4e101c 100644 --- a/src/org/traccar/protocol/V680ProtocolDecoder.java +++ b/src/org/traccar/protocol/V680ProtocolDecoder.java @@ -47,9 +47,9 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { "(\\d+)#" + // Packet number "([^#]+)?#?" + // GSM base station "(?:[^#]+#)?" + - "(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) + "(\\d+)?(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) "([EW])," + - "(\\d+)(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) + "(\\d+)?(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) "([NS])," + "(\\d+\\.\\d+)," + // Speed "(\\d+\\.?\\d*)?#" + // Course @@ -120,13 +120,15 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { extendedInfo.set("gsm", parser.group(index++)); // Longitude - Double longitude = Double.valueOf(parser.group(index++)); + String lon = parser.group(index++); + Double longitude = (lon != null) ? Double.valueOf(lon) : 0.0; longitude += Double.valueOf(parser.group(index++)) / 60; if (parser.group(index++).compareTo("W") == 0) longitude = -longitude; position.setLongitude(longitude); // Latitude - Double latitude = Double.valueOf(parser.group(index++)); + String lat = parser.group(index++); + Double latitude = (lat != null) ? Double.valueOf(lat) : 0.0; latitude += Double.valueOf(parser.group(index++)) / 60; if (parser.group(index++).compareTo("S") == 0) latitude = -latitude; position.setLatitude(latitude); diff --git a/test/org/traccar/protocol/V680ProtocolDecoderTest.java b/test/org/traccar/protocol/V680ProtocolDecoderTest.java index 8e5a8a235..f481bfda4 100644 --- a/test/org/traccar/protocol/V680ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/V680ProtocolDecoderTest.java @@ -59,6 +59,9 @@ public class V680ProtocolDecoderTest { verify(decoder.decode(null, null, "#353588102031599##1#0000#AUT#01#41300304843fc1#7955.124400,E,642.095500,N,5.28,95.21#041213#074431.000##")); + + verify(decoder.decode(null, null, + "1#0000#AUT#01#23403007fa650e#16.747700,W,5136.356500,N,0.00,0.00#040415#002051.000")); } |