From 3ae0b76c4c8129833ef3b7a51275b2ad2586ac04 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 7 Aug 2021 17:27:57 -0700 Subject: Simplify coordinates filtering --- src/main/java/org/traccar/handler/DistanceHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/handler/DistanceHandler.java b/src/main/java/org/traccar/handler/DistanceHandler.java index a336a884e..1e7e444f6 100644 --- a/src/main/java/org/traccar/handler/DistanceHandler.java +++ b/src/main/java/org/traccar/handler/DistanceHandler.java @@ -1,6 +1,6 @@ /* * Copyright 2015 Amila Silva - * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2021 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,11 +61,11 @@ public class DistanceHandler extends BaseDataHandler { last.getLatitude(), last.getLongitude()); distance = BigDecimal.valueOf(distance).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } - if (filter && last.getValid() && last.getLatitude() != 0 && last.getLongitude() != 0) { + if (filter && last.getLatitude() != 0 && last.getLongitude() != 0) { boolean satisfiesMin = coordinatesMinError == 0 || distance > coordinatesMinError; - boolean satisfiesMax = coordinatesMaxError == 0 - || distance < coordinatesMaxError || position.getValid(); + boolean satisfiesMax = coordinatesMaxError == 0 || distance < coordinatesMaxError; if (!satisfiesMin || !satisfiesMax) { + position.setValid(last.getValid()); position.setLatitude(last.getLatitude()); position.setLongitude(last.getLongitude()); distance = 0; -- cgit v1.2.3