aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-10-04 13:43:06 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-10-04 13:43:06 +1300
commitd2f79ef95411e7be309eb7e0fc6a0ec1b2227a7d (patch)
tree367f61005ae06edd30aea1e2730636aaf657aad3 /src/org/traccar
parent9cab5ed55b930c9a227cb0a9bf4d43913c2249b4 (diff)
downloadtraccar-server-d2f79ef95411e7be309eb7e0fc6a0ec1b2227a7d.tar.gz
traccar-server-d2f79ef95411e7be309eb7e0fc6a0ec1b2227a7d.tar.bz2
traccar-server-d2f79ef95411e7be309eb7e0fc6a0ec1b2227a7d.zip
Add filtering time limit
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/FilterHandler.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index 18ae2ecae..5298f1d7f 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -33,6 +33,7 @@ public class FilterHandler extends OneToOneDecoder {
private boolean filterZero;
private boolean filterDuplicate;
private int filterDistance;
+ private long filterLimit;
private final Map<Long, Position> lastPositions = new HashMap<Long, Position>();
@@ -50,6 +51,9 @@ public class FilterHandler extends OneToOneDecoder {
value = properties.getProperty("filter.distance");
if (value != null) filterDistance = Integer.valueOf(value);
+
+ value = properties.getProperty("filter.limit");
+ if (value != null) filterLimit = Long.valueOf(value) * 1000;
}
private boolean filterInvalid(Position position) {
@@ -91,6 +95,19 @@ public class FilterHandler extends OneToOneDecoder {
}
}
+ private boolean filterLimit(Position position) {
+ if (filterLimit != 0) {
+ Position last = lastPositions.get(position.getDeviceId());
+ if (last != null) {
+ return (position.getTime().getTime() - last.getTime().getTime()) > filterLimit;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
private boolean filter(Position p) {
boolean result =
@@ -99,6 +116,10 @@ public class FilterHandler extends OneToOneDecoder {
filterDuplicate(p) ||
filterDistance(p);
+ if (filterLimit(p)) {
+ result = false;
+ }
+
if (!result) {
lastPositions.put(p.getDeviceId(), p);
} else {