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;
}
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");
}
Aggregations