aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-31 18:18:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-31 18:18:19 +1300
commit1c488e9f1896d8f4ced142cb303169e45cbd27fb (patch)
tree6f560a1f71a17eb70d5b4be80e3f1e9e95acbca2
parent43c41653d90be21476c65b4e8d9b03c18ac6f8e2 (diff)
downloadtrackermap-server-1c488e9f1896d8f4ced142cb303169e45cbd27fb.tar.gz
trackermap-server-1c488e9f1896d8f4ced142cb303169e45cbd27fb.tar.bz2
trackermap-server-1c488e9f1896d8f4ced142cb303169e45cbd27fb.zip
Fix GPS103 time calculation logic
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java13
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 9fa71ad58..4bf1ca15d 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -69,8 +69,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
@@ -121,15 +120,15 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
int localHours = parser.nextInt();
int localMinutes = parser.nextInt();
- int utcHours = parser.nextInt();
- int utcMinutes = parser.nextInt();
+ String utcHours = parser.next();
+ String utcMinutes = parser.next();
dateBuilder.setTime(localHours, localMinutes, parser.nextInt(), parser.nextInt());
// Timezone calculation
- if (utcHours != 0 && utcMinutes != 0) {
- int deltaMinutes = (localHours - utcHours) * 60;
- deltaMinutes += localMinutes - utcMinutes;
+ if (utcHours != null && utcMinutes != null) {
+ int deltaMinutes = (localHours - Integer.valueOf(utcHours)) * 60;
+ deltaMinutes += localMinutes - Integer.valueOf(utcMinutes);
if (deltaMinutes <= -12 * 60) {
deltaMinutes += 24 * 60;
} else if (deltaMinutes > 12 * 60) {
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 09452c5e6..80d1424fc 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -11,6 +11,10 @@ public class Gps103ProtocolDecoderTest extends ProtocolDecoderTest {
Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new Gps103Protocol());
verifyPosition(decoder, text(
+ "imei:359710045559474,tracker,151030080103,,F,000101.000,A,5443.3834,N,02512.9071,E,0.00,0;"),
+ position("2015-10-30 00:01:01.000", true, 54.72306, 25.21512));
+
+ verifyPosition(decoder, text(
"imei:359710049092324,tracker,151027025958,,F,235957.000,A,2429.5156,N,04424.5828,E,0.01,27.91,,0,0,,,;"),
position("2015-10-26 23:59:57.000", true, 24.49193, 44.40971));