Search in sources :

Example 1 with Line

use of org.rutebanken.netex.model.Line in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method mapRouteWithAgencySpecified.

@Test
public void mapRouteWithAgencySpecified() {
    NetexImportDataIndex netexIndex = new NetexImportDataIndex();
    OtpTransitServiceBuilder transitBuilder = new OtpTransitServiceBuilder();
    Network network = new Network().withId(NETWORK_ID).withTransportOrganisationRef(createJaxbElement(new OrganisationRefStructure().withRef(AUTHORITY_ID)));
    netexIndex.networkById.add(network);
    netexIndex.authoritiesById.add(new Authority().withId(AUTHORITY_ID));
    transitBuilder.getAgenciesById().add(createAgency());
    Line line = createExampleLine();
    RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, transitBuilder.getAgenciesById(), transitBuilder.getOperatorsById(), netexIndex.readOnlyView(), TIME_ZONE);
    Route route = routeMapper.mapRoute(line);
    assertEquals(AUTHORITY_ID, route.getAgency().getId().getId());
}
Also used : OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) Line(org.rutebanken.netex.model.Line) OrganisationRefStructure(org.rutebanken.netex.model.OrganisationRefStructure) NetexImportDataIndex(org.opentripplanner.netex.loader.NetexImportDataIndex) Authority(org.rutebanken.netex.model.Authority) Network(org.rutebanken.netex.model.Network) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Example 2 with Line

use of org.rutebanken.netex.model.Line in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method createExampleLine.

private Line createExampleLine() {
    Line line = new Line();
    line.setId(RUT_LINE_ID);
    line.setTransportMode(AllVehicleModesOfTransportEnumeration.METRO);
    line.setName(new MultilingualString().withValue("Line 1"));
    line.setPublicCode("L1");
    line.setRepresentedByGroupRef(new GroupOfLinesRefStructure().withRef(NETWORK_ID));
    return line;
}
Also used : Line(org.rutebanken.netex.model.Line) MultilingualString(org.rutebanken.netex.model.MultilingualString) GroupOfLinesRefStructure(org.rutebanken.netex.model.GroupOfLinesRefStructure)

Example 3 with Line

use of org.rutebanken.netex.model.Line in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method mapRouteWithDefaultAgency.

@Test
public void mapRouteWithDefaultAgency() {
    NetexImportDataIndex netexImportDataIndex = new NetexImportDataIndex();
    Line line = createExampleLine();
    RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, new EntityById<>(), new EntityById<>(), netexImportDataIndex.readOnlyView(), TimeZone.getDefault().toString());
    Route route = routeMapper.mapRoute(line);
    assertEquals(MappingSupport.ID_FACTORY.createId("RUT:Line:1"), route.getId());
    assertEquals("Line 1", route.getLongName());
    assertEquals("L1", route.getShortName());
}
Also used : Line(org.rutebanken.netex.model.Line) NetexImportDataIndex(org.opentripplanner.netex.loader.NetexImportDataIndex) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Example 4 with Line

use of org.rutebanken.netex.model.Line in project OpenTripPlanner by opentripplanner.

the class RouteMapperTest method mapRouteWithColor.

@Test
public void mapRouteWithColor() {
    NetexImportDataIndex netexImportDataIndex = new NetexImportDataIndex();
    Line line = createExampleLine();
    byte[] color = new byte[] { 127, 0, 0 };
    byte[] textColor = new byte[] { 0, 127, 0 };
    line.setPresentation(new PresentationStructure().withColour(color).withTextColour(textColor));
    RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, new EntityById<>(), new EntityById<>(), netexImportDataIndex.readOnlyView(), TimeZone.getDefault().toString());
    Route route = routeMapper.mapRoute(line);
    assertEquals(route.getColor(), "7F0000");
    assertEquals(route.getTextColor(), "007F00");
}
Also used : Line(org.rutebanken.netex.model.Line) PresentationStructure(org.rutebanken.netex.model.PresentationStructure) NetexImportDataIndex(org.opentripplanner.netex.loader.NetexImportDataIndex) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Example 5 with Line

use of org.rutebanken.netex.model.Line 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();
        }
    };
}
Also used : Operator(org.rutebanken.netex.model.Operator) StopPlace(org.rutebanken.netex.model.StopPlace) TariffZone(org.rutebanken.netex.model.TariffZone) DestinationDisplay(org.rutebanken.netex.model.DestinationDisplay) GroupOfStopPlaces(org.rutebanken.netex.model.GroupOfStopPlaces) Authority(org.rutebanken.netex.model.Authority) DayType(org.rutebanken.netex.model.DayType) GroupOfLines(org.rutebanken.netex.model.GroupOfLines) Line(org.rutebanken.netex.model.Line) JourneyPattern(org.rutebanken.netex.model.JourneyPattern) Notice(org.rutebanken.netex.model.Notice) DayTypeRefsToServiceIdAdapter(org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter) OperatingPeriod(org.rutebanken.netex.model.OperatingPeriod) Collection(java.util.Collection) NoticeAssignment(org.rutebanken.netex.model.NoticeAssignment) Quay(org.rutebanken.netex.model.Quay) ServiceLink(org.rutebanken.netex.model.ServiceLink) Route(org.rutebanken.netex.model.Route)

Aggregations

Line (org.rutebanken.netex.model.Line)6 Route (org.opentripplanner.model.Route)4 Test (org.junit.Test)3 NetexImportDataIndex (org.opentripplanner.netex.loader.NetexImportDataIndex)3 Authority (org.rutebanken.netex.model.Authority)2 Collection (java.util.Collection)1 OtpTransitServiceBuilder (org.opentripplanner.model.impl.OtpTransitServiceBuilder)1 DayTypeRefsToServiceIdAdapter (org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter)1 DayType (org.rutebanken.netex.model.DayType)1 DestinationDisplay (org.rutebanken.netex.model.DestinationDisplay)1 GroupOfLines (org.rutebanken.netex.model.GroupOfLines)1 GroupOfLinesRefStructure (org.rutebanken.netex.model.GroupOfLinesRefStructure)1 GroupOfStopPlaces (org.rutebanken.netex.model.GroupOfStopPlaces)1 JourneyPattern (org.rutebanken.netex.model.JourneyPattern)1 MultilingualString (org.rutebanken.netex.model.MultilingualString)1 Network (org.rutebanken.netex.model.Network)1 Notice (org.rutebanken.netex.model.Notice)1 NoticeAssignment (org.rutebanken.netex.model.NoticeAssignment)1 OperatingPeriod (org.rutebanken.netex.model.OperatingPeriod)1 Operator (org.rutebanken.netex.model.Operator)1