From 34b1bd88ab1f5e75156567ba75d7d3a06f39048c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 5 Nov 2012 23:55:46 +1300 Subject: Wierd gps103 message (fix #78) --- src/org/traccar/protocol/Gps103ProtocolDecoder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit v1.2.3