aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-03-02 22:51:17 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-03-02 22:51:17 +1300
commit808e1134878630796bb9e35e0f5501be942f4c5b (patch)
treee85886fa98c4466eb28c87fd2a7961f35d4dad5c
parente9d0dd5df65eea669d34750ed9a4b505d68f6dc5 (diff)
downloadtraccar-server-808e1134878630796bb9e35e0f5501be942f4c5b.tar.gz
traccar-server-808e1134878630796bb9e35e0f5501be942f4c5b.tar.bz2
traccar-server-808e1134878630796bb9e35e0f5501be942f4c5b.zip
Fix negative altitude
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Xexun2ProtocolDecoder.java15
-rw-r--r--test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java3
3 files changed, 7 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index d81655933..2e3620179 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -154,7 +154,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(0.0);
// Speed
- position.setSpeed(Double.valueOf(parser.group(index++)) * 0.539957);
+ position.setSpeed(Double.valueOf(parser.group(index++)));
// Course
String course = parser.group(index++);
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
index 2e84ef47f..6981c8d42 100644
--- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,14 +26,8 @@ import org.traccar.ServerManager;
import org.traccar.helper.Log;
import org.traccar.model.Position;
-/**
- * Xexun tracker protocol decoder
- */
public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
- /**
- * Initialize
- */
public Xexun2ProtocolDecoder(ServerManager serverManager) {
super(serverManager);
}
@@ -61,14 +55,12 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
".*imei:" +
"(\\d+)," + // IMEI
"(\\d+)," + // Satellites
- "(\\d+\\.\\d+)," + // Altitude
+ "(-?\\d+\\.\\d+)," + // Altitude
"[FL]:(\\d+\\.\\d+)V," + // Power
".*" +
"[\r\n]*");
- /**
- * Decode message
- */
+ @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
@@ -77,7 +69,6 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
Matcher parser = pattern.matcher(sentence);
if (!parser.matches()) {
- //throw new ParseException(null, 0);
return null;
}
diff --git a/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java b/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java
index 9a4b6e28d..c9b97684c 100644
--- a/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class Xexun2ProtocolDecoderTest {
decoder.setDataManager(new TestDataManager());
assertNotNull(decoder.decode(null, null,
+ "130302125349,+79604870506,GPRMC,085349.000,A,4503.2392,N,03858.5660,E,6.95,154.65,020313,,,A*6C,F,, imei:012207007744243,03,-1.5,F:4.15V,1,139,28048,250,01,278A,5072"));
+
+ assertNotNull(decoder.decode(null, null,
"111111120009,+436763737552,GPRMC,120009.590,A,4639.6774,N,01418.5737,E,0.00,0.00,111111,,,A*68,F,, imei:359853000144328,04,481.2,F:4.15V,0,139,2689,232,03,2725,0576"));
assertNotNull(decoder.decode(null, null,