Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.State


        JButton dominateButton = new JButton();
        dominateButton.setText("dominates");
        dominateButton.addActionListener(new ActionListener(){
      @Override
      public void actionPerformed(ActionEvent e) {
        State s1 = firstComparePathStates.getSelectedValue();
        State s2 = secondComparePathStates.getSelectedValue();
       
        System.out.println("s1 dominates s2:"+MultiShortestPathTree.dominates(s1,s2));
        System.out.println("s2 dominates s1:"+MultiShortestPathTree.dominates(s2,s1));
      }
        });
        pane.add(dominateButton);
       
        // A button that executes the 'traverse' function leading to the last clicked state
        // in either window. Also only useful if you set a breakpoint.
        JButton traverseButton = new JButton();
        traverseButton.setText("traverse");
        traverseButton.addActionListener(new ActionListener(){
      @Override
      public void actionPerformed(ActionEvent e) {
        if(lastStateClicked==null){
          return;
        }
       
        Edge backEdge = lastStateClicked.getBackEdge();
        State backState = lastStateClicked.getBackState();
       
        backEdge.traverse(backState);
      }
        });
        pane.add(traverseButton);
View Full Code Here


            outgoingEdges.clearSelection();
            incomingEdges.clearSelection();
   
            @SuppressWarnings("unchecked")
        JList<State> theList = (JList<State>)e.getSource();
            State st = (State)theList.getSelectedValue();
            Edge edge = st.getBackEdge();
            reactToEdgeSelection( edge, false );
          }
        });
        
View Full Code Here

       
        // if the vertex has any states that dominate the new state, don't add the state
        // if the new state dominates any old states, remove them
        Iterator<State> it = states.iterator();
        while (it.hasNext()) {
            State oldState = it.next();
            // order is important, because in the case of a tie
            // we want to reject the new state
            if (dominates( oldState, newState) )
                return false;
            if (dominates( newState, oldState) )
View Full Code Here

  @Override
    public State getState(Vertex dest) {
        Collection<State> states = stateSets.get(dest);
        if (states == null)
            return null;
        State ret = null;
        for (State s : states) {
            if ((ret == null || s.betterThan(ret)) && s.isFinal() && s.allPathParsersAccept()) {
                ret = s;
            }
        }
View Full Code Here

     * This is done by doing a Dijkstra search for the first reachable transit stop.
     */
    private double determineRequiredWalkDistance(RoutingRequest req) {
        if ( ! req.modes.isTransit()) return 0; // required walk distance will be unused.
        GenericDijkstra gd = new GenericDijkstra(req);
        State s = new State(req.rctx.target, req);
        gd.setHeuristic(new TrivialRemainingWeightHeuristic());
        final ClosestStopTraverseVisitor visitor = new ClosestStopTraverseVisitor();
        gd.traverseVisitor = visitor;
        gd.searchTerminationStrategy = new SearchTerminationStrategy() {
            @Override public boolean shouldSearchTerminate(Vertex origin, Vertex target, State current,
View Full Code Here

               !options.reverseOptimizing &&
                s0.isEverBoarded() &&
                s0.getLastNextArrivalDelta() <= bestWait &&
                s0.getLastNextArrivalDelta() > -1) {
                // it is re-reversed by optimize, so this still yields a forward tree
                State optimized = s1.makeState().optimizeOrReverse(true, true);
                if (optimized == null) LOG.error("Null optimized state. This shouldn't happen.");
                return optimized;
            }
           
            /* If we didn't return an optimized path, return an unoptimized one. */
 
View Full Code Here

        return ret;
    }

    @Override
    public GraphPath getPath(Vertex dest, boolean optimize) {
        State s = getState(dest);
        if (s == null)
            return null;
        else
            return new GraphPath(s, optimize);
    }
View Full Code Here

     */
    public Collection<StopTimesInPattern> stopTimesForStop(Stop stop) {
        List<StopTimesInPattern> ret = Lists.newArrayList();
        RoutingRequest req = new RoutingRequest();
        req.setRoutingContext(graph, (Vertex)null, (Vertex)null);
        State state = new State(req);
        for (TripPattern pattern : patternsForStop.get(stop)) {
            StopTimesInPattern times = new StopTimesInPattern(pattern);
            // Should actually be getUpdatedTimetable
            Timetable table = pattern.scheduledTimetable;
            // A Stop may occur more than once in a pattern, so iterate over all Stops.
View Full Code Here

    @Override
    public boolean add(State state) {
        Graph graph = state.getOptions().rctx.graph;
        Vertex here = state.getVertex();
        State existing = states.get(here);
        if (existing == null || state.betterThan(existing)) {
            states.put(here, state);
            return true;
        } else {
            final Edge backEdge = existing.getBackEdge();
            // If the previous back edge had turn restrictions, we need to continue
            // the search because the previous path may be prevented by from reaching the end by
            // turn restrictions.

            return !graph.getTurnRestrictions(backEdge).isEmpty();
View Full Code Here

        }
    }

    @Override
    public List<State> getStates(Vertex dest) {
        State s = states.get(dest);
        if (s == null)
            return Collections.emptyList();
        else
            return Arrays.asList(s); // single-element array-backed list
    }
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.