aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-04-29 13:56:51 -0700
committerAnton Tananaev <anton@traccar.org>2023-04-29 13:56:51 -0700
commit03cebd3191a9c27c4b38e585b323d5c8d6868571 (patch)
tree6678635e1b4bff7c41de557a0f3c8f0b9ee357c2 /src/main/java/org/traccar/handler
parent2b3c1be84310e2c7c6a3dff4ec37be2560af772e (diff)
downloadtrackermap-server-03cebd3191a9c27c4b38e585b323d5c8d6868571.tar.gz
trackermap-server-03cebd3191a9c27c4b38e585b323d5c8d6868571.tar.bz2
trackermap-server-03cebd3191a9c27c4b38e585b323d5c8d6868571.zip
Add outdated position filter
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/FilterHandler.java9
1 files changed, 9 insertions, 0 deletions
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 ");
}