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

Java Trip类代码示例

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

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



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

示例1: testFrequency

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


示例2: getEntityClasses

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
public static List<Class<?>> getEntityClasses() {
  List<Class<?>> entityClasses = new ArrayList<Class<?>>();
  entityClasses.add(FeedInfo.class);
  entityClasses.add(Agency.class);
  entityClasses.add(Block.class);
  entityClasses.add(ShapePoint.class);
  entityClasses.add(Route.class);
  entityClasses.add(Stop.class);
  entityClasses.add(Trip.class);
  entityClasses.add(StopTime.class);
  entityClasses.add(ServiceCalendar.class);
  entityClasses.add(ServiceCalendarDate.class);
  entityClasses.add(FareAttribute.class);
  entityClasses.add(FareRule.class);
  entityClasses.add(Frequency.class);
  entityClasses.add(Pathway.class);
  entityClasses.add(Transfer.class);
  return entityClasses;
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:20,代码来源:GtfsEntitySchemaFactory.java


示例3: getEntityComparators

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
public static Map<Class<?>, Comparator<?>> getEntityComparators() {
  Map<Class<?>, Comparator<?>> comparators = new HashMap<Class<?>, Comparator<?>>();
  comparators.put(Agency.class,
      getComparatorForIdentityBeanType(Agency.class));
  comparators.put(Block.class,
      getComparatorForIdentityBeanType(Block.class));
  comparators.put(Route.class, getComparatorForIdentityBeanType(Route.class));
  comparators.put(Stop.class, getComparatorForIdentityBeanType(Stop.class));
  comparators.put(Trip.class, getComparatorForIdentityBeanType(Trip.class));
  comparators.put(StopTime.class, new StopTimeComparator());
  comparators.put(ShapePoint.class, new ShapePointComparator());
  comparators.put(ServiceCalendar.class, new ServiceCalendarComparator());
  comparators.put(ServiceCalendarDate.class,
      new ServiceCalendarDateComparator());
  return comparators;
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:17,代码来源:GtfsEntitySchemaFactory.java


示例4: getTripsForBlockId

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


示例5: testFrequency

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


示例6: testSyntheticGetTripAgencyIdsReferencingServiceId

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


示例7: buildTripDescriptor

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
private TripDescriptor buildTripDescriptor(VesselLocationResponse vlr) {
  TripDescriptor.Builder tripDescriptor = TripDescriptor.newBuilder();

  ActivatedTrip activatedTrip = _tripResolutionService.resolve(vlr.getDepartingTerminalID().toString(),
          ts(vlr.getScheduledDeparture().getValue()),
          vlr.getArrivingTerminalID().getValue().toString());

  if (activatedTrip == null) {
    return null;
  }

  Trip trip = activatedTrip.getTrip();
  ServiceDate sd = activatedTrip.getServiceDate();

  tripDescriptor.setTripId(trip.getId().getId());
  tripDescriptor.setRouteId(trip.getRoute().getId().getId());
  tripDescriptor.setStartDate(sd.getAsString());

  return tripDescriptor.build();
}
 
开发者ID:kurtraschke,项目名称:wsf-gtfsrealtime,代码行数:21,代码来源:WSFRealtimeProvider.java


示例8: getListCellRendererComponent

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
@Override
public Component getListCellRendererComponent(
        JList list, Object value, int index,
        boolean isSelected, boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index,
            isSelected, cellHasFocus);

    if (value != null) {
        Trip trip = (Trip) value;

        if (trip.getTripShortName() != null) {
            setText(trip.getTripShortName());
        } else if (trip.getTripHeadsign() != null) {
            setText(trip.getTripHeadsign());
        } else {
            setText(trip.getId().getId());
        }

    } else {
        setText("Select Trip...");
    }
    return this;
}
 
开发者ID:kurtraschke,项目名称:gtfsview,代码行数:24,代码来源:TripRenderer.java


示例9: dumpToWriter

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
public void dumpToWriter(GtfsWriter gtfsWriter) {
    for(Agency agency : agencies){
    	gtfsWriter.handleEntity( agency );
    }
    for(Route route : routes){
    	gtfsWriter.handleEntity(route);
    }
    for(Trip trip : trips){
    	gtfsWriter.handleEntity(trip);
    }
    for(Stop stop : stops){
    	gtfsWriter.handleEntity(stop);
    }
    for(StopTime stoptime : stoptimes){
    	gtfsWriter.handleEntity(stoptime);
    }
    for(Frequency fr : frequencies){
    	gtfsWriter.handleEntity(fr);
    }
    for(ServiceCalendar sc : calendars){
    	gtfsWriter.handleEntity(sc);
    }
}
 
开发者ID:conveyal,项目名称:geom2gtfs,代码行数:24,代码来源:GtfsQueue.java


示例10: matchesFrom

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
private boolean matchesFrom(Trip trip) {
    checkNotNull(trip);
    
    boolean match = false;
    int specificity = getFromSpecificity();
    if (specificity == 0) {
        match = true;
    }
    else if (specificity == 1) {
        if (trip.getRoute().getId().equals(fromRouteId)) {
            match = true;
        }
    }
    else if (specificity == 2) {
        if (trip.getId().equals(fromTripId)) {
            match = true;
        }
    }
    return match;
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:21,代码来源:SpecificTransfer.java


示例11: matchesTo

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
private boolean matchesTo(Trip trip) {
    checkNotNull(trip);

    boolean match = false;
    int specificity = getToSpecificity();
    if (specificity == 0) {
        match = true;
    }
    else if (specificity == 1) {
        if (trip.getRoute().getId().equals(toRouteId)) {
            match = true;
        }
    }
    else if (specificity == 2) {
        if (trip.getId().equals(toTripId)) {
            match = true;
        }
    }
    return match;
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:21,代码来源:SpecificTransfer.java


示例12: getTransferTime

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
/**
 * Get the transfer time that should be used when transferring from a trip to another trip.
 * Note that this function does not check whether another specific transfer exists with the
 * same specificity, what is forbidden by the specifications.    
 * @param fromTrip is the arriving trip
 * @param toTrip is the departing trip
 * @return the transfer time in seconds. May contain special (negative) values which meaning
 *   can be found in the *_TRANSFER constants.
 */
public int getTransferTime(Trip fromTrip, Trip toTrip) {
    // By default the transfer is unknown
    int transferTime = UNKNOWN_TRANSFER;
    
    // Pick the matching specific transfer with the highest specificity
    int maxFoundSpecificity = SpecificTransfer.MIN_SPECIFICITY - 1;
    for (SpecificTransfer specificTransfer : specificTransfers) {
        int specificity = specificTransfer.getSpecificity(); 
        if (specificity > maxFoundSpecificity) {
            if (specificTransfer.matches(fromTrip, toTrip)) {
                // Set the found transfer time
                transferTime = specificTransfer.transferTime;
                maxFoundSpecificity = specificity;
                
                // Break when highest specificity is found
                if (maxFoundSpecificity == SpecificTransfer.MAX_SPECIFICITY) {
                    break;
                }
            }
        }
    }
    
    // Return transfer time
    return transferTime;
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:35,代码来源:StopTransfer.java


示例13: addTransferTime

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
/**
 * Add a transfer time to the transfer table.
 * 
 * @param fromStop is the arriving stop
 * @param toStop is the departing stop
 * @param fromRoute is the arriving route; is allowed to be null
 * @param toRoute is the departing route; is allowed to be null
 * @param fromTrip is the arriving trip; is allowed to be null
 * @param toTrip is the departing trip; is allowed to be null
 * @param transferTime is the transfer time in seconds. May contain special (negative) values
 *        which meaning can be found in the StopTransfer.*_TRANSFER constants. If no transfer is
 *        found, StopTransfer.UNKNOWN_TRANSFER is returned.
 */
public void addTransferTime(Stop fromStop, Stop toStop, Route fromRoute, Route toRoute, Trip fromTrip, Trip toTrip,
        int transferTime) {
    checkNotNull(fromStop);
    checkNotNull(toStop);
    
    // Check whether this transfer is preferred (or timed)
    if ((transferTime == StopTransfer.PREFERRED_TRANSFER) || (transferTime == StopTransfer.TIMED_TRANSFER)) {
        this.preferredTransfers = true;
    }

    // Lookup whether a transfer between the two stops already exists
    P2<AgencyAndId> stopIdPair = new P2<AgencyAndId>(fromStop.getId(), toStop.getId());
    StopTransfer stopTransfer = this.table.get(stopIdPair);
    if (stopTransfer == null) {
        // If not, create one and add to table
        stopTransfer = new StopTransfer();
        this.table.put(stopIdPair, stopTransfer);
    }
    assert (stopTransfer != null);

    // Create and add a specific transfer to the stop transfer
    SpecificTransfer specificTransfer = new SpecificTransfer(fromRoute, toRoute, fromTrip, toTrip, transferTime);
    stopTransfer.addSpecificTransfer(specificTransfer);
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:38,代码来源:TransferTable.java


示例14: testGetAllTrips

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

@Test
public void testGetAllTrips() {
  List<Trip> trips = _dao.getAllTrips();
  assertEquals(260, trips.size());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:10,代码来源:HibernateGtfsRelationalDaoImplCaltrainTest.java


示例15: testGetTripById

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
@Test
public void testGetTripById() {
  Route route = _dao.getRouteForId(aid("ct_local"));

  Trip trip = _dao.getTripForId(aid("10101272009"));
  assertEquals(aid("10101272009"), trip.getId());
  assertNull(trip.getBlockId());
  assertEquals("0", trip.getDirectionId());
  assertEquals(route, trip.getRoute());
  assertNull(trip.getRouteShortName());
  assertEquals(aid("WD01272009"), trip.getServiceId());
  assertEquals(aid("cal_sj_sf"), trip.getShapeId());
  assertEquals("101", trip.getTripShortName());
  assertEquals("San Jose to San Francisco", trip.getTripHeadsign());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:16,代码来源:HibernateGtfsRelationalDaoImplCaltrainTest.java


示例16: testFrequenciesForTrip

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
@Test
public void testFrequenciesForTrip() {
  Trip trip = _dao.getTripForId(new AgencyAndId("AirBART", "M-FSAT1DN"));
  List<Frequency> frequencies = _dao.getFrequenciesForTrip(trip);
  assertEquals(1, frequencies.size());

  Frequency frequency = frequencies.get(0);
  assertEquals(5 * 60 * 60, frequency.getStartTime());
  assertEquals(6 * 60 * 60, frequency.getEndTime());
  assertEquals(trip, frequency.getTrip());
  assertEquals(1200, frequency.getHeadwaySecs());
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:13,代码来源:HibernateGtfsRelationalImplBartTest.java


示例17: compare

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
@Override
public int compare(StopTime o1, StopTime o2) {
  Trip trip1 = o1.getTrip();
  Trip trip2 = o2.getTrip();
  int c = trip1.getId().compareTo(trip2.getId());
  
  if( c == 0)
    c = o1.getStopSequence() - o2.getStopSequence();
  
  return c;
}
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:12,代码来源:StopTimeComparator.java


示例18: GtfsReader

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
public GtfsReader() {

    _entityClasses.add(Agency.class);
    _entityClasses.add(Block.class);
    _entityClasses.add(ShapePoint.class);
    _entityClasses.add(Route.class);
    _entityClasses.add(Stop.class);
    _entityClasses.add(Trip.class);
    _entityClasses.add(StopTime.class);
    _entityClasses.add(ServiceCalendar.class);
    _entityClasses.add(ServiceCalendarDate.class);
    _entityClasses.add(FareAttribute.class);
    _entityClasses.add(FareRule.class);
    _entityClasses.add(Frequency.class);
    _entityClasses.add(Pathway.class);
    _entityClasses.add(Transfer.class);
    _entityClasses.add(FeedInfo.class);

    CsvTokenizerStrategy tokenizerStrategy = new CsvTokenizerStrategy();
    tokenizerStrategy.getCsvParser().setTrimInitialWhitespace(true);
    setTokenizerStrategy(tokenizerStrategy);
    
    setTrimValues(true);

    /**
     * Prep the Entity Schema Factories
     */
    DefaultEntitySchemaFactory schemaFactory = createEntitySchemaFactory();
    setEntitySchemaFactory(schemaFactory);

    CsvEntityContext ctx = getContext();
    ctx.put(KEY_CONTEXT, _context);

    addEntityHandler(new EntityHandlerImpl());
  }
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:36,代码来源:GtfsReader.java


示例19: handleEntity

import org.onebusaway.gtfs.model.Trip; //导入依赖的package包/类
public void handleEntity(Object entity) {

      if (entity instanceof Agency) {
        Agency agency = (Agency) entity;
        if (agency.getId() == null) {
          if (_defaultAgencyId == null)
            agency.setId(agency.getName());
          else
            agency.setId(_defaultAgencyId);
        }

        // If we already have this agency from a previous load, then we don't
        // add it or save it to the entity store
        if (_agencies.contains(agency))
          return;

        _agencies.add((Agency) entity);
      } else if (entity instanceof Pathway) {
        Pathway pathway = (Pathway) entity;
        registerAgencyId(Pathway.class, pathway.getId());
      } else if (entity instanceof Route) {
        Route route = (Route) entity;
        registerAgencyId(Route.class, route.getId());
      } else if (entity instanceof Trip) {
        Trip trip = (Trip) entity;
        registerAgencyId(Trip.class, trip.getId());
      } else if (entity instanceof Stop) {
        Stop stop = (Stop) entity;
        registerAgencyId(Stop.class, stop.getId());
      } else if (entity instanceof FareAttribute) {
        FareAttribute fare = (FareAttribute) entity;
        registerAgencyId(FareAttribute.class, fare.getId());
      }

      if (entity instanceof IdentityBean<?>) {
        _entityStore.saveEntity(entity);
      }

    }
 
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:40,代码来源:GtfsReader.java


示例20: getStopTimesForTrip

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

  if (_stopTimesByTrip == null) {
    _stopTimesByTrip = mapToValueList(getAllStopTimes(), "trip", Trip.class);
    for (List<StopTime> stopTimes : _stopTimesByTrip.values())
      Collections.sort(stopTimes);
  }

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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