private Route doMap(org.onebusaway.gtfs.model.Route rhs) { Route lhs = new Route(); lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())); lhs.setAgency(agencyMapper.map(rhs.getAgency())); lhs.setShortName(rhs.getShortName()); lhs.setLongName(rhs.getLongName()); lhs.setType(rhs.getType()); lhs.setDesc(rhs.getDesc()); lhs.setUrl(rhs.getUrl()); lhs.setColor(rhs.getColor()); lhs.setTextColor(rhs.getTextColor()); lhs.setRouteBikesAllowed(rhs.getRouteBikesAllowed()); lhs.setBikesAllowed(rhs.getBikesAllowed()); lhs.setSortOrder(rhs.getSortOrder()); lhs.setBrandingUrl(rhs.getBrandingUrl()); return lhs; } }
String routeColor = route.getColor(); String textColor = route.getTextColor(); textColor = "FFFFFF"; route.setTextColor(textColor);
private void setLTDRoute(Route daoRoute, Route refRoute) { daoRoute.setShortName(refRoute.getShortName()); daoRoute.setLongName(refRoute.getLongName()); daoRoute.setType(refRoute.getType()); daoRoute.setDesc(refRoute.getDesc()); daoRoute.setUrl(refRoute.getUrl()); daoRoute.setColor(refRoute.getColor()); daoRoute.setTextColor(refRoute.getTextColor()); //set the id to also be the same daoRoute.setId(refRoute.getId()); } }
addValueToCounterIfValid(route.getShortName(), shortNames, count); addValueToCounterIfValid(route.getLongName(), longNames, count); addValueToCounterIfValid(route.getDesc(), descriptions, count); addValueToCounterIfValid(route.getColor(), colors, count); addValueToCounterIfValid(route.getTextColor(), textColors, count); addValueToCounterIfValid(route.getUrl(), urls, count); types.increment(route.getType(), count);
route.getId().setAgencyId(reader.getDefaultAgencyId()); generateRouteColor(route);
public void validateEntity(CsvEntityContext context, Map<String, Object> csvValues, BeanWrapper object) { Route route = object.getWrappedInstance(Route.class); String shortName = route.getShortName(); String longName = route.getLongName(); if ((shortName == null || shortName.length() == 0) && (longName == null || longName.length() == 0)) throw new RouteNameException(route.getId()); } }
private Route getShuttleRoute(GtfsMutableRelationalDao dao, Route orig) { Route shuttleRoute = new Route(orig); AgencyAndId id = new AgencyAndId(shuttleRoute.getId().getAgencyId(), shuttleRoute.getId().getId() + SHUTTLE_ID_SUFFIX); shuttleRoute.setId(id); shuttleRoute.setShortName(shuttleRoute.getShortName() + SHUTTLE_ID_SUFFIX); shuttleRoute.setLongName(shuttleRoute.getLongName() + SHUTTLE_NAME_SUFFIX); shuttleRoute.setType(SHUTTLE_ROUTE_TYPE); dao.saveEntity(shuttleRoute); return shuttleRoute; } }
private List<Document> getRouteCollectionAsDocuments( RouteCollection routeCollection) { List<Document> documents = new ArrayList<Document>(); AgencyAndId routeCollectionId = routeCollection.getId(); for (Route route : routeCollection.getRoutes()) { Document document = new Document(); // Route Collection document.add(new Field(FIELD_ROUTE_COLLECTION_AGENCY_ID, routeCollectionId.getAgencyId(), Field.Store.YES, Field.Index.NO)); document.add(new Field(FIELD_ROUTE_COLLECTION_ID, routeCollectionId.getId(), Field.Store.YES, Field.Index.NO)); // Id AgencyAndId id = route.getId(); document.add(new Field(FIELD_AGENCY_ID, id.getAgencyId(), Field.Store.YES, Field.Index.NO)); document.add(new Field(FIELD_ROUTE_ID, id.getId(), Field.Store.YES, Field.Index.ANALYZED)); if (isValue(route.getShortName())) document.add(new Field(FIELD_ROUTE_SHORT_NAME, route.getShortName(), Field.Store.NO, Field.Index.ANALYZED)); if (isValue(route.getLongName())) document.add(new Field(FIELD_ROUTE_LONG_NAME, route.getLongName(), Field.Store.NO, Field.Index.ANALYZED)); if (isValue(route.getDesc())) document.add(new Field(FIELD_ROUTE_DESCRIPTION, route.getDesc(), Field.Store.NO, Field.Index.ANALYZED)); documents.add(document); } return documents; }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
public static String getRouteName(Route route) { if (route.getShortName() != null) return route.getShortName(); return route.getLongName(); }
private TripEntryImpl processTrip(TransitGraphImpl graph, Trip trip) { List<StopTime> stopTimes = _gtfsDao.getStopTimesForTrip(trip); // A trip without stop times is a trip we don't care about if (stopTimes.isEmpty()) return null; ShapePoints shapePoints = null; if (trip.getShapeId() != null) shapePoints = _shapePointsService.getShapePointsForShapeId(trip.getShapeId()); Agency agency = trip.getRoute().getAgency(); TimeZone tz = TimeZone.getTimeZone(agency.getTimezone()); LocalizedServiceId lsid = new LocalizedServiceId(trip.getServiceId(), tz); TripEntryImpl tripEntry = new TripEntryImpl(); tripEntry.setId(trip.getId()); tripEntry.setRouteId(unique(trip.getRoute().getId())); tripEntry.setDirectionId(unique(trip.getDirectionId())); tripEntry.setServiceId(unique(lsid)); // Only set the shape id for a trip if there are actually shape points to // back it up if (!(shapePoints == null || shapePoints.isEmpty())) tripEntry.setShapeId(unique(trip.getShapeId())); List<StopTimeEntryImpl> stopTimesForTrip = _stopTimeEntriesFactory.processStopTimes( graph, stopTimes, tripEntry, shapePoints); double tripDistance = getTripDistance(stopTimesForTrip, shapePoints); tripEntry.setTotalTripDistance(tripDistance); tripEntry.setStopTimes(cast(stopTimesForTrip)); graph.putTripEntry(tripEntry); return tripEntry; }
private TripNarrative getTripNarrative(Trip trip) { String headsign = trip.getTripHeadsign(); if (headsign == null) { Route route = trip.getRoute(); headsign = route.getLongName(); } TripNarrative.Builder builder = TripNarrative.builder(); builder.setRouteShortName(deduplicate(trip.getRouteShortName())); builder.setTripHeadsign(deduplicate(headsign)); builder.setTripShortName(deduplicate(trip.getTripShortName())); return builder.create(); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao, Object entity) { if (!(entity instanceof Trip)) return; Trip trip = (Trip) entity; String headsign = trip.getTripHeadsign(); Route route = trip.getRoute(); String shortName = route.getShortName(); if (headsign == null || shortName == null) return; headsign = headsign.replaceAll("^" + shortName + "\\s+", ""); headsign = headsign.replaceAll("-\\s+" + shortName + "\\s+", "- "); trip.setTripHeadsign(headsign); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { for (Route route: dao.getAllRoutes()) { if (route.getLongName().endsWith(" Line")) { route.setLongName(route.getLongName().replace(" Line", "")); } } } }
private void retainRoute(Route route, boolean retainUp) { if (retainUp) { for (Trip trip : _dao.getTripsForRoute(route)) retainUp(trip); } else { retainDown(route.getAgency()); } }
@Override public int hashCode() { return route.hashCode() * 7 + id.hashCode() * 13; }
public static TraverseMode getTraverseMode(Route route) { switch (route.getType()) { case 0: return TraverseMode.TRAM; case 1: return TraverseMode.SUBWAY; case 2: return TraverseMode.RAIL; case 3: return TraverseMode.BUS; case 4: return TraverseMode.FERRY; case 5: return TraverseMode.CABLE_CAR; case 6: return TraverseMode.GONDOLA; case 7: return TraverseMode.FUNICULAR; default: throw new IllegalArgumentException("unknown gtfs route type " + route.getType()); } }
private void setRoute(Route daoRoute, Route refRoute) { daoRoute.setShortName(refRoute.getShortName()); daoRoute.setLongName(refRoute.getLongName()); daoRoute.setType(refRoute.getType()); daoRoute.setDesc(refRoute.getDesc()); daoRoute.setUrl(refRoute.getUrl()); daoRoute.setColor(refRoute.getColor()); daoRoute.setTextColor(refRoute.getTextColor()); }
addValueToCounterIfValid(route.getShortName(), shortNames, count); addValueToCounterIfValid(route.getLongName(), longNames, count); addValueToCounterIfValid(route.getDesc(), descriptions, count); addValueToCounterIfValid(route.getColor(), colors, count); addValueToCounterIfValid(route.getTextColor(), textColors, count); addValueToCounterIfValid(route.getUrl(), urls, count); types.increment(route.getType(), count);