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; } }
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 List<Stop> getStopsForStation(Stop station) { if (_stopsByStation == null) { _stopsByStation = new HashMap<Stop, List<Stop>>(); for (Stop stop : getAllStops()) { if (stop.getLocationType() == 0 && stop.getParentStation() != null) { Stop parentStation = getStopForId(new AgencyAndId( stop.getId().getAgencyId(), stop.getParentStation())); List<Stop> subStops = _stopsByStation.get(parentStation); if (subStops == null) { subStops = new ArrayList<Stop>(2); _stopsByStation.put(parentStation, subStops); } subStops.add(stop); } } } return list(_stopsByStation.get(station)); }
@Override public List<Stop> getStopsForStation(Stop station) { if (_stopsByStation == null) { _stopsByStation = new HashMap<Stop, List<Stop>>(); for (Stop stop : getAllStops()) { if (stop.getLocationType() == 0 && stop.getParentStation() != null) { Stop parentStation = getStopForId(new AgencyAndId( stop.getId().getAgencyId(), stop.getParentStation())); List<Stop> subStops = _stopsByStation.get(parentStation); if (subStops == null) { subStops = new ArrayList<Stop>(2); _stopsByStation.put(parentStation, subStops); } subStops.add(stop); } } } return list(_stopsByStation.get(station)); }
MTAStationDirection dir = dirByStation.get(st.getStop().getParentStation()); if (dir == null) { _log.debug("Missing station ID = {}", st.getStop().getParentStation()); continue;
@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); } } }
private void makePathways(Collection<List<Stop>> complexes, GtfsMutableRelationalDao dao) { String feedId = dao.getAllStops().iterator().next().getId().getAgencyId(); List<Pathway> newPathways = new ArrayList<>(); PathwayUtil util = new PathwayUtil(feedId, newPathways); for (List<Stop> complex : complexes) { for (Stop s : complex) { for (Stop t : complex) { if (s != null && s.getParentStation() != null && t != null) { if (!s.equals(t)) { String id = String.format("complex-%s-%s", s.getId().getId(), t.getId().getId()); util.createPathway(s, t, PATHWAY_MODE_GENERIC, genericPathwayTraversalTime, -1, id, null, false); } } else { _log.error("Illegal Stop {}", s); } } } } for (Pathway p : newPathways) { dao.saveEntity(p); } }
String parentStation = stop.getParentStation(); if (parentStation != null) { Stop existingStop = dao.getStopForId(new AgencyAndId(agencyAndId.getAgencyId(), parentStation));
if (stopsHaveParents) { String gid = stop.getLocationType() == LOCATION_TYPE_STOP ? stop.getParentStation() : stop.getId().getId(); StopGroup group = stopGroups.get(gid); if (group == null) {
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 void retainStop(Stop stop, boolean retainUp) { if (retainUp) { for (StopTime stopTime : _dao.getStopTimesForStop(stop)) retainUp(stopTime); } else { String parentStationId = stop.getParentStation(); if (parentStationId != null) { AgencyAndId id = stop.getId(); Stop parent = _dao.getStopForId(new AgencyAndId(id.getAgencyId(), parentStationId)); retainDown(parent); } /** * Need to make sure a stop's agency is included as well, since the agency * might not be included by any routes serving that stop */ AgencyAndId stopId = stop.getId(); String agencyId = stopId.getAgencyId(); Agency agency = _dao.getAgencyForId(agencyId); if (agency != null) { retainDown(agency); } } }