aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/config/Keys.java8
-rw-r--r--src/main/java/org/traccar/handler/FilterHandler.java9
2 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 8ced32153..c69289403 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1239,6 +1239,14 @@ public final class Keys {
List.of(KeyType.CONFIG));
/**
+ * Filter messages that do not have GPS location. If they are not filtered, they will include the last known
+ * location.
+ */
+ public static final ConfigKey<Boolean> FILTER_OUTDATED = new BooleanConfigKey(
+ "filter.outdated",
+ List.of(KeyType.CONFIG));
+
+ /**
* 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.
*/
diff --git a/src/main/java/org/traccar/handler/FilterHandler.java b/src/main/java/org/traccar/handler/FilterHandler.java
index 1d1c27b7a..9ff94deb0 100644
--- a/src/main/java/org/traccar/handler/FilterHandler.java
+++ b/src/main/java/org/traccar/handler/FilterHandler.java
@@ -48,6 +48,7 @@ public class FilterHandler extends ChannelInboundHandlerAdapter {
private final boolean filterInvalid;
private final boolean filterZero;
private final boolean filterDuplicate;
+ private final boolean filterOutdated;
private final long filterFuture;
private final long filterPast;
private final boolean filterApproximate;
@@ -69,6 +70,7 @@ public class FilterHandler extends ChannelInboundHandlerAdapter {
filterInvalid = config.getBoolean(Keys.FILTER_INVALID);
filterZero = config.getBoolean(Keys.FILTER_ZERO);
filterDuplicate = config.getBoolean(Keys.FILTER_DUPLICATE);
+ filterOutdated = config.getBoolean(Keys.FILTER_OUTDATED);
filterFuture = config.getLong(Keys.FILTER_FUTURE) * 1000;
filterPast = config.getLong(Keys.FILTER_PAST) * 1000;
filterAccuracy = config.getInteger(Keys.FILTER_ACCURACY);
@@ -115,6 +117,10 @@ public class FilterHandler extends ChannelInboundHandlerAdapter {
return false;
}
+ private boolean filterOutdated(Position position) {
+ return filterOutdated && position.getOutdated();
+ }
+
private boolean filterFuture(Position position) {
return filterFuture != 0 && position.getFixTime().getTime() > System.currentTimeMillis() + filterFuture;
}
@@ -189,6 +195,9 @@ public class FilterHandler extends ChannelInboundHandlerAdapter {
if (filterZero(position)) {
filterType.append("Zero ");
}
+ if (filterOutdated(position)) {
+ filterType.append("Outdated ");
+ }
if (filterFuture(position)) {
filterType.append("Future ");
}