diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-28 16:59:18 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-28 17:16:00 +0500 |
commit | 8d489fd4290bd93b394f0066983611f25e2e103b (patch) | |
tree | 1a88091185128dd1f2769d54f0036937ee97d9ed /src | |
parent | 879a25f09033068eb8cb174c1cb3150df594f2e4 (diff) | |
download | trackermap-server-8d489fd4290bd93b394f0066983611f25e2e103b.tar.gz trackermap-server-8d489fd4290bd93b394f0066983611f25e2e103b.tar.bz2 trackermap-server-8d489fd4290bd93b394f0066983611f25e2e103b.zip |
- Do not filter alarms
- Fix division
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/FilterHandler.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 1f5fffc86..ff53c9e25 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -30,6 +30,7 @@ public class FilterHandler extends BaseDataHandler { private int filterDistance; private int filterMaxSpeed; private long filterLimit; + private boolean allowAlarms; public void setFilterInvalid(boolean filterInvalid) { this.filterInvalid = filterInvalid; @@ -67,6 +68,10 @@ public class FilterHandler extends BaseDataHandler { this.filterLimit = filterLimit; } + public void setAllowAlarms(boolean allowAlarms) { + this.allowAlarms = allowAlarms; + } + public FilterHandler() { Config config = Context.getConfig(); if (config != null) { @@ -79,6 +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"); } } @@ -127,7 +133,7 @@ public class FilterHandler extends BaseDataHandler { 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)) > filterMaxSpeed; + return UnitsConverter.knotsFromMps(distance / (time / 1000.0)) > filterMaxSpeed; } return false; } @@ -146,6 +152,10 @@ public class FilterHandler extends BaseDataHandler { private boolean filter(Position position) { + if (allowAlarms && position.getAttributes().containsKey(Position.KEY_ALARM)) { + return false; + } + StringBuilder filterType = new StringBuilder(); Position last = null; |