aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-11-15 22:28:25 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-11-15 22:28:25 +1300
commit09ee4cc93d600edce023f414c9d373639c137975 (patch)
tree7995615ab99aadec97eb9cffc94f0bd1b0dbc3ab
parent0a2205a648243a755325c2cfceaa630f887d8952 (diff)
downloadtrackermap-server-09ee4cc93d600edce023f414c9d373639c137975.tar.gz
trackermap-server-09ee4cc93d600edce023f414c9d373639c137975.tar.bz2
trackermap-server-09ee4cc93d600edce023f414c9d373639c137975.zip
Improve OKO NAVI regex pattern
-rw-r--r--src/org/traccar/protocol/OkoProtocolDecoder.java12
-rw-r--r--test/org/traccar/protocol/OkoProtocolDecoderTest.java6
2 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/OkoProtocolDecoder.java b/src/org/traccar/protocol/OkoProtocolDecoder.java
index 312127283..e86acf0b8 100644
--- a/src/org/traccar/protocol/OkoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OkoProtocolDecoder.java
@@ -35,14 +35,14 @@ public class OkoProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.text("{")
.number("(d{15}),").optional() // imei
- .number("(dd)(dd)(dd).(ddd),") // time
+ .number("(dd)(dd)(dd).d+,") // time
.expression("([AV]),") // validity
.number("(dd)(dd.d+),") // latitude
.expression("([NS]),")
.number("(ddd)(dd.d+),") // longitude
.expression("([EW]),")
- .number("(d+.?d*),") // speed
- .number("(d+.?d*),") // course
+ .number("(d+.?d*)?,") // speed
+ .number("(d+.?d*)?,") // course
.number("(dd)(dd)(dd),") // date (ddmmyy)
.number("(d+),") // satellites
.number("(d+.d+),") // adc
@@ -77,13 +77,13 @@ public class OkoProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setValid(parser.next().equals("A"));
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
- position.setSpeed(parser.nextDouble());
- position.setCourse(parser.nextDouble());
+ position.setSpeed(parser.nextDouble(0));
+ position.setCourse(parser.nextDouble(0));
dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
diff --git a/test/org/traccar/protocol/OkoProtocolDecoderTest.java b/test/org/traccar/protocol/OkoProtocolDecoderTest.java
index a13839d5b..7e913ca2b 100644
--- a/test/org/traccar/protocol/OkoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OkoProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class OkoProtocolDecoderTest extends ProtocolTest {
OkoProtocolDecoder decoder = new OkoProtocolDecoder(new OkoProtocol());
verifyPosition(decoder, text(
+ "{861694033681089,045403.00,A,4924.14181,N,03207.43787,E,0.080,,151117,07,0.00,01,24.8,1,02,5n4}"));
+
+ verifyPosition(decoder, text(
+ "{045411.00,A,4924.14243,N,03207.43754,E,0.172,,151117,07,0.00,F9,28.1,2,C2,5n4}"));
+
+ verifyPosition(decoder, text(
"{861001001016415,115031.000,A,4804.101180,N,02255.227002,E,4.121,111.0,211215,6,0.00,F7,13.6,1,00"));
verifyPosition(decoder, text(