diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-06 23:08:22 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-11-06 23:08:22 +1300 |
commit | 85317819e2ff62941ecc76031248792b430ac0b3 (patch) | |
tree | 37a77667ccc3c28fe4261a9088bc5cae006d3110 | |
parent | f629297ceecfd6fb1ad64adf1549980d30e0343f (diff) | |
download | trackermap-server-85317819e2ff62941ecc76031248792b430ac0b3.tar.gz trackermap-server-85317819e2ff62941ecc76031248792b430ac0b3.tar.bz2 trackermap-server-85317819e2ff62941ecc76031248792b430ac0b3.zip |
Add course to gps103 protocol
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 16 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gps103ProtocolDecoderTest.java | 7 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 020feb6f6..4c8c4255c 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -47,13 +47,14 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder { "(\\d{2})(\\d{2})(\\d{2})\\d+," + // Date "[^,]*," + "[FL]," + // F - full / L - low - "(\\d{2})(\\d{2})(\\d{2}).(\\d{3})," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS) "([AV])," + // Validity - "(\\d{2})(\\d{2}.\\d{4})," + // Latitude (DDMM.MMMM) + "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM) "([NS])," + - "(\\d{3})(\\d{2}.\\d{4})," + // Longitude (DDDMM.MMMM) + "(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM) "([EW])?," + "(\\d+\\.?\\d*)," + // Speed + "(\\d+\\.\\d+)?" + // Course ".*"); /** @@ -135,7 +136,14 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder { // Speed position.setSpeed(Double.valueOf(parser.group(index++))); - position.setCourse(0.0); + + // Course + String course = parser.group(index++); + if (course != null) { + position.setCourse(Double.valueOf(course)); + } else { + position.setCourse(0.0); + } // Extended info position.setExtendedInfo(extendedInfo.toString()); diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java index 0c2b33536..61585d3c1 100644 --- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java @@ -60,7 +60,12 @@ public class Gps103ProtocolDecoderTest { assertNotNull(decoder.decode(null, null, "imei:863070010423167,tracker,1211051840,,F,104000.000,A,2220.6483,N,11407.6377,,0,0,")); - + + assertNotNull(decoder.decode(null, null, + "imei:863070010423167,tracker,1211051951,63360926,F,115123.000,A,2220.6322,N,11407.5313,E,0.00,,")); + + assertNotNull(decoder.decode(null, null, + "imei:863070010423167,tracker,1211060621,,F,062152.000,A,2220.6914,N,11407.5506,E,15.85,347.84,")); } } |