diff options
author | Anton Tananaev <anton@traccar.org> | 2023-02-22 07:15:04 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-02-22 07:15:04 -0800 |
commit | 2b7c3ecde2512478dac381feaab9d35a93c3b9cb (patch) | |
tree | cd573662ae1dc6b86b899f252a243005008e4243 /src/main/java/org | |
parent | afef64ee9a572e1c65368de3012bc5792374e411 (diff) | |
download | trackermap-server-2b7c3ecde2512478dac381feaab9d35a93c3b9cb.tar.gz trackermap-server-2b7c3ecde2512478dac381feaab9d35a93c3b9cb.tar.bz2 trackermap-server-2b7c3ecde2512478dac381feaab9d35a93c3b9cb.zip |
Small code cleanup
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/protocol/WialonProtocolDecoder.java | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java index b319a5947..ffa4472ef 100644 --- a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java @@ -135,27 +135,13 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { for (String param : values) { Matcher paramParser = Pattern.compile("(.*):[1-3]:(.*)").matcher(param); if (paramParser.matches()) { - // Parsing gives a (string,string) key-value pair String key = paramParser.group(1).toLowerCase(); String value = paramParser.group(2); - - // Key is already in correct type (string) - - // If we can parse the value as a double, then we use that as the value's type. - // This covers both integer (x:1:y) and double (x:2:y) types in the Wialon protocol - - // If not, value type is a string unless it is equal to some specific cases - // (true, false), in which case we convert into a boolean - try { - double doubleValue = Double.parseDouble(value); - - // Since accuracy is not part of the general parameter list, - // we need to handle it separately by calling setAccuracy directly if (key.equals("accuracy")) { - position.setAccuracy(doubleValue); + position.setAccuracy(Double.parseDouble(value)); } else { - position.set(key, doubleValue); + position.set(key, Double.parseDouble(value)); } } catch (NumberFormatException e) { if (value.equalsIgnoreCase("true")) { |