aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/VisiontekProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-27 12:39:55 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-27 12:39:55 +1300
commit0abae87d85964f7b0afd3e2d128be7a211ae4715 (patch)
treee16302fca042ae062dc917d1e23b1b584a1b8e86 /src/org/traccar/protocol/VisiontekProtocolDecoder.java
parent52f6ed7567fc11babf831401ac9744f9ebd7c735 (diff)
downloadtrackermap-server-0abae87d85964f7b0afd3e2d128be7a211ae4715.tar.gz
trackermap-server-0abae87d85964f7b0afd3e2d128be7a211ae4715.tar.bz2
trackermap-server-0abae87d85964f7b0afd3e2d128be7a211ae4715.zip
Extend Visiontek protocol decoder (fix #1475)
Diffstat (limited to 'src/org/traccar/protocol/VisiontekProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 0dce4954d..31e9ff069 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -22,10 +22,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.helper.DateBuilder;
-import org.traccar.helper.Parser;
-import org.traccar.helper.PatternBuilder;
-import org.traccar.helper.UnitsConverter;
+import org.traccar.helper.*;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -41,13 +38,17 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),").optional() // imei
.number("(dd),(dd),(dd),") // date
.number("(dd),(dd),(dd),") // time
- .number("(dd)(dd).?(dddd)") // latitude
- .expression("([NS]),")
- .number("(ddd)(dd).?(dddd)") // longitude
- .expression("([EW]),")
+ .groupBegin()
+ .number("(dd)(dd).?(d+)([NS]),") // latitude
+ .number("(ddd)(dd).?(d+)([EW]),") // longitude
+ .or()
+ .number("(dd.d+)([NS]),") // latitude
+ .number("(ddd.d+)([EW]),") // longitude
+ .groupEnd()
.number("(d+.?d+),") // speed
.number("(d+),") // course
.groupBegin()
+ .groupBegin()
.number("(d+),") // altitude
.number("(d+),") // satellites
.groupEnd("?")
@@ -60,8 +61,10 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
.number("(d),") // external battery status
.number("(d+),") // gsm
.groupEnd("?")
- .expression("([AV]),?") // validity
- .number("(d+)?") // rfid
+ .groupEnd("?")
+ .any()
+ .expression("([AV])") // validity
+ .number(",(d{10})").optional() // rfid
.any()
.compile();
@@ -79,7 +82,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
String id = parser.next();
String imei = parser.next();
- if (!identify(id, channel, null, false) && !identify(imei, channel)) {
+ if (!identify(id, channel, null, false) && (imei == null || !identify(imei, channel))) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -89,8 +92,14 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
- position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
- position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
+ if (parser.hasNext(8)) {
+ position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
+ position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_MIN_MIN_HEM));
+ }
+ if (parser.hasNext(4)) {
+ position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
+ position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM));
+ }
position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(
parser.next().replace(".", "")) / 10));