diff options
author | Alexandre Truppel <alex.truppel@gmail.com> | 2023-02-22 16:05:21 +0100 |
---|---|---|
committer | Alexandre Truppel <alex.truppel@gmail.com> | 2023-02-22 16:05:21 +0100 |
commit | 47398e91b1450c744cf3ed31de46f7ea02bbede1 (patch) | |
tree | 6408121a872d7821e54b37fe16ce37fd351c7212 /src | |
parent | 6c4f99117bbd3645f3b55852b2148beb28c1e0f9 (diff) | |
download | trackermap-server-47398e91b1450c744cf3ed31de46f7ea02bbede1.tar.gz trackermap-server-47398e91b1450c744cf3ed31de46f7ea02bbede1.tar.bz2 trackermap-server-47398e91b1450c744cf3ed31de46f7ea02bbede1.zip |
Review
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/WialonProtocolDecoder.java | 10 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java | 11 |
2 files changed, 5 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java index baf3847a1..1166d0708 100644 --- a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java @@ -145,7 +145,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { // 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, yes, etc), in which case we convert into a boolean + // (true, false), in which case we convert into a boolean try { double doubleValue = Double.parseDouble(value); @@ -158,13 +158,9 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { position.set(key, doubleValue); } } catch (NumberFormatException e) { - if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("t") - || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("y") - || value.equalsIgnoreCase("on")) { + if (value.equalsIgnoreCase("true")) { position.set(key, true); - } else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("f") - || value.equalsIgnoreCase("no") || value.equalsIgnoreCase("n") - || value.equalsIgnoreCase("off")) { + } else if (value.equalsIgnoreCase("false")) { position.set(key, false); } else { position.set(key, value); diff --git a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java index e25ff7f9e..0a47edcb4 100644 --- a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java @@ -78,15 +78,8 @@ public class WialonProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, text( "#B#110315;045857;5364.0167;N;06127.8262;E;0;155;965;7;2.40;4;0;14.77,0.02,3.6;AB45DF01145;")); - verifyAttributes(decoder, text( - "#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;motion:3:true")); - - verifyAttributes(decoder, text( - "#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;motion:3:false")); - - Position p = (Position)decoder.decode(null, null, text( - "#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;accuracy:2:12.3")); - assertEquals(p.getAccuracy(), 12.3, 0.001); + verifyAttribute(decoder, text( + "#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;motion:3:false"), "motion", false); } } |