Package org.opentripplanner.routing.graph

Examples of org.opentripplanner.routing.graph.Vertex$ValidEdgeTypes


        BinHeap<State> pq = new BinHeap<State>();
        pq.insert(initialState, 0);

        while (!pq.empty()) {
            State u = pq.extract_min();
            Vertex u_vertex = u.getVertex();
            if (!spt.visit(u))
                continue;
            Collection<Edge> edges = options.arriveBy ? u_vertex.getIncoming() : u_vertex.getOutgoing();
            for (Edge edge : edges) {
                for (State v = edge.traverse(u); v != null; v = v.getNextResult()) {
                    if (isWorstTimeExceeded(v, options)) {
                        continue;
                    }
View Full Code Here


     */
    private PartialStreetEdge makePartialEdgeAlong(StreetEdge e, StreetVertex u,
            StreetVertex v) {
        DistanceLibrary dLib = SphericalDistanceLibrary.getInstance();

        Vertex head = e.getFromVertex();
        double uDist = dLib.fastDistance(head.getCoordinate(), u.getCoordinate());
        double vDist = dLib.fastDistance(head.getCoordinate(), v.getCoordinate());

        // Order the vertices along the partial edge by distance from the head of the edge.
        // TODO(flamholz): this logic is insufficient for curvy streets/roundabouts.
        StreetVertex first = u;
        StreetVertex second = v;
View Full Code Here

     * targets have been reached.
     */
    @Override
    public boolean shouldSearchTerminate(Vertex origin, Vertex target, State current,
                                         ShortestPathTree spt, RoutingRequest traverseOptions) {
        Vertex currentVertex = current.getVertex();
               
        // TODO(flamholz): update this to handle vertices that are not in the graph
        // but rather along edges in the graph.
        if (unreachedTargets.contains(currentVertex)) {
            unreachedTargets.remove(currentVertex);
View Full Code Here

            } else {
                fromVertex = null;
            }
            if (opt.intermediatePlaces != null) {
                for (GenericLocation intermediate : opt.intermediatePlaces) {
                    Vertex vertex = graph.streetIndex.getVertexForLocation(intermediate, opt);
                    intermediateVertices.add(vertex);
                }
            }
        } else {
            // debug mode, force endpoint vertices to those specified rather than searching
View Full Code Here

     *     distance / transit speed (no need for boarding cost), again considering any mandatory
     *     walking.
     */
    @Override
    public double computeForwardWeight(State s, Vertex target) {
        Vertex sv = s.getVertex();
        double euclideanDistance = distanceLibrary.fastDistance(sv.getY(), sv.getX(), targetY, targetX);
        if (transit) {
            if (euclideanDistance < requiredWalkDistance) {
                return walkReluctance * euclideanDistance / maxStreetSpeed;
            }
            /* Due to the above conditional, the following value is known to be positive. */
 
View Full Code Here

     * {@link ShortestPathTree} Interface
     ****/

    @Override
    public boolean add(State newState) {
        Vertex vertex = newState.getVertex();
        List<State> states = stateSets.get(vertex);
       
        // if the vertex has no states, add one and return
        if (states == null) {
            states = new ArrayList<State>();
View Full Code Here

        JButton zoomToNodeButton = new JButton("Zoom to node");
        zoomToNodeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String nodeName = (String) JOptionPane.showInputDialog(frame, "Node id",
                        JOptionPane.PLAIN_MESSAGE);
                Vertex v = getGraph().getVertex(nodeName);
                if (v == null) {
                    System.out.println("no such node " + nodeName);
                } else {
                    showGraph.zoomToVertex(v);
                }
            }
        });
        buttonPanel.add(zoomToNodeButton);

        JButton zoomToLocationButton = new JButton("Zoom to location");
        zoomToLocationButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String result = JOptionPane.showInputDialog("Enter the location (lat lon)");
                if (result == null || result.length() == 0)
                    return;
                String[] tokens = result.split("[\\s,]+");
                double lat = Double.parseDouble(tokens[0]);
                double lon = Double.parseDouble(tokens[1]);
                Coordinate c = new Coordinate(lon, lat);
                showGraph.zoomToLocation(c);
            }
        });
        buttonPanel.add(zoomToLocationButton);

        JButton zoomOutButton = new JButton("Zoom out");
        zoomOutButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                showGraph.zoomOut();
            }
        });
        buttonPanel.add(zoomOutButton);

        JButton routeButton2 = new JButton("Route");
        routeButton2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // String initialFrom = "";
                // Object selected = nearbyVertices.getSelectedValue();
                // if (selected != null) {
                // initialFrom = selected.toString();
                // }
                // RouteDialog dlg = new RouteDialog(frame, initialFrom); // modal
                String from = sourceVertex.getText();
                String to = sinkVertex.getText();
                route(from, to);
            }
        });
        buttonPanel.add(routeButton2);

        JButton findButton = new JButton("Find node");
        findButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String nodeName = (String) JOptionPane.showInputDialog(frame, "Node id",
                        JOptionPane.PLAIN_MESSAGE);
                Vertex v = getGraph().getVertex(nodeName);
                if (v == null) {
                    System.out.println("no such node " + nodeName);
                } else {
                    showGraph.highlightVertex(v);
                    ArrayList<Vertex> l = new ArrayList<Vertex>();
                    l.add(v);
                    verticesSelected(l);
                }
            }
        });
        buttonPanel.add(findButton);

        JButton findEdgeButton = new JButton("Find edge");
        findEdgeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String edgeName = (String) JOptionPane.showInputDialog(frame, "Edge name like",
                        JOptionPane.PLAIN_MESSAGE);
                for (Vertex gv : getGraph().getVertices()) {
                    for (Edge edge : gv.getOutgoing()) {
                        if (edge.getName() != null && edge.getName().contains(edgeName)) {
                            showGraph.highlightVertex(gv);
                            ArrayList<Vertex> l = new ArrayList<Vertex>();
                            l.add(gv);
                            verticesSelected(l);
                        }
                    }
                }
            }
        });
        buttonPanel.add(findEdgeButton);

        JButton checkButton = new JButton("Check graph");
        checkButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                checkGraph();
            }
        });
        buttonPanel.add(checkButton);

        JButton traceButton = new JButton("Trace");
        traceButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                trace();
            }
        });
        buttonPanel.add(traceButton);

        // annotation search button
        JButton annotationButton = new JButton("Find annotations");
        annotationButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                findAnnotation();
            }
        });
        buttonPanel.add(annotationButton);

        JButton findEdgeByIdButton = new JButton("Find edge ID");
        findEdgeByIdButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String edgeIdStr = (String) JOptionPane.showInputDialog(frame, "Edge ID",
                        JOptionPane.PLAIN_MESSAGE);
                Integer edgeId = Integer.parseInt(edgeIdStr);
                Edge edge = getGraph().getEdgeById(edgeId);
                if (edge != null) {
                    showGraph.highlightEdge(edge);
                    showGraph.highlightVertex(edge.getFromVertex());
                } else {
                    System.out.println("Found no edge with ID " + edgeIdStr);
                }
            }
        });
        buttonPanel.add(findEdgeByIdButton);
       
        JButton snapButton = new JButton("Snap location");
        snapButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String locString = (String) JOptionPane.showInputDialog(frame, "Location string",
                        "");
                GenericLocation loc = GenericLocation.fromOldStyleString(locString);
                RoutingRequest rr = new RoutingRequest();
                Vertex v = graph.streetIndex.getVertexForLocation(
                        loc, rr);
                showGraph.highlightVertex(v);
            }
        });
        buttonPanel.add(snapButton);
