aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-25 13:24:35 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-25 13:24:35 +0500
commitbef1a064b91d1c432fdcd38a0b84cab8c5d53b4e (patch)
treedb2387bba19d3c3cdbd593d5fb8474dcd2e6035f /src/org/traccar/reports
parent0a98a11fce24cde2904cadcfee3a0c9ac0044fe7 (diff)
downloadtrackermap-server-bef1a064b91d1c432fdcd38a0b84cab8c5d53b4e.tar.gz
trackermap-server-bef1a064b91d1c432fdcd38a0b84cab8c5d53b4e.tar.bz2
trackermap-server-bef1a064b91d1c432fdcd38a0b84cab8c5d53b4e.zip
Made trips detector behavior configurable
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r--src/org/traccar/reports/Trips.java31
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()