diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-29 17:03:23 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-29 17:03:23 -0700 |
commit | aed0411f4ae5cfc007d27e0521a39a242fab7840 (patch) | |
tree | a704e82dc4c82e0d128e9619290ebb5cb8a66ea1 /src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | |
parent | 8921fc12ea0590c290f3780fa20df7176b8c0000 (diff) | |
download | trackermap-server-aed0411f4ae5cfc007d27e0521a39a242fab7840.tar.gz trackermap-server-aed0411f4ae5cfc007d27e0521a39a242fab7840.tar.bz2 trackermap-server-aed0411f4ae5cfc007d27e0521a39a242fab7840.zip |
Unify signed magnitude int decoding
Diffstat (limited to 'src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index 67a82a688..938d290c0 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -21,6 +21,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.config.Keys; +import org.traccar.helper.BufferUtil; import org.traccar.helper.model.AttributeUtil; import org.traccar.session.DeviceSession; import org.traccar.Protocol; @@ -673,19 +674,11 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(mask, 11)) { - long value = buf.readUnsignedInt(); - if (BitUtil.check(value, 31)) { - value = -BitUtil.to(value, 31); - } - position.setLatitude(value / 1000000.0); + position.setLatitude(BufferUtil.readSignedMagnitudeInt(buf) / 1000000.0); } if (BitUtil.check(mask, 12)) { - long value = buf.readUnsignedInt(); - if (BitUtil.check(value, 31)) { - value = -BitUtil.to(value, 31); - } - position.setLongitude(value / 1000000.0); + position.setLongitude(BufferUtil.readSignedMagnitudeInt(buf) / 1000000.0); } if (BitUtil.check(mask, 13)) { |