aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorRohit Singhal <errohitsinghal@gmail.com>2014-05-08 07:49:54 +0530
committerRohit Singhal <errohitsinghal@gmail.com>2014-05-08 07:49:54 +0530
commit87834b948b441decf408e4d634d8c155d3226465 (patch)
tree73553fc19e23c6e87b40c6fca49e1dd615535937 /src/org/traccar
parent62e04a3d493a98790172def8d1996be63400eb15 (diff)
downloadtrackermap-server-87834b948b441decf408e4d634d8c155d3226465.tar.gz
trackermap-server-87834b948b441decf408e4d634d8c155d3226465.tar.bz2
trackermap-server-87834b948b441decf408e4d634d8c155d3226465.zip
Update CarTrackProtocolDecoder.java
Update Speed Parsing Code and Null Pointer Handling
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/CarTrackProtocolDecoder.java9
1 files changed, 7 insertions, 2 deletions
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++);