Search in sources :

Example 11 with IntersectionVertex

use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.

the class TestGraph method testGetVertex.

public void testGetVertex() throws Exception {
    Graph g = new Graph();
    Vertex a = new IntersectionVertex(g, "A", 5, 5);
    Vertex b = g.getVertex("A");
    assertEquals(a, b);
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex)

Example 12 with IntersectionVertex

use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.

the class TestGraph method testGetEdgesAndVerticesById.

public void testGetEdgesAndVerticesById() {
    Graph g = new Graph();
    StreetVertex a = new IntersectionVertex(g, "A", 5, 5);
    StreetVertex b = new IntersectionVertex(g, "B", 6, 6);
    StreetVertex c = new IntersectionVertex(g, "C", 3, 2);
    Set<Edge> allEdges = new HashSet<Edge>(4);
    allEdges.add(edge(a, b, 1.0));
    allEdges.add(edge(b, c, 1.0));
    allEdges.add(edge(c, b, 1.0));
    allEdges.add(edge(c, a, 1.0));
    // Before rebuilding the indices, they are empty.
    for (Edge e : allEdges) {
        assertNull(g.getEdgeById(e.getId()));
    }
    for (Vertex v : g.getVertices()) {
        assertNull(g.getVertexById(v.getIndex()));
    }
    g.rebuildVertexAndEdgeIndices();
    for (Edge e : allEdges) {
        assertEquals(e, g.getEdgeById(e.getId()));
    }
    for (Vertex v : g.getVertices()) {
        assertEquals(v, g.getVertexById(v.getIndex()));
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge) HashSet(java.util.HashSet)

Example 13 with IntersectionVertex

use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.

the class TestGraph method testGetEdgesOneEdge.

public void testGetEdgesOneEdge() {
    Graph g = new Graph();
    Vertex a = new IntersectionVertex(g, "A", 5, 5);
    Vertex b = new IntersectionVertex(g, "B", 6, 6);
    FreeEdge ee = new FreeEdge(a, b);
    List<Edge> edges = new ArrayList<Edge>(g.getEdges());
    assertEquals(1, edges.size());
    assertEquals(ee, edges.get(0));
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) ArrayList(java.util.ArrayList) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 14 with IntersectionVertex

use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.

the class TestGraph method testAddEdge.

public void testAddEdge() throws Exception {
    Graph g = new Graph();
    Vertex a = new IntersectionVertex(g, "A", 5, 5);
    Vertex b = new IntersectionVertex(g, "B", 6, 6);
    FreeEdge ee = new FreeEdge(a, b);
    assertNotNull(ee);
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge)

Example 15 with IntersectionVertex

use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.

the class TestGraph method testGetStreetEdgesSeveral.

public void testGetStreetEdgesSeveral() {
    Graph g = new Graph();
    StreetVertex a = new IntersectionVertex(g, "A", 5, 5);
    StreetVertex b = new IntersectionVertex(g, "B", 6, 6);
    StreetVertex c = new IntersectionVertex(g, "C", 3, 2);
    Set<Edge> allStreetEdges = new HashSet<Edge>(4);
    allStreetEdges.add(edge(a, b, 1.0));
    allStreetEdges.add(edge(b, c, 1.0));
    allStreetEdges.add(edge(c, b, 1.0));
    allStreetEdges.add(edge(c, a, 1.0));
    Set<StreetEdge> edges = new HashSet<StreetEdge>(g.getStreetEdges());
    assertEquals(4, edges.size());
    assertEquals(allStreetEdges, edges);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge) HashSet(java.util.HashSet)

Aggregations

IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)38 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)23 Graph (org.opentripplanner.routing.graph.Graph)17 Coordinate (com.vividsolutions.jts.geom.Coordinate)16 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)14 Vertex (org.opentripplanner.routing.graph.Vertex)12 LineString (com.vividsolutions.jts.geom.LineString)10 Test (org.junit.Test)10 Edge (org.opentripplanner.routing.graph.Edge)10 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)8 HashSet (java.util.HashSet)8 FreeEdge (org.opentripplanner.routing.edgetype.FreeEdge)8 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)5 ArrayList (java.util.ArrayList)5 Point (com.vividsolutions.jts.geom.Point)4 P2 (org.opentripplanner.common.model.P2)4 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)4 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)3 State (org.opentripplanner.routing.core.State)3 AreaEdge (org.opentripplanner.routing.edgetype.AreaEdge)3