Package org.onebusaway.transit_data_federation.services.realtime

Examples of org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance


      /**
       * We've possibly transfered to another stop, so we need to insert the
       * walk leg
       */
      ArrivalAndDepartureInstance fromStopTimeInstance = arrival.getInstance();
      StopEntry fromStop = fromStopTimeInstance.getStop();

      DepartureVertex toStopVertex = (DepartureVertex) vTo;
      StopEntry toStop = toStopVertex.getStop();

      addTransferLegIfNeeded(state, fromStop, toStop, options, legs);
View Full Code Here


  }

  private void applyFromStopDetailsForTransitLeg(TransitLegBuilder builder,
      TransitLegBean transitLeg, LegBean leg) {

    ArrivalAndDepartureInstance fromStopTimeInstance = builder.getFromStop();

    if (fromStopTimeInstance == null)
      return;

    BlockStopTimeEntry bstFrom = fromStopTimeInstance.getBlockStopTime();

    StopTimeEntry fromStopTime = bstFrom.getStopTime();
    StopTimeNarrative stopTimeNarrative = _narrativeService.getStopTimeForEntry(fromStopTime);
    transitLeg.setRouteShortName(stopTimeNarrative.getRouteShortName());
    transitLeg.setTripHeadsign(stopTimeNarrative.getStopHeadsign());

    StopEntry fromStop = fromStopTimeInstance.getStop();
    StopBean fromStopBean = _stopBeanService.getStopForId(fromStop.getId());
    transitLeg.setFromStop(fromStopBean);

    transitLeg.setFromStopSequence(fromStopTime.getSequence());

    leg.setFrom(fromStop.getStopLocation());

    BlockLocation blockLocation = fromStopTimeInstance.getBlockLocation();
    if (blockLocation != null) {
      AgencyAndId vehicleId = blockLocation.getVehicleId();
      transitLeg.setVehicleId(AgencyAndIdLibrary.convertToString(vehicleId));
    }
  }
View Full Code Here

    OBAState state = (OBAState) s0;

    int maxBlockSequence = state.getMaxBlockSequence();

    if (maxBlockSequence < 0) {
      ArrivalAndDepartureInstance nextTransferStop = service.getNextTransferStopArrivalAndDeparture(_from);
      if (nextTransferStop != null) {

        long departure = _from.getBestDepartureTime();
        long arrival = nextTransferStop.getBestArrivalTime();
        int runningTime = (int) ((arrival - departure) / 1000);

        Vertex fromVertex = new BlockDepartureVertex(_context, _from);
        Vertex toVertex = new BlockArrivalVertex(_context, nextTransferStop);
        EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);

        StateEditor edit = s0.edit(this, narrative);
        edit.incrementTimeInSeconds(runningTime);
        edit.incrementWeight(runningTime);

        State result = edit.makeState();
        results = result.addToExistingResultChain(results);

        maxBlockSequence = nextTransferStop.getBlockStopTime().getBlockSequence();
      } else {
        maxBlockSequence = Integer.MAX_VALUE;
      }
    }

    ArrivalAndDepartureInstance nextStop = service.getNextStopArrivalAndDeparture(_from);

    if (nextStop != null
        && nextStop.getBlockStopTime().getBlockSequence() < maxBlockSequence) {

      long departure = _from.getBestDepartureTime();
      long arrival = nextStop.getBestArrivalTime();
      int runningTime = (int) ((arrival - departure) / 1000);

      Vertex fromVertex = new BlockDepartureVertex(_context, _from);
      Vertex toVertex = new BlockArrivalVertex(_context, nextStop);
      EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);
View Full Code Here

  }

  private void applyToStopDetailsForTransitLeg(TransitLegBuilder builder,
      TransitLegBean transitLeg, LegBean leg) {

    ArrivalAndDepartureInstance toStopTimeInstance = builder.getToStop();

    if (toStopTimeInstance == null)
      return;

    StopEntry toStop = toStopTimeInstance.getStop();
    StopBean toStopBean = _stopBeanService.getStopForId(toStop.getId());
    transitLeg.setToStop(toStopBean);

    BlockStopTimeEntry blockStopTime = toStopTimeInstance.getBlockStopTime();
    StopTimeEntry stopTime = blockStopTime.getStopTime();
    transitLeg.setToStopSequence(stopTime.getSequence());

    leg.setTo(toStop.getStopLocation());

    BlockLocation blockLocation = toStopTimeInstance.getBlockLocation();
    if (blockLocation != null) {
      AgencyAndId vehicleId = blockLocation.getVehicleId();
      transitLeg.setVehicleId(AgencyAndIdLibrary.convertToString(vehicleId));
    }
  }
