aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-11-05 23:55:46 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2012-11-05 23:55:46 +1300
commit34b1bd88ab1f5e75156567ba75d7d3a06f39048c (patch)
treeae7e39a0a31609cc468a53ece2db2cdad7edf4b3
parent8b4dc809a91bcd124ae087988aa79ceaeff1fd36 (diff)
downloadtrackermap-server-34b1bd88ab1f5e75156567ba75d7d3a06f39048c.tar.gz
trackermap-server-34b1bd88ab1f5e75156567ba75d7d3a06f39048c.tar.bz2
trackermap-server-34b1bd88ab1f5e75156567ba75d7d3a06f39048c.zip
Wierd gps103 message (fix #78)
-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,"));
}