diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-13 11:12:18 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-13 11:12:18 +1300 |
commit | 43a64fc359f8acf08f97d70ebdb93dafa607dc08 (patch) | |
tree | 52da0b19c3da83a57348f603e7dd6467b6717b96 /src/org/traccar/protocol/Jt600ProtocolDecoder.java | |
parent | e997c2642b35350241614acaef6d606e37223fe6 (diff) | |
download | trackermap-server-43a64fc359f8acf08f97d70ebdb93dafa607dc08.tar.gz trackermap-server-43a64fc359f8acf08f97d70ebdb93dafa607dc08.tar.bz2 trackermap-server-43a64fc359f8acf08f97d70ebdb93dafa607dc08.zip |
Remove data model and fix some issues
Diffstat (limited to 'src/org/traccar/protocol/Jt600ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/Jt600ProtocolDecoder.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 6ce282988..184c96c97 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -34,6 +34,12 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } + private static double convertCoordinate(int raw) { + int degrees = raw / 1000000; + double minutes = (raw % 1000000) / 10000.0; + return degrees + minutes / 60; + } + private Position decodeNormalMessage(ChannelBuffer buf, Channel channel) { Position position = new Position(); @@ -66,14 +72,8 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { position.setTime(time.getTime()); // Coordinates - int temp = ChannelBufferTools.readHexInteger(buf, 8); - double latitude = temp % 1000000; - latitude /= 60 * 10000; - latitude += temp / 1000000; - temp = ChannelBufferTools.readHexInteger(buf, 9); - double longitude = temp % 1000000; - longitude /= 60 * 10000; - longitude += temp / 1000000; + double latitude = convertCoordinate(ChannelBufferTools.readHexInteger(buf, 8)); + double longitude = convertCoordinate(ChannelBufferTools.readHexInteger(buf, 9)); // Flags byte flags = buf.readByte(); |