aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-06 11:47:53 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-06 11:47:53 +1200
commit926873438a66abcbaa204884970663e70b6882f8 (patch)
tree071983935fd47d36269d0ec75b4781f787667a2b
parent16ebb921e416e94cb9e01340d38c7071882dd65f (diff)
downloadtrackermap-server-926873438a66abcbaa204884970663e70b6882f8.tar.gz
trackermap-server-926873438a66abcbaa204884970663e70b6882f8.tar.bz2
trackermap-server-926873438a66abcbaa204884970663e70b6882f8.zip
Modify Visiontek regex pattern
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java15
-rw-r--r--test/org/traccar/protocol/VisiontekProtocolDecoderTest.java6
2 files changed, 11 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 2fe58e5be..236f417e3 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -19,10 +19,8 @@ import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Event;
@@ -40,9 +38,9 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
"(?:(\\d+),)?" + // IMEI
"(\\d{2}),(\\d{2}),(\\d{2})," + // Date
"(\\d{2}),(\\d{2}),(\\d{2})," + // Time
- "(\\d{2})(\\d{6})([NS])," + // Latitude
- "(\\d{3})(\\d{6})([EW])," + // Longitude
- "(\\d+\\.\\d+)," + // Speed
+ "(\\d{2})(\\d{2}\\.?\\d{4})([NS])," + // Latitude
+ "(\\d{3})(\\d{2}\\.?\\d{4})([EW])," + // Longitude
+ "(\\d+\\.?\\d+)," + // Speed
"(\\d+)," + // Course
"(?:(\\d+)," + // Altitude
"(\\d+),)?" + // Satellites
@@ -97,18 +95,19 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
- latitude += Double.valueOf(parser.group(index++)) / 600000;
+ latitude += Double.valueOf(parser.group(index++).replace(".", "")) / 600000;
if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
position.setLatitude(latitude);
// Longitude
Double longitude = Double.valueOf(parser.group(index++));
- longitude += Double.valueOf(parser.group(index++)) / 600000;
+ longitude += Double.valueOf(parser.group(index++).replace(".", "")) / 600000;
if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
position.setLongitude(longitude);
// Speed
- position.setSpeed(UnitsConverter.knotsFromKph(Double.valueOf(parser.group(index++))));
+ position.setSpeed(UnitsConverter.knotsFromKph(Double.valueOf(
+ parser.group(index++).replace(".", "")) / 10));
// Course
position.setCourse(Double.valueOf(parser.group(index++)));
diff --git a/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java b/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java
index 3eb1045a7..19e9b3287 100644
--- a/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java
@@ -1,9 +1,8 @@
package org.traccar.protocol;
-import org.traccar.helper.TestDataManager;
-import static org.traccar.helper.DecoderVerifier.verify;
import static org.junit.Assert.assertNull;
import org.junit.Test;
+import static org.traccar.helper.DecoderVerifier.verify;
public class VisiontekProtocolDecoderTest extends ProtocolDecoderTest {
@@ -11,6 +10,9 @@ public class VisiontekProtocolDecoderTest extends ProtocolDecoderTest {
public void testDecode() throws Exception {
VisiontekProtocolDecoder decoder = new VisiontekProtocolDecoder(null);
+
+ //verify(decoder.decode(null, null,
+ // "$1,AP116,05,06,15,11,48,32,1725.0460N,07824.5289E,0617,07,0,030,2091,0,0,0,1,1,1,1,20,00.0000,00.3820,00.0000,VAJRA V1.00,A#"));
verify(decoder.decode(null, null,
"$1,AP09BU9397,861785006462448,20,06,14,15,03,28,17267339N,078279407E,060.0,073,0550,11,0,1,0,0,1,1,26,A,0000000000"));