aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-09 02:54:27 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-09 02:54:27 +1300
commit7638564f34b182b3f9a4e650d3f180f04fe8ae28 (patch)
tree87d8e33c17b63df36f0aa662ddadd918d2e2fe45 /src/org
parent627069db35c2ef3a433847a546aa7a2c0e0f4d3b (diff)
downloadtraccar-server-7638564f34b182b3f9a4e650d3f180f04fe8ae28.tar.gz
traccar-server-7638564f34b182b3f9a4e650d3f180f04fe8ae28.tar.bz2
traccar-server-7638564f34b182b3f9a4e650d3f180f04fe8ae28.zip
Workaround for Granit coordinates (fix #2664)
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/GranitProtocolDecoder.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java
index 5fa786e4d..6e8bc24bf 100644
--- a/src/org/traccar/protocol/GranitProtocolDecoder.java
+++ b/src/org/traccar/protocol/GranitProtocolDecoder.java
@@ -61,7 +61,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponseCurrent(Channel channel, int deviceId, long time) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
response.writeBytes("BB+UGRC~".getBytes(StandardCharsets.US_ASCII));
- response.writeShort(6); //binary length
+ response.writeShort(6); // length
response.writeInt((int) time);
response.writeShort(deviceId);
appendChecksum(response, 16);
@@ -71,7 +71,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponseArchive(Channel channel, int deviceId, int packNum) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
response.writeBytes("BB+ARCF~".getBytes(StandardCharsets.US_ASCII));
- response.writeShort(4); //binary length
+ response.writeShort(4); // length
response.writeShort(packNum);
response.writeShort(deviceId);
appendChecksum(response, 14);
@@ -95,14 +95,19 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
int latDegrees = buf.readUnsignedByte();
int lonMinutes = buf.readUnsignedShort();
int latMinutes = buf.readUnsignedShort();
+
double latitude = latDegrees + latMinutes / 60000.0;
double longitude = lonDegrees + lonMinutes / 60000.0;
- if (!BitUtil.check(flags, 4)) {
- latitude = -latitude;
- }
- if (!BitUtil.check(flags, 5)) {
- longitude = -longitude;
+
+ if (position.getValid()) {
+ if (!BitUtil.check(flags, 4)) {
+ latitude = -latitude;
+ }
+ if (!BitUtil.check(flags, 5)) {
+ longitude = -longitude;
+ }
}
+
position.setLongitude(longitude);
position.setLatitude(latitude);
@@ -135,11 +140,11 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(buf.readUnsignedByte() * 10);
- short diOut = buf.readUnsignedByte();
+ int output = buf.readUnsignedByte();
for (int i = 0; i < 8; i++) {
- position.set(Position.PREFIX_IO + (i + 1), BitUtil.check(diOut, i));
+ position.set(Position.PREFIX_IO + (i + 1), BitUtil.check(output, i));
}
- buf.skipBytes(1); //StatMess
+ buf.readUnsignedByte(); // status message buffer
}
@Override