View Full Code Here

      query.setTrip(trip);
      query.setServiceDate(serviceDate);
      query.setVehicleId(vehicleId);
      query.setTime(options.currentTime);

      ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);

      b.setFromStop(instance);
      b.setBlockTripInstanceFrom(instance.getBlockTripInstance());
      b.setScheduledDepartureTime(instance.getScheduledDepartureTime());
      b.setPredictedDepartureTime(instance.getPredictedDepartureTime());
    }

    if (transitLeg.getToStop() != null
        && transitLeg.getToStop().getId() != null) {

      AgencyAndId toStopId = AgencyAndIdLibrary.convertFromString(transitLeg.getToStop().getId());
      StopEntry toStop = _transitGraphDao.getStopEntryForId(toStopId, true);
      int toStopSequence = transitLeg.getToStopSequence();

      ArrivalAndDepartureQuery query = new ArrivalAndDepartureQuery();
      query.setStop(toStop);
      query.setStopSequence(toStopSequence);
      query.setTrip(trip);
      query.setServiceDate(serviceDate);
      query.setVehicleId(vehicleId);
      query.setTime(options.currentTime);

      ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);

      b.setToStop(instance);
      b.setBlockTripInstanceTo(instance.getBlockTripInstance());
      b.setScheduledArrivalTime(instance.getScheduledArrivalTime());
      b.setPredictedArrivalTime(instance.getPredictedArrivalTime());
    }

    if (b.getBlockTripInstanceFrom() == null) {

      BlockEntry block = trip.getBlock();
View Full Code Here

  }

  private State extraSpecialMode(State s0, OBATraverseOptions obaOpts) {

    ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();
    ArrivalAndDepartureInstance nextStop = service.getNextStopArrivalAndDeparture(_from);

    if (nextStop == null)
      return null;

    Vertex fromVertex = new BlockDepartureVertex(_context, _from);
    Vertex toVertex = new BlockArrivalVertex(_context, nextStop);
    EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);

    StateEditor edit = s0.edit(this, narrative);

    long departure = _from.getBestDepartureTime();
    long arrival = nextStop.getBestArrivalTime();
    int runningTime = (int) ((arrival - departure) / 1000);
    edit.incrementTimeInSeconds(runningTime);
    edit.incrementWeight(runningTime);

    return edit.makeState();
View Full Code Here

    OBAState obaState = (OBAState) state;

    if (obaState.getMaxBlockSequence() >= 0 && v instanceof AbstractBlockVertex) {

      AbstractBlockVertex abv = (AbstractBlockVertex) v;
      ArrivalAndDepartureInstance instance = abv.getInstance();

      BlockInstance blockInstance = instance.getBlockInstance();
      BlockConfigurationEntry blockConfig = blockInstance.getBlock();
      List<BlockStopTimeEntry> stopTimes = blockConfig.getStopTimes();
      int maxBlockSequence = Math.min(obaState.getMaxBlockSequence(),
          stopTimes.size());

      BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
      int sequence = blockStopTime.getBlockSequence();
      StopTimeEntry origStopTime = blockStopTime.getStopTime();

      double minTime = Double.POSITIVE_INFINITY;
View Full Code Here

  public ArrivalAndDepartureBean getArrivalAndDepartureForStop(
      ArrivalAndDepartureQuery query) {

    long time = query.getTime();

    ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
    if (instance == null) {
      return null;
    }

    ArrivalAndDepartureBean bean = getStopTimeInstanceAsBean(time, instance,
View Full Code Here

  @Override
  public Collection<Edge> getIncoming() {

    ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();
    ArrivalAndDepartureInstance previous = service.getPreviousStopArrivalAndDeparture(_instance);

    if (previous == null)
      return Collections.emptyList();

    return Arrays.asList((Edge) new BlockHopEdge(_context, previous, _instance));
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance

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.