use of org.onebusaway.gtfs.impl.GtfsDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsReaderExampleMain method main.
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err.println("usage: gtfsPath");
System.exit(-1);
}
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
/**
* You can register an entity handler that listens for new objects as they
* are read
*/
reader.addEntityHandler(new GtfsEntityHandler());
/**
* Or you can use the internal entity store, which has references to all the
* loaded entities
*/
GtfsDaoImpl store = new GtfsDaoImpl();
reader.setEntityStore(store);
reader.run();
// Access entities through the store
Map<AgencyAndId, Route> routesById = store.getEntitiesByIdForEntityType(AgencyAndId.class, Route.class);
for (Route route : routesById.values()) {
System.out.println("route: " + route.getShortName());
}
}
Aggregations