aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/config/Keys.java12
-rw-r--r--src/main/java/org/traccar/handler/FilterHandler.java9
2 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 7ab45312f..5f31fe99c 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1104,14 +1104,22 @@ public final class Keys {
List.of(KeyType.CONFIG));
/**
- * Filter records with fix time in future. The values is specified in seconds. Records that have fix time more than
- * specified number of seconds later than current server time would be filtered out.
+ * Filter records with fix time in the future. The value is specified in seconds. Records that have fix time more
+ * than the specified number of seconds later than current server time would be filtered out.
*/
public static final ConfigKey<Long> FILTER_FUTURE = new LongConfigKey(
"filter.future",
List.of(KeyType.CONFIG));
/**
+ * Filter records with fix time in the past. The value is specified in seconds. Records that have fix time more
+ * than the specified number of seconds before current server time would be filtered out.
+ */
+ public static final ConfigKey<Long> FILTER_PAST = new LongConfigKey(
+ "filter.past",
+ List.of(KeyType.CONFIG));
+
+ /**
* Filter positions with accuracy less than specified value in meters.
*/
public static final ConfigKey<Integer> FILTER_ACCURACY = new IntegerConfigKey(
diff --git a/src/main/java/org/traccar/handler/FilterHandler.java b/src/main/java/org/traccar/handler/FilterHandler.java
index 0bd57319a..37f5cd566 100644
--- a/src/main/java/org/traccar/handler/FilterHandler.java
+++ b/src/main/java/org/traccar/handler/FilterHandler.java
@@ -47,6 +47,7 @@ public class FilterHandler extends BaseDataHandler {
private final boolean filterZero;
private final boolean filterDuplicate;
private final long filterFuture;
+ private final long filterPast;
private final boolean filterApproximate;
private final int filterAccuracy;
private final boolean filterStatic;
@@ -67,6 +68,7 @@ public class FilterHandler extends BaseDataHandler {
filterZero = config.getBoolean(Keys.FILTER_ZERO);
filterDuplicate = config.getBoolean(Keys.FILTER_DUPLICATE);
filterFuture = config.getLong(Keys.FILTER_FUTURE) * 1000;
+ filterPast = config.getLong(Keys.FILTER_PAST) * 1000;
filterAccuracy = config.getInteger(Keys.FILTER_ACCURACY);
filterApproximate = config.getBoolean(Keys.FILTER_APPROXIMATE);
filterStatic = config.getBoolean(Keys.FILTER_STATIC);
@@ -116,6 +118,10 @@ public class FilterHandler extends BaseDataHandler {
return filterFuture != 0 && position.getFixTime().getTime() > System.currentTimeMillis() + filterFuture;
}
+ private boolean filterPast(Position position) {
+ return filterPast != 0 && position.getFixTime().getTime() < System.currentTimeMillis() - filterPast;
+ }
+
private boolean filterAccuracy(Position position) {
return filterAccuracy != 0 && position.getAccuracy() > filterAccuracy;
}
@@ -185,6 +191,9 @@ public class FilterHandler extends BaseDataHandler {
if (filterFuture(position)) {
filterType.append("Future ");
}
+ if (filterPast(position)) {
+ filterType.append("Past ");
+ }
if (filterAccuracy(position)) {
filterType.append("Accuracy ");
}