use of org.opentripplanner.routing.location.TemporaryStreetLocation in project OpenTripPlanner by opentripplanner.
the class TestHalfEdges method testRouteToSameEdgeBackwards.
@Test
public void testRouteToSameEdgeBackwards() {
RoutingRequest options = new RoutingRequest();
// Sits only on the leftmost edge, not on its reverse.
HashSet<Edge> turns = new HashSet<Edge>();
turns.add(left);
TemporaryStreetLocation start = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "start", new NonLocalizedString("start"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.8).getCoordinate(left.getGeometry()), false);
TemporaryStreetLocation end = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "end", new NonLocalizedString("end"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), true);
assertEquals(start.getX(), end.getX(), 0.001);
assertTrue(start.getY() > end.getY());
Collection<Edge> edges = end.getIncoming();
assertEquals(1, edges.size());
long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 11, 1, 12, 34, 25);
options.dateTime = startTime;
options.setRoutingContext(graph, start, end);
options.setMaxWalkDistance(Double.MAX_VALUE);
ShortestPathTree spt = aStar.getShortestPathTree(options);
GraphPath path = spt.getPath(end, false);
assertNotNull("There must be a path from start to end", path);
assertTrue(path.edges.size() > 1);
options.cleanup();
}
use of org.opentripplanner.routing.location.TemporaryStreetLocation in project OpenTripPlanner by opentripplanner.
the class AStarTest method testForwardExtraEdges.
@Test
public void testForwardExtraEdges() {
RoutingRequest options = new RoutingRequest();
options.walkSpeed = 1.0;
TemporaryStreetLocation from = new TemporaryStreetLocation("near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), new NonLocalizedString("near_shilshole_22nd"), false);
new TemporaryConcreteEdge(from, _graph.getVertex("shilshole_22nd"));
TemporaryStreetLocation to = new TemporaryStreetLocation("near_56th_20th", new Coordinate(-122.382347, 47.669518), new NonLocalizedString("near_56th_20th"), true);
new TemporaryConcreteEdge(_graph.getVertex("56th_20th"), to);
options.setRoutingContext(_graph, from, to);
ShortestPathTree tree = new AStar().getShortestPathTree(options);
options.cleanup();
GraphPath path = tree.getPath(to, false);
List<State> states = path.states;
assertEquals(9, states.size());
assertEquals("near_shilshole_22nd", states.get(0).getVertex().getLabel());
assertEquals("shilshole_22nd", states.get(1).getVertex().getLabel());
assertEquals("ballard_22nd", states.get(2).getVertex().getLabel());
assertEquals("market_22nd", states.get(3).getVertex().getLabel());
assertEquals("market_leary", states.get(4).getVertex().getLabel());
assertEquals("market_russell", states.get(5).getVertex().getLabel());
assertEquals("market_20th", states.get(6).getVertex().getLabel());
assertEquals("56th_20th", states.get(7).getVertex().getLabel());
assertEquals("near_56th_20th", states.get(8).getVertex().getLabel());
}
Aggregations