Search in sources :

Example 21 with Trip

use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.

the class TestSpecificTransfer method testSpecificTransfer.

/**
 * Test different specific transfers
 */
public void testSpecificTransfer() {
    // Setup from trip with route
    Route fromRoute = new Route();
    fromRoute.setId(new FeedScopedId("A1", "R1"));
    Trip fromTrip = new Trip();
    fromTrip.setId(new FeedScopedId("A1", "T1"));
    fromTrip.setRoute(fromRoute);
    // Setup to trip with route
    Route toRoute = new Route();
    toRoute.setId(new FeedScopedId("A1", "R2"));
    Trip toTrip = new Trip();
    toTrip.setId(new FeedScopedId("A1", "T2"));
    toTrip.setRoute(toRoute);
    // Create full SpecificTransfer
    SpecificTransfer s1 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), fromTrip.getId(), toTrip.getId(), 1);
    assertTrue(s1.matches(fromTrip, toTrip));
    assertTrue(s1.getSpecificity() == SpecificTransfer.MAX_SPECIFICITY);
    assertTrue(s1.transferTime == 1);
    // Create empty SpecificTransfer
    SpecificTransfer s2 = new SpecificTransfer((FeedScopedId) null, null, null, null, 2);
    assertTrue(s2.matches(fromTrip, toTrip));
    assertTrue(s2.getSpecificity() == SpecificTransfer.MIN_SPECIFICITY);
    assertTrue(s2.transferTime == 2);
    // Create SpecificTransfer one trip missing
    SpecificTransfer s3 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), null, toTrip.getId(), 3);
    assertTrue(s3.matches(fromTrip, toTrip));
    assertTrue(s3.getSpecificity() == 3);
    assertTrue(s3.transferTime == 3);
    // Create SpecificTransfer one trip different
    SpecificTransfer s4 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), new FeedScopedId("A1", "T3"), toTrip.getId(), 4);
    assertFalse(s4.matches(fromTrip, toTrip));
    assertTrue(s4.getSpecificity() == SpecificTransfer.MAX_SPECIFICITY);
    assertTrue(s4.transferTime == 4);
    // Create SpecificTransfer one trip and route missing
    SpecificTransfer s5 = new SpecificTransfer(null, toRoute.getId(), null, toTrip.getId(), 5);
    assertTrue(s5.matches(fromTrip, toTrip));
    assertTrue(s5.getSpecificity() == 2);
    assertTrue(s5.transferTime == 5);
    // Create SpecificTransfer one trip only
    SpecificTransfer s6 = new SpecificTransfer(null, null, null, toTrip.getId(), 6);
    assertTrue(s6.matches(fromTrip, toTrip));
    assertTrue(s6.getSpecificity() == 2);
    assertTrue(s6.transferTime == 6);
    // Create SpecificTransfer one route only
    SpecificTransfer s7 = new SpecificTransfer(fromRoute.getId(), null, null, null, 7);
    assertTrue(s7.matches(fromTrip, toTrip));
    assertTrue(s7.getSpecificity() == 1);
    assertTrue(s7.transferTime == 7);
}
Also used : Trip(org.opentripplanner.model.Trip) FeedScopedId(org.opentripplanner.model.FeedScopedId) Route(org.opentripplanner.model.Route)

Example 22 with Trip

use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.

the class ToStringBuilderTest method addTransitEntity.

@Test
public void addTransitEntity() {
    Trip trip = new Trip();
    trip.setId(new FeedScopedId("F", "1"));
    assertEquals("ToStringBuilderTest{tripId: F:1}", subject().addEntityId("tripId", trip).toString());
}
Also used : Trip(org.opentripplanner.model.Trip) FeedScopedId(org.opentripplanner.model.FeedScopedId) Test(org.junit.Test)

Example 23 with Trip

use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.

the class NoticeAssignmentMapperTest method mapNoticeAssignmentOnStopPoint.

