use of org.onebusaway.admin.service.bundle.hastus.HastusGtfsFactory in project onebusaway-application-modules by camsys.
the class HastusTranslateTask method createGtfs.
private void createGtfs(HastusData hd) {
if (hd == null) {
_log.info("nothing to do");
return;
}
if (!hd.isValid()) {
_log.info("incomplete hd=" + hd);
return;
}
File hastus = new File(hd.getScheduleDataDirectory());
File gis = new File(hd.getGisDataDirectory());
try {
HastusGtfsFactory factory = new HastusGtfsFactory();
if (hastus != null && gis != null) {
File outputDir = new File(requestResponse.getResponse().getBundleOutputDirectory() + File.separator + hd.getAgencyId());
outputDir.mkdirs();
factory.setScheduleInputPath(hastus);
factory.setGisInputPath(gis);
factory.setGtfsOutputPath(outputDir);
factory.setCalendarStartDate(new ServiceDate(requestResponse.getRequest().getBundleStartDate().toDateTimeAtStartOfDay().toDate()));
factory.setCalendarEndDate(new ServiceDate(requestResponse.getRequest().getBundleEndDate().toDateTimeAtStartOfDay().toDate()));
_log.info("running HastusGtfsFactory...");
factory.run();
_log.info("done!");
String zipFilename = postPackage(outputDir.toString(), requestResponse.getResponse().getTmpDirectory(), hd.getAgencyId());
cleanup(outputDir);
updateGtfsBundle(requestResponse, zipFilename, hd);
_log.info("created zipFilename=" + zipFilename);
String msg = "Packaged " + hastus + " and " + gis + " to GTFS to support Community Transit with output=" + outputDir;
_log.info(msg);
logger.changelog(msg);
} else {
_log.error("missing required inputs: hastus=" + hastus + ", gis=" + gis);
}
} catch (Throwable ex) {
_log.error("error packaging Community Transit gtfs:", ex);
}
}
Aggregations