Search in sources :

Example 1 with GtfsStatisticsService

use of com.conveyal.gtfs.service.impl.GtfsStatisticsService in project onebusaway-application-modules by camsys.

the class GtfsStatisticsTask method run.

public void run() {
    File basePath = _bundle.getPath();
    _log.info("Starting GTFS stats to basePath=" + basePath);
    GtfsStatisticsService service = new GtfsStatisticsService(_dao);
    logger.header(FILENAME, "id,name,route_count,trip_count,stop_count,stop_times_count,calendar_service_start,calendar_service_end,calendar_start_date,calendar_end_date");
    // per agency status
    Collection<Agency> agencies = service.getAllAgencies();
    for (Agency agency : agencies) {
        _log.info("processing stats for agency: " + agency.getId() + " (" + agency.getName() + ")");
        String stats = insertAgencyName(service.getStatisticAsCSV(agency.getId()), agency.getName());
        logger.logCSV(FILENAME, stats);
    }
    // overall stats/totals
    Statistic all = new Statistic();
    Agency allAgency = new Agency();
    allAgency.setId(ALL_AGENCIES);
    all.setAgencyId(ALL_AGENCIES);
    all.setRouteCount(service.getRouteCount());
    all.setTripCount(service.getTripCount());
    all.setStopCount(service.getStopCount());
    all.setStopTimeCount(service.getStopTimesCount());
    all.setCalendarStartDate(service.getCalendarServiceRangeStart());
    all.setCalendarEndDate(service.getCalendarServiceRangeEnd());
    String stats = insertAgencyName(GtfsStatisticsService.formatStatisticAsCSV(all), "");
    logger.logCSV(FILENAME, stats);
    _log.info("exiting");
}
Also used : Agency(org.onebusaway.gtfs.model.Agency) Statistic(com.conveyal.gtfs.model.Statistic) GtfsStatisticsService(com.conveyal.gtfs.service.impl.GtfsStatisticsService) File(java.io.File)

Example 2 with GtfsStatisticsService

use of com.conveyal.gtfs.service.impl.GtfsStatisticsService in project onebusaway-application-modules by camsys.

the class GtfsStatisticsTask method run.

public void run() {
    File basePath = _bundle.getPath();
    _log.info("Starting GTFS stats to basePath=" + basePath);
    GtfsStatisticsService service = new GtfsStatisticsService(_dao);
    // create logger file
    GtfsCsvLogger csvLogger = new GtfsCsvLogger();
    csvLogger.setBasePath(basePath);
    csvLogger.open();
    csvLogger.header();
    // per agency status
    Collection<Agency> agencies = service.getAllAgencies();
    for (Agency agency : agencies) {
        _log.info("processing stats for agency: " + agency.getId() + " (" + agency.getName() + ")");
        csvLogger.logStat(agency.getId(), service.getStatistic(agency.getId()));
    }
    // overall stats/totals
    Statistic all = new Statistic();
    Agency allAgency = new Agency();
    allAgency.setId(ALL_AGENCIES);
    all.setAgencyId(ALL_AGENCIES);
    all.setRouteCount(service.getRouteCount());
    all.setTripCount(service.getTripCount());
    all.setStopCount(service.getStopCount());
    all.setStopTimeCount(service.getStopTimesCount());
    all.setCalendarStartDate(service.getCalendarServiceRangeStart());
    all.setCalendarEndDate(service.getCalendarServiceRangeEnd());
    csvLogger.logStat(allAgency.getId(), all);
    _log.info("cleaning up");
    // cleanup
    csvLogger.close();
    _log.info("exiting");
}
Also used : Agency(org.onebusaway.gtfs.model.Agency) Statistic(com.conveyal.gtfs.model.Statistic) GtfsStatisticsService(com.conveyal.gtfs.service.impl.GtfsStatisticsService) File(java.io.File)

Aggregations

Statistic (com.conveyal.gtfs.model.Statistic)2 GtfsStatisticsService (com.conveyal.gtfs.service.impl.GtfsStatisticsService)2 File (java.io.File)2 Agency (org.onebusaway.gtfs.model.Agency)2