aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-07-10 22:17:59 +0300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-07-10 22:17:59 +0300
commit9d26d56e297f7bdd147cb702a75d78584d7db6ec (patch)
treef911c67457ae38bcb1805de774367588c14cec96 /src/org/traccar
parent5603d7bc03d9378fd647992c4b05941c83c080ab (diff)
downloadtrackermap-server-9d26d56e297f7bdd147cb702a75d78584d7db6ec.tar.gz
trackermap-server-9d26d56e297f7bdd147cb702a75d78584d7db6ec.tar.bz2
trackermap-server-9d26d56e297f7bdd147cb702a75d78584d7db6ec.zip
Support Continental extended precision
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/ContinentalProtocolDecoder.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/ContinentalProtocolDecoder.java b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
index 20134fc1f..b8f322dc6 100644
--- a/src/org/traccar/protocol/ContinentalProtocolDecoder.java
+++ b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
@@ -37,6 +37,14 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ACK = 0x06;
public static final int MSG_NACK = 0x15;
+ private double readCoordinate(ByteBuf buf, boolean extended) {
+ long value = buf.readUnsignedInt();
+ if (extended ? (value & 0x08000000) != 0 : (value & 0x00800000) != 0) {
+ value |= extended ? 0xF0000000 : 0xFF000000;
+ }
+ return (int) value / (extended ? 360000.0 : 3600.0);
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -64,11 +72,9 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
position.setFixTime(new Date(buf.readUnsignedInt() * 1000L));
- buf.readUnsignedByte();
- position.setLatitude(buf.readMedium() / 3600.0);
-
- buf.readUnsignedByte();
- position.setLongitude(buf.readMedium() / 3600.0);
+ boolean extended = buf.getUnsignedByte(buf.readerIndex()) != 0;
+ position.setLatitude(readCoordinate(buf, extended));
+ position.setLongitude(readCoordinate(buf, extended));
position.setCourse(buf.readUnsignedShort());
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));