diff options
Diffstat (limited to 'src/org/traccar/protocol')
6 files changed, 22 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java index 322ebd06e..29748f489 100644 --- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java @@ -39,9 +39,9 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_HISTORY = 0x12; private static double convertCoordinate(int raw) { - double result = raw / 1000000; - result += (raw % 1000000) / 600000.0; - return result; + int degrees = raw / 1000000; + double minutes = (raw % 1000000) / 10000.0; + return degrees + minutes / 60; } private Position decodePosition(ChannelBuffer buf, boolean history) { 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(); diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 82cba08a5..7c5399a37 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -252,7 +252,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { command.append(imei).append(",CCC,").append(positions.size()).append("*"); int checksum = 0; for (int i = 0; i < command.length(); i += 1) checksum += command.charAt(i); - command.append(String.format("%02x\r\n", checksum & 0xff).toUpperCase()); + command.append(String.format("%02x", checksum & 0xff).toUpperCase()); + command.append("\r\n"); channel.write(command.toString()); } diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java index 6dcc19db5..b2e1699c3 100644 --- a/src/org/traccar/protocol/OrionProtocolDecoder.java +++ b/src/org/traccar/protocol/OrionProtocolDecoder.java @@ -48,9 +48,9 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder { } } - private static double convertCoordinate(int value) { - double degrees = value / 1000000; - double minutes = (value % 1000000) / 10000.0; + private static double convertCoordinate(int raw) { + int degrees = raw / 1000000; + double minutes = (raw % 1000000) / 10000.0; return degrees + minutes / 60; } diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index bf7c649ce..51cf6951c 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -125,13 +125,13 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { position.setLongitude(buf.readInt() * 180.0 / 0x7FFFFFFF); // Speed - position.setSpeed(buf.readUnsignedInt() / 100); + position.setSpeed(buf.readUnsignedInt() / 100.0); // Course - position.setCourse(buf.readUnsignedShort() / 100); + position.setCourse(buf.readUnsignedShort() / 100.0); // Altitude - position.setAltitude(buf.readUnsignedShort() / 100); + position.setAltitude(buf.readUnsignedShort() / 100.0); // Satellites int satellitesNumber = buf.readUnsignedByte(); diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java index 0879d86be..9d5b499cc 100644 --- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java +++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java @@ -44,10 +44,10 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { coordinate = 0xffffffffl - coordinate; } - double degrees = coordinate / 1000000; - degrees += (coordinate % 1000000) / 600000.0; + long degrees = coordinate / 1000000; + double minutes = (coordinate % 1000000) / 10000.0; - return sign * degrees; + return sign * (degrees + minutes / 60); } @Override |