From 87834b948b441decf408e4d634d8c155d3226465 Mon Sep 17 00:00:00 2001 From: Rohit Singhal Date: Thu, 8 May 2014 07:49:54 +0530 Subject: Update CarTrackProtocolDecoder.java Update Speed Parsing Code and Null Pointer Handling --- src/org/traccar/protocol/CarTrackProtocolDecoder.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java index c5242497c..3b1869d62 100644 --- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java @@ -46,7 +46,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { "([NS])," + // N/S "(\\d{3})(\\d{2}\\.\\d{4})," + // Long : YYYMM.DDDD "([EW])," + // E/W - "(\\d+.\\d*)," + // Speed in Knots + "(\\d+.\\d*)?," + // Speed in Knots "(\\d+.\\d*)?," + // Heading "(\\d{2})(\\d{2})(\\d{2})" + // DDMMYY ".*" + @@ -109,7 +109,12 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(longitude); // Speed - position.setSpeed(Double.valueOf(parser.group(index++))); + String speed = parser.group(index++); + if(speed != null){ + position.setSpeed(Double.valueOf(speed)); + } else { + position.setSpeed(0.0); + } // Course String course = parser.group(index++); -- cgit v1.2.3