Search in sources :

Example 1 with PresentationStructure

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

the class RouteMapper method mapRoute.

org.opentripplanner.model.Route mapRoute(Line line) {
    org.opentripplanner.model.Route otpRoute = new org.opentripplanner.model.Route();
    otpRoute.setId(idFactory.createId(line.getId()));
    otpRoute.setAgency(findOrCreateAuthority(line));
    otpRoute.setOperator(findOperator(line));
    otpRoute.setLongName(line.getName().getValue());
    otpRoute.setShortName(line.getPublicCode());
    int transportType = transportModeMapper.getTransportMode(line.getTransportMode(), line.getTransportSubmode());
    otpRoute.setType(transportType);
    otpRoute.setMode(TransitModeMapper.mapMode(transportType));
    if (line.getPresentation() != null) {
        PresentationStructure presentation = line.getPresentation();
        if (presentation.getColour() != null) {
            otpRoute.setColor(hexBinaryAdapter.marshal(presentation.getColour()));
        }
        if (presentation.getTextColour() != null) {
            otpRoute.setTextColor(hexBinaryAdapter.marshal(presentation.getTextColour()));
        }
    }
    return otpRoute;
}
Also used : PresentationStructure(org.rutebanken.netex.model.PresentationStructure)

Example 2 with PresentationStructure

use of org.rutebanken.netex.model.PresentationStructure 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)

Aggregations

PresentationStructure (org.rutebanken.netex.model.PresentationStructure)2 Test (org.junit.Test)1 Route (org.opentripplanner.model.Route)1 NetexImportDataIndex (org.opentripplanner.netex.loader.NetexImportDataIndex)1 Line (org.rutebanken.netex.model.Line)1