use of org.rutebanken.netex.model.JourneyPattern in project OpenTripPlanner by opentripplanner.
the class NetexMapper method mapTripPatterns.
private void mapTripPatterns(NetexImportDataIndexReadOnlyView netexIndex) {
TripPatternMapper tripPatternMapper = new TripPatternMapper(idFactory, transitBuilder.getStops(), transitBuilder.getRoutes(), transitBuilder.getShapePoints().keySet(), netexIndex.getRouteById(), netexIndex.getJourneyPatternsById(), netexIndex.getQuayIdByStopPointRef(), netexIndex.getDestinationDisplayById(), netexIndex.getServiceJourneyByPatternId(), deduplicator);
for (JourneyPattern journeyPattern : netexIndex.getJourneyPatternsById().localValues()) {
TripPatternMapper.Result result = tripPatternMapper.mapTripPattern(journeyPattern);
for (Map.Entry<Trip, List<StopTime>> it : result.tripStopTimes.entrySet()) {
transitBuilder.getStopTimesSortedByTrip().put(it.getKey(), it.getValue());
transitBuilder.getTripsById().add(it.getKey());
}
for (TripPattern it : result.tripPatterns) {
transitBuilder.getTripPatterns().put(it.stopPattern, it);
}
stopTimesByNetexId.putAll(result.stopTimeByNetexId);
}
}
use of org.rutebanken.netex.model.JourneyPattern 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.rutebanken.netex.model.JourneyPattern in project OpenTripPlanner by opentripplanner.
the class NetexImportDataIndexTest method lookupJourneyPatternById.
@Test
public void lookupJourneyPatternById() {
JourneyPattern value = new JourneyPattern().withId(ID);
root.journeyPatternsById.add(value);
assertEquals(value, child.journeyPatternsById.lookup(ID));
}
use of org.rutebanken.netex.model.JourneyPattern 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);
}
use of org.rutebanken.netex.model.JourneyPattern in project OpenTripPlanner by opentripplanner.
the class NetexImportDataIndex method readOnlyView.
public NetexImportDataIndexReadOnlyView readOnlyView() {
return new NetexImportDataIndexReadOnlyView() {
/**
* Lookup a Network given a GroupOfLine id or an Network id. If the given
* {@code groupOfLineOrNetworkId} is a GroupOfLine ID, we lookup the GroupOfLine, and then
* lookup its Network. If the given {@code groupOfLineOrNetworkId} is a Network ID then we
* can lookup the Network directly.
* <p/>
* If no Network is found {@code null} is returned.
*/
public Network lookupNetworkForLine(String groupOfLineOrNetworkId) {
GroupOfLines groupOfLines = groupOfLinesById.lookup(groupOfLineOrNetworkId);
String networkId = groupOfLines == null ? groupOfLineOrNetworkId : networkIdByGroupOfLineId.lookup(groupOfLines.getId());
return networkById.lookup(networkId);
}
public ReadOnlyHierarchicalMapById<Authority> getAuthoritiesById() {
return authoritiesById;
}
public ReadOnlyHierarchicalMapById<DayType> getDayTypeById() {
return dayTypeById;
}
public ReadOnlyHierarchicalMap<String, Collection<DayTypeAssignment>> getDayTypeAssignmentByDayTypeId() {
return dayTypeAssignmentByDayTypeId;
}
public Iterable<DayTypeRefsToServiceIdAdapter> getDayTypeRefs() {
return Collections.unmodifiableSet(dayTypeRefs);
}
public ReadOnlyHierarchicalMapById<DestinationDisplay> getDestinationDisplayById() {
return destinationDisplayById;
}
public ReadOnlyHierarchicalMapById<GroupOfStopPlaces> getGroupOfStopPlacesById() {
return groupOfStopPlacesById;
}
public ReadOnlyHierarchicalMapById<JourneyPattern> getJourneyPatternsById() {
return journeyPatternsById;
}
public ReadOnlyHierarchicalMapById<Line> getLineById() {
return lineById;
}
public ReadOnlyHierarchicalMapById<StopPlace> getMultiModalStopPlaceById() {
return multiModalStopPlaceById;
}
public ReadOnlyHierarchicalMapById<Notice> getNoticeById() {
return noticeById;
}
public ReadOnlyHierarchicalMapById<NoticeAssignment> getNoticeAssignmentById() {
return noticeAssignmentById;
}
public ReadOnlyHierarchicalMapById<OperatingPeriod> getOperatingPeriodById() {
return operatingPeriodById;
}
public ReadOnlyHierarchicalMapById<Operator> getOperatorsById() {
return operatorsById;
}
public ReadOnlyHierarchicalMap<String, Collection<TimetabledPassingTime>> getPassingTimeByStopPointId() {
return passingTimeByStopPointId;
}
public ReadOnlyHierarchicalVersionMapById<Quay> getQuayById() {
return quayById;
}
public ReadOnlyHierarchicalMap<String, String> getQuayIdByStopPointRef() {
return quayIdByStopPointRef;
}
public ReadOnlyHierarchicalMapById<Route> getRouteById() {
return routeById;
}
public ReadOnlyHierarchicalMap<String, Collection<ServiceJourney>> getServiceJourneyByPatternId() {
return serviceJourneyByPatternId;
}
public ReadOnlyHierarchicalMapById<ServiceLink> getServiceLinkById() {
return serviceLinkById;
}
public ReadOnlyHierarchicalVersionMapById<StopPlace> getStopPlaceById() {
return stopPlaceById;
}
public ReadOnlyHierarchicalMapById<TariffZone> getTariffZonesById() {
return tariffZonesById;
}
public String getTimeZone() {
return timeZone.get();
}
};
}
Aggregations