use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.
the class SimpleTraversalCostModelTest method testInferredFreeFlowing.
@Test
public void testInferredFreeFlowing() {
// 3 points on a roughly on line
Coordinate a = new Coordinate(-73.990989, 40.750167);
Coordinate b = new Coordinate(-73.988049, 40.749094);
Coordinate c = new Coordinate(-73.984981, 40.747761);
// A vertex for each. No light.
IntersectionVertex u = vertex("from_v", a, false);
IntersectionVertex v = vertex("intersection", b, false);
IntersectionVertex w = vertex("to_v", c, false);
// Two edges - will infer that the vertex is free-flowing since there is no light.
StreetEdge fromEdge = edge(u, v, 1.0, false);
StreetEdge toEdge = edge(v, w, 1.0, false);
float fromSpeed = 1.0f;
float toSpeed = 1.0f;
TraverseMode mode = TraverseMode.CAR;
double traversalCost = costModel.computeTraversalCost(v, fromEdge, toEdge, mode, options, fromSpeed, toSpeed);
// Vertex is free-flowing so cost should be 0.0.
assertEquals(0.0, traversalCost, 0.0);
}
use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.
the class SimpleTraversalCostModelTest method testTurnDirectionChecking.
@Test
public void testTurnDirectionChecking() {
// 3 points on a roughly on line
Coordinate a = new Coordinate(-73.990989, 40.750167);
Coordinate b = new Coordinate(-73.988049, 40.749094);
Coordinate c = new Coordinate(-73.984981, 40.747761);
// A vertex for each. No light.
IntersectionVertex u = vertex("from_v", a, false);
IntersectionVertex v = vertex("intersection", b, false);
IntersectionVertex w = vertex("to_v", c, false);
// Two edges.
StreetEdge fromEdge = edge(u, v, 1.0, false);
StreetEdge toEdge = edge(v, w, 1.0, false);
int turnAngle = costModel.calculateTurnAngle(fromEdge, toEdge, options);
assertFalse(costModel.isRightTurn(turnAngle));
assertFalse(costModel.isLeftTurn(turnAngle));
// AKA is a straight ahead.
}
use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.
the class SimpleTraversalCostModelTest method testLeftNoLightInCar.
@Test
public void testLeftNoLightInCar() {
// 3 points that form a right turn on the map
Coordinate a = new Coordinate(40.750167, -73.990989);
Coordinate b = new Coordinate(40.749094, -73.988049);
Coordinate c = new Coordinate(40.749760, -73.987749);
// A vertex for each. No light.
IntersectionVertex u = vertex("from_v", a, false);
IntersectionVertex v = vertex("intersection", b, false);
IntersectionVertex w = vertex("to_v", c, false);
// Two edges.
StreetEdge fromEdge = edge(u, v, 1.0, false);
StreetEdge toEdge = edge(v, w, 1.0, false);
// 3rd edge prevents inferral of free-flowingness
StreetEdge extraEdge = edge(v, u, 1.0, false);
int turnAngle = costModel.calculateTurnAngle(fromEdge, toEdge, options);
assertFalse(costModel.isRightTurn(turnAngle));
assertTrue(costModel.isLeftTurn(turnAngle));
float fromSpeed = 1.0f;
float toSpeed = 1.0f;
TraverseMode mode = TraverseMode.CAR;
double traversalCost = costModel.computeTraversalCost(v, fromEdge, toEdge, mode, options, fromSpeed, toSpeed);
// Cost with default values = 8.0
assertEquals(8.0, traversalCost, 0.0);
}
use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.
the class SimpleTraversalCostModelTest method vertex.
/**
**
* Private Methods
***
*/
private IntersectionVertex vertex(String label, Coordinate coord, boolean hasLight) {
IntersectionVertex v = new IntersectionVertex(_graph, label, coord.y, coord.x);
v.trafficLight = (hasLight);
return v;
}
use of org.opentripplanner.routing.vertextype.IntersectionVertex in project OpenTripPlanner by opentripplanner.
the class TestGraph method testAddVertex.
public void testAddVertex() throws Exception {
Graph g = new Graph();
Vertex a = new IntersectionVertex(g, "A", 5, 5);
assertEquals(a.getLabel(), "A");
}
Aggregations