• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AgencyAndId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.onebusaway.gtfs.model.AgencyAndId的典型用法代码示例。如果您正苦于以下问题:Java AgencyAndId类的具体用法?Java AgencyAndId怎么用?Java AgencyAndId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AgencyAndId类属于org.onebusaway.gtfs.model包,在下文中一共展示了AgencyAndId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testSyntheticGetTripAgencyIdsReferencingServiceId

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testSyntheticGetTripAgencyIdsReferencingServiceId() {

  GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();

  AgencyAndId serviceId = new AgencyAndId("C", "serviceId");

  Trip tripA = new Trip();
  tripA.setId(new AgencyAndId("A", "tripId"));
  tripA.setServiceId(serviceId);
  dao.saveEntity(tripA);

  Trip tripB = new Trip();
  tripB.setId(new AgencyAndId("B", "tripId"));
  tripB.setServiceId(serviceId);
  dao.saveEntity(tripB);

  List<String> agencyIds = dao.getTripAgencyIdsReferencingServiceId(serviceId);
  assertEquals(2, agencyIds.size());
  assertTrue(agencyIds.contains("A"));
  assertTrue(agencyIds.contains("B"));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:23,代码来源:GtfsRelationalDaoImplTest.java


示例2: testFrequency

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testFrequency() throws CsvEntityIOException, IOException {

  _reader.setDefaultAgencyId("1");

  Trip trip = new Trip();
  trip.setId(new AgencyAndId("1", "trip"));
  _reader.injectEntity(trip);

  StringBuilder b = new StringBuilder();
  b.append("trip_id,start_time,end_time,headway_secs,exact_times\n");
  b.append("trip,08:30:00,09:45:00,300,1\n");

  _reader.readEntities(Frequency.class, new StringReader(b.toString()));

  Frequency frequency = _dao.getFrequencyForId(1);
  assertEquals(30600, frequency.getStartTime());
  assertEquals(35100, frequency.getEndTime());
  assertEquals(1, frequency.getExactTimes());
  assertEquals(300, frequency.getHeadwaySecs());
  assertSame(trip, frequency.getTrip());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:23,代码来源:GtfsMappingTest.java


示例3: translateFromCSVToObject

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public void translateFromCSVToObject(CsvEntityContext context,
    Map<String, Object> csvValues, BeanWrapper object) {

  String agencyId = (String) csvValues.get(_csvFieldName + "_agencyId");
  String id = (String) csvValues.get(_csvFieldName + "_id");
  boolean missing = (agencyId == null || agencyId.isEmpty())
      || (id == null || id.isEmpty());
  if (missing) {
    if (_required)
      throw new MissingRequiredFieldException(_entityType, _csvFieldName);
    return;
  }
  AgencyAndId agencyAndId = new AgencyAndId(agencyId, id);
  object.setPropertyValue(_objFieldName, agencyAndId);
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:17,代码来源:AgencyIdFieldMappingFactory.java


示例4: getStopsForStation

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public List<Stop> getStopsForStation(Stop station) {
  if (_stopsByStation == null) {
    _stopsByStation = new HashMap<Stop, List<Stop>>();
    for (Stop stop : getAllStops()) {
      if (stop.getLocationType() == 0 && stop.getParentStation() != null) {
        Stop parentStation = getStopForId(new AgencyAndId(
            stop.getId().getAgencyId(), stop.getParentStation()));
        List<Stop> subStops = _stopsByStation.get(parentStation);
        if (subStops == null) {
          subStops = new ArrayList<Stop>(2);
          _stopsByStation.put(parentStation, subStops);
        }
        subStops.add(stop);
      }
    }
  }
  return list(_stopsByStation.get(station));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:20,代码来源:GtfsRelationalDaoImpl.java


示例5: getTripsForBlockId

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public List<Trip> getTripsForBlockId(AgencyAndId blockId) {

  if (_tripsByBlockId == null) {
    _tripsByBlockId = new HashMap<AgencyAndId, List<Trip>>();
    for (Trip trip : getAllTrips()) {
      if (trip.getBlockId() != null) {
        AgencyAndId bid = new AgencyAndId(trip.getId().getAgencyId(),
            trip.getBlockId());
        List<Trip> trips = _tripsByBlockId.get(bid);
        if (trips == null) {
          trips = new ArrayList<Trip>();
          _tripsByBlockId.put(bid, trips);
        }
        trips.add(trip);
      }
    }
  }

  return list(_tripsByBlockId.get(blockId));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:22,代码来源:GtfsRelationalDaoImpl.java


示例6: testBart

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testBart() throws IOException, ParseException {

  File resourcePath = GtfsTestData.getBartGtfs();
  String agencyId = "BART";
  GtfsDao entityStore = processFeed(resourcePath, agencyId, false);

  Collection<Frequency> frequencies = entityStore.getAllFrequencies();
  assertEquals(6, frequencies.size());

  List<Frequency> frequenciesForTrip = GtfsTestData.grep(frequencies,
      "trip.id", new AgencyAndId("AirBART", "M-FSAT1DN"));
  assertEquals(1, frequenciesForTrip.size());
  Frequency frequencyForTrip = frequenciesForTrip.get(0);
  assertEquals(18000, frequencyForTrip.getStartTime());
  assertEquals(21600, frequencyForTrip.getEndTime());
  assertEquals(1200, frequencyForTrip.getHeadwaySecs());

  Collection<Transfer> transfers = entityStore.getAllTransfers();
  assertEquals(4, transfers.size());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:22,代码来源:GtfsReaderTest.java


示例7: testUtf8

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testUtf8() throws IOException, ParseException,
    InterruptedException {

  MockGtfs mockGtfs = MockGtfs.create();
  mockGtfs.putDefaultStopTimes();
  mockGtfs.putFile("routes.txt", new File(
      "src/test/resources/org/onebusaway/gtfs/utf8-routes.txt"));

  String agencyId = "1";
  GtfsDao dao = processFeed(mockGtfs.getPath(), agencyId, false);

  Route route = dao.getRouteForId(new AgencyAndId(agencyId, "R10"));
  assertEquals("Enguera-Alcúdia de Crespins-Xàtiva", route.getLongName());

  route = dao.getRouteForId(new AgencyAndId(agencyId, "R11"));
  assertEquals("Tuéjar-Casinos", route.getLongName());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:19,代码来源:GtfsReaderTest.java


示例8: testFrequency

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testFrequency() throws CsvEntityIOException, IOException {

  GtfsReader reader = new GtfsReader();
  reader.setDefaultAgencyId("1");

  Trip trip = new Trip();
  trip.setId(new AgencyAndId("1", "trip"));
  reader.injectEntity(trip);

  StringBuilder b = new StringBuilder();
  b.append("trip_id,start_time,end_time,headway_secs,exact_times\n");
  b.append("trip,08:30:00,09:45:00,300,1\n");

  reader.readEntities(Frequency.class, new StringReader(b.toString()));

  Frequency frequency = reader.getEntityStore().getEntityForId(
      Frequency.class, 1);
  assertEquals(30600, frequency.getStartTime());
  assertEquals(35100, frequency.getEndTime());
  assertEquals(1, frequency.getExactTimes());
  assertEquals(300, frequency.getHeadwaySecs());
  assertSame(trip, frequency.getTrip());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:25,代码来源:GtfsReaderTest.java


示例9: testCsvParser

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testCsvParser() throws CsvEntityIOException, IOException {
  GtfsReader reader = new GtfsReader();
  reader.setDefaultAgencyId("1");

  Agency agency = new Agency();
  agency.setId("1");
  reader.setAgencies(Arrays.asList(agency));

  StringBuilder b = new StringBuilder();
  b.append("agency_id,route_id,route_short_name,route_long_name,route_type\n");
  b.append("        1,    R-10,              10,   \"Ten, Ten\",3\n");
  reader.readEntities(Route.class, new StringReader(b.toString()));
  Route route = reader.getEntityStore().getEntityForId(Route.class,
      new AgencyAndId("1", "R-10"));
  assertEquals("Ten, Ten", route.getLongName());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:18,代码来源:GtfsReaderTest.java


示例10: testExtensionRead

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的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


示例11: testPutCalendarDates

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testPutCalendarDates() throws IOException {
  _gtfs.putMinimal();
  _gtfs.putCalendarDates("sid0=20120901,-20120902", "sid1=20120903");
  GtfsRelationalDao dao = _gtfs.read();
  List<ServiceCalendarDate> dates = dao.getCalendarDatesForServiceId(new AgencyAndId(
      "a0", "sid0"));
  assertEquals(2, dates.size());
  assertEquals(new ServiceDate(2012, 9, 1), dates.get(0).getDate());
  assertEquals(1, dates.get(0).getExceptionType());
  assertEquals(new ServiceDate(2012, 9, 2), dates.get(1).getDate());
  assertEquals(2, dates.get(1).getExceptionType());
  dates = dao.getCalendarDatesForServiceId(new AgencyAndId("a0", "sid1"));
  assertEquals(1, dates.size());
  assertEquals(new ServiceDate(2012, 9, 3), dates.get(0).getDate());
  assertEquals(1, dates.get(0).getExceptionType());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:18,代码来源:MockGtfsTest.java


示例12: testDaylightSavingTime

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testDaylightSavingTime() {

  CalendarServiceDataFactoryImpl factory = new CalendarServiceDataFactoryImpl();

  Agency agencyA = agency("A", "America/Los_Angeles");
  AgencyAndId serviceId = new AgencyAndId("A", "2");

  ServiceDate dStart = new ServiceDate(2012, 3, 1);
  ServiceDate dEnd = new ServiceDate(2012, 3, 31);

  ServiceCalendar c = calendar(serviceId, dStart, dEnd, "1111111");

  GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
  factory.setGtfsDao(dao);

  saveEntities(dao, agencyA);
  saveEntities(dao, c);

  CalendarServiceData data = factory.createData();
  List<ServiceDate> serviceDates = data.getServiceDatesForServiceId(serviceId);
  assertTrue(serviceDates.contains(new ServiceDate(2012, 3, 11)));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:24,代码来源:CalendarServiceDataFactoryImplSyntheticTest.java


示例13: getTripAgencyIdsReferencingServiceId

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
/****
 * {@link GtfsRelationalDao} Interface
 ****/

@Override
public List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId) {
  return _ops.findByNamedQueryAndNamedParam("agencyIdsReferencingServiceId",
      "serviceId", serviceId);
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:10,代码来源:HibernateGtfsRelationalDaoImpl.java


示例14: getAllServiceIds

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public List<AgencyAndId> getAllServiceIds() {
  List<AgencyAndId> calendarIds = _ops.findByNamedQuery("calendarServiceIds");
  List<AgencyAndId> calendarDateIds = _ops.findByNamedQuery("calendarDateServiceIds");
  Set<AgencyAndId> allIds = new HashSet<AgencyAndId>();
  allIds.addAll(calendarIds);
  allIds.addAll(calendarDateIds);
  return new ArrayList<AgencyAndId>(allIds);
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:10,代码来源:HibernateGtfsRelationalDaoImpl.java


示例15: testDaylightSavingTimeCalendarDatesOnly

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testDaylightSavingTimeCalendarDatesOnly() throws IOException {

  CalendarServiceDataFactoryImpl factory = new CalendarServiceDataFactoryImpl();

  Agency agencyA = agency("A", "America/Los_Angeles");

  AgencyAndId serviceId = new AgencyAndId("A", "2");

  ServiceCalendarDate cd1 = calendarDate(serviceId, new ServiceDate(2012, 3,
      10), ServiceCalendarDate.EXCEPTION_TYPE_ADD);
  ServiceCalendarDate cd2 = calendarDate(serviceId, new ServiceDate(2012, 3,
      11), ServiceCalendarDate.EXCEPTION_TYPE_ADD);
  ServiceCalendarDate cd3 = calendarDate(serviceId, new ServiceDate(2012, 3,
      12), ServiceCalendarDate.EXCEPTION_TYPE_ADD);

  GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
  factory.setGtfsDao(dao);

  saveEntities(dao, agencyA);
  saveEntities(dao, cd1, cd2, cd3);

  CalendarServiceData data = factory.createData();
  List<ServiceDate> serviceDates = data.getServiceDatesForServiceId(serviceId);
  assertEquals(serviceDates,
      Arrays.asList(cd1.getDate(), cd2.getDate(), cd3.getDate()));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:28,代码来源:CalendarServiceDataFactoryImplSyntheticTest.java


示例16: getCalendarForServiceId

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public ServiceCalendar getCalendarForServiceId(AgencyAndId serviceId) {

  List<ServiceCalendar> calendars = _ops.findByNamedQueryAndNamedParam(
      "calendarsForServiceId", "serviceId", serviceId);

  switch (calendars.size()) {
    case 0:
      return null;
    case 1:
      return calendars.get(0);
  }

  throw new MultipleCalendarsForServiceIdException(serviceId);
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:16,代码来源:HibernateGtfsRelationalDaoImpl.java


示例17: testStopsForStation

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testStopsForStation() {

  Stop stationA = new Stop();
  stationA.setId(new AgencyAndId("X", "A"));
  _dao.saveEntity(stationA);

  Stop stationB = new Stop();
  stationB.setId(new AgencyAndId("X", "B"));
  _dao.saveEntity(stationB);

  Stop stopA1 = new Stop();
  stopA1.setId(new AgencyAndId("X", "A1"));
  stopA1.setParentStation("A");
  _dao.saveEntity(stopA1);

  Stop stopA2 = new Stop();
  stopA2.setId(new AgencyAndId("X", "A2"));
  stopA2.setParentStation("A");
  _dao.saveEntity(stopA2);

  Stop stopB1 = new Stop();
  stopB1.setId(new AgencyAndId("X", "B1"));
  stopB1.setParentStation("B");
  _dao.saveEntity(stopB1);

  _dao.flush();

  Stop station2 = _dao.getStopForId(new AgencyAndId("X", "A"));
  List<Stop> stops = _dao.getStopsForStation(station2);
  assertEquals(2, stops.size());
  Set<String> ids = new HashSet<String>();
  ids.add("A1");
  ids.add("A2");
  assertTrue(ids.contains(stops.get(0).getId().getId()));
  assertTrue(ids.contains(stops.get(1).getId().getId()));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:38,代码来源:HibernateGtfsRelationalDaoImplTest.java


示例18: testGetStopById

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testGetStopById() {
  AgencyAndId id = aid("Gilroy Caltrain");
  Stop stop = _dao.getStopForId(id);
  assertEquals(id, stop.getId());
  assertNull(stop.getCode());
  assertEquals("7150 Monterey Street, Gilroy", stop.getDesc());
  assertEquals(37.003084, stop.getLat(), 0.000001);
  assertEquals(-121.567091, stop.getLon(), 0.000001);
  assertEquals(0, stop.getLocationType());
  assertEquals("Gilroy Caltrain", stop.getName());
  assertEquals("6", stop.getZoneId());
  assertNull(stop.getUrl());
  assertNull(stop.getParentStation());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:16,代码来源:HibernateGtfsRelationalDaoImplCaltrainTest.java


示例19: testGet

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
/****
 * {@link ShapePoint} Methods
 ****/

@Test
public void testGet() {
  List<AgencyAndId> shapeIds = _dao.getAllShapeIds();
  assertEquals(6,shapeIds.size());
  assertTrue(shapeIds.contains(aid("cal_gil_sf")));
  assertTrue(shapeIds.contains(aid("cal_sf_gil")));
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:12,代码来源:HibernateGtfsRelationalDaoImplCaltrainTest.java


示例20: testCalendarForServiceId

import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testCalendarForServiceId() {

  ServiceCalendar calendar = _dao.getCalendarForServiceId(new AgencyAndId(
      "BART", "WKDY"));
  assertEquals(new ServiceDate(2007, 1, 1), calendar.getStartDate());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:8,代码来源:HibernateGtfsRelationalImplBartTest.java



注:本文中的org.onebusaway.gtfs.model.AgencyAndId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MetricsRESTSourceImpl类代码示例发布时间:2022-05-23
下一篇:
Java BasicDevice类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap