本文整理汇总了Java中org.onebusaway.gtfs.serialization.GtfsReader类的典型用法代码示例。如果您正苦于以下问题:Java GtfsReader类的具体用法?Java GtfsReader怎么用?Java GtfsReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GtfsReader类属于org.onebusaway.gtfs.serialization包,在下文中一共展示了GtfsReader类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(
"src/test/resources/org/onebusaway/gtfs/caltrain-long-route.zip"));
reader.setEntityStore(_dao);
reader.setDefaultAgencyId(_agencyId);
List<Class<?>> entityClasses = reader.getEntityClasses();
entityClasses.clear();
entityClasses.add(Agency.class);
entityClasses.add(Route.class);
reader.run();
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:23,代码来源:LongRouteDescriptionTest.java
示例2: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(
"src/test/resources/org/onebusaway/gtfs/caltrain.zip"));
reader.setEntityStore(_dao);
reader.setDefaultAgencyId(_agencyId);
reader.run();
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:17,代码来源:HibernateGtfsRelationalDaoImplCaltrainTest.java
示例3: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(
"src/test/resources/org/onebusaway/gtfs/bart.zip"));
reader.setEntityStore(_dao);
reader.setDefaultAgencyId(_agencyId);
reader.run();
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:17,代码来源:HibernateGtfsRelationalImplBartTest.java
示例4: testExtensionRead
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@Test
public void testExtensionRead() throws IOException {
MockGtfs gtfs = MockGtfs.create();
gtfs.putMinimal();
gtfs.putStops(2, "label=a,b");
DefaultEntitySchemaFactory factory = GtfsEntitySchemaFactory.createEntitySchemaFactory();
factory.addExtension(Stop.class, StopExtension.class);
GtfsReader reader = new GtfsReader();
reader.setEntitySchemaFactory(factory);
GtfsMutableRelationalDao dao = gtfs.read(reader);
Stop stop = dao.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension = stop.getExtension(StopExtension.class);
assertEquals("a", extension.getLabel());
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:18,代码来源:ExtensionsTest.java
示例5: main
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
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));
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:23,代码来源:EntityCounterMain.java
示例6: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@Before
public void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
_dao.open();
_reader = new GtfsReader();
_reader.setEntityStore(_dao);
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:14,代码来源:GtfsMappingTest.java
示例7: translateFromCSVToObject
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
public void translateFromCSVToObject(CsvEntityContext context,
Map<String, Object> csvValues, BeanWrapper object) {
GtfsReaderContext ctx = (GtfsReaderContext) context.get(GtfsReader.KEY_CONTEXT);
String agencyId = (String) csvValues.get(_csvFieldName);
Agency agency = null;
if (isMissing(csvValues)) {
List<Agency> agencies = ctx.getAgencies();
if (agencies.isEmpty()) {
throw new AgencyNotFoundForRouteException(Route.class,
object.getWrappedInstance(Route.class));
} else if (agencies.size() > 1) {
throw new MissingRequiredFieldException(_entityType, _csvFieldName);
}
agency = agencies.get(0);
} else {
agencyId = ctx.getTranslatedAgencyId(agencyId);
for (Agency testAgency : ctx.getAgencies()) {
if (testAgency.getId().equals(agencyId)) {
agency = testAgency;
break;
}
}
if (agency == null)
throw new AgencyNotFoundForRouteException(Route.class,
object.getWrappedInstance(Route.class), agencyId);
}
object.setPropertyValue(_objFieldName, agency);
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:34,代码来源:RouteAgencyFieldMappingFactory.java
示例8: create
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
/****
* {@link ConverterFactory}
****/
@Override
public Converter create(CsvEntityContext context) {
GtfsReaderContext ctx = (GtfsReaderContext) context.get(GtfsReader.KEY_CONTEXT);
return new ConverterImpl(ctx);
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:10,代码来源:EntityFieldMappingImpl.java
示例9: resolveAgencyId
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
private String resolveAgencyId(CsvEntityContext context, BeanWrapper object) {
if (_agencyIdPath == null) {
GtfsReaderContext ctx = (GtfsReaderContext) context.get(GtfsReader.KEY_CONTEXT);
return ctx.getDefaultAgencyId();
}
for (String property : _agencyIdPath.split("\\.")) {
Object value = object.getPropertyValue(property);
object = BeanWrapperFactory.wrap(value);
}
return object.getWrappedInstance(Object.class).toString();
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:15,代码来源:DefaultAgencyIdFieldMappingFactory.java
示例10: read
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
public GtfsMutableRelationalDao read(GtfsReader reader) throws IOException {
reader.setInputLocation(_path);
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
reader.setEntityStore(dao);
try {
reader.run();
} finally {
reader.close();
}
return dao;
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:12,代码来源:MockGtfs.java
示例11: main
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
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());
}
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:34,代码来源:GtfsReaderExampleMain.java
示例12: get
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@Override
public GtfsRelationalDao get() {
_log.info("Loading GTFS from {}", _gtfsPath.toString());
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsReader reader = new GtfsReader();
reader.setEntityStore(dao);
try {
reader.setInputLocation(_gtfsPath);
reader.run();
reader.close();
} catch (IOException e) {
throw new RuntimeException("Failure while reading GTFS", e);
}
return dao;
}
开发者ID:kurtraschke,项目名称:wsf-gtfsrealtime,代码行数:16,代码来源:GtfsRelationalDaoProvider.java
示例13: setGtfsBundle
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
public void setGtfsBundle(File gtfsBundle) throws IOException {
GtfsReader reader = new GtfsReader();
reader.setInputLocation(gtfsBundle);
dao = new GtfsRelationalDaoImpl();
reader.setEntityStore((GtfsRelationalDaoImpl) dao);
reader.run();
}
开发者ID:kurtraschke,项目名称:gtfsview,代码行数:9,代码来源:GtfsViewController.java
示例14: main
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
if (!(args.length == 1 || args.length == 2)) {
System.err.println("usage: gtfsPath [hibernate-config.xml]");
System.exit(-1);
}
String resource = "classpath:org/onebusaway/gtfs/examples/hibernate-configuration-examples.xml";
if (args.length == 2)
resource = args[1];
HibernateGtfsFactory factory = createHibernateGtfsFactory(resource);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
GtfsMutableRelationalDao dao = factory.getDao();
reader.setEntityStore(dao);
reader.run();
Collection<Stop> stops = dao.getAllStops();
for (Stop stop : stops)
System.out.println(stop.getName());
CalendarService calendarService = factory.getCalendarService();
Set<AgencyAndId> serviceIds = calendarService.getServiceIds();
for (AgencyAndId serviceId : serviceIds) {
Set<ServiceDate> dates = calendarService.getServiceDatesForServiceId(serviceId);
ServiceDate from = null;
ServiceDate to = null;
for (ServiceDate date : dates) {
from = min(from, date);
to = max(to, date);
}
System.out.println("serviceId=" + serviceId + " from=" + from + " to="
+ to);
}
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:42,代码来源:GtfsHibernateReaderExampleMain.java
示例15: testExtensionWrite
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
@Test
public void testExtensionWrite() throws IOException {
DefaultEntitySchemaFactory factory = GtfsEntitySchemaFactory.createEntitySchemaFactory();
factory.addExtension(Stop.class, StopExtension.class);
{
MockGtfs gtfs = MockGtfs.create();
gtfs.putMinimal();
gtfs.putStops(2, "label=a,b");
GtfsReader reader = new GtfsReader();
reader.setEntitySchemaFactory(factory);
GtfsMutableRelationalDao dao = gtfs.read(reader);
Stop stop = dao.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension = stop.getExtension(StopExtension.class);
assertEquals("a", extension.getLabel());
GtfsWriter writer = new GtfsWriter();
writer.setEntitySchemaFactory(factory);
writer.setOutputLocation(_tmpDirectory);
writer.run(dao);
writer.close();
}
{
GtfsReader reader2 = new GtfsReader();
reader2.setEntitySchemaFactory(factory);
reader2.setInputLocation(_tmpDirectory);
GtfsRelationalDaoImpl dao2 = new GtfsRelationalDaoImpl();
reader2.setDefaultAgencyId("a0");
reader2.setEntityStore(dao2);
reader2.readEntities(Stop.class);
Stop stop2 = dao2.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension2 = stop2.getExtension(StopExtension.class);
assertEquals("a", extension2.getLabel());
}
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:42,代码来源:ExtensionsTest.java
示例16: readGtfs
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
public static GtfsContext readGtfs(File path, String defaultAgencyId) throws IOException {
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsReader reader = new GtfsReader();
reader.setInputLocation(path);
reader.setEntityStore(dao);
if (defaultAgencyId != null) {
reader.setDefaultAgencyId(defaultAgencyId);
}
reader.run();
CalendarService calendarService = createCalendarService(dao);
return new GtfsContextImpl(dao, calendarService);
}
开发者ID:trein,项目名称:gtfs-java,代码行数:19,代码来源:GtfsLibrary.java
示例17: translateFromCSVToObject
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
public void translateFromCSVToObject(CsvEntityContext context, Map<String, Object> csvValues, BeanWrapper object) {
if (isMissingAndOptional(csvValues))
return;
String agencyId = (String) csvValues.get(_csvFieldName);
GtfsReaderContext ctx = (GtfsReaderContext) context.get(GtfsReader.KEY_CONTEXT);
agencyId = ctx.getTranslatedAgencyId(agencyId);
object.setPropertyValue(_objFieldName, agencyId);
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:13,代码来源:AgencyIdTranslationFieldMappingFactory.java
示例18: readGtfs
import org.onebusaway.gtfs.serialization.GtfsReader; //导入依赖的package包/类
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();
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:13,代码来源:GtfsTestData.java
注:本文中的org.onebusaway.gtfs.serialization.GtfsReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论