diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-10-17 21:54:15 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-17 21:54:15 +1300 |
commit | 5108e83e378fae8fe3f834fa00f3a6df63785579 (patch) | |
tree | e120d382290e39b1fc03c336c873808211499cf8 /src/org | |
parent | 83ca0476167d91f16f18ae3cc532d56cd97f743e (diff) | |
parent | 9dd22617c1b066195baca5b6e6ae141c54493107 (diff) | |
download | trackermap-server-5108e83e378fae8fe3f834fa00f3a6df63785579.tar.gz trackermap-server-5108e83e378fae8fe3f834fa00f3a6df63785579.tar.bz2 trackermap-server-5108e83e378fae8fe3f834fa00f3a6df63785579.zip |
Merge pull request #2447 from renaudallard/master
Add a static filter to filter positions with zero speed
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/FilterHandler.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 5315bad9e..b6917cbfb 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -28,12 +28,13 @@ public class FilterHandler extends BaseDataHandler { private final boolean filterDuplicate; private final boolean filterFuture; private final boolean filterApproximate; + private final boolean filterStatic; private final int filterDistance; private final long filterLimit; public FilterHandler( boolean filterInvalid, boolean filterZero, boolean filterDuplicate, boolean filterFuture, - boolean filterApproximate, int filterDistance, long filterLimit) { + boolean filterApproximate, boolean filterStatic, int filterDistance, long filterLimit) { this.filterInvalid = filterInvalid; this.filterZero = filterZero; @@ -41,6 +42,7 @@ public class FilterHandler extends BaseDataHandler { this.filterDistance = filterDistance; this.filterFuture = filterFuture; this.filterApproximate = filterApproximate; + this.filterStatic = filterStatic; this.filterLimit = filterLimit; } @@ -52,6 +54,7 @@ public class FilterHandler extends BaseDataHandler { 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; } @@ -93,6 +96,10 @@ public class FilterHandler extends BaseDataHandler { return filterApproximate && approximate != null && approximate; } + private boolean filterStatic(Position position) { + return filterStatic && position.getSpeed() == 0.0; + } + private boolean filterDistance(Position position) { if (filterDistance != 0) { Position last = getLastPosition(position.getDeviceId()); @@ -125,7 +132,8 @@ public class FilterHandler extends BaseDataHandler { private boolean filter(Position p) { boolean result = filterInvalid(p) || filterZero(p) || filterDuplicate(p) - || filterFuture(p) || filterApproximate(p) || filterDistance(p); + || filterFuture(p) || filterApproximate(p) || filterStatic(p) + || filterDistance(p); if (filterLimit(p)) { result = false; |