aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java11
-rw-r--r--test/org/traccar/protocol/XexunProtocolDecoderTest.java3
2 files changed, 10 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index a6c298f44..7a0d71e64 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -41,9 +41,9 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
"(\\d+)(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
"(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
- "([EW])," +
- "(\\d+\\.\\d+)," + // Speed
- "(\\d+\\.\\d+)?," + // Course
+ "([EW])?," +
+ "(\\d+\\.?\\d*)," + // Speed
+ "(\\d+\\.?\\d*)?," + // Course
"(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY)
".*\r?\n?.*imei:" +
"(\\d+),"); // IMEI
@@ -86,7 +86,10 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
// Longitude
Double longitude = Double.valueOf(parser.group(index++));
longitude += Double.valueOf(parser.group(index++)) / 60;
- if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
+ String hemisphere = parser.group(index++);
+ if (hemisphere != null) {
+ if (hemisphere.compareTo("W") == 0) longitude = -longitude;
+ }
position.setLongitude(longitude);
// Altitude
diff --git a/test/org/traccar/protocol/XexunProtocolDecoderTest.java b/test/org/traccar/protocol/XexunProtocolDecoderTest.java
index 79ea5740f..252293655 100644
--- a/test/org/traccar/protocol/XexunProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/XexunProtocolDecoderTest.java
@@ -30,6 +30,9 @@ public class XexunProtocolDecoderTest {
verify(decoder.decode(null, null,
"GPRMC,014623.000,A,4710.8260,N,1948.1220,E,0.11,105.40,111212,00,0000.0,A*49,F,,imei:357713002048962,"));
+ verify(decoder.decode(null, null,
+ "GPRMC,220828.678,A,5206.1446,N,02038.2403,,0,0,160912,,,E*23,L,imei:358948012501019,"));
+
}
}