use of org.opentripplanner.netex.loader.util.HierarchicalMapById 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());
}
use of org.opentripplanner.netex.loader.util.HierarchicalMapById in project OpenTripPlanner by opentripplanner.
the class TripMapperTest method mapTripWithRouteRefViaJourneyPattern.
@Test
public void mapTripWithRouteRefViaJourneyPattern() {
OtpTransitServiceBuilder transitBuilder = new OtpTransitServiceBuilder();
Route route = new Route();
route.setId(ID_FACTORY.createId(ROUTE_ID));
transitBuilder.getRoutes().add(route);
JourneyPattern journeyPattern = new JourneyPattern().withId(JOURNEY_PATTERN_ID);
journeyPattern.setRouteRef(new RouteRefStructure().withRef(ROUTE_ID));
ServiceJourney serviceJourney = createExampleServiceJourney();
serviceJourney.setJourneyPatternRef(MappingSupport.createWrappedRef(JOURNEY_PATTERN_ID, JourneyPatternRefStructure.class));
org.rutebanken.netex.model.Route netexRoute = new org.rutebanken.netex.model.Route();
netexRoute.setLineRef(LINE_REF);
netexRoute.setId(ROUTE_ID);
HierarchicalMapById<org.rutebanken.netex.model.Route> routeById = new HierarchicalMapById<>();
routeById.add(netexRoute);
HierarchicalMapById<JourneyPattern> journeyPatternById = new HierarchicalMapById<>();
journeyPatternById.add(journeyPattern);
TripMapper tripMapper = new TripMapper(ID_FACTORY, transitBuilder.getRoutes(), routeById, journeyPatternById, Collections.emptySet());
Trip trip = tripMapper.mapServiceJourney(serviceJourney);
assertEquals(trip.getId(), ID_FACTORY.createId("RUT:ServiceJourney:1"));
}
use of org.opentripplanner.netex.loader.util.HierarchicalMapById in project OpenTripPlanner by opentripplanner.
the class ServiceLinkMapperTest method mapServiceLinks.
@Test
public void mapServiceLinks() {
JourneyPattern journeyPattern = new JourneyPattern().withId("RUT:JourneyPattern:1300");
journeyPattern.setLinksInSequence(new LinksInJourneyPattern_RelStructure().withServiceLinkInJourneyPatternOrTimingLinkInJourneyPattern(new ServiceLinkInJourneyPattern_VersionedChildStructure().withServiceLinkRef(new ServiceLinkRefStructure().withRef("RUT:ServiceLink:1"))).withServiceLinkInJourneyPatternOrTimingLinkInJourneyPattern(new ServiceLinkInJourneyPattern_VersionedChildStructure().withServiceLinkRef(new ServiceLinkRefStructure().withRef("RUT:ServiceLink:2"))));
ServiceLink serviceLink1 = createServiceLink("RUT:ServiceLink:1", 200.0, new Double[] { COORDINATES[0], COORDINATES[1], COORDINATES[2], COORDINATES[3] });
ServiceLink serviceLink2 = createServiceLink("RUT:ServiceLink:2", 100.0, new Double[] { COORDINATES[2], COORDINATES[3], COORDINATES[4], COORDINATES[5] });
HierarchicalMapById<ServiceLink> serviceLinksById = new HierarchicalMapById<>();
serviceLinksById.add(serviceLink1);
serviceLinksById.add(serviceLink2);
Quay quay1 = new Quay().withId("NSR:Quay:1");
Quay quay2 = new Quay().withId("NSR:Quay:2");
Quay quay3 = new Quay().withId("NSR:Quay:3");
HierarchicalVersionMapById<Quay> quaysById = new HierarchicalVersionMapById<>();
quaysById.add(quay1);
quaysById.add(quay2);
quaysById.add(quay3);
HierarchicalMap<String, String> quayIdByStopPointRef = new HierarchicalMap<>();
quayIdByStopPointRef.add("RUT:StopPoint:1", "NSR:Quay:1");
quayIdByStopPointRef.add("RUT:StopPoint:2", "NSR:Quay:2");
quayIdByStopPointRef.add("RUT:StopPoint:3", "NSR:Quay:3");
ServiceLinkMapper serviceLinkMapper = new ServiceLinkMapper(new FeedScopedIdFactory("RB"), new DataImportIssueStore(false));
Collection<ShapePoint> shapePoints = serviceLinkMapper.getShapePointsByJourneyPattern(journeyPattern, serviceLinksById, quayIdByStopPointRef, quaysById);
List<ShapePoint> shapePointList = shapePoints.stream().sorted(Comparator.comparing(ShapePoint::getSequence)).collect(Collectors.toList());
Assert.assertEquals(COORDINATES[0], shapePointList.get(0).getLat(), 0.0001);
Assert.assertEquals(COORDINATES[1], shapePointList.get(0).getLon(), 0.0001);
Assert.assertEquals(COORDINATES[2], shapePointList.get(1).getLat(), 0.0001);
Assert.assertEquals(COORDINATES[3], shapePointList.get(1).getLon(), 0.0001);
Assert.assertEquals(COORDINATES[2], shapePointList.get(2).getLat(), 0.0001);
Assert.assertEquals(COORDINATES[3], shapePointList.get(2).getLon(), 0.0001);
Assert.assertEquals(COORDINATES[4], shapePointList.get(3).getLat(), 0.0001);
Assert.assertEquals(COORDINATES[5], shapePointList.get(3).getLon(), 0.0001);
}
Aggregations