use of org.onebusaway.gtfs.serialization.GtfsReader in project onebusaway-gtfs-modules by OneBusAway.
the class AbstractTestSupport method transform.
protected GtfsRelationalDao transform() {
try {
_transformer.run();
GtfsReader reader = new GtfsReader();
reader.setInputLocation(_outputPath);
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
reader.setEntityStore(dao);
reader.run();
return dao;
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
use of org.onebusaway.gtfs.serialization.GtfsReader in project onebusaway-gtfs-modules by OneBusAway.
the class EntityRetentionGraphTest method setup.
@Before
public void setup() throws IOException {
_dao = new GtfsRelationalDaoImpl();
_graph = new EntityRetentionGraph(_dao);
GtfsReader reader = new GtfsReader();
File path = new File(getClass().getResource("/org/onebusaway/gtfs_transformer/testagency").getPath());
reader.setInputLocation(path);
reader.setEntityStore(_dao);
reader.run();
}
use of org.onebusaway.gtfs.serialization.GtfsReader in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsTestData method readGtfs.
public static <T extends GenericMutableDao> void readGtfs(T entityStore, File resourcePath, String defaultAgencyId) throws IOException {
GtfsReader reader = new GtfsReader();
reader.setDefaultAgencyId(defaultAgencyId);
reader.setInputLocation(resourcePath);
reader.setEntityStore(entityStore);
reader.run();
}
use of org.onebusaway.gtfs.serialization.GtfsReader 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());
}
}
use of org.onebusaway.gtfs.serialization.GtfsReader in project onebusaway-gtfs-modules by OneBusAway.
the class EntityCounterMain method main.
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err.println("usage: path/to/gtfs_feed");
System.exit(-1);
}
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
EntityCounter counter = new EntityCounter();
reader.addEntityHandler(counter);
reader.run();
Map<Class<?>, Integer> counts = counter.getCounts();
List<Class<?>> types = new ArrayList<Class<?>>(counts.keySet());
Collections.sort(types, new ClassNameComparator());
for (Class<?> type : types) System.out.println(type.getName() + " " + counts.get(type));
}
Aggregations