aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-30 11:45:35 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-30 11:45:35 +1300
commit933f990cefb03d141508abd60681f5615e3db9e2 (patch)
tree2e433f5121b0949492f4af2bcb11701045e5dbb5 /src/org
parent6334866893bb4a66163e4e7a7a11431ff3b2038f (diff)
downloadtrackermap-server-933f990cefb03d141508abd60681f5615e3db9e2.tar.gz
trackermap-server-933f990cefb03d141508abd60681f5615e3db9e2.tar.bz2
trackermap-server-933f990cefb03d141508abd60681f5615e3db9e2.zip
Fix TK103 speed and time decoding
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 21aa81bda..72fdc10b7 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -44,7 +44,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
"([NS]),?" +
"(\\d{3})(\\d{2}\\.\\d+)" + // Longitude (DDDMM.MMMM)
"([EW]),?" +
- "(\\d+\\.\\d{1,2}),?" + // Speed
+ "(\\d+\\.\\d)(?:\\d*,)?" + // Speed
"(\\d{2})(\\d{2})(\\d{2}),?" + // Time (HHMMSS)
"(\\d+\\.?\\d{1,2}),?" + // Course
"(?:([01]{8})|([0-9a-fA-F]{8}))?,?" + // State
@@ -96,45 +96,45 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
if (parser.group(index++) == null) {
- time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
- time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
- time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
+ time.set(Calendar.YEAR, 2000 + Integer.parseInt(parser.group(index++)));
+ time.set(Calendar.MONTH, Integer.parseInt(parser.group(index++)) - 1);
+ time.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parser.group(index++)));
} else {
- time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
- time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
- time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
+ time.set(Calendar.DAY_OF_MONTH, Integer.parseInt(parser.group(index++)));
+ time.set(Calendar.MONTH, Integer.parseInt(parser.group(index++)) - 1);
+ time.set(Calendar.YEAR, 2000 + Integer.parseInt(parser.group(index++)));
}
// Validity
position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
- Double latitude = Double.valueOf(parser.group(index++));
- latitude += Double.valueOf(parser.group(index++)) / 60;
+ Double latitude = Double.parseDouble(parser.group(index++));
+ latitude += Double.parseDouble(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
position.setLatitude(latitude);
// Longitude
- Double longitude = Double.valueOf(parser.group(index++));
- longitude += Double.valueOf(parser.group(index++)) / 60;
+ Double longitude = Double.parseDouble(parser.group(index++));
+ longitude += Double.parseDouble(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
position.setLongitude(longitude);
// Speed
if (Context.getConfig().getBoolean(getProtocolName() + ".mph")) {
- position.setSpeed(UnitsConverter.knotsFromMph(Double.valueOf(parser.group(index++))));
+ position.setSpeed(UnitsConverter.knotsFromMph(Double.parseDouble(parser.group(index++))));
} else {
- position.setSpeed(UnitsConverter.knotsFromKph(Double.valueOf(parser.group(index++))));
+ position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(parser.group(index++))));
}
// Time
- time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
- time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
- time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
+ time.set(Calendar.HOUR_OF_DAY, Integer.parseInt(parser.group(index++)));
+ time.set(Calendar.MINUTE, Integer.parseInt(parser.group(index++)));
+ time.set(Calendar.SECOND, Integer.parseInt(parser.group(index++)));
position.setTime(time.getTime());
// Course
- position.setCourse(Double.valueOf(parser.group(index++)));
+ position.setCourse(Double.parseDouble(parser.group(index++)));
// State
String status = parser.group(index++); // binary status