diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-15 11:19:37 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-15 11:19:37 +1300 |
commit | 7de7d81c59eef4a134e313615012a2694a8ca572 (patch) | |
tree | cd84384a76dda1541d5963df9307a4ade7e5d0e8 /src/org/traccar/protocol | |
parent | 3f44240490ccb0cfc0da59cb5ecf101bf622ae1d (diff) | |
download | trackermap-server-7de7d81c59eef4a134e313615012a2694a8ca572.tar.gz trackermap-server-7de7d81c59eef4a134e313615012a2694a8ca572.tar.bz2 trackermap-server-7de7d81c59eef4a134e313615012a2694a8ca572.zip |
Fix ITS speed decoding
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/ItsProtocolDecoder.java | 21 |
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; } |