From 9107c244020331de12d60f2437c8665011b7162d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 22 May 2017 11:33:29 +0500 Subject: Organize KEY_xDOP values --- src/org/traccar/protocol/DishaProtocolDecoder.java | 2 +- src/org/traccar/protocol/GlobalSatProtocolDecoder.java | 2 +- src/org/traccar/protocol/Gt30ProtocolDecoder.java | 2 +- src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 2 +- src/org/traccar/protocol/MeitrackProtocolDecoder.java | 2 +- src/org/traccar/protocol/TotemProtocolDecoder.java | 10 +++++----- src/org/traccar/protocol/TrackboxProtocolDecoder.java | 2 +- src/org/traccar/protocol/VisiontekProtocolDecoder.java | 2 +- src/org/traccar/protocol/WialonProtocolDecoder.java | 2 +- src/org/traccar/protocol/XirgoProtocolDecoder.java | 2 +- test/org/traccar/ProtocolTest.java | 16 ++++++++++++++++ 11 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/org/traccar/protocol/DishaProtocolDecoder.java b/src/org/traccar/protocol/DishaProtocolDecoder.java index ba2f5a5a4..181054adb 100644 --- a/src/org/traccar/protocol/DishaProtocolDecoder.java +++ b/src/org/traccar/protocol/DishaProtocolDecoder.java @@ -85,7 +85,7 @@ public class DishaProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble(0)); position.set(Position.KEY_SATELLITES, parser.next()); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); position.set(Position.KEY_RSSI, parser.next()); position.set(Position.KEY_CHARGE, parser.nextInt(0) == 2); position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt(0)); diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 317a253ec..c45a937d4 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -225,7 +225,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble(0)); position.set(Position.KEY_SATELLITES, parser.nextInt(0)); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); return position; } diff --git a/src/org/traccar/protocol/Gt30ProtocolDecoder.java b/src/org/traccar/protocol/Gt30ProtocolDecoder.java index ca5a23380..51135c80a 100644 --- a/src/org/traccar/protocol/Gt30ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt30ProtocolDecoder.java @@ -104,7 +104,7 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder { dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)); position.setTime(dateBuilder.getDate()); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); position.setAltitude(parser.nextDouble(0)); diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index b947b2855..199feaf97 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -227,7 +227,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)); position.setTime(dateBuilder.getDate()); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); if (parser.hasNext()) { position.setAltitude(parser.nextDouble(0)); diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index da363666a..908ed43e4 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -142,7 +142,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); position.setCourse(parser.nextDouble(0)); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); position.setAltitude(parser.nextDouble(0)); diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 71ef4f7cd..6f4441145 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -244,11 +244,11 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateBuilder.getDate()); if (pattern == PATTERN1) { - position.set(Position.KEY_PDOP, parser.next()); - position.set(Position.KEY_HDOP, parser.next()); - position.set(Position.KEY_VDOP, parser.next()); + position.set(Position.KEY_PDOP, parser.nextDouble()); + position.set(Position.KEY_HDOP, parser.nextDouble()); + position.set(Position.KEY_VDOP, parser.nextDouble()); } else { - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); } position.set(Position.PREFIX_IO + 1, parser.next()); @@ -291,7 +291,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, parser.next()); position.setCourse(parser.nextDouble(0)); position.setSpeed(parser.nextDouble(0)); - position.set(Position.KEY_PDOP, parser.next()); + position.set(Position.KEY_PDOP, parser.nextDouble()); position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000); position.setLatitude(parser.nextCoordinate()); diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java index deb2f2775..2302a2466 100644 --- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java +++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java @@ -87,7 +87,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); position.setAltitude(parser.nextDouble(0)); diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index 51c4deb7b..ac767452b 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -119,7 +119,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { } if (parser.hasNext(7)) { - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); position.setAltitude(parser.nextDouble(0)); position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000); position.set(Position.KEY_INPUT, parser.next()); diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 90b7e7847..72bf51862 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -98,7 +98,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, satellites); } - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); position.set(Position.KEY_INPUT, parser.next()); position.set(Position.KEY_OUTPUT, parser.next()); diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java index cf1f1575e..c356b53b6 100644 --- a/src/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java @@ -145,7 +145,7 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { position.setCourse(parser.nextDouble(0)); position.set(Position.KEY_SATELLITES, parser.next()); - position.set(Position.KEY_HDOP, parser.next()); + position.set(Position.KEY_HDOP, parser.nextDouble()); if (newFormat) { position.set(Position.KEY_ODOMETER, UnitsConverter.metersFromMiles(parser.nextDouble(0))); diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index a1b14c74d..2eb6871f3 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -180,6 +180,22 @@ public class ProtocolTest extends BaseTest { Assert.assertFalse("no attributes", attributes.isEmpty()); } + if (attributes.containsKey(Position.KEY_INDEX)) { + Assert.assertTrue(attributes.get(Position.KEY_INDEX) instanceof Number); + } + + if (attributes.containsKey(Position.KEY_HDOP)) { + Assert.assertTrue(attributes.get(Position.KEY_HDOP) instanceof Number); + } + + if (attributes.containsKey(Position.KEY_VDOP)) { + Assert.assertTrue(attributes.get(Position.KEY_VDOP) instanceof Number); + } + + if (attributes.containsKey(Position.KEY_PDOP)) { + Assert.assertTrue(attributes.get(Position.KEY_PDOP) instanceof Number); + } + if (attributes.containsKey(Position.KEY_ODOMETER)) { Assert.assertTrue(attributes.get(Position.KEY_ODOMETER) instanceof Number); } -- cgit v1.2.3