diff options
author | Anton Tananaev <anton@traccar.org> | 2022-12-16 20:32:01 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-12-16 20:32:01 -0800 |
commit | ddf72b364323ed3f787fd41c5d5126c3521b96b7 (patch) | |
tree | 95d977f2e551008b021512c7a1ae0c4e278a2c2e /src/main/java/org/traccar/model | |
parent | 1c791638d74998b4451b3c6290c04c46ecd1a9c5 (diff) | |
download | trackermap-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/model')
-rw-r--r-- | src/main/java/org/traccar/model/Position.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java index 2b743433a..1286db5f2 100644 --- a/src/main/java/org/traccar/model/Position.java +++ b/src/main/java/org/traccar/model/Position.java @@ -227,9 +227,10 @@ public class Position extends Message { } public void setLatitude(double latitude) { - if (latitude >= -90 && latitude <= 90) { - this.latitude = latitude; + if (latitude < -90 || latitude > 90) { + throw new IllegalArgumentException("Latitude out of range"); } + this.latitude = latitude; } private double longitude; @@ -239,9 +240,10 @@ public class Position extends Message { } public void setLongitude(double longitude) { - if (longitude >= -180 && longitude <= 180) { - this.longitude = longitude; + if (longitude < -180 || longitude > 180) { + throw new IllegalArgumentException("Longitude out of range"); } + this.longitude = longitude; } private double altitude; // value in meters |