From dbb56e3b500c624ef26cce8f8d1188fdef49f5e3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 Mar 2017 14:29:38 +1300 Subject: Alternative TAIP protocol format --- src/org/traccar/protocol/TaipProtocolDecoder.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java index 309263cd5..a46cdefe3 100644 --- a/src/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/org/traccar/protocol/TaipProtocolDecoder.java @@ -54,8 +54,13 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { .number("(dd)(dd)(dd)") // date (mmddyy) .number("(dd)(dd)(dd)") // time (hhmmss) .groupEnd() + .groupBegin() .number("([-+]dd)(d{5})") // latitude .number("([-+]ddd)(d{5})") // longitude + .or() + .number("([-+])(dd)(dd.dddd)") // latitude + .number("([-+])(ddd)(dd.dddd)") // longitude + .groupEnd() .number("(ddd)") // speed .number("(ddd)") // course .groupBegin() @@ -112,8 +117,15 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); } - position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG)); - position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG)); + if (parser.hasNext(4)) { + position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG)); + position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG)); + } + if (parser.hasNext(6)) { + position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN)); + position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN)); + } + position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble())); position.setCourse(parser.nextDouble()); -- cgit v1.2.3