Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.State


        StateEditor s0e = s0.edit(this);
        s0e.incrementWeight(options.bikeParkCost);
        s0e.incrementTimeInSeconds(options.bikeParkTime);
        s0e.setBackMode(TraverseMode.LEG_SWITCH);
        s0e.setBikeParked(true);
        State s1 = s0e.makeState();
        return s1;
    }
View Full Code Here


    @Override
    public State traverse(State s0) {
        final RoutingRequest options = s0.getOptions();
        final TraverseMode currMode = s0.getNonTransitMode();
        StateEditor editor = doTraverse(s0, options, s0.getNonTransitMode());
        State state = (editor == null) ? null : editor.makeState();
        /* Kiss and ride support. Mode transitions occur without the explicit loop edges used in park-and-ride. */
        if (options.kissAndRide) {
            if (options.arriveBy) {
                // Branch search to "unparked" CAR mode ASAP after transit has been used.
                // Final WALK check prevents infinite recursion.
                if (s0.isCarParked() && s0.isEverBoarded() && currMode == TraverseMode.WALK) {
                    editor = doTraverse(s0, options, TraverseMode.CAR);
                    if (editor != null) {
                        editor.setCarParked(false); // Also has the effect of switching to CAR
                        State forkState = editor.makeState();
                        if (forkState != null) {
                            forkState.addToExistingResultChain(state);
                            return forkState; // return both parked and unparked states
                        }
                    }
                }
            } else { /* departAfter */
 
View Full Code Here

                        }

                        if (coordinates.size() < 2) {   // Otherwise the walk step generator breaks.
                            ArrayList<Coordinate> coordinateList = new ArrayList<Coordinate>(2);
                            coordinateList.add(graphPath.states.get(1).getVertex().getCoordinate());
                            State lastState = graphPath.states.getLast().getBackState();
                            coordinateList.add(lastState.getVertex().getCoordinate());
                            coordinates = new CoordinateArrayListSequence(coordinateList);
                        }

                        LineString geometry = geometryFactory.createLineString(new
                                PackedCoordinateSequence.Double(coordinates.toCoordinateArray()));
View Full Code Here

        rr.walkSpeed = request.walkSpeed;
        rr.bikeSpeed = request.bikeSpeed;
        GenericAStar astar = new GenericAStar();
        rr.setNumItineraries(1);
        ShortestPathTree spt = astar.getShortestPathTree(rr, System.currentTimeMillis() + 5000);
        State state = spt.getState(rr.rctx.target);
        if (state != null) {
            LOG.info("Found non-transit option for mode {}", mode);
            directPaths.add(new StopAtDistance(state));
        }
        routingContexts.add(rr.rctx); // save context for later cleanup so temp edges remain available
View Full Code Here

        return accumulatedError + currentError;
    }

    protected boolean carsCanTraverse(Edge edge) {
        // should be done with a method on edge (canTraverse already exists on turnEdge)
        State s0 = new State(edge.getFromVertex(), traverseOptions);
        State s1 = edge.traverse(s0);
        return s1 != null;
    }
View Full Code Here

        TripTimes s = new TripTimes(trip, stopTimes, new Deduplicator());

        RoutingRequest request = new RoutingRequest(TraverseMode.BICYCLE);
        Vertex v = new SimpleConcreteVertex(graph, "", 0.0, 0.0);
        request.setRoutingContext(graph, v, v);
        State s0 = new State(request);

        assertFalse(s.tripAcceptable(s0, 0));

        BikeAccess.setForTrip(trip, BikeAccess.ALLOWED);
        assertTrue(s.tripAcceptable(s0, 0));
View Full Code Here

        s1.incrementTimeInSeconds(options.arriveBy ? options.bikeRentalDropoffTime
                : options.bikeRentalPickupTime);
        s1.setBikeRenting(true);
        s1.setBikeRentalNetwork(networks);
        s1.setBackMode(s0.getNonTransitMode());
        State s1b = s1.makeState();
        return s1b;
    }
View Full Code Here

                : options.bikeRentalDropoffCost);
        s1e.incrementTimeInSeconds(options.arriveBy ? options.bikeRentalPickupTime
                : options.bikeRentalDropoffTime);
        s1e.setBikeRenting(false);
        s1e.setBackMode(TraverseMode.WALK);
        State s1 = s1e.makeState();
        return s1;
    }
View Full Code Here

     * 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) {

      /**
       * For now, we skip real-time arrival that might have been included that
       * are beyond our range (ex. vehicle running late)
       */
      ArrivalAndDepartureInstance arrival = pair.getSecond();
      if (arrival.getBestArrivalTime() > s0.getTime())
        break;

      Vertex fromV = new TPBlockArrivalVertex(_context, _pathState,
          pair.getFirst(), pair.getSecond());

      EdgeNarrative narrative = narrative(s0, fromV, toV);

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

      int dwellTime = computeWaitTime(s0, pair);
      edit.incrementTimeInSeconds(-dwellTime);

      double w = ItineraryWeightingLibrary.computeWeightForWait(s0, dwellTime);
      edit.incrementWeight(w);

      if (arrival.getBlockSequence() != null)
        edit.appendTripSequence(arrival.getBlockSequence());
      else
        edit.appendTripSequence(arrival.getBlockTrip());

      State s1 = edit.makeState();
      results = s1.addToExistingResultChain(results);
    }

    return results;
  }
View Full Code Here

      query.setLookaheadTime(obaOpts.lookaheadTime);

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

    State results = null;

    for (Pair<ArrivalAndDepartureInstance> pair : instances) {

      ArrivalAndDepartureInstance departure = pair.getFirst();
      if (departure.getBestDepartureTime() < s0.getTime()
          - query.getLookaheadTime() * 1000)
        continue;

      Vertex toV = new TPBlockDepartureVertex(_context, _pathState, departure,
          pair.getSecond());

      int dwellTime = computeWaitTime(s0, pair);

      double w = ItineraryWeightingLibrary.computeWeightForWait(s0, dwellTime);

      EdgeNarrative narrative = narrative(s0, fromV, toV);
      OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);
      edit.setTime(departure.getBestDepartureTime());
      edit.incrementWeight(w);

      /**
       * If the departure time is less than the starting state time, it must
       * mean the departure was included as determined by the lookahead
       * parameter. Thus, we indicate that we have a lookahead itinerary.
       */
      if (departure.getBestDepartureTime() < s0.getTime())
        edit.setLookaheadItinerary();

      if (departure.getBlockSequence() != null)
        edit.appendTripSequence(departure.getBlockSequence());
      else
        edit.appendTripSequence(departure.getBlockTrip());

      State s1 = edit.makeState();
      results = s1.addToExistingResultChain(results);
    }

    return results;
  }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.core.State

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.