aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-08 21:56:44 +1200
committerGitHub <noreply@github.com>2017-09-08 21:56:44 +1200
commit2721bf4adc12eeacf19c00af30e266ae65e6a4a9 (patch)
treed728cea2cf1c4a1b8d19b12c7bb6aae91e576900 /src/org/traccar
parentd36fa0963f8e1045d2f974cd88a0be68aea6f2ef (diff)
parent640770638943146f5c2e7dcfb0c05b84fc9b3cff (diff)
downloadtrackermap-server-2721bf4adc12eeacf19c00af30e266ae65e6a4a9.tar.gz
trackermap-server-2721bf4adc12eeacf19c00af30e266ae65e6a4a9.tar.bz2
trackermap-server-2721bf4adc12eeacf19c00af30e266ae65e6a4a9.zip
Merge pull request #3514 from Abyss777/skip_filter
Implement skipping filtering by list of attributes
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/FilterHandler.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index f63fd17dd..4cd3eb0eb 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -30,7 +30,7 @@ public class FilterHandler extends BaseDataHandler {
private int filterDistance;
private int filterMaxSpeed;
private long skipLimit;
- private boolean skipAlarms;
+ private boolean skipAttributes;
public void setFilterInvalid(boolean filterInvalid) {
this.filterInvalid = filterInvalid;
@@ -68,8 +68,8 @@ public class FilterHandler extends BaseDataHandler {
this.skipLimit = skipLimit;
}
- public void setSkipAlarms(boolean skipAlarms) {
- this.skipAlarms = skipAlarms;
+ public void setSkipAttributes(boolean skipAttributes) {
+ this.skipAttributes = skipAttributes;
}
public FilterHandler() {
@@ -84,7 +84,7 @@ public class FilterHandler extends BaseDataHandler {
filterDistance = config.getInteger("filter.distance");
filterMaxSpeed = config.getInteger("filter.maxSpeed");
skipLimit = config.getLong("filter.skipLimit") * 1000;
- skipAlarms = config.getBoolean("filter.skipAlarms");
+ skipAttributes = config.getBoolean("filter.skipAttributes.enable");
}
}
@@ -145,8 +145,17 @@ public class FilterHandler extends BaseDataHandler {
return false;
}
- private boolean skipAlarms(Position position) {
- return skipAlarms && position.getAttributes().containsKey(Position.KEY_ALARM);
+ private boolean skipAttributes(Position position) {
+ if (skipAttributes) {
+ String attributesString = Context.getIdentityManager().lookupAttributeString(
+ position.getDeviceId(), "filter.skipAttributes", "", true);
+ for (String attribute : attributesString.split("[ ,]")) {
+ if (position.getAttributes().containsKey(attribute)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
private boolean filter(Position position) {
@@ -158,7 +167,7 @@ public class FilterHandler extends BaseDataHandler {
last = Context.getIdentityManager().getLastPosition(position.getDeviceId());
}
- if (skipLimit(position, last) || skipAlarms(position)) {
+ if (skipLimit(position, last) || skipAttributes(position)) {
return false;
}