aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-23 09:50:33 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-23 09:50:33 +1300
commitdfa728598edc0fd3ad495198c3b4666fc644d16c (patch)
tree3de6dec3840ba8eafe2546e65b364ac5322df024
parent62b5879f68d5f2201b527082309808977de9e8f9 (diff)
downloadtrackermap-server-dfa728598edc0fd3ad495198c3b4666fc644d16c.tar.gz
trackermap-server-dfa728598edc0fd3ad495198c3b4666fc644d16c.tar.bz2
trackermap-server-dfa728598edc0fd3ad495198c3b4666fc644d16c.zip
Fix hemisphere decoding for H02 protocol
-rw-r--r--src/org/traccar/helper/Parser.java2
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java12
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java4
3 files changed, 11 insertions, 7 deletions
diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java
index 7c5f84f55..a3f118df0 100644
--- a/src/org/traccar/helper/Parser.java
+++ b/src/org/traccar/helper/Parser.java
@@ -157,7 +157,7 @@ public class Parser {
}
public double nextCoordinate() {
- return nextCoordinate(CoordinateFormat.DEG_MIN_HEM);
+ return nextCoordinate(CoordinateFormat.DEG_MIN_HEM);
}
}
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 2b8adda4a..c4ba6ffa3 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -123,15 +123,15 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)(dd)(dd),") // time
.expression("([AV])?,") // validity
.groupBegin()
- .number("(d+)(dd.d+),") // latitude
- .or()
.number("-(d+)-(d+.d+),") // latitude
+ .or()
+ .number("(d+)(dd.d+),") // latitude
.groupEnd()
.expression("([NS]),")
.groupBegin()
- .number("(d+)(dd.d+),") // longitude
- .or()
.number("-(d+)-(d+.d+),") // longitude
+ .or()
+ .number("(d+)(dd.d+),") // longitude
.groupEnd()
.expression("([EW]),")
.number("(d+.?d*),") // speed
@@ -164,14 +164,14 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
}
if (parser.hasNext(2)) {
- position.setLatitude(parser.nextCoordinate());
+ position.setLatitude(-parser.nextCoordinate());
}
if (parser.hasNext(2)) {
position.setLatitude(parser.nextCoordinate());
}
if (parser.hasNext(2)) {
- position.setLongitude(parser.nextCoordinate());
+ position.setLongitude(-parser.nextCoordinate());
}
if (parser.hasNext(2)) {
position.setLongitude(parser.nextCoordinate());
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index cc4c47e66..8e0abac58 100644
--- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -10,6 +10,10 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol());
+ verifyPosition(decoder, buffer(
+ "*HQ,4210051415,V1,164549,A,0956.3869,N,08406.7068,W,000.00,000,221215,FFFFFBFF,712,01,0,0,6#"),
+ position("2015-12-22 16:45:49.000", true, 9.93978, -84.11178));
+
verifyNothing(decoder, buffer(
"*HQ,1451316451,NBR,112315,724,10,2,2,215,2135,123,215,2131,121,011215,FFFFFFFF#"));