Search in sources :

Example 11 with StopTime

use of org.opentripplanner.model.StopTime 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 12 with StopTime

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

the class OtpTransitServiceImplTest method testGetAllStopTimes.

@Test
public void testGetAllStopTimes() {
    List<StopTime> stopTimes = new ArrayList<>();
    for (Trip trip : subject.getAllTrips()) {
        stopTimes.addAll(subject.getStopTimesForTrip(trip));
    }
    assertEquals(80, stopTimes.size());
    assertEquals("StopTime(seq=1 stop=Z:A trip=agency:1.1 times=00:00:00-00:00:00)", first(stopTimes).toString());
}
Also used : Trip(org.opentripplanner.model.Trip) ArrayList(java.util.ArrayList) StopTime(org.opentripplanner.model.StopTime) Test(org.junit.Test)

Example 13 with StopTime

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

the class OtpTransitServiceBuilderLimitPeriodTest method createStopTime.

private static StopTime createStopTime(Stop stop, int time) {
    StopTime st = new StopTime();
    st.setStop(stop);
    st.setDepartureTime(time);
    st.setArrivalTime(time);
    st.setPickupType(1);
    st.setDropOffType(1);
    return st;
}
Also used : StopTime(org.opentripplanner.model.StopTime)

Example 14 with StopTime

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

the class TripTimesTest method testApply.

@Test
public void testApply() {
    Trip trip = new Trip();
    trip.setId(tripId);
    List<StopTime> stopTimes = new LinkedList<StopTime>();
    StopTime stopTime0 = new StopTime();
    StopTime stopTime1 = new StopTime();
    StopTime stopTime2 = new StopTime();
    Stop stop0 = Stop.stopForTest(stops[0].getId(), 0.0, 0.0);
    Stop stop1 = Stop.stopForTest(stops[1].getId(), 0.0, 0.0);
    Stop stop2 = Stop.stopForTest(stops[2].getId(), 0.0, 0.0);
    stopTime0.setStop(stop0);
    stopTime0.setDepartureTime(0);
    stopTime0.setStopSequence(0);
    stopTime1.setStop(stop1);
    stopTime1.setArrivalTime(30);
    stopTime1.setDepartureTime(60);
    stopTime1.setStopSequence(1);
    stopTime2.setStop(stop2);
    stopTime2.setArrivalTime(90);
    stopTime2.setStopSequence(2);
    stopTimes.add(stopTime0);
    stopTimes.add(stopTime1);
    stopTimes.add(stopTime2);
    TripTimes differingTripTimes = new TripTimes(trip, stopTimes, new Deduplicator());
    TripTimes updatedTripTimesA = new TripTimes(differingTripTimes);
    updatedTripTimesA.updateArrivalTime(1, 89);
    updatedTripTimesA.updateDepartureTime(1, 98);
    assertFalse(updatedTripTimesA.timesIncreasing());
}
Also used : Trip(org.opentripplanner.model.Trip) Stop(org.opentripplanner.model.Stop) LinkedList(java.util.LinkedList) StopTime(org.opentripplanner.model.StopTime) Test(org.junit.Test)

Example 15 with StopTime

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

the class StopTimesMapperTest method testMapStopTimes.

@Test
public void testMapStopTimes() {
    NetexTestDataSample sample = new NetexTestDataSample();
    StopTimesMapper stopTimesMapper = new StopTimesMapper(MappingSupport.ID_FACTORY, sample.getStopsById(), sample.getDestinationDisplayById(), sample.getQuayIdByStopPointRef());
    StopTimesMapper.MappedStopTimes result = stopTimesMapper.mapToStopTimes(sample.getJourneyPattern(), new Trip(), sample.getTimetabledPassingTimes());
    List<StopTime> stopTimes = result.stopTimes;
    assertEquals(4, stopTimes.size());
    assertStop(stopTimes.get(0), "NSR:Quay:1", 18000, "Bergen");
    assertStop(stopTimes.get(1), "NSR:Quay:2", 18240, "Bergen");
    assertStop(stopTimes.get(2), "NSR:Quay:3", 18600, "Stavanger");
    assertStop(stopTimes.get(3), "NSR:Quay:4", 18900, "Stavanger");
    Map<String, StopTime> map = result.stopTimeByNetexId;
    assertEquals(stopTimes.get(0), map.get("TTPT-1"));
    assertEquals(stopTimes.get(1), map.get("TTPT-2"));
    assertEquals(stopTimes.get(2), map.get("TTPT-3"));
    assertEquals(stopTimes.get(3), map.get("TTPT-4"));
}
Also used : Trip(org.opentripplanner.model.Trip) StopTime(org.opentripplanner.model.StopTime) Test(org.junit.Test)

Aggregations

StopTime (org.opentripplanner.model.StopTime)25 Trip (org.opentripplanner.model.Trip)9 Stop (org.opentripplanner.model.Stop)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)5 FeedScopedId (org.opentripplanner.model.FeedScopedId)4 TripPattern (org.opentripplanner.model.TripPattern)4 ZonedDateTime (java.time.ZonedDateTime)3 HashSet (java.util.HashSet)3 StopPattern (org.opentripplanner.model.StopPattern)3 EstimatedCall (uk.org.siri.siri20.EstimatedCall)3 TIntList (gnu.trove.list.TIntList)2 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 LinkedList (java.util.LinkedList)2 LineString (org.locationtech.jts.geom.LineString)2 TimetableHelper.createUpdatedTripTimes (org.opentripplanner.ext.siri.TimetableHelper.createUpdatedTripTimes)2 Route (org.opentripplanner.model.Route)2 ShapePoint (org.opentripplanner.model.ShapePoint)2 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)2