From 7de7d81c59eef4a134e313615012a2694a8ca572 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Nov 2018 11:19:37 +1300 Subject: Fix ITS speed decoding --- src/org/traccar/protocol/ItsProtocolDecoder.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') 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; } -- cgit v1.2.3