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


Java Trip类代码示例

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


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


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