aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java8
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java3
2 files changed, 9 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index cc0fcb9cb..a8d819cbc 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -40,6 +40,7 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder {
/**
* Regular expressions pattern
*/
+ //imei:863070010423167,tracker,1211051840,,F,104000.000,A,2220.6483,N,11407.6377,,0,0,
static private Pattern pattern = Pattern.compile(
"imei:" +
"([\\d]+)," + // IMEI
@@ -52,7 +53,7 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder {
"([\\d]{2})([\\d]{2}.[\\d]{4})," + // Latitude (DDMM.MMMM)
"([NS])," +
"([\\d]{3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM)
- "([EW])," +
+ "([EW])?," +
"([\\d]+.[\\d]{2})," + // Speed
".*");
@@ -124,7 +125,10 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder {
// Longitude
Double lonlitude = Double.valueOf(parser.group(index++));
lonlitude += Double.valueOf(parser.group(index++)) / 60;
- if (parser.group(index++).compareTo("W") == 0) lonlitude = -lonlitude;
+ String hemisphere = parser.group(index++);
+ if (hemisphere != null) {
+ if (hemisphere.compareTo("W") == 0) lonlitude = -lonlitude;
+ }
position.setLongitude(lonlitude);
// Altitude
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 427d4afb4..0c2b33536 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -57,6 +57,9 @@ public class Gps103ProtocolDecoderTest {
// Over speed alarm
assertNotNull(decoder.decode(null, null,
"imei:359586015829802,speed,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
+
+ assertNotNull(decoder.decode(null, null,
+ "imei:863070010423167,tracker,1211051840,,F,104000.000,A,2220.6483,N,11407.6377,,0,0,"));
}