diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-09-25 20:17:11 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-09-25 20:17:11 +1200 |
commit | e9f466d5169fbbdea0e780a3a7b8221481035ec3 (patch) | |
tree | bf28c48a1fce80260158df3a3eb4474136ef7580 /src | |
parent | 2ad522b24213fc04e88329978001d3c95fef9070 (diff) | |
download | traccar-server-e9f466d5169fbbdea0e780a3a7b8221481035ec3.tar.gz traccar-server-e9f466d5169fbbdea0e780a3a7b8221481035ec3.tar.bz2 traccar-server-e9f466d5169fbbdea0e780a3a7b8221481035ec3.zip |
Improve gps103 decoder
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index cd6dbdcd0..24a1c525d 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -38,7 +38,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "(\\d+)," + // IMEI "([^,]+)," + // Alarm "(\\d{2})/?(\\d{2})/?(\\d{2})\\s?" + // Local Date - "(\\d{2}):?(\\d{2})," + // Local Time + "(\\d{2}):?(\\d{2})(?:\\d{2})?," + // Local Time "[^,]*," + "[FL]," + // F - full / L - low "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time UTC (HHMMSS.SSS) @@ -48,7 +48,8 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) "([EW])?," + "(\\d+\\.?\\d*)," + // Speed - "(\\d+\\.\\d+)?" + // Course + "(\\d+\\.?\\d*)?(?:," + // Course + "(\\d+\\.?\\d*)?)?" + // Altitude ".*"); @Override @@ -145,9 +146,6 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { } position.setLongitude(longitude); - // Altitude - position.setAltitude(0.0); - // Speed position.setSpeed(Double.valueOf(parser.group(index++))); @@ -159,6 +157,14 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { position.setCourse(0.0); } + // Altitude + String altitude = parser.group(index++); + if (altitude != null) { + position.setAltitude(Double.valueOf(altitude)); + } else { + position.setAltitude(0.0); + } + // Extended info position.setExtendedInfo(extendedInfo.toString()); |