aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/ReportUtils.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-06-15 22:06:20 +1200
committerGitHub <noreply@github.com>2017-06-15 22:06:20 +1200
commit6c3d168ed9240ed4b5485b537294db6ec9d94379 (patch)
tree6904733446c33f39e26ea34a0f6072b7c3969c80 /src/org/traccar/reports/ReportUtils.java
parentf4b7d595334a12bd612575e36c8e2ebf7253c8a4 (diff)
parent2aa95dfab102e6e0f40a425bb4fdcecf55940ec8 (diff)
downloadtrackermap-server-6c3d168ed9240ed4b5485b537294db6ec9d94379.tar.gz
trackermap-server-6c3d168ed9240ed4b5485b537294db6ec9d94379.tar.bz2
trackermap-server-6c3d168ed9240ed4b5485b537294db6ec9d94379.zip
Merge pull request #3252 from Abyss777/trips_by_gaps
Detect Trips and Stops by gaps in data
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r--src/org/traccar/reports/ReportUtils.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index ead50571a..1e004beae 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -132,7 +132,8 @@ public final class ReportUtils {
Context.getConfig().getLong("report.trip.minimalTripDuration", 300) * 1000,
Context.getConfig().getLong("report.trip.minimalTripDistance", 500),
Context.getConfig().getLong("report.trip.minimalParkingDuration", 300) * 1000,
- Context.getConfig().getBoolean("report.trip.greedyParking"));
+ Context.getConfig().getBoolean("report.trip.greedyParking"),
+ Context.getConfig().getLong("report.trip.minimalNoDataDuration", 3600) * 1000);
}
private static TripReport calculateTrip(
@@ -212,6 +213,16 @@ public final class ReportUtils {
}
+ private static boolean isMoving(ArrayList<Position> positions, int index,
+ TripsConfig tripsConfig, double speedThreshold) {
+ if (tripsConfig.getMinimalNoDataDuration() > 0 && index < positions.size() - 1
+ && positions.get(index + 1).getFixTime().getTime() - positions.get(index).getFixTime().getTime()
+ >= tripsConfig.getMinimalNoDataDuration()) {
+ return false;
+ }
+ return positions.get(index).getSpeed() > speedThreshold;
+ }
+
public static Collection<BaseReport> detectTripsAndStops(TripsConfig tripsConfig, boolean ignoreOdometer,
double speedThreshold, Collection<Position> positionCollection, boolean trips) {
@@ -230,7 +241,7 @@ public final class ReportUtils {
boolean tripFiltered = false;
for (int i = 0; i < positions.size(); i++) {
- isMoving = positions.get(i).getSpeed() > speedThreshold;
+ isMoving = isMoving(positions, i, tripsConfig, speedThreshold);
isLast = i == positions.size() - 1;
if ((isMoving || isLast) && startParkingIndex != -1) {