diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-08-25 23:42:01 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-25 23:42:01 +1200 |
commit | dd07064905c4a25f92cbe105346783bedd75a320 (patch) | |
tree | 981a715aeff24eb451ffe2cde0f1edd8fdb6e24d /src/org/traccar/reports/Trips.java | |
parent | fb2f46db97e259059ab902236eb7817c4b14756b (diff) | |
parent | bef1a064b91d1c432fdcd38a0b84cab8c5d53b4e (diff) | |
download | traccar-server-dd07064905c4a25f92cbe105346783bedd75a320.tar.gz traccar-server-dd07064905c4a25f92cbe105346783bedd75a320.tar.bz2 traccar-server-dd07064905c4a25f92cbe105346783bedd75a320.zip |
Merge pull request #2252 from Abyss777/trips_detector
Made trips detector behavior configurable
Diffstat (limited to 'src/org/traccar/reports/Trips.java')
-rw-r--r-- | src/org/traccar/reports/Trips.java | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java index b661ffffa..2171d5f93 100644 --- a/src/org/traccar/reports/Trips.java +++ b/src/org/traccar/reports/Trips.java @@ -75,6 +75,7 @@ public final class Trips { long minimalTripDuration = Context.getConfig().getLong("report.trip.minimalTripDuration", 300) * 1000; double minimalTripDistance = Context.getConfig().getLong("report.trip.minimalTripDistance", 500); long minimalParkingDuration = Context.getConfig().getLong("report.trip.minimalParkingDuration", 300) * 1000; + boolean greedyParking = Context.getConfig().getBoolean("report.trip.greedyParking"); Collection<TripReport> result = new ArrayList<>(); ArrayList<Position> positions = new ArrayList<>(Context.getDataManager().getPositions(deviceId, from, to)); @@ -100,20 +101,28 @@ public final class Trips { endParkingIndex = i; } if (!isMoving && startParkingIndex == -1) { - long tripDuration = positions.get(i).getFixTime().getTime() - - positions.get(endParkingIndex).getFixTime().getTime(); - double tripDistance = ReportUtils.calculateDistance(positions.get(endParkingIndex), - positions.get(i), false); - tripFiltered = tripDuration < minimalTripDuration && tripDistance < minimalTripDistance; - if (tripFiltered) { - startParkingIndex = previousStartParkingIndex; - endParkingIndex = previousEndParkingIndex; - tripFiltered = false; + if (greedyParking) { + long tripDuration = positions.get(i).getFixTime().getTime() + - positions.get(endParkingIndex).getFixTime().getTime(); + double tripDistance = ReportUtils.calculateDistance(positions.get(endParkingIndex), + positions.get(i), false); + tripFiltered = tripDuration < minimalTripDuration && tripDistance < minimalTripDistance; + if (tripFiltered) { + startParkingIndex = previousStartParkingIndex; + endParkingIndex = previousEndParkingIndex; + tripFiltered = false; + } else { + previousStartParkingIndex = i; + startParkingIndex = i; + } } else { - previousStartParkingIndex = i; + long tripDuration = positions.get(i).getFixTime().getTime() + - positions.get(previousEndParkingIndex).getFixTime().getTime(); + double tripDistance = ReportUtils.calculateDistance(positions.get(previousEndParkingIndex), + positions.get(i), false); + tripFiltered = tripDuration < minimalTripDuration && tripDistance < minimalTripDistance; startParkingIndex = i; } - } if (startParkingIndex != -1 && (endParkingIndex > startParkingIndex || isLast)) { long parkingDuration = positions.get(endParkingIndex).getFixTime().getTime() |