aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-11-15 11:19:37 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-11-15 11:19:37 +1300
commit7de7d81c59eef4a134e313615012a2694a8ca572 (patch)
treecd84384a76dda1541d5963df9307a4ade7e5d0e8 /src
parent3f44240490ccb0cfc0da59cb5ecf101bf622ae1d (diff)
downloadtraccar-server-7de7d81c59eef4a134e313615012a2694a8ca572.tar.gz
traccar-server-7de7d81c59eef4a134e313615012a2694a8ca572.tar.bz2
traccar-server-7de7d81c59eef4a134e313615012a2694a8ca572.zip
Fix ITS speed decoding
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/ItsProtocolDecoder.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/ItsProtocolDecoder.java b/src/org/traccar/protocol/ItsProtocolDecoder.java
index 226c27cd8..d3cdb14c3 100644
--- a/src/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/org/traccar/protocol/ItsProtocolDecoder.java
@@ -57,8 +57,14 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.expression("([AV]),").optional() // valid
.number("(d+.d+),([NS]),") // latitude
.number("(d+.d+),([EW]),") // longitude
- .number("(-?d+.d+),").optional() // altitude
+ .groupBegin()
+ .number("(d+.d+),") // speed
+ .number("(d+.d+),") // course
+ .number("(d+),") // satellites
+ .or()
+ .number("(-?d+.d+),") // altitude
.number("(d+.d+),") // speed
+ .groupEnd()
.any()
.compile();
@@ -88,8 +94,17 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
}
position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
- position.setAltitude(parser.nextDouble(0));
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+
+ if (parser.hasNext(3)) {
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setCourse(parser.nextDouble());
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ }
+
+ if (parser.hasNext()) {
+ position.setAltitude(parser.nextDouble(0));
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ }
return position;
}