private static Collection<Stop> readStopsFromGtfsPath(String path) throws IOException { String defaultAgencyId = null; int index = path.indexOf(File.pathSeparatorChar); if( index != -1) { defaultAgencyId = path.substring(index+1); path = path.substring(0,index); } GtfsReader reader = new GtfsReader(); reader.setInputLocation(new File(path)); if( defaultAgencyId != null) reader.setDefaultAgencyId(defaultAgencyId); reader.readEntities(Agency.class); reader.readEntities(Stop.class); return reader.getEntityStore().getAllEntitiesForType(Stop.class); } }
private static Collection<Stop> readStopsFromGtfsPath(String path, String defaultAgencyId) throws IOException { GtfsReader reader = new GtfsReader(); reader.setInputLocation(new File(path)); if (defaultAgencyId != null) reader.setDefaultAgencyId(defaultAgencyId); reader.readEntities(Agency.class); reader.readEntities(Stop.class); return reader.getEntityStore().getAllEntitiesForType(Stop.class); }
private static Collection<Stop> readStopsFromGtfsPath(String path, String defaultAgencyId) throws IOException { GtfsReader reader = new GtfsReader(); reader.setInputLocation(new File(path)); if (defaultAgencyId != null) reader.setDefaultAgencyId(defaultAgencyId); reader.readEntities(Agency.class); reader.readEntities(Stop.class); return reader.getEntityStore().getAllEntitiesForType(Stop.class); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); CalendarService refCalendarService = CalendarServiceDataFactoryImpl.createService(reference); int tripsTomorrow = 0; int tripsNextDay = 0; int tripsDayAfterNext = 0; Date tomorrow = removeTime(addDays(new Date(), 1)); Date nextDay = removeTime(addDays(new Date(), 2)); Date dayAfterNext = removeTime(addDays(new Date(), 3)); tripsTomorrow = hasRouteServiceForDate(dao, reference, refCalendarService, tomorrow); tripsNextDay = hasRouteServiceForDate(dao, reference, refCalendarService, nextDay); tripsDayAfterNext = hasRouteServiceForDate(dao, reference, refCalendarService, dayAfterNext); _log.error("Active routes {}: {}, {}: {}, {}: {}", tomorrow, tripsTomorrow, nextDay, tripsNextDay, dayAfterNext, tripsDayAfterNext); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); CalendarService refCalendarService = CalendarServiceDataFactoryImpl.createService(reference); int tripsTomorrow = 0; int tripsNextDay = 0; int tripsDayAfterNext = 0; Date tomorrow = removeTime(addDays(new Date(), 1)); Date nextDay = removeTime(addDays(new Date(), 2)); Date dayAfterNext = removeTime(addDays(new Date(), 3)); tripsTomorrow = hasRouteServiceForDate(dao, reference, refCalendarService, tomorrow); tripsNextDay = hasRouteServiceForDate(dao, reference, refCalendarService, nextDay); tripsDayAfterNext = hasRouteServiceForDate(dao, reference, refCalendarService, dayAfterNext); _log.error("Active routes {}: {}, {}: {}, {}: {}", tomorrow, tripsTomorrow, nextDay, tripsNextDay, dayAfterNext, tripsDayAfterNext); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary(); //trips updated, array of mta_ids that we've updated HashMap<String, Trip> tripsUpdated = new HashMap<>(); //trips to remove, list of trips that have duplicate mta_ids ArrayList<Trip> tripsToRemove = new ArrayList<>(); _log.info("Total dao {}", dao.getAllTrips().size()); _log.info("Stop times: {}" , dao.getAllStopTimes().size()); for (Trip trip : dao.getAllTrips()) { if (trip.getMtaTripId() != null) { if (tripsUpdated.containsKey(trip.getMtaTripId())) { tripsToRemove.add(trip); for (StopTime stopTime : dao.getStopTimesForTrip(trip)){ stopTime.setTrip(tripsUpdated.get(trip.getMtaTripId())); } } else { tripsUpdated.put(trip.getMtaTripId(), trip); trip.setId(new AgencyAndId(trip.getId().getAgencyId(), trip.getMtaTripId())); } } } for (Trip tripToRemove : tripsToRemove) { //removeEntityLibrary.removeTrip(dao, tripToRemove); dao.removeEntity(tripToRemove); } _log.info("Total dao {}", dao.getAllTrips().size()); _log.info("Stop times: {}" , dao.getAllStopTimes().size()); }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); String agency = dao.getAllTrips().iterator().next().getId().getAgencyId();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); String agency = reference.getAllTrips().iterator().next().getId().getAgencyId(); ArrayList<String> missingStops = new ArrayList<>();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore();
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); ExternalServices es = new ExternalServicesBridgeFactory().getExternalServices(); CalendarService refCalendarService = CalendarServiceDataFactoryImpl.createService(reference);
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); HashMap<String, Route> referenceRoutes = new HashMap<>(); for (Route route : reference.getAllRoutes()) { referenceRoutes.put(route.getId().getId(), route); } for (Route route: dao.getAllRoutes()) { String identifier = route.getId().getId(); if (identifier.length() > 2) { identifier = identifier.substring(0,2); } Route refRoute = referenceRoutes.get(identifier); if (refRoute != null) { route.setShortName(refRoute.getShortName()); route.setLongName(refRoute.getLongName()); route.setType(refRoute.getType()); route.setDesc(refRoute.getDesc()); route.setUrl(refRoute.getUrl()); route.setColor(refRoute.getColor()); route.setTextColor(refRoute.getTextColor()); route.setId(refRoute.getId()); } } } }