From 9164f1fbdf12ba2ed65839eb83a794fcc602edf8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 2 Dec 2014 21:34:18 +1300 Subject: Handle empty speed and course --- src/org/traccar/protocol/WialonProtocolDecoder.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 65cc17bcd..5b8d9a24e 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -47,8 +47,8 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { "([NS]);" + "(\\d{3})(\\d{2}\\.\\d+);" + // Longitude (DDDMM.MMMM) "([EW]);" + - "(\\d+\\.?\\d*);" + // Speed - "(\\d+\\.?\\d*);" + // Course + "(\\d+\\.?\\d*)?;" + // Speed + "(\\d+\\.?\\d*)?;" + // Course "(?:(\\d+\\.?\\d*)|NA);" + // Altitude "(?:(\\d+)|NA)" + // Satellites ".*"); // Full format @@ -103,10 +103,20 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(longitude); // Speed - position.setSpeed(Double.valueOf(parser.group(index++)) * 0.539957); + String speed = parser.group(index++); + if (speed != null) { + position.setSpeed(Double.valueOf(speed) * 0.539957); + } else { + position.setSpeed(0.0); + } // Course - position.setCourse(Double.valueOf(parser.group(index++))); + String course = parser.group(index++); + if (course != null) { + position.setCourse(Double.valueOf(course)); + } else { + position.setCourse(0.0); + } // Altitude String altitude = parser.group(index++); -- cgit v1.2.3