aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-12-16 20:32:01 -0800
committerAnton Tananaev <anton@traccar.org>2022-12-16 20:32:01 -0800
commitddf72b364323ed3f787fd41c5d5126c3521b96b7 (patch)
tree95d977f2e551008b021512c7a1ae0c4e278a2c2e /src/main/java/org/traccar/protocol
parent1c791638d74998b4451b3c6290c04c46ecd1a9c5 (diff)
downloadtrackermap-server-ddf72b364323ed3f787fd41c5d5126c3521b96b7.tar.gz
trackermap-server-ddf72b364323ed3f787fd41c5d5126c3521b96b7.tar.bz2
trackermap-server-ddf72b364323ed3f787fd41c5d5126c3521b96b7.zip
Throw on invalid coordinates
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
index e537edf1d..0ddb95c14 100644
--- a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
@@ -151,15 +151,11 @@ public class GlobalstarProtocolDecoder extends BaseHttpProtocolDecoder {
position.setCourse(BitUtil.from(flags, 5) * 45);
- position.setLatitude(buf.readUnsignedMedium() * 90.0 / (1 << 23));
- if (position.getLatitude() > 90) {
- position.setLatitude(position.getLatitude() - 180);
- }
+ double latitude = buf.readUnsignedMedium() * 90.0 / (1 << 23);
+ position.setLatitude(latitude > 90 ? latitude - 180 : latitude);
- position.setLongitude(buf.readUnsignedMedium() * 180.0 / (1 << 23));
- if (position.getLongitude() > 180) {
- position.setLongitude(position.getLongitude() - 360);
- }
+ double longitude = buf.readUnsignedMedium() * 180.0 / (1 << 23);
+ position.setLongitude(longitude > 180 ? longitude - 360 : longitude);
int speed = buf.readUnsignedByte();
position.setSpeed(UnitsConverter.knotsFromKph(speed));