private void setParents(Collection<List<Stop>> complexes, GtfsMutableRelationalDao dao) { for (List<Stop> complex : complexes) { Map<String, List<Stop>> grouped = complex.stream() .collect(Collectors.groupingBy(Stop::getName)); for (List<Stop> group : grouped.values()) { String parent = group.get(0).getParentStation(); for (Stop stop : group) { stop.setParentStation(parent); dao.updateEntity(stop); } } } }
@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); } } }
atisStop.setDirection(refStop.getDirection()); atisStop.setId(refStop.getId()); atisStop.setParentStation(refStop.getParentStation()); atisStop.setLocationType(refStop.getLocationType()); stopsAdded.put(atisStop.getId(), new AgencyAndId(agencyAndId.getAgencyId(), atisId));
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; }