Package org.onebusaway.transit_data_federation.services.blocks

Examples of org.onebusaway.transit_data_federation.services.blocks.BlockTripInstance


  private ArrivalAndDepartureInstance createArrivalAndDeparture(
      BlockInstance blockInstance, AgencyAndId tripId, AgencyAndId stopId,
      int stopSequence, long serviceDate, int timeOfServiceDate,
      long prevFrequencyTime) {

    BlockTripInstance blockTripInstance = BlockTripInstanceLibrary.getBlockTripInstance(
        blockInstance, tripId);

    if (blockTripInstance == null)
      return null;

    BlockStopTimeEntry blockStopTime = getBlockStopTime(blockTripInstance,
        stopId, stopSequence, timeOfServiceDate);
    StopTimeInstance stopTimeInstance = new StopTimeInstance(blockStopTime,
        blockTripInstance.getState());

    return createArrivalAndDeparture(stopTimeInstance, prevFrequencyTime,
        StopTimeInstance.UNSPECIFIED_FREQUENCY_OFFSET);
  }
View Full Code Here


   * @return the active trip instance for the block location
   */
  public BlockTripInstance getActiveTripInstance() {
    if (activeTrip == null)
      return null;
    return new BlockTripInstance(activeTrip, blockInstance.getState());
  }
View Full Code Here

    stopTime(0, stop, trip, time(8, 53), 0);
    BlockEntryImpl block = block("block");
    BlockConfigurationEntry blockConfig = blockConfiguration(block,
        serviceIds(lsids("a"), lsids()), trip);

    BlockTripInstance blockTripInstance = new BlockTripInstance(
        blockConfig.getTrips().get(0), new InstanceState(
            System.currentTimeMillis()));

    List<ServiceAlert> alerts = _service.getServiceAlertsForVehicleJourney(
        System.currentTimeMillis(), blockTripInstance, new AgencyAndId("1",
View Full Code Here

    for (Map.Entry<BlockInstance, List<BlockLocation>> entry : locationsByInstance.entrySet()) {

      BlockInstance blockInstance = entry.getKey();
      List<BlockLocation> locations = entry.getValue();

      BlockTripInstance blockTripInstance = BlockTripInstanceLibrary.getBlockTripInstance(
          blockInstance, tripId);

      if (blockTripInstance == null)
        throw new IllegalStateException("expected blockTrip for trip="
            + tripEntry + " and block=" + blockInstance);
View Full Code Here

    if (blockLocation.isLastKnownOrientationSet())
      bean.setLastKnownOrientation(blockLocation.getLastKnownOrientation());

    bean.setScheduleDeviation(blockLocation.getScheduleDeviation());

    BlockTripInstance activeTripInstance = blockLocation.getActiveTripInstance();

    if (activeTripInstance != null) {
      BlockTripEntry activeBlockTrip = activeTripInstance.getBlockTrip();
      bean.setScheduledDistanceAlongTrip(blockLocation.getScheduledDistanceAlongBlock()
          - activeBlockTrip.getDistanceAlongBlock());
      bean.setDistanceAlongTrip(blockLocation.getDistanceAlongBlock()
          - activeBlockTrip.getDistanceAlongBlock());
      TripEntry activeTrip = activeBlockTrip.getTrip();
      bean.setTotalDistanceAlongTrip(activeTrip.getTotalTripDistance());

      TripBean activeTripBean = _tripBeanService.getTripForId(activeTrip.getId());
      bean.setActiveTrip(activeTripBean);
      bean.setBlockTripSequence(activeBlockTrip.getSequence());

      if (blockLocation.isLastKnownDistanceAlongBlockSet()) {
        bean.setLastKnownDistanceAlongTrip(blockLocation.getLastKnownDistanceAlongBlock()
            - activeBlockTrip.getDistanceAlongBlock());
      }

      FrequencyEntry frequencyLabel = activeTripInstance.getFrequencyLabel();

      if (frequencyLabel != null) {
        FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(
            serviceDate, frequencyLabel);
        bean.setFrequency(fb);
View Full Code Here

  public BlockTripEntry getBlockTrip() {
    return stopTimeInstance.getTrip();
  }

  public BlockTripInstance getBlockTripInstance() {
    return new BlockTripInstance(stopTimeInstance.getTrip(),
        stopTimeInstance.getState());
  }
View Full Code Here

  }

  private TransitLegBuilder getTransitLegBuilderAsLeg(
      TransitLegBuilder builder, List<LegBean> legs) {

    BlockTripInstance blockTripInstanceFrom = builder.getBlockTripInstanceFrom();

    if (blockTripInstanceFrom == null)
      return new TransitLegBuilder();

    LegBean leg = createTransitLegFromBuilder(builder);
View Full Code Here

    return new TransitLegBuilder();
  }

  private LegBean createTransitLegFromBuilder(TransitLegBuilder builder) {

    BlockTripInstance blockTripInstanceFrom = builder.getBlockTripInstanceFrom();

    LegBean leg = new LegBean();

    leg.setStartTime(builder.getBestDepartureTime());
    leg.setEndTime(builder.getBestArrivalTime());

    double distance = getTransitLegBuilderAsDistance(builder);
    leg.setDistance(distance);

    leg.setMode(MODE_TRANSIT);

    TripEntry trip = blockTripInstanceFrom.getBlockTrip().getTrip();

    TransitLegBean transitLeg = new TransitLegBean();
    leg.setTransitLeg(transitLeg);

    transitLeg.setServiceDate(blockTripInstanceFrom.getServiceDate());

    FrequencyEntry frequencyLabel = blockTripInstanceFrom.getFrequencyLabel();
    if (frequencyLabel != null) {
      FrequencyBean frequency = FrequencyBeanLibrary.getBeanForFrequency(
          blockTripInstanceFrom.getServiceDate(), frequencyLabel);
      transitLeg.setFrequency(frequency);
    }

    TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
    transitLeg.setTrip(tripBean);
View Full Code Here

    return leg;
  }

  private double getTransitLegBuilderAsDistance(TransitLegBuilder builder) {

    BlockTripInstance blockTripInstanceFrom = builder.getBlockTripInstanceFrom();
    BlockTripEntry trip = blockTripInstanceFrom.getBlockTrip();

    BlockStopTimeEntry fromStop = null;
    BlockStopTimeEntry toStop = null;

    if (builder.getFromStop() != null)
View Full Code Here

    return toStop.getDistanceAlongBlock() - fromStop.getDistanceAlongBlock();
  }

  private String getTransitLegBuilderAsPath(TransitLegBuilder builder) {

    BlockTripInstance blockTripInstanceFrom = builder.getBlockTripInstanceFrom();
    BlockTripEntry blockTrip = blockTripInstanceFrom.getBlockTrip();
    TripEntry trip = blockTrip.getTrip();

    AgencyAndId shapeId = trip.getShapeId();

    if (shapeId == null)
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.blocks.BlockTripInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.