@Test
public void mapNoticeAssignmentOnStopPoint() {
    HierarchicalMultimap<String, TimetabledPassingTime> passingTimeByStopPointId = new HierarchicalMultimap<>();
    HierarchicalMapById<Notice> noticesById = new HierarchicalMapById<>();
    passingTimeByStopPointId.add(STOP_POINT_ID, new TimetabledPassingTime().withId(TIMETABLED_PASSING_TIME1));
    passingTimeByStopPointId.add(STOP_POINT_ID, new TimetabledPassingTime().withId(TIMETABLED_PASSING_TIME2));
    Trip trip = new Trip();
    trip.setId(new FeedScopedId("T", "1"));
    StopTime stopTime1 = createStopTime(1, trip);
    StopTime stopTime2 = createStopTime(2, trip);
    Map<String, StopTime> stopTimesById = new HashMap<>();
    stopTimesById.put(TIMETABLED_PASSING_TIME1, stopTime1);
    stopTimesById.put(TIMETABLED_PASSING_TIME2, stopTime2);
    noticesById.add(NOTICE);
    NoticeAssignment noticeAssignment = new NoticeAssignment().withNoticedObjectRef(new VersionOfObjectRefStructure().withRef(STOP_POINT_ID)).withNoticeRef(new NoticeRefStructure().withRef(NOTICE_ID));
    NoticeAssignmentMapper noticeAssignmentMapper = new NoticeAssignmentMapper(MappingSupport.ID_FACTORY, passingTimeByStopPointId, noticesById, new EntityById<>(), new EntityById<>(), stopTimesById);
    Multimap<TransitEntity<?>, org.opentripplanner.model.Notice> noticesByElement = noticeAssignmentMapper.map(noticeAssignment);
    org.opentripplanner.model.Notice notice2a = noticesByElement.get(stopTime1.getId()).stream().findFirst().orElseThrow(IllegalStateException::new);
    org.opentripplanner.model.Notice notice2b = noticesByElement.get(stopTime2.getId()).stream().findFirst().orElseThrow(IllegalStateException::new);
    assertEquals(NOTICE_ID, notice2a.getId().getId());
    assertEquals(NOTICE_ID, notice2b.getId().getId());
}
Also used : Trip(org.opentripplanner.model.Trip) NoticeRefStructure(org.rutebanken.netex.model.NoticeRefStructure) VersionOfObjectRefStructure(org.rutebanken.netex.model.VersionOfObjectRefStructure) HashMap(java.util.HashMap) TransitEntity(org.opentripplanner.model.TransitEntity) MultilingualString(org.rutebanken.netex.model.MultilingualString) HierarchicalMultimap(org.opentripplanner.netex.loader.util.HierarchicalMultimap) HierarchicalMapById(org.opentripplanner.netex.loader.util.HierarchicalMapById) TimetabledPassingTime(org.rutebanken.netex.model.TimetabledPassingTime) Notice(org.rutebanken.netex.model.Notice) FeedScopedId(org.opentripplanner.model.FeedScopedId) NoticeAssignment(org.rutebanken.netex.model.NoticeAssignment) StopTime(org.opentripplanner.model.StopTime) Test(org.junit.Test)

Example 24 with Trip

use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.

the class OtpTransitServiceBuilderLimitPeriodTest method createTrip.

private Trip createTrip(String id, FeedScopedId serviceId) {
    Trip trip = new Trip();
    trip.setId(new FeedScopedId(FEED_ID, id));
    trip.setServiceId(serviceId);
    trip.setDirectionId("1");
    trip.setRoute(route);
    return trip;
}
Also used : Trip(org.opentripplanner.model.Trip) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 25 with Trip

use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.

the class OtpTransitServiceBuilderLimitPeriodTest method createTripPattern.

private TripPattern createTripPattern(Collection<Trip> trips) {
    TripPattern p = new TripPattern(route, STOP_PATTERN);
    p.setId(new FeedScopedId(FEED_ID, trips.stream().map(t -> t.getId().getId()).collect(Collectors.joining(":"))));
    p.name = "Pattern";
    for (Trip trip : trips) {
        p.add(new TripTimes(trip, STOP_TIMES, DEDUPLICATOR));
    }
    return p;
}
Also used : FeedScopedId(org.opentripplanner.model.FeedScopedId) Trip(org.opentripplanner.model.Trip) TripPattern(org.opentripplanner.model.TripPattern) Stop(org.opentripplanner.model.Stop) Collection(java.util.Collection) ServiceCalendar(org.opentripplanner.model.calendar.ServiceCalendar) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) StopTime(org.opentripplanner.model.StopTime) Collectors(java.util.stream.Collectors) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) List(java.util.List) Route(org.opentripplanner.model.Route) StopPattern(org.opentripplanner.model.StopPattern) ServiceCalendarDate(org.opentripplanner.model.calendar.ServiceCalendarDate) Deduplicator(org.opentripplanner.routing.trippattern.Deduplicator) TraverseMode(org.opentripplanner.routing.core.TraverseMode) TransitMode(org.opentripplanner.model.TransitMode) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) ServiceDateInterval(org.opentripplanner.model.calendar.ServiceDateInterval) Trip(org.opentripplanner.model.Trip) FeedScopedId(org.opentripplanner.model.FeedScopedId) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) TripPattern(org.opentripplanner.model.TripPattern)

Aggregations

Trip (org.opentripplanner.model.Trip)58 FeedScopedId (org.opentripplanner.model.FeedScopedId)29 TripPattern (org.opentripplanner.model.TripPattern)28 Stop (org.opentripplanner.model.Stop)20 Test (org.junit.Test)19 Route (org.opentripplanner.model.Route)15 ArrayList (java.util.ArrayList)13 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)13 StopTime (org.opentripplanner.model.StopTime)10 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)9 ZonedDateTime (java.time.ZonedDateTime)7 HashSet (java.util.HashSet)7 List (java.util.List)6 Agency (org.opentripplanner.model.Agency)6 Timetable (org.opentripplanner.model.Timetable)6 RoutingService (org.opentripplanner.routing.RoutingService)5 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 Station (org.opentripplanner.model.Station)4 TimetableSnapshot (org.opentripplanner.model.TimetableSnapshot)4