diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-20 23:10:00 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-20 23:10:00 +1200 |
commit | f26304bf414e86c00ea85cce143226084434cacc (patch) | |
tree | 197fa205f438b3aae242d36bf5b454e74d9632d5 /src/org | |
parent | 6f0bcdc18a8b0060c9842497045a9358f0920957 (diff) | |
download | trackermap-server-f26304bf414e86c00ea85cce143226084434cacc.tar.gz trackermap-server-f26304bf414e86c00ea85cce143226084434cacc.tar.bz2 trackermap-server-f26304bf414e86c00ea85cce143226084434cacc.zip |
Add new GPS103 format (fix #1177)
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 90b170cff..0d8257e55 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -48,10 +48,12 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "(?:(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)|" + // Time UTC (HHMMSS.SSS) "(?:\\d{1,5}\\.\\d+))," + "([AV])," + // Validity + "(?:([NS]),)?" + "(\\d+)(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) - "([NS])," + + "(?:([NS]),)?" + + "(?:([EW]),)?" + "(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) - "([EW])?," + + "(?:([EW])?,)?" + "(\\d+\\.?\\d*)?,?" + // Speed "(\\d+\\.?\\d*)?,?" + // Course "(\\d+\\.?\\d*)?,?" + // Altitude @@ -150,17 +152,28 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.group(index++).compareTo("A") == 0); // Latitude + String hemisphere = parser.group(index++); Double latitude = Double.valueOf(parser.group(index++)); latitude += Double.valueOf(parser.group(index++)) / 60; - if (parser.group(index++).compareTo("S") == 0) latitude = -latitude; + if (parser.group(index) != null) { + hemisphere = parser.group(index); + } + index++; + if (hemisphere.compareTo("S") == 0) { + latitude = -latitude; + } position.setLatitude(latitude); // Longitude + hemisphere = parser.group(index++); Double longitude = Double.valueOf(parser.group(index++)); longitude += Double.valueOf(parser.group(index++)) / 60; - String hemisphere = parser.group(index++); - if (hemisphere != null) { - if (hemisphere.compareTo("W") == 0) longitude = -longitude; + if (parser.group(index) != null) { + hemisphere = parser.group(index); + } + index++; + if (hemisphere != null && hemisphere.compareTo("W") == 0) { + longitude = -longitude; } position.setLongitude(longitude); |