use of org.onebusaway.transit_data_federation.bundle.model.GtfsBundle in project onebusaway-application-modules by camsys.
the class GtfsFullValidationTask method getGtfsBundles.
protected GtfsBundles getGtfsBundles(ApplicationContext context) {
GtfsBundles bundles = (GtfsBundles) context.getBean("gtfs-bundles");
if (bundles != null)
return bundles;
GtfsBundle bundle = (GtfsBundle) context.getBean("gtfs-bundle");
if (bundle != null) {
bundles = new GtfsBundles();
bundles.getBundles().add(bundle);
return bundles;
}
throw new IllegalStateException("must define either \"gtfs-bundles\" or \"gtfs-bundle\" in config");
}
use of org.onebusaway.transit_data_federation.bundle.model.GtfsBundle in project onebusaway-application-modules by camsys.
the class HastusTranslateTask method updateGtfsBundle.
private void updateGtfsBundle(BundleRequestResponse requestResponse, String zipFilename, HastusData hd) {
GtfsBundles bundles = getGtfsBundles(_applicationContext);
GtfsBundle bundle = new GtfsBundle();
bundle.setDefaultAgencyId(hd.getAgencyId());
bundle.setPath(new File(zipFilename));
bundles.getBundles().add(bundle);
}
use of org.onebusaway.transit_data_federation.bundle.model.GtfsBundle in project onebusaway-application-modules by camsys.
the class MultiAgencyModTask method run.
@Override
public void run() {
try {
_log.info("GtfsModTask Starting");
GtfsBundles gtfsBundles = getGtfsBundles(_applicationContext);
for (GtfsBundle gtfsBundle : gtfsBundles.getBundles()) {
String agencyId = parseAgencyDir(gtfsBundle.getPath().getPath());
// _log.info("no modUrl found for agency " + agencyId + " and bundle " + gtfsBundle.getPath());
String oldFilename = gtfsBundle.getPath().getPath();
String newFilename = runModifications(gtfsBundle, agencyId, getEmptyModUrl(), null);
logger.changelog("Transformed " + oldFilename + " to " + newFilename + " to add multi-agency support");
}
} catch (Throwable ex) {
_log.error("error modifying gtfs:", ex);
} finally {
_log.info("GtfsModTask Exiting");
}
}
use of org.onebusaway.transit_data_federation.bundle.model.GtfsBundle in project onebusaway-application-modules by camsys.
the class GtfsComputePolylineBoundaryForStopsMain method run.
public void run(String[] args) throws IOException {
try {
Parser parser = new GnuParser();
Options options = new Options();
buildOptions(options);
CommandLine commandLine = parser.parse(options, args);
String[] remainingArgs = commandLine.getArgs();
if (remainingArgs.length < 2) {
printUsage();
System.exit(-1);
}
List<GtfsBundle> bundles = getGtfsBundlesFromCommandLine(remainingArgs);
EFormat format = getFormat(commandLine);
StopToPolygonEntityHandler handler = new StopToPolygonEntityHandler(2500);
for (GtfsBundle bundle : bundles) {
System.err.println(bundle.getPath());
GtfsReader reader = new GtfsReader();
reader.addEntityHandler(handler);
reader.setInputLocation(bundle.getPath());
if (bundle.getDefaultAgencyId() != null)
reader.setDefaultAgencyId(bundle.getDefaultAgencyId());
reader.readEntities(Stop.class);
}
PrintWriter out = getOutputAsPrinter(remainingArgs[remainingArgs.length - 1]);
switch(format) {
case OSM:
handleOutputAsOSMPolygon(out, handler);
break;
case TEXT:
handleOutputAsText(out, handler);
break;
}
out.close();
} catch (ParseException ex) {
System.err.println(ex.getLocalizedMessage());
printUsage();
System.exit(-1);
}
System.exit(0);
}
use of org.onebusaway.transit_data_federation.bundle.model.GtfsBundle in project onebusaway-application-modules by camsys.
the class GtfsStopReplacementVerificationMain method main.
@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.err.println("usage: stop-consolidation-file gtfs_path [gtfs_path:defaultAgencyId data-sources.xml ...]");
System.exit(-1);
}
EntityHandlerImpl handler = new EntityHandlerImpl();
List<String> paths = new ArrayList<String>();
for (int i = 1; i < args.length; i++) {
paths.add(args[i]);
}
List<GtfsBundle> bundles = UtilityLibrary.getGtfsBundlesForArguments(paths);
for (GtfsBundle bundle : bundles) {
GtfsReader reader = new GtfsReader();
reader.setDefaultAgencyId(bundle.getDefaultAgencyId());
reader.setInputLocation(bundle.getPath());
for (Map.Entry<String, String> entry : bundle.getAgencyIdMappings().entrySet()) reader.addAgencyIdMapping(entry.getKey(), entry.getValue());
reader.getEntityClasses().retainAll(Arrays.asList(Agency.class, Stop.class));
reader.addEntityHandler(handler);
reader.run();
}
Set<AgencyAndId> ids = handler.getIds();
InputStream in = IOLibrary.getPathAsInputStream(args[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null) {
if (line.startsWith("#") || line.startsWith("{{{") || line.startsWith("}}}") || line.length() == 0)
continue;
String[] tokens = line.split("\\s+");
AgencyAndId id = AgencyAndIdLibrary.convertFromString(tokens[0]);
if (!ids.contains(id))
System.out.println(id + " <- " + line);
}
}
Aggregations