aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-09-02 20:33:09 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2014-09-02 20:33:09 +1200
commit1f56f881365fbe31736c26c3b5ba848c2fda4f64 (patch)
tree1a4c6a0c77f3e9868c92cb9c79f2dd6779f9f57b
parent5601a825b55eedd78e2a95263db7731ff67ed861 (diff)
downloadtrackermap-server-1f56f881365fbe31736c26c3b5ba848c2fda4f64.tar.gz
trackermap-server-1f56f881365fbe31736c26c3b5ba848c2fda4f64.tar.bz2
trackermap-server-1f56f881365fbe31736c26c3b5ba848c2fda4f64.zip
Fix coordinates decoding
-rw-r--r--src/org/traccar/protocol/OrionProtocolDecoder.java11
-rw-r--r--test/org/traccar/protocol/OrionProtocolDecoderTest.java4
2 files changed, 10 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java
index fa04c6dca..1846bba23 100644
--- a/src/org/traccar/protocol/OrionProtocolDecoder.java
+++ b/src/org/traccar/protocol/OrionProtocolDecoder.java
@@ -25,7 +25,6 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
-import org.traccar.helper.Crc;
import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
@@ -49,6 +48,12 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private static double convertCoordinate(int value) {
+ double degrees = value / 1000000;
+ double minutes = (Math.abs(value) % 1000000) / 10000.0;
+ return degrees + minutes / 60;
+ }
+
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
@@ -91,8 +96,8 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
extendedInfo.set("flag2", buf.readUnsignedByte());
// Location
- position.setLatitude(buf.readInt() / 10000.0);
- position.setLongitude(buf.readInt() / 10000.0);
+ position.setLatitude(convertCoordinate(buf.readInt()));
+ position.setLongitude(convertCoordinate(buf.readInt()));
position.setAltitude(buf.readShort()/ 10.0);
position.setCourse((double) buf.readUnsignedShort());
position.setSpeed(buf.readUnsignedShort() * 0.0539957);
diff --git a/test/org/traccar/protocol/OrionProtocolDecoderTest.java b/test/org/traccar/protocol/OrionProtocolDecoderTest.java
index d46efce6e..9e37ab5a1 100644
--- a/test/org/traccar/protocol/OrionProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OrionProtocolDecoderTest.java
@@ -16,7 +16,7 @@ public class OrionProtocolDecoderTest {
OrionProtocolDecoder decoder = new OrionProtocolDecoder(null);
decoder.setDataManager(new TestDataManager());
- /*verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(
+ verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(
new int[] {0x50,0x57,0x00,0x41,0x07,0x36,0x7C,0x24,0x2B,0x44,0x09,0x01,0xAD,0xE9,0x7D,0x01,0x63,0x14,0x3B,0x07,0xB0,0x03,0x00,0x00,0x00,0x00,0x0D,0x04,0x19,0x17,0x38,0x2D,0x00,0x0B,0x01,0x01,0x00,0x05,0x11,0x00,0x00,0x00,0x00,0x06,0x82,0x05,0x00,0x00,0x00,0x8E,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0x03,0x00,0x84,0x03,0x00,0x85,0x03,0x00,0x09,0x0A,0x00,0x00,0x00,0x00,0x48,0x01,0x00,0x00,0x00,0x8A,0xFC}))));
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(
@@ -27,7 +27,7 @@ public class OrionProtocolDecoderTest {
verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(
new int[] {0x50,0x57,0x00,0x41,0x2a,0xc8,0x62,0x36,0x35,0x40,0x09,0x11,0x4d,0x20,0xe4,0x02,0x21,0x0f,0x1f,0x00,0xd2,0x04,0x00,0x00,0x00,0x00,0x0e,0x06,0x11,0x0d,0x34,0x14,0x00,0x0b,0x01,0x01,0x00,0x12,0x28,0x00,0x00,0x00,0x00,0x06,0x82,0x05,0x00,0x00,0x00,0x8e,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x8c,0x03,0x00,0x84,0x03,0x00,0x85,0x03,0x00,0x03,0x06,0x7b,0x00,0x68,0x01,0x00,0x09,0x30}))));
-*/
+
}
}