aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Truppel <alex.truppel@gmail.com>2023-02-22 15:36:45 +0100
committerAlexandre Truppel <alex.truppel@gmail.com>2023-02-22 15:36:45 +0100
commit345262a970292541c07aee9982c6a26a29c11f9c (patch)
treee6ed045e705290110163a98ab4415d9b2a3efce8
parent51f0299aefe728163ac69f36cf9223c08ecd97aa (diff)
downloadtrackermap-server-345262a970292541c07aee9982c6a26a29c11f9c.tar.gz
trackermap-server-345262a970292541c07aee9982c6a26a29c11f9c.tar.bz2
trackermap-server-345262a970292541c07aee9982c6a26a29c11f9c.zip
Boolean special case for Wialon done, added tests
-rw-r--r--src/main/java/org/traccar/protocol/WialonProtocolDecoder.java10
-rw-r--r--src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java6
2 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
index 1fc434ed8..4c4ff7a63 100644
--- a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
@@ -140,9 +140,13 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
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
- // 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
-
+
+ // 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, yes, etc), in which case we convert into a boolean
+
try {
position.set(key, Double.parseDouble(value));
} catch (NumberFormatException e) {
diff --git a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
index 6953784fb..45fbfbb1d 100644
--- a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
@@ -19,6 +19,12 @@ public class WialonProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, text(
"#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;101_521347:1:521246,101_158:1:510,101_521055:1:510,101_521055_2.9:1:509,101_521056:1:3;626B"));
+ 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"));
+
verifyNull(decoder, text(
"#L#123456789012345;test"));