当前位置: 首页>>代码示例>>Java>>正文


Java GtfsReader.setInputLocation方法代码示例

本文整理汇总了Java中org.onebusaway.gtfs.serialization.GtfsReader.setInputLocation方法的典型用法代码示例。如果您正苦于以下问题:Java GtfsReader.setInputLocation方法的具体用法?Java GtfsReader.setInputLocation怎么用?Java GtfsReader.setInputLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onebusaway.gtfs.serialization.GtfsReader的用法示例。


在下文中一共展示了GtfsReader.setInputLocation方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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.setInputLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。