aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-21 16:42:19 +1300
committerGitHub <noreply@github.com>2016-12-21 16:42:19 +1300
commit973b9e34ea077abba137d91da3000be41e35055b (patch)
tree8cb696c771efbcf1d45b5644d3c2d5e7e4faa926
parent7ff14665cb215410e258c2f8c88ae5ca2dbf0ddf (diff)
parent444d74eac0f05756de4367b783b57a60b6ba39b6 (diff)
downloadtrackermap-server-973b9e34ea077abba137d91da3000be41e35055b.tar.gz
trackermap-server-973b9e34ea077abba137d91da3000be41e35055b.tar.bz2
trackermap-server-973b9e34ea077abba137d91da3000be41e35055b.zip
Merge pull request #2718 from renaudallard/master
Allow setting the interval in Future filter
-rw-r--r--src/org/traccar/FilterHandler.java16
-rw-r--r--test/org/traccar/FilterHandlerTest.java2
2 files changed, 8 insertions, 10 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index 898651837..0a54cfeca 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -21,16 +21,14 @@ import org.traccar.model.Position;
public class FilterHandler extends BaseDataHandler {
- private static final long FILTER_FUTURE_LIMIT = 5 * 60 * 1000;
-
private boolean filterInvalid;
private boolean filterZero;
private boolean filterDuplicate;
- private boolean filterFuture;
private boolean filterApproximate;
private boolean filterStatic;
private int filterDistance;
private long filterLimit;
+ private long filterFuture;
public void setFilterInvalid(boolean filterInvalid) {
this.filterInvalid = filterInvalid;
@@ -44,10 +42,6 @@ public class FilterHandler extends BaseDataHandler {
this.filterDuplicate = filterDuplicate;
}
- public void setFilterFuture(boolean filterFuture) {
- this.filterFuture = filterFuture;
- }
-
public void setFilterApproximate(boolean filterApproximate) {
this.filterApproximate = filterApproximate;
}
@@ -64,17 +58,21 @@ public class FilterHandler extends BaseDataHandler {
this.filterLimit = filterLimit;
}
+ public void setFilterFuture(long filterFuture) {
+ this.filterFuture = filterFuture;
+ }
+
public FilterHandler() {
Config config = Context.getConfig();
if (config != null) {
filterInvalid = config.getBoolean("filter.invalid");
filterZero = config.getBoolean("filter.zero");
filterDuplicate = config.getBoolean("filter.duplicate");
- filterFuture = config.getBoolean("filter.future");
filterApproximate = config.getBoolean("filter.approximate");
filterStatic = config.getBoolean("filter.static");
filterDistance = config.getInteger("filter.distance");
filterLimit = config.getLong("filter.limit") * 1000;
+ filterFuture = config.getLong("filter.future") * 1000;
}
}
@@ -107,7 +105,7 @@ public class FilterHandler extends BaseDataHandler {
}
private boolean filterFuture(Position position) {
- return filterFuture && position.getFixTime().getTime() > System.currentTimeMillis() + FILTER_FUTURE_LIMIT;
+ return filterFuture != 0 && position.getFixTime().getTime() > System.currentTimeMillis() + filterFuture;
}
private boolean filterApproximate(Position position) {
diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java
index ea06a490d..11b4163a1 100644
--- a/test/org/traccar/FilterHandlerTest.java
+++ b/test/org/traccar/FilterHandlerTest.java
@@ -22,11 +22,11 @@ public class FilterHandlerTest extends BaseTest {
filtingHandler.setFilterInvalid(true);
filtingHandler.setFilterZero(true);
filtingHandler.setFilterDuplicate(true);
- filtingHandler.setFilterFuture(true);
filtingHandler.setFilterApproximate(true);
filtingHandler.setFilterStatic(true);
filtingHandler.setFilterDistance(10);
filtingHandler.setFilterLimit(10);
+ filtingHandler.setFilterFuture(5 * 60);
}
@After