aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-10-26 20:18:07 -0700
committerAnton Tananaev <anton@traccar.org>2023-10-26 20:18:07 -0700
commit3bb48d3b472a9434d1d228767fef1d692b070b8e (patch)
tree140a7423411ddaf44f4c2958d14bddd86bbcb4f7 /src
parentf159a96647c091f2234db6ad84203735251598c8 (diff)
downloadtrackermap-server-3bb48d3b472a9434d1d228767fef1d692b070b8e.tar.gz
trackermap-server-3bb48d3b472a9434d1d228767fef1d692b070b8e.tar.bz2
trackermap-server-3bb48d3b472a9434d1d228767fef1d692b070b8e.zip
Fix coordinates filter (fix #5203)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/handler/DistanceHandler.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/handler/DistanceHandler.java b/src/main/java/org/traccar/handler/DistanceHandler.java
index 7fdefa1f4..6bb774a15 100644
--- a/src/main/java/org/traccar/handler/DistanceHandler.java
+++ b/src/main/java/org/traccar/handler/DistanceHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2023 Anton Tananaev (anton@traccar.org)
* Copyright 2015 Amila Silva
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,15 +36,15 @@ public class DistanceHandler extends BaseDataHandler {
private final CacheManager cacheManager;
private final boolean filter;
- private final int coordinatesMinError;
- private final int coordinatesMaxError;
+ private final int minError;
+ private final int maxError;
@Inject
public DistanceHandler(Config config, CacheManager cacheManager) {
this.cacheManager = cacheManager;
this.filter = config.getBoolean(Keys.COORDINATES_FILTER);
- this.coordinatesMinError = config.getInteger(Keys.COORDINATES_MIN_ERROR);
- this.coordinatesMaxError = config.getInteger(Keys.COORDINATES_MAX_ERROR);
+ this.minError = config.getInteger(Keys.COORDINATES_MIN_ERROR);
+ this.maxError = config.getInteger(Keys.COORDINATES_MAX_ERROR);
}
@Override
@@ -66,8 +66,8 @@ public class DistanceHandler extends BaseDataHandler {
distance = BigDecimal.valueOf(distance).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
}
if (filter && last.getLatitude() != 0 && last.getLongitude() != 0) {
- boolean satisfiesMin = coordinatesMinError == 0 || distance > coordinatesMinError;
- boolean satisfiesMax = coordinatesMaxError == 0 || distance < coordinatesMaxError;
+ boolean satisfiesMin = minError == 0 || distance > minError;
+ boolean satisfiesMax = maxError == 0 || distance < maxError || position.getValid();
if (!satisfiesMin || !satisfiesMax) {
position.setValid(last.getValid());
position.setLatitude(last.getLatitude());