From ad18dad83638ac2b003596eb1b6226bb9c407abc Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 17 Aug 2017 16:37:29 +0500 Subject: Fix trip detector --- src/org/traccar/reports/ReportUtils.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 46aea0757..74cdaf9b5 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -284,17 +284,21 @@ public final class ReportUtils { for (int i = 0; i < positions.size(); i++) { Map event = motionHandler.updateMotionState(deviceState, positions.get(i), isMoving(positions, i, tripsConfig, speedThreshold)); - if (deviceState.getMotionPosition() != null && startEventIndex == -1 - && trips != deviceState.getMotionState()) { + if (startEventIndex == -1 + && (trips != deviceState.getMotionState() && deviceState.getMotionPosition() != null + || trips == deviceState.getMotionState() && event != null)) { startEventIndex = i; startNoEventIndex = -1; + } else if (trips != deviceState.getMotionState() && startEventIndex != -1 + && deviceState.getMotionPosition() == null && event == null) { + startEventIndex = -1; } - if (trips == deviceState.getMotionState()) { - if (startNoEventIndex == -1) { - startNoEventIndex = i; - } else if (deviceState.getMotionPosition() == null) { - startNoEventIndex = -1; - } + if (startNoEventIndex == -1 + && (trips == deviceState.getMotionState() && deviceState.getMotionPosition() != null + || trips != deviceState.getMotionState() && event != null)) { + startNoEventIndex = i; + } else if (startNoEventIndex != -1 && deviceState.getMotionPosition() == null && event == null) { + startNoEventIndex = -1; } if (startEventIndex != -1 && startNoEventIndex != -1 && event != null && trips != deviceState.getMotionState()) { -- cgit v1.2.3