aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-04 13:28:03 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-04 13:28:03 +1300
commit1423209d00804948110e1b70c2e41248b4945877 (patch)
tree4529df0b6c3398126433f049baf5da7450a62e5f
parentb29929c4c8f78f665dd1614e43ee108c6eeeaa89 (diff)
downloadtraccar-server-1423209d00804948110e1b70c2e41248b4945877.tar.gz
traccar-server-1423209d00804948110e1b70c2e41248b4945877.tar.bz2
traccar-server-1423209d00804948110e1b70c2e41248b4945877.zip
Ensure that odometer is a number (fix #2967)
-rw-r--r--src/org/traccar/protocol/AquilaProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java2
-rw-r--r--test/org/traccar/ProtocolTest.java4
4 files changed, 7 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java
index e1cebd20d..11ab15c86 100644
--- a/src/org/traccar/protocol/AquilaProtocolDecoder.java
+++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java
@@ -132,7 +132,7 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.nextInt());
if (parser.hasNext(9)) {
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 4862b4937..f5253566b 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -124,7 +124,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(parser.nextDouble());
- position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.nextInt());
position.set("runtime", parser.next());
position.setNetwork(new Network(
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 6a4b2052c..f36ef8143 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -290,7 +290,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble());
position.setSpeed(parser.nextDouble());
position.set("pdop", parser.next());
- position.set(Position.KEY_ODOMETER, parser.next());
+ position.set(Position.KEY_ODOMETER, parser.nextInt() * 1000);
position.setLatitude(parser.nextCoordinate());
position.setLongitude(parser.nextCoordinate());
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index f4072ad24..faf27071d 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -176,6 +176,10 @@ public class ProtocolTest extends BaseTest {
Assert.assertFalse("no attributes", attributes.isEmpty());
}
+ if (attributes.containsKey(Position.KEY_ODOMETER)) {
+ Assert.assertTrue(attributes.get(Position.KEY_ODOMETER) instanceof Number);
+ }
+
if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) {
for (CellTower cellTower : position.getNetwork().getCellTowers()) {
checkInteger(cellTower.getMobileCountryCode(), 0, 999);