aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-10 23:17:14 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-10 23:17:14 -0800
commitc37ebc1b07ba7ea6eeccc0b04b2cac72041507e0 (patch)
treefdee36a7a45476928099ed689a158d861cb3726c /src
parent3d2a3ee8ccf6f0989a149eec74b3d69d42963756 (diff)
downloadtrackermap-server-c37ebc1b07ba7ea6eeccc0b04b2cac72041507e0.tar.gz
trackermap-server-c37ebc1b07ba7ea6eeccc0b04b2cac72041507e0.tar.bz2
trackermap-server-c37ebc1b07ba7ea6eeccc0b04b2cac72041507e0.zip
Improve ITS decoding (fix #4144)
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/ItsProtocolDecoder.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/ItsProtocolDecoder.java b/src/org/traccar/protocol/ItsProtocolDecoder.java
index 62bf1f1e6..e2b1dc238 100644
--- a/src/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/org/traccar/protocol/ItsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2019 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN = new PatternBuilder()
+ .expression("[^$]*")
.text("$,")
.expression("[^,]+,") // event
.groupBegin()
@@ -59,8 +60,8 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d+),([NS]),") // latitude
.number("(d+.d+),([EW]),") // longitude
.groupBegin()
- .number("(d+.d+),") // speed
- .number("(d+.d+),") // course
+ .number("(d+.?d*),") // speed
+ .number("(d+.?d*),") // course
.number("(d+),") // satellites
.or()
.number("(-?d+.d+),") // altitude
@@ -108,8 +109,8 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.nextInt());
}
- if (parser.hasNext()) {
- position.setAltitude(parser.nextDouble(0));
+ if (parser.hasNext(2)) {
+ position.setAltitude(parser.nextDouble());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
}