View Full Code Here

 
          /* for turns, highlight the outgoing street's ends */
          if (selected instanceof StreetEdge) {
              List<Vertex> vertices = new ArrayList<Vertex>();
              List<Edge> edges = new ArrayList<Edge>();
              Vertex tov = selected.getToVertex();
              for (Edge og : tov.getOutgoing()) {
                  if (og instanceof StreetEdge) {
                      edges.add(og);
                      vertices.add(og.getToVertex());
                      break;
                  }
              }
              Vertex fromv = selected.getFromVertex();
              for (Edge ic : fromv.getIncoming()) {
                  if (ic instanceof StreetEdge) {
                      edges.add(ic);
                      vertices.add(ic.getFromVertex());
                      break;
                  }
              }
              // showGraph.setHighlightedVertices(vertices);
              showGraph.setHighlightedEdges(edges);
          }
 
          /* add the connected vertices to the list of vertices */
          VertexList nearbyModel = (VertexList) nearbyVertices.getModel();
          List<Vertex> vertices = nearbyModel.selected;
 
          Vertex v;
          if (outgoing) {
              v = selected.getToVertex();
          } else {
              v = selected.getFromVertex();
          }
          if (!vertices.contains(v)) {
              vertices.add(v);
              nearbyModel = new VertexList(vertices);
              nearbyVertices.setModel(nearbyModel); // this should just be an event, but for
                                                    // some reason, JList doesn't implement
                                                    // the right event.
          }
 
          /* set up metadata tab */
          metadataModel.clear();
          getMetadata(selected);
          // fromv
          Vertex fromv = selected.getFromVertex();
          getMetadata(fromv);
          if (selected instanceof StreetEdge) {
              //TODO ElevationProfileSegment do not exist anymore
              //getMetadata(((StreetEdge) selected).getElevationProfileSegment());
          }
View Full Code Here

            public void valueChanged(ListSelectionEvent e) {
                outgoingEdges.removeAll();
                incomingEdges.removeAll();
                DisplayVertex selected = (DisplayVertex) nearbyVertices.getSelectedValue();
                if (selected != null) {
                    Vertex nowSelected = selected.vertex;
                    showGraph.highlightVertex(nowSelected);
                    outgoingEdges.setModel(new EdgeListModel(nowSelected.getOutgoing()));
                    incomingEdges.setModel(new EdgeListModel(nowSelected.getIncoming()));
                }
            }
        });
       
        // listener useful for both incoming and outgoing edge list panes
View Full Code Here

    protected void trace() {
        DisplayVertex selected = (DisplayVertex) nearbyVertices.getSelectedValue();
        if (selected == null) {
            return;
        }
        Vertex v = selected.vertex;

        if (tracingVertex != v) {
            tracingVertex = v;
            closed = new HashSet<Vertex>();
            open = new HashSet<Vertex>();
            open.add(v);
            seen = new HashSet<Vertex>();
        }
        HashSet<Vertex> newOpen = new HashSet<Vertex>();
        for (Vertex v2 : open) {
            closed.add(v2);
            for (Edge e : v2.getOutgoing()) {
                Vertex target = e.getToVertex();
                if (closed.contains(target)) {
                    continue;
                }
                newOpen.add(target);
            }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.graph.Vertex$ValidEdgeTypes

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.