diff options
author | Anton Tananaev <anton@traccar.org> | 2023-08-03 21:06:41 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-08-03 21:06:52 -0700 |
commit | 230f629c3dce039aa8856fe2fb4c447a086d72e4 (patch) | |
tree | fef6152ca3bdb0586c41ce2d8d9f7fa436033b15 /src/main/java | |
parent | 28440b7726f186d08073acf7b9b119ec995b1ab7 (diff) | |
download | trackermap-server-230f629c3dce039aa8856fe2fb4c447a086d72e4.tar.gz trackermap-server-230f629c3dce039aa8856fe2fb4c447a086d72e4.tar.bz2 trackermap-server-230f629c3dce039aa8856fe2fb4c447a086d72e4.zip |
Handle invalid Ruptela GPS (fix #5152)
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index 2122d5081..649de7c5c 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -248,17 +248,21 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // priority (reserved) - position.setValid(true); - position.setLongitude(buf.readInt() / 10000000.0); - position.setLatitude(buf.readInt() / 10000000.0); - position.setAltitude(buf.readUnsignedShort() / 10.0); - position.setCourse(buf.readUnsignedShort() / 100.0); - - position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); - - position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort())); - - position.set(Position.KEY_HDOP, buf.readUnsignedByte() / 10.0); + int longitude = buf.readInt(); + int latitude = buf.readInt(); + if (longitude > Integer.MIN_VALUE && latitude > Integer.MIN_VALUE) { + position.setValid(true); + position.setLongitude(longitude / 10000000.0); + position.setLatitude(latitude / 10000000.0); + position.setAltitude(buf.readUnsignedShort() / 10.0); + position.setCourse(buf.readUnsignedShort() / 100.0); + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort())); + position.set(Position.KEY_HDOP, buf.readUnsignedByte() / 10.0); + } else { + buf.skipBytes(8); + getLastLocation(position, null); + } if (type == MSG_EXTENDED_RECORDS) { position.set(Position.KEY_EVENT, buf.readUnsignedShort()); |