From d5c07a40ab27e3e4021f1c8a881b64cc9e43ff00 Mon Sep 17 00:00:00 2001 From: Renaud Allard Date: Mon, 17 Oct 2016 18:14:34 +0200 Subject: Log which filters have been used --- src/org/traccar/FilterHandler.java | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 1ce9e2460..8acc06935 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -150,16 +150,40 @@ public class FilterHandler extends BaseDataHandler { private boolean filter(Position p) { + String filterType = ""; + boolean result = filterInvalid(p) || filterZero(p) || filterDuplicate(p) || filterFuture(p) || filterApproximate(p) || filterStatic(p) || filterDistance(p); + if (filterInvalid(p)) { + filterType = "Invalid "; + } + if (filterZero(p)) { + filterType = (filterType + "Zero "); + } + if (filterDuplicate(p)) { + filterType = (filterType + "Duplicate "); + } + if (filterFuture(p)) { + filterType = (filterType + "Future "); + } + if (filterApproximate(p)) { + filterType = (filterType + "Approximate "); + } + if (filterStatic(p)) { + filterType = (filterType + "Static "); + } + if (filterDistance(p)) { + filterType = (filterType + "Distance "); + } + if (filterLimit(p)) { result = false; } if (result) { - Log.info("Position filtered from " + p.getDeviceId()); + Log.info("Position filtered by " + filterType + "filters from " + p.getDeviceId()); } return result; -- cgit v1.2.3 From 4b47a62d2dc0dd7f1b7ced01a7e6c7887e3840ad Mon Sep 17 00:00:00 2001 From: Renaud Allard Date: Mon, 17 Oct 2016 23:30:07 +0200 Subject: Do not double check the filter results Some cleaning in the logic --- src/org/traccar/FilterHandler.java | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 8acc06935..62df83378 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -150,36 +150,33 @@ public class FilterHandler extends BaseDataHandler { private boolean filter(Position p) { + boolean result = false; String filterType = ""; - boolean result = filterInvalid(p) || filterZero(p) || filterDuplicate(p) - || filterFuture(p) || filterApproximate(p) || filterStatic(p) - || filterDistance(p); - if (filterInvalid(p)) { - filterType = "Invalid "; + filterType = filterType + "Invalid "; } if (filterZero(p)) { - filterType = (filterType + "Zero "); + filterType = filterType + "Zero "; } if (filterDuplicate(p)) { - filterType = (filterType + "Duplicate "); + filterType = filterType + "Duplicate "; } if (filterFuture(p)) { - filterType = (filterType + "Future "); + filterType = filterType + "Future "; } if (filterApproximate(p)) { - filterType = (filterType + "Approximate "); + filterType = filterType + "Approximate "; } if (filterStatic(p)) { - filterType = (filterType + "Static "); + filterType = filterType + "Static "; } if (filterDistance(p)) { - filterType = (filterType + "Distance "); + filterType = filterType + "Distance "; } - if (filterLimit(p)) { - result = false; + if (!"".equals(filterType) && !filterLimit(p)) { + result = true; } if (result) { -- cgit v1.2.3 From 8756277141ff7549cb0a019e8f67bef58948bd59 Mon Sep 17 00:00:00 2001 From: Renaud Allard Date: Mon, 17 Oct 2016 23:42:17 +0200 Subject: Use StringBuilder for filter logging --- src/org/traccar/FilterHandler.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 62df83378..725f9c429 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -151,36 +151,36 @@ public class FilterHandler extends BaseDataHandler { private boolean filter(Position p) { boolean result = false; - String filterType = ""; + StringBuilder filterType = new StringBuilder(8 + 5 + 10 + 7 + 12 + 7 + 9); if (filterInvalid(p)) { - filterType = filterType + "Invalid "; + filterType.append("Invalid "); } if (filterZero(p)) { - filterType = filterType + "Zero "; + filterType.append("Zero "); } if (filterDuplicate(p)) { - filterType = filterType + "Duplicate "; + filterType.append("Duplicate "); } if (filterFuture(p)) { - filterType = filterType + "Future "; + filterType.append("Future "); } if (filterApproximate(p)) { - filterType = filterType + "Approximate "; + filterType.append("Approximate "); } if (filterStatic(p)) { - filterType = filterType + "Static "; + filterType.append("Static "); } if (filterDistance(p)) { - filterType = filterType + "Distance "; + filterType.append("Distance "); } - if (!"".equals(filterType) && !filterLimit(p)) { + if (!"".equals(filterType.toString()) && !filterLimit(p)) { result = true; } if (result) { - Log.info("Position filtered by " + filterType + "filters from " + p.getDeviceId()); + Log.info("Position filtered by " + filterType.toString() + "filters from " + p.getDeviceId()); } return result; -- cgit v1.2.3 From 54d48825f34b1a211960b68c98a817eedcdbba9c Mon Sep 17 00:00:00 2001 From: Renaud Allard Date: Mon, 17 Oct 2016 23:54:53 +0200 Subject: Rework the circumvoluted logic in filter logging --- src/org/traccar/FilterHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index 725f9c429..f1df7ce2c 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -175,10 +175,14 @@ public class FilterHandler extends BaseDataHandler { filterType.append("Distance "); } - if (!"".equals(filterType.toString()) && !filterLimit(p)) { + if (filterType.length() > 0) { result = true; } + if (filterLimit(p)) { + result = false; + } + if (result) { Log.info("Position filtered by " + filterType.toString() + "filters from " + p.getDeviceId()); } -- cgit v1.2.3 From c0acd034c1103cf5d38e94bd42ec183147678135 Mon Sep 17 00:00:00 2001 From: Renaud Allard Date: Tue, 18 Oct 2016 00:07:06 +0200 Subject: Rename variable p into position in filter checking --- src/org/traccar/FilterHandler.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java index f1df7ce2c..e9e3245a6 100644 --- a/src/org/traccar/FilterHandler.java +++ b/src/org/traccar/FilterHandler.java @@ -148,30 +148,30 @@ public class FilterHandler extends BaseDataHandler { } } - private boolean filter(Position p) { + private boolean filter(Position position) { boolean result = false; StringBuilder filterType = new StringBuilder(8 + 5 + 10 + 7 + 12 + 7 + 9); - if (filterInvalid(p)) { + if (filterInvalid(position)) { filterType.append("Invalid "); } - if (filterZero(p)) { + if (filterZero(position)) { filterType.append("Zero "); } - if (filterDuplicate(p)) { + if (filterDuplicate(position)) { filterType.append("Duplicate "); } - if (filterFuture(p)) { + if (filterFuture(position)) { filterType.append("Future "); } - if (filterApproximate(p)) { + if (filterApproximate(position)) { filterType.append("Approximate "); } - if (filterStatic(p)) { + if (filterStatic(position)) { filterType.append("Static "); } - if (filterDistance(p)) { + if (filterDistance(position)) { filterType.append("Distance "); } @@ -179,12 +179,12 @@ public class FilterHandler extends BaseDataHandler { result = true; } - if (filterLimit(p)) { + if (filterLimit(position)) { result = false; } if (result) { - Log.info("Position filtered by " + filterType.toString() + "filters from " + p.getDeviceId()); + Log.info("Position filtered by " + filterType.toString() + "filters from " + position.getDeviceId()); } return result; -- cgit v1.2.3