Search in sources :

Example 6 with TripsConfig

use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.

the class ReportUtilsTest method testDetectStopsMoving.

@Test
public void testDetectStopsMoving() throws ParseException {
    Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 5, 0), position("2016-01-01 00:01:00.000", 5, 0), position("2016-01-01 00:02:00.000", 3, 0), position("2016-01-01 00:03:00.000", 5, 0), position("2016-01-01 00:04:00.000", 5, 0), position("2016-01-01 00:05:00.000", 5, 0));
    TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
    Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
    assertNotNull(result);
    assertTrue(result.isEmpty());
}
Also used : Position(org.traccar.model.Position) TripsConfig(org.traccar.reports.model.TripsConfig) StopReport(org.traccar.reports.model.StopReport) Test(org.junit.Test) BaseTest(org.traccar.BaseTest)

Example 7 with TripsConfig

use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.

the class ReportUtilsTest method testDetectStopsOnly.

@Test
public void testDetectStopsOnly() throws ParseException {
    Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 1, 0), position("2016-01-01 00:03:00.000", 0, 0), position("2016-01-01 00:04:00.000", 1, 0), position("2016-01-01 00:05:00.000", 0, 0));
    TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
    Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    StopReport itemStop = result.iterator().next();
    assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
    assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
    assertEquals(300000, itemStop.getDuration());
}
Also used : Position(org.traccar.model.Position) TripsConfig(org.traccar.reports.model.TripsConfig) StopReport(org.traccar.reports.model.StopReport) Test(org.junit.Test) BaseTest(org.traccar.BaseTest)

Example 8 with TripsConfig

use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.

the class ReportUtilsTest method testDetectTripAndStopByGap.

@Test
public void testDetectTripAndStopByGap() throws ParseException {
    Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 7, 100), position("2016-01-01 00:01:00.000", 7, 300), position("2016-01-01 00:02:00.000", 5, 500), position("2016-01-01 00:03:00.000", 5, 600), position("2016-01-01 00:04:00.000", 3, 700), position("2016-01-01 00:23:00.000", 2, 700), position("2016-01-01 00:24:00.000", 5, 800), position("2016-01-01 00:25:00.000", 5, 900));
    TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01);
    Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
    assertNotNull(trips);
    assertFalse(trips.isEmpty());
    TripReport itemTrip = trips.iterator().next();
    assertEquals(date("2016-01-01 00:00:00.000"), itemTrip.getStartTime());
    assertEquals(date("2016-01-01 00:04:00.000"), itemTrip.getEndTime());
    assertEquals(240000, itemTrip.getDuration());
    assertEquals(6.75, itemTrip.getAverageSpeed(), 0.01);
    assertEquals(7, itemTrip.getMaxSpeed(), 0.01);
    assertEquals(600, itemTrip.getDistance(), 0.01);
    Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
    assertNotNull(stops);
    assertFalse(stops.isEmpty());
    StopReport itemStop = stops.iterator().next();
    assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getStartTime());
    assertEquals(date("2016-01-01 00:24:00.000"), itemStop.getEndTime());
    assertEquals(1200000, itemStop.getDuration());
}
Also used : TripReport(org.traccar.reports.model.TripReport) Position(org.traccar.model.Position) TripsConfig(org.traccar.reports.model.TripsConfig) StopReport(org.traccar.reports.model.StopReport) Test(org.junit.Test) BaseTest(org.traccar.BaseTest)

Example 9 with TripsConfig

use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.

the class ReportUtilsTest method testDetectTripsWithFluctuation.

@Test
public void testDetectTripsWithFluctuation() throws ParseException {
    List<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 10, 0), 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", 10, 3000), position("2016-01-01 00:06:00.000", 10, 4000), 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));
    TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
    Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
    assertNotNull(trips);
    assertFalse(trips.isEmpty());
    TripReport itemTrip = trips.iterator().next();
    assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
    assertEquals(date("2016-01-01 00:09:00.000"), itemTrip.getEndTime());
    assertEquals(420000, itemTrip.getDuration());
    assertEquals(8.57, itemTrip.getAverageSpeed(), 0.01);
    assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
    assertEquals(7000, itemTrip.getDistance(), 0.01);
    Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
    assertNotNull(stops);
    assertFalse(stops.isEmpty());
    Iterator<StopReport> iterator = stops.iterator();
    StopReport itemStop = iterator.next();
    assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
    assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
    assertEquals(120000, itemStop.getDuration());
    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());
}
Also used : TripReport(org.traccar.reports.model.TripReport) Position(org.traccar.model.Position) TripsConfig(org.traccar.reports.model.TripsConfig) StopReport(org.traccar.reports.model.StopReport) Test(org.junit.Test) BaseTest(org.traccar.BaseTest)

Example 10 with TripsConfig

use of org.traccar.reports.model.TripsConfig in project traccar by tananaev.

the class ReportUtilsTest method testDetectTripsSimpleWithIgnition.

@Test
public void testDetectTripsSimpleWithIgnition() throws ParseException {
    List<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 10, 0), 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));
    data.get(5).set(Position.KEY_IGNITION, false);
    TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01);
    Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
    assertNotNull(trips);
    assertFalse(trips.isEmpty());
    TripReport itemTrip = trips.iterator().next();
    assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
    assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
    assertEquals(180000, itemTrip.getDuration());
    assertEquals(10, itemTrip.getAverageSpeed(), 0.01);
    assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
    assertEquals(3000, itemTrip.getDistance(), 0.01);
    trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
    assertNotNull(trips);
    assertFalse(trips.isEmpty());
    itemTrip = trips.iterator().next();
    assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
    assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
    assertEquals(180000, itemTrip.getDuration());
    assertEquals(10, itemTrip.getAverageSpeed(), 0.01);
    assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
    assertEquals(3000, itemTrip.getDistance(), 0.01);
    Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
    assertNotNull(stops);
    assertFalse(stops.isEmpty());
    Iterator<StopReport> iterator = stops.iterator();
    StopReport itemStop = iterator.next();
    assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
    assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
    assertEquals(120000, itemStop.getDuration());
    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());
}
Also used : TripReport(org.traccar.reports.model.TripReport) Position(org.traccar.model.Position) TripsConfig(org.traccar.reports.model.TripsConfig) StopReport(org.traccar.reports.model.StopReport) Test(org.junit.Test) BaseTest(org.traccar.BaseTest)

Aggregations

TripsConfig (org.traccar.reports.model.TripsConfig)12 Test (org.junit.Test)11 BaseTest (org.traccar.BaseTest)11 Position (org.traccar.model.Position)11 StopReport (org.traccar.reports.model.StopReport)8 TripReport (org.traccar.reports.model.TripReport)4 DeviceState (org.traccar.model.DeviceState)3 Event (org.traccar.model.Event)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Date (java.util.Date)1 AttributesManager (org.traccar.database.AttributesManager)1 CommandsManager (org.traccar.database.CommandsManager)1 ConnectionManager (org.traccar.database.ConnectionManager)1 DataManager (org.traccar.database.DataManager)1 DeviceManager (org.traccar.database.DeviceManager)1 DriversManager (org.traccar.database.DriversManager)1 GroupsManager (org.traccar.database.GroupsManager)1 LdapProvider (org.traccar.database.LdapProvider)1 MediaManager (org.traccar.database.MediaManager)1 PermissionsManager (org.traccar.database.PermissionsManager)1