Package org.onebusaway.transit_data_federation.services

Examples of org.onebusaway.transit_data_federation.services.ArrivalAndDepartureService


  private State traverseReverse(State s0) {

    OBATraverseOptions obaOpts = (OBATraverseOptions) s0.getOptions();

    ArrivalAndDepartureService adService = _context.getArrivalAndDepartureService();

    Vertex toV = new TPArrivalVertex(_context, _pathState);

    Pair<StopEntry> stopPair = _pathState.getStops();

    TargetTime targetTime = new TargetTime(s0.getTime(), obaOpts.currentTime);

    ArrivalAndDeparturePairQuery query = new ArrivalAndDeparturePairQuery();
    query.setResultCount(obaOpts.numItineraries);
    query.setApplyRealTime(obaOpts.useRealtime);
    query.setIncludePrivateService(false);

    /**
     * Recall that the stopPair is in reverse order (toStop => fromStop)
     */
    List<Pair<ArrivalAndDepartureInstance>> instances = adService.getPreviousArrivalsForStopPair(
        stopPair.getSecond(), stopPair.getFirst(), targetTime, query);

    State results = null;

    for (Pair<ArrivalAndDepartureInstance> pair : instances) {
View Full Code Here


  private State traverseForward(State s0) {

    OBATraverseOptions obaOpts = (OBATraverseOptions) s0.getOptions();

    ArrivalAndDepartureService adService = _context.getArrivalAndDepartureService();

    Vertex fromV = new TPDepartureVertex(_context, _pathState);

    Pair<StopEntry> stopPair = _pathState.getStops();

    TargetTime targetTime = new TargetTime(s0.getTime(), obaOpts.currentTime);

    ArrivalAndDeparturePairQuery query = new ArrivalAndDeparturePairQuery();
    query.setResultCount(obaOpts.numItineraries);
    query.setApplyRealTime(obaOpts.useRealtime);
    query.setIncludePrivateService(false);
    if (s0.getNumBoardings() == 0)
      query.setLookaheadTime(obaOpts.lookaheadTime);

    List<Pair<ArrivalAndDepartureInstance>> instances = adService.getNextDeparturesForStopPair(
        stopPair.getFirst(), stopPair.getSecond(), targetTime, query);

    State results = null;

    for (Pair<ArrivalAndDepartureInstance> pair : instances) {
View Full Code Here

    OBATraverseOptions obaOpts = (OBATraverseOptions) s0.getOptions();
    if (obaOpts.extraSpecialMode)
      return extraSpecialMode(s0, obaOpts);

    ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();

    State results = null;

    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();
View Full Code Here

    return results;
  }

  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);
View Full Code Here

    boolean useRealTime = false;
    OBATraverseOptions config = options.getExtension(OBATraverseOptions.class);
    if (config != null)
      useRealTime = config.useRealtime;

    ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();

    if (useRealTime) {
      /**
       * TODO : If we want to simulate real-time trip planning with the system
       * in some past state, we'll need a way to adjust NOW here
       */
      TargetTime target = new TargetTime(time, System.currentTimeMillis());
      return service.getArrivalsAndDeparturesForStopInTimeRange(_stop, target,
          timeFrom, timeTo);
    } else {
      return service.getScheduledArrivalsAndDeparturesForStopInTimeRange(_stop,
          time, timeFrom, timeTo);
    }
  }
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

    TraverseOptions options = s0.getOptions();
    OBATraverseOptions config = options.getExtension(OBATraverseOptions.class);
    if (config != null)
      useRealtime = config.useRealtime;

    ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();

    if (useRealtime) {
      /**
       * TODO : If we want to simulate real-time trip planning with the system
       * in some past state, we'll need a way to adjust NOW here
       */
      TargetTime time = new TargetTime(s0.getTime(), System.currentTimeMillis());
      return service.getArrivalsAndDeparturesForStopInTimeRange(_stop, time,
          fromTime, toTime);
    } else {
      return service.getScheduledArrivalsAndDeparturesForStopInTimeRange(_stop,
          s0.getTime(), fromTime, toTime);
    }
  }
View Full Code Here

    return edit.makeState();
  }

  private State getNextScheduledBlockDepartureResults(State s0) {

    ArrivalAndDepartureService arrivalAndDepartureService = _context.getArrivalAndDepartureService();

    List<ArrivalAndDepartureInstance> instances = arrivalAndDepartureService.getNextScheduledBlockTripDeparturesForStop(
        _stop, s0.getTime(), false);

    State results = null;

    for (ArrivalAndDepartureInstance instance : instances) {
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.ArrivalAndDepartureService

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.