aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-29 08:44:12 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-29 08:44:12 +0500
commit57d2621cdf5e318a236b036a9435358121a4adf5 (patch)
treeb59d83660c9f20a63dce35518d6b380f0a6d7ed6 /src/org
parent8d489fd4290bd93b394f0066983611f25e2e103b (diff)
downloadtrackermap-server-57d2621cdf5e318a236b036a9435358121a4adf5.tar.gz
trackermap-server-57d2621cdf5e318a236b036a9435358121a4adf5.tar.bz2
trackermap-server-57d2621cdf5e318a236b036a9435358121a4adf5.zip
- Rename parameter
- Move Limit to the begining
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/FilterHandler.java30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index ff53c9e25..91fbac68f 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 filterLimit;
- private boolean allowAlarms;
+ private boolean keepAlarms;
public void setFilterInvalid(boolean filterInvalid) {
this.filterInvalid = filterInvalid;
@@ -68,8 +68,8 @@ public class FilterHandler extends BaseDataHandler {
this.filterLimit = filterLimit;
}
- public void setAllowAlarms(boolean allowAlarms) {
- this.allowAlarms = allowAlarms;
+ public void setKeepAlarms(boolean keepAlarms) {
+ this.keepAlarms = keepAlarms;
}
public FilterHandler() {
@@ -84,7 +84,7 @@ public class FilterHandler extends BaseDataHandler {
filterDistance = config.getInteger("filter.distance");
filterMaxSpeed = config.getInteger("filter.maxSpeed");
filterLimit = config.getLong("filter.limit") * 1000;
- allowAlarms = config.getBoolean("filter.allowAlarms");
+ keepAlarms = config.getBoolean("filter.keepAlarms");
}
}
@@ -132,27 +132,22 @@ public class FilterHandler extends BaseDataHandler {
private boolean filterMaxSpeed(Position position, Position last) {
if (filterMaxSpeed != 0 && last != null) {
double distance = position.getDouble(Position.KEY_DISTANCE);
- long time = position.getFixTime().getTime() - last.getFixTime().getTime();
- return UnitsConverter.knotsFromMps(distance / (time / 1000.0)) > filterMaxSpeed;
+ double time = position.getFixTime().getTime() - last.getFixTime().getTime();
+ return UnitsConverter.knotsFromMps(distance / (time / 1000)) > filterMaxSpeed;
}
return false;
}
private boolean filterLimit(Position position, Position last) {
- if (filterLimit != 0) {
- if (last != null) {
- return (position.getFixTime().getTime() - last.getFixTime().getTime()) > filterLimit;
- } else {
- return false;
- }
- } else {
- return false;
+ if (filterLimit != 0 && last != null) {
+ return (position.getFixTime().getTime() - last.getFixTime().getTime()) > filterLimit;
}
+ return false;
}
private boolean filter(Position position) {
- if (allowAlarms && position.getAttributes().containsKey(Position.KEY_ALARM)) {
+ if (keepAlarms && position.getAttributes().containsKey(Position.KEY_ALARM)) {
return false;
}
@@ -163,6 +158,9 @@ public class FilterHandler extends BaseDataHandler {
last = Context.getIdentityManager().getLastPosition(position.getDeviceId());
}
+ if (filterLimit(position, last)) {
+ filterType.append("Limit ");
+ }
if (filterInvalid(position)) {
filterType.append("Invalid ");
}
@@ -188,7 +186,7 @@ public class FilterHandler extends BaseDataHandler {
filterType.append("MaxSpeed ");
}
- if (filterType.length() > 0 && !filterLimit(position, last)) {
+ if (filterType.length() > 0) {
StringBuilder message = new StringBuilder();
message.append("Position filtered by ");