diff options
-rw-r--r-- | src/org/traccar/Context.java | 3 | ||||
-rw-r--r-- | src/org/traccar/events/FuelDropEventHandler.java | 2 | ||||
-rw-r--r-- | src/org/traccar/events/MotionEventHandler.java | 3 | ||||
-rw-r--r-- | src/org/traccar/reports/model/TripsConfig.java | 13 | ||||
-rw-r--r-- | test/org/traccar/events/MotionEventHandlerTest.java | 6 | ||||
-rw-r--r-- | test/org/traccar/reports/ReportUtilsTest.java | 16 |
6 files changed, 28 insertions, 15 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 340eb742c..cf857178f 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -258,7 +258,8 @@ public final class Context { config.getLong("report.trip.minimalTripDuration", 300) * 1000, config.getLong("report.trip.minimalParkingDuration", 300) * 1000, config.getLong("report.trip.minimalNoDataDuration", 3600) * 1000, - config.getBoolean("report.trip.useIgnition")); + config.getBoolean("report.trip.useIgnition"), + config.getBoolean("event.motion.processInvalidPositions")); } public static void init(String[] arguments) throws Exception { diff --git a/src/org/traccar/events/FuelDropEventHandler.java b/src/org/traccar/events/FuelDropEventHandler.java index 4fc512162..2ee3e1a58 100644 --- a/src/org/traccar/events/FuelDropEventHandler.java +++ b/src/org/traccar/events/FuelDropEventHandler.java @@ -35,7 +35,7 @@ public class FuelDropEventHandler extends BaseEventHandler { if (device == null) { return null; } - if (!Context.getIdentityManager().isLatestPosition(position) || !position.getValid()) { + if (!Context.getIdentityManager().isLatestPosition(position)) { return null; } diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java index ae64c10ea..0c1c4848f 100644 --- a/src/org/traccar/events/MotionEventHandler.java +++ b/src/org/traccar/events/MotionEventHandler.java @@ -109,7 +109,8 @@ public class MotionEventHandler extends BaseEventHandler { if (device == null) { return null; } - if (!Context.getIdentityManager().isLatestPosition(position) || !position.getValid()) { + if (!Context.getIdentityManager().isLatestPosition(position) + || !tripsConfig.getProcessInvalidPositions() && !position.getValid()) { return null; } diff --git a/src/org/traccar/reports/model/TripsConfig.java b/src/org/traccar/reports/model/TripsConfig.java index 22fddd072..ca361a466 100644 --- a/src/org/traccar/reports/model/TripsConfig.java +++ b/src/org/traccar/reports/model/TripsConfig.java @@ -22,12 +22,13 @@ public class TripsConfig { } public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, - long minimalNoDataDuration, boolean useIgnition) { + long minimalNoDataDuration, boolean useIgnition, boolean processInvalidPositions) { this.minimalTripDistance = minimalTripDistance; this.minimalTripDuration = minimalTripDuration; this.minimalParkingDuration = minimalParkingDuration; this.minimalNoDataDuration = minimalNoDataDuration; this.useIgnition = useIgnition; + this.processInvalidPositions = processInvalidPositions; } private double minimalTripDistance; @@ -80,4 +81,14 @@ public class TripsConfig { this.useIgnition = useIgnition; } + private boolean processInvalidPositions; + + public boolean getProcessInvalidPositions() { + return processInvalidPositions; + } + + public void setProcessInvalidPositions(boolean processInvalidPositions) { + this.processInvalidPositions = processInvalidPositions; + } + } diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java index b88328e58..a2e5cf651 100644 --- a/test/org/traccar/events/MotionEventHandlerTest.java +++ b/test/org/traccar/events/MotionEventHandlerTest.java @@ -31,7 +31,7 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testMotionWithPosition() throws Exception { MotionEventHandler motionEventHandler = new MotionEventHandler( - new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false)); + new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false)); Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); @@ -72,7 +72,7 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testMotionWithStatus() throws Exception { MotionEventHandler motionEventHandler = new MotionEventHandler( - new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false)); + new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false)); Position position = new Position(); position.setTime(new Date(System.currentTimeMillis() - 360000)); @@ -93,7 +93,7 @@ public class MotionEventHandlerTest extends BaseTest { @Test public void testStopWithPositionIgnition() throws Exception { MotionEventHandler motionEventHandler = new MotionEventHandler( - new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true)); + new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false)); Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java index 261291255..23fdbd0b1 100644 --- a/test/org/traccar/reports/ReportUtilsTest.java +++ b/test/org/traccar/reports/ReportUtilsTest.java @@ -80,7 +80,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:06:00.000", 0, 3000), position("2016-01-01 00:07:00.000", 0, 3000)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false); Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); @@ -132,7 +132,7 @@ public class ReportUtilsTest extends BaseTest { data.get(5).set(Position.KEY_IGNITION, false); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false); Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); @@ -200,7 +200,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:10:00.000", 0, 7000), position("2016-01-01 00:11:00.000", 0, 7000)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false); Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); @@ -248,7 +248,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 1, 0), position("2016-01-01 00:05:00.000", 0, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); @@ -274,7 +274,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 1, 0), position("2016-01-01 00:05:00.000", 2, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); @@ -300,7 +300,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 0, 0), position("2016-01-01 00:05:00.000", 0, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); @@ -326,7 +326,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:04:00.000", 5, 0), position("2016-01-01 00:05:00.000", 5, 0)); - TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false); Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, StopReport.class); @@ -348,7 +348,7 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:24:00.000", 5, 800), position("2016-01-01 00:25:00.000", 5, 900)); - TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false); + TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false); Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, 0.01, TripReport.class); |