aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-02-23 16:20:23 -0800
committerAnton Tananaev <anton@traccar.org>2023-02-23 16:20:23 -0800
commit2ac77554f7771a014d62a6e5eeb381b4650dc4f4 (patch)
treee7a31b0c19cfabef33427d964f2af8f77e4745ce /src
parentb943cdbc7bce5d28e9c32b16b17bf3da6380e031 (diff)
downloadtrackermap-server-2ac77554f7771a014d62a6e5eeb381b4650dc4f4.tar.gz
trackermap-server-2ac77554f7771a014d62a6e5eeb381b4650dc4f4.tar.bz2
trackermap-server-2ac77554f7771a014d62a6e5eeb381b4650dc4f4.zip
Fix short trips and stops
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java2
-rw-r--r--src/test/java/org/traccar/reports/ReportUtilsTest.java34
2 files changed, 18 insertions, 18 deletions
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index a7c420095..35faa9c8b 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -386,7 +386,7 @@ public class ReportUtils {
}
}
}
- if (startEventIndex >= 0 && startEventIndex < positions.size() - 1) {
+ if (detected & startEventIndex >= 0 && startEventIndex < positions.size() - 1) {
int endIndex = startNoEventIndex >= 0 ? startNoEventIndex : positions.size() - 1;
result.add(calculateTripOrStop(
device, positions, startEventIndex, endIndex, ignoreOdometer, reportClass));
diff --git a/src/test/java/org/traccar/reports/ReportUtilsTest.java b/src/test/java/org/traccar/reports/ReportUtilsTest.java
index 4bf668064..aa166dc25 100644
--- a/src/test/java/org/traccar/reports/ReportUtilsTest.java
+++ b/src/test/java/org/traccar/reports/ReportUtilsTest.java
@@ -98,8 +98,8 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:03:00.000", 10, 1000),
position("2016-01-01 00:04:00.000", 10, 2000),
position("2016-01-01 00:05:00.000", 0, 3000),
- position("2016-01-01 00:06:00.000", 0, 3000),
- position("2016-01-01 00:07:00.000", 0, 3000));
+ position("2016-01-01 00:15:00.000", 0, 3000),
+ position("2016-01-01 00:25:00.000", 0, 3000));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
ReportUtils reportUtils = new ReportUtils(
@@ -136,8 +136,8 @@ public class ReportUtilsTest extends BaseTest {
itemStop = iterator.next();
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getStartTime());
- assertEquals(date("2016-01-01 00:07:00.000"), itemStop.getEndTime());
- assertEquals(120000, itemStop.getDuration());
+ assertEquals(date("2016-01-01 00:25:00.000"), itemStop.getEndTime());
+ assertEquals(1200000, itemStop.getDuration());
}
@@ -151,8 +151,8 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:03:00.000", 10, 1000),
position("2016-01-01 00:04:00.000", 10, 2000),
position("2016-01-01 00:05:00.000", 0, 3000),
- position("2016-01-01 00:06:00.000", 0, 3000),
- position("2016-01-01 00:07:00.000", 0, 3000));
+ position("2016-01-01 00:15:00.000", 0, 3000),
+ position("2016-01-01 00:25:00.000", 0, 3000));
data.get(5).set(Position.KEY_IGNITION, false);
@@ -205,8 +205,8 @@ public class ReportUtilsTest extends BaseTest {
itemStop = iterator.next();
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getStartTime());
- assertEquals(date("2016-01-01 00:07:00.000"), itemStop.getEndTime());
- assertEquals(120000, itemStop.getDuration());
+ assertEquals(date("2016-01-01 00:25:00.000"), itemStop.getEndTime());
+ assertEquals(1200000, itemStop.getDuration());
}
@@ -224,8 +224,8 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:07:00.000", 0, 5000),
position("2016-01-01 00:08:00.000", 10, 6000),
position("2016-01-01 00:09:00.000", 0, 7000),
- position("2016-01-01 00:10:00.000", 0, 7000),
- position("2016-01-01 00:11:00.000", 0, 7000));
+ position("2016-01-01 00:19:00.000", 0, 7000),
+ position("2016-01-01 00:29:00.000", 0, 7000));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
ReportUtils reportUtils = new ReportUtils(
@@ -262,8 +262,8 @@ public class ReportUtilsTest extends BaseTest {
itemStop = iterator.next();
assertEquals(date("2016-01-01 00:09:00.000"), itemStop.getStartTime());
- assertEquals(date("2016-01-01 00:11:00.000"), itemStop.getEndTime());
- assertEquals(120000, itemStop.getDuration());
+ assertEquals(date("2016-01-01 00:29:00.000"), itemStop.getEndTime());
+ assertEquals(1200000, itemStop.getDuration());
}
@@ -332,9 +332,9 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:00:00.000", 2, 0),
position("2016-01-01 00:01:00.000", 1, 0),
position("2016-01-01 00:02:00.000", 0, 0),
- position("2016-01-01 00:03:00.000", 0, 0),
- position("2016-01-01 00:04:00.000", 0, 0),
- position("2016-01-01 00:05:00.000", 0, 0));
+ position("2016-01-01 00:12:00.000", 0, 0),
+ position("2016-01-01 00:22:00.000", 0, 0),
+ position("2016-01-01 00:32:00.000", 0, 0));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
ReportUtils reportUtils = new ReportUtils(
@@ -349,8 +349,8 @@ public class ReportUtilsTest extends BaseTest {
StopReportItem itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getStartTime());
- assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
- assertEquals(180000, itemStop.getDuration());
+ assertEquals(date("2016-01-01 00:32:00.000"), itemStop.getEndTime());
+ assertEquals(1800000, itemStop.getDuration());
}