[gpstracker] Fix NumberFormatException (#15337)

Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2023-08-05 22:41:12 +02:00 committed by GitHub
parent 7d2d86f244
commit c4d79a7502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,10 +50,10 @@ public class LocationMessage {
private String trackerId = ""; private String trackerId = "";
/** /**
* Altitude (iOS, Android/integer/meters/optional) * Altitude (iOS, Android/float/meters/optional)
*/ */
@SerializedName("alt") @SerializedName("alt")
private Integer altitude = Integer.MIN_VALUE; private BigDecimal altitude = BigDecimal.ZERO;
/** /**
* Latitude (iOS, Android/float/meters/required) * Latitude (iOS, Android/float/meters/required)
@ -109,7 +109,8 @@ public class LocationMessage {
* @return Conversion result * @return Conversion result
*/ */
public State getTrackerLocation() { public State getTrackerLocation() {
if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude) && Integer.MIN_VALUE != altitude) { if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude)
&& !BigDecimal.ZERO.equals(altitude)) {
return new PointType(new DecimalType(latitude), new DecimalType(longitude), new DecimalType(altitude)); return new PointType(new DecimalType(latitude), new DecimalType(longitude), new DecimalType(altitude));
} else if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude)) { } else if (!BigDecimal.ZERO.equals(latitude) && !BigDecimal.ZERO.equals(longitude)) {
return new PointType(new DecimalType(latitude), new DecimalType(longitude)); return new PointType(new DecimalType(latitude), new DecimalType(longitude));