diff options
Diffstat (limited to 'src')
-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; } |