From e9f466d5169fbbdea0e780a3a7b8221481035ec3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 25 Sep 2013 20:17:11 +1200 Subject: Improve gps103 decoder --- src/org/traccar/protocol/Gps103ProtocolDecoder.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/org/traccar') 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()); -- cgit v1.2.3