aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-09-19 21:16:26 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2014-09-19 21:16:26 +1200
commit3c3596868b8a18a6c207e902a6568c8e850e7696 (patch)
tree91c3e1f19a99e079d3b24a913d7b4188a0ca8301
parent5bced58f76ef64bab98c4ef5323860cee1c4bbec (diff)
downloadtrackermap-server-3c3596868b8a18a6c207e902a6568c8e850e7696.tar.gz
trackermap-server-3c3596868b8a18a6c207e902a6568c8e850e7696.tar.bz2
trackermap-server-3c3596868b8a18a6c207e902a6568c8e850e7696.zip
Workaround missing hemisphere (fix #874)
-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,"));
+
}
}