private Stop doMap(org.onebusaway.gtfs.model.Stop rhs) { Stop lhs = new Stop(); lhs.setId(mapAgencyAndId(rhs.getId())); lhs.setName(rhs.getName()); lhs.setLat(rhs.getLat()); lhs.setLon(rhs.getLon()); lhs.setCode(rhs.getCode()); lhs.setDesc(rhs.getDesc()); lhs.setZoneId(rhs.getZoneId()); lhs.setUrl(rhs.getUrl()); lhs.setLocationType(rhs.getLocationType()); lhs.setParentStation(rhs.getParentStation()); lhs.setWheelchairBoarding(rhs.getWheelchairBoarding()); lhs.setDirection(rhs.getDirection()); lhs.setTimezone(rhs.getTimezone()); lhs.setVehicleType(rhs.getVehicleType()); lhs.setPlatformCode(rhs.getPlatformCode()); return lhs; } }
referenceStopNamesToStops.put(stop.getName(), stop); Stop referenceStop = referenceStopNamesToStops.get(stop.getName()); if (referenceStop == null && stop.getName().contains("-")) { referenceStop = referenceStopNamesToStops.get(swap(stop.getName())); if (referenceStop == null && stop.getName().contains("Park")) { referenceStop = referenceStopNamesToStops.get(stop.getName().replaceAll("Park", "Pk")); if (referenceStop == null && stop.getName().contains("-")) { referenceStop = referenceStopNamesToStops.get(swap(stop.getName().replaceAll("Park", "Pk"))); if (referenceStop == null && stop.getName().contains("Pk")) { referenceStop = referenceStopNamesToStops.get(stop.getName().replaceAll("Pk", "Park")); if (referenceStop == null && stop.getName().contains("-")) { referenceStop = referenceStopNamesToStops.get(swap(stop.getName().replaceAll("Pk", "Park"))); } else { unmatched++; if (!ignoreMatches.contains(stop.getName())) { _log.error("unmatched stop |{}|", stop.getName());
private Document getStopAsDocument(Stop stop) { Document document = new Document(); // Id AgencyAndId id = stop.getId(); document.add(new Field(FIELD_AGENCY_ID, id.getAgencyId(), Field.Store.YES, Field.Index.NO)); document.add(new Field(FIELD_STOP_ID, id.getId(), Field.Store.YES, Field.Index.ANALYZED)); // Code if (stop.getCode() != null && stop.getCode().length() > 0) document.add(new Field(FIELD_STOP_CODE, stop.getCode(), Field.Store.NO, Field.Index.ANALYZED)); else document.add(new Field(FIELD_STOP_CODE, stop.getId().getId(), Field.Store.NO, Field.Index.ANALYZED)); if (stop.getName() != null && stop.getName().length() > 0) document.add(new Field(FIELD_STOP_NAME, stop.getName(), Field.Store.YES, Field.Index.ANALYZED)); return document; } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { for (Trip trip: dao.getAllTrips()){ List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); Stop lastStop = stopTimes.get(stopTimes.size() - 1).getStop(); trip.setTripHeadsign(lastStop.getName()); } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { Map<String, String> map = new InputLibrary().readOrderedMap((String)context.getParameter(("stopMappingFile"))); Map<String, String> regexMap = new InputLibrary().readOrderedMap((String)context.getParameter(("regexFile"))); for (Stop stop : dao.getAllStops()) { String upperCaseName = stop.getName(); String beautifiedName = ""; if (upperCaseName == null) continue; for (String s : upperCaseName.split(" ")) { beautifiedName += toProperCase(s) + " "; } beautifiedName = beautifiedName.substring(0, beautifiedName.length()-1); for (String regex : regexMap.keySet()) { try { beautifiedName = beautifiedName.replaceAll(regex, regexMap.get(regex)); } catch (PatternSyntaxException pse) { _log.error(" invalid regex combination |{}|=|{}|", regex, regexMap.get(regex), pse); } } if (map.containsKey(beautifiedName)) { _log.trace("swapped |{}| for |{}|", beautifiedName, map.get(beautifiedName)); beautifiedName = map.get(beautifiedName); } stop.setName(beautifiedName); } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { int update = 0; int fallback = 0; for (Trip trip : dao.getAllTrips()) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); if (stopTimes != null && stopTimes.size() > 0) { String tripHeadSign = stopTimes.get(stopTimes.size()-1).getStop().getName(); if (tripHeadSign != null) { trip.setTripHeadsign(tripHeadSign); update++; } else { fallbackSetHeadsign(trip); fallback++; } } else { fallbackSetHeadsign(trip); fallback++; } } _log.error("trip headsign update:{} fallback: {}", update, fallback); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { Map<Route, Route> shuttleRoutes = new HashMap<>(); for (Trip trip : dao.getAllTrips()) { if (trip.getTripHeadsign().endsWith(SHUTTLE_HEADSIGN_SUFFIX)) { Route shuttleRoute = shuttleRoutes.computeIfAbsent(trip.getRoute(), r -> getShuttleRoute(dao, r)); trip.setRoute(shuttleRoute); dao.updateEntity(trip); } } // Shuttle stops share mta_stop_id with non-shuttle version Map<String, String> parentStopByMtaStopId = new HashMap<>(); for (Stop stop : dao.getAllStops()) { if (!stop.getName().endsWith(SHUTTLE_STOP_SUFFIX) && stop.getParentStation() != null) { parentStopByMtaStopId.put(stop.getMtaStopId(), stop.getParentStation()); } } for (Stop stop : dao.getAllStops()) { if (stop.getName().endsWith(SHUTTLE_STOP_SUFFIX)) { String parent = parentStopByMtaStopId.get(stop.getMtaStopId()); if (parent == null) { _log.info("No parent for shuttle stop {}", stop.getId()); } stop.setParentStation(parent); dao.updateEntity(stop); } } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { for (Trip trip : dao.getAllTrips()) { if(trip.getTripHeadsign() == null) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); if (stopTimes != null && stopTimes.size() > 0) { String tripHeadSign = stopTimes.get(stopTimes.size()-1).getStop().getName(); if (tripHeadSign != null) { trip.setTripHeadsign(tripHeadSign); } else { fallbackSetHeadsign(trip); } } else { fallbackSetHeadsign(trip); } } } }
Stop stopToAdd = new Stop(); stopToAdd.setId(referenceStops.get(parentStation).getId()); stopToAdd.setName(referenceStops.get(parentStation).getName()); stopToAdd.setLat(referenceStops.get(parentStation).getLat()); stopToAdd.setLon(referenceStops.get(parentStation).getLon());
Stop referenceStop = reference.getStopForId(lastStop.getId()); if (trip.getTripHeadsign() == null || referenceStop != null) { String tripHeadSign = stopTimes.get(stopTimes.size()-1).getStop().getName(); if (tripHeadSign != null) { trip.setTripHeadsign(tripHeadSign);
String tripHeadSign = gtfsStop.getName(); if (tripHeadSign != null) { trip.setTripHeadsign(tripHeadSign);
Stop refStop = referenceStops.get(stop.getMtaStopId()); if (refStop != null) { stop.setName(refStop.getName());
private void loadStops(Graph graph) { for (Stop stop : _dao.getAllStops()) { graph.addVertex(new TransitStop(id(stop.getId()), stop.getLon(), stop.getLat(), stop.getName(), stop.getId().getId(), stop)); } } /**
atisStop.setName(gtfsStop.getName()); atisStop.setDirection(gtfsStop.getDirection()); atisStop.setId(gtfsStop.getId());
public void generateStopNarratives(NarrativeProviderImpl provider) { Map<AgencyAndId, List<ProjectedPoint>> shapePointCache = new HashMap<AgencyAndId, List<ProjectedPoint>>(); int index = 0; Collection<Stop> allStops = _gtfsDao.getAllStops(); Map<AgencyAndId, Stop> stopsById = MappingLibrary.mapToValue(allStops, "id"); int logInterval = LoggingIntervalUtil.getAppropriateLoggingInterval(allStops.size()); for (StopEntry stopEntry : _transitGraphDao.getAllStops()) { if (index % logInterval == 0) _log.info("stops=" + index); index++; Stop stop = stopsById.get(stopEntry.getId()); StopNarrative.Builder narrative = StopNarrative.builder(); narrative.setCode(deduplicate(stop.getCode())); narrative.setDescription(deduplicate(stop.getDesc())); narrative.setName(deduplicate(stop.getName())); narrative.setUrl(deduplicate(stop.getUrl())); String direction = computeStopDirection(provider, shapePointCache, stop, stopEntry); narrative.setDirection(deduplicate(direction)); provider.setNarrativeForStop(stopEntry.getId(), narrative.create()); } }
public void generateStopNarratives(NarrativeProviderImpl provider) { Map<AgencyAndId, List<ProjectedPoint>> shapePointCache = new HashMap<AgencyAndId, List<ProjectedPoint>>(); int index = 0; Collection<Stop> allStops = _gtfsDao.getAllStops(); Map<AgencyAndId, Stop> stopsById = MappingLibrary.mapToValue(allStops, "id"); for (StopEntry stopEntry : _transitGraphDao.getAllStops()) { if (index % 10 == 0) _log.info("stops=" + index); index++; Stop stop = stopsById.get(stopEntry.getId()); StopNarrative.Builder narrative = StopNarrative.builder(); narrative.setCode(deduplicate(stop.getCode())); narrative.setDescription(deduplicate(stop.getDesc())); narrative.setName(deduplicate(stop.getName())); narrative.setUrl(deduplicate(stop.getUrl())); String direction = computeStopDirection(provider, shapePointCache, stop, stopEntry); narrative.setDirection(deduplicate(direction)); provider.setNarrativeForStop(stopEntry.getId(), narrative.create()); } }
private Stop createStop(Stop stop, int locationType, int wheelchairAccessible, String suffix) { if (stop == null) return null; Stop entrance = new Stop(); AgencyAndId id = new AgencyAndId(); id.setAgencyId(agencyId); id.setId(stop.getId().getId() + "-" + suffix); entrance.setId(id); entrance.setName(stop.getName()); entrance.setLat(stop.getLat()); entrance.setLon(stop.getLon()); entrance.setLocationType(locationType); entrance.setWheelchairBoarding(wheelchairAccessible); entrance.setParentStation(stop.getId().getId()); newStops.add(entrance); return entrance; }
Vertex startJourneyArrive = graph.addVertex(id(s0.getId()) + "_" + tripId + "_" + st0.getStopSequence() + "_A", s0.getName(), s0.getId().getId(), s0.getLon(), s0.getLat()); Vertex startJourneyDepart = graph.addVertex(id(s0.getId()) + "_" + tripId + "_" + st0.getStopSequence() + "_D", s0.getName(), s0.getId().getId(), s0.getLon(), s0.getLat()); Vertex endJourneyArrive = graph.addVertex(id(s1.getId()) + "_" + tripId + "_" + st1.getStopSequence() + "_A", s1.getName(), s1.getId().getId(), s1.getLon(), s1 .getLat());
private StopBean fillStopBean(Stop stop, StopBean bean) { bean.setId(ApplicationBeanLibrary.getId(stop.getId())); bean.setLat(stop.getLat()); bean.setLon(stop.getLon()); StopNarrative stopNarrative = _narrativeService.getStopForId(stop.getId()); if (stopNarrative != null) bean.setDirection(stopNarrative.getDireciton()); bean.setName(stop.getName()); bean.setCode(StringLibrary.getBestName(stop.getCode(), stop.getId().getId())); bean.setLocationType(stop.getLocationType()); return bean; }