diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-22 22:33:46 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-04-22 22:33:46 -0700 |
commit | 149c71740105130d19aa55738042bc5be0280429 (patch) | |
tree | f5ff12f92f4ad9eb6e2c43f1c1394f6795bc8ef1 /src | |
parent | bda405e1aa178b33a46edb2c3e2594d74be3bc5c (diff) | |
download | traccar-server-149c71740105130d19aa55738042bc5be0280429.tar.gz traccar-server-149c71740105130d19aa55738042bc5be0280429.tar.bz2 traccar-server-149c71740105130d19aa55738042bc5be0280429.zip |
Fix GPS decoding
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/Gs100ProtocolDecoder.java | 6 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/Gs100ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gs100ProtocolDecoder.java index 28a42476c..69232dd55 100644 --- a/src/main/java/org/traccar/protocol/Gs100ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gs100ProtocolDecoder.java @@ -99,15 +99,15 @@ public class Gs100ProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(Integer.parseInt(coordinates.substring(10, 12)) + Integer.parseInt(coordinates.substring(12, 18)) * 0.0001 / 60); int flags = Integer.parseInt(coordinates.substring(9, 10), 16); - if (!BitUtil.check(flags, 4)) { + if (!BitUtil.check(flags, 3)) { position.setLongitude(-position.getLongitude()); } - if (!BitUtil.check(flags, 3)) { + if (!BitUtil.check(flags, 2)) { position.setLatitude(-position.getLatitude()); } String other = ByteBufUtil.hexDump(buf.readSlice(4)); - position.setSpeed(Integer.parseInt(other.substring(0, 5))); + position.setSpeed(Integer.parseInt(other.substring(0, 5)) * 0.01); position.setCourse(Integer.parseInt(other.substring(5, 8))); } else { diff --git a/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java index 91bbf386c..68c9b8219 100644 --- a/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java @@ -14,6 +14,9 @@ public class Gs100ProtocolDecoderTest extends ProtocolTest { "474C490F383632343632303332353036373030133839333831303131363039313838343837323546084657312E302E3236")); verifyPositions(decoder, binary( + "47440416900000124833220421018478956c445263460110426616900000124838220421018478907c445263470055824116900000124839220421018478890c445263440091526116900000124840220421018478867c4452634401312272")); + + verifyPositions(decoder, binary( "47440216900000064113030417020236402C452286650051929716900000064115030417020236408C4522866800379020")); } |