aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-01 10:16:42 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-01 10:16:42 +1300
commit9034cd07e95320a37a0f788ee6eaa546af5f4df1 (patch)
tree1e991b7b3682a07d22d9f1e138608024af963e66 /src/org/traccar
parentf16ce106253ce3a857efbe4cd7b65f76c77d6364 (diff)
downloadtrackermap-server-9034cd07e95320a37a0f788ee6eaa546af5f4df1.tar.gz
trackermap-server-9034cd07e95320a37a0f788ee6eaa546af5f4df1.tar.bz2
trackermap-server-9034cd07e95320a37a0f788ee6eaa546af5f4df1.zip
Implemenet future message filtering
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/FilterHandler.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index c601016b4..e24de487f 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -19,18 +19,24 @@ import org.traccar.helper.DistanceCalculator;
import org.traccar.helper.Log;
import org.traccar.model.Position;
+import java.util.Date;
+
public class FilterHandler extends BaseDataHandler {
+ private static final long FILTER_FUTURE_LIMIT = 5 * 60 * 1000;
+
private final boolean filterInvalid;
private final boolean filterZero;
private final boolean filterDuplicate;
+ private final boolean filterFuture;
private final int filterDistance;
private final long filterLimit;
-
+
public FilterHandler(
boolean filterInvalid,
boolean filterZero,
boolean filterDuplicate,
+ boolean filterFuture,
int filterDistance,
long filterLimit) {
@@ -38,6 +44,7 @@ public class FilterHandler extends BaseDataHandler {
this.filterZero = filterZero;
this.filterDuplicate = filterDuplicate;
this.filterDistance = filterDistance;
+ this.filterFuture = filterFuture;
this.filterLimit = filterLimit;
}
@@ -47,6 +54,7 @@ public class FilterHandler extends BaseDataHandler {
filterInvalid = config.getBoolean("filter.invalid");
filterZero = config.getBoolean("filter.zero");
filterDuplicate = config.getBoolean("filter.duplicate");
+ filterFuture = config.getBoolean("filter.future");
filterDistance = config.getInteger("filter.distance");
filterLimit = config.getLong("filter.limit") * 1000;
}
@@ -80,6 +88,10 @@ public class FilterHandler extends BaseDataHandler {
return false;
}
}
+
+ private boolean filterFuture(Position position) {
+ return filterFuture && (position.getFixTime().getTime() > System.currentTimeMillis() + FILTER_FUTURE_LIMIT);
+ }
private boolean filterDistance(Position position) {
if (filterDistance != 0) {
@@ -116,6 +128,7 @@ public class FilterHandler extends BaseDataHandler {
filterInvalid(p) ||
filterZero(p) ||
filterDuplicate(p) ||
+ filterFuture(p) ||
filterDistance(p);
if (filterLimit(p)) {