use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class BarrierVertexTest method testStreetsWithBollard.
@Test
public void testStreetsWithBollard() {
Graph _graph = new Graph();
// default permissions are PEDESTRIAND and BICYCLE
BarrierVertex bv = new BarrierVertex(_graph, "start_bollard", 2.0, 2.0, 0);
StreetVertex endVertex = new IntersectionVertex(_graph, "end_vertex", 1.0, 2.0);
StreetEdge bv_to_endVertex_forward = edge(bv, endVertex, 100, false);
assertTrue(bv_to_endVertex_forward.canTraverse(new TraverseModeSet("CAR")));
assertTrue(bv_to_endVertex_forward.canTraverse(new TraverseModeSet("BICYCLE")));
assertTrue(bv_to_endVertex_forward.canTraverse(new TraverseModeSet("WALK")));
assertFalse(bv_to_endVertex_forward.canTraverseIncludingBarrier(TraverseMode.CAR));
assertTrue(bv_to_endVertex_forward.canTraverseIncludingBarrier(TraverseMode.BICYCLE));
assertTrue(bv_to_endVertex_forward.canTraverseIncludingBarrier(TraverseMode.WALK));
StreetEdge endVertex_to_bv_backward = edge(endVertex, bv, 100, true);
assertTrue(endVertex_to_bv_backward.canTraverse(new TraverseModeSet("CAR")));
assertTrue(endVertex_to_bv_backward.canTraverse(new TraverseModeSet("BICYCLE")));
assertTrue(endVertex_to_bv_backward.canTraverse(new TraverseModeSet("WALK")));
assertFalse(endVertex_to_bv_backward.canTraverseIncludingBarrier(TraverseMode.CAR));
assertTrue(endVertex_to_bv_backward.canTraverseIncludingBarrier(TraverseMode.BICYCLE));
assertTrue(endVertex_to_bv_backward.canTraverseIncludingBarrier(TraverseMode.WALK));
StreetEdge bv_to_endVertex_backward = edge(bv, endVertex, 100, true);
assertTrue(bv_to_endVertex_backward.canTraverse(new TraverseModeSet("CAR")));
assertTrue(bv_to_endVertex_backward.canTraverse(new TraverseModeSet("BICYCLE")));
assertTrue(bv_to_endVertex_backward.canTraverse(new TraverseModeSet("WALK")));
assertFalse(bv_to_endVertex_backward.canTraverseIncludingBarrier(TraverseMode.CAR));
assertTrue(bv_to_endVertex_backward.canTraverseIncludingBarrier(TraverseMode.BICYCLE));
assertTrue(bv_to_endVertex_backward.canTraverseIncludingBarrier(TraverseMode.WALK));
StreetEdge endVertex_to_bv_forward = edge(endVertex, bv, 100, false);
assertTrue(endVertex_to_bv_forward.canTraverse(new TraverseModeSet("CAR")));
assertTrue(endVertex_to_bv_forward.canTraverse(new TraverseModeSet("BICYCLE")));
assertTrue(endVertex_to_bv_forward.canTraverse(new TraverseModeSet("WALK")));
assertFalse(endVertex_to_bv_forward.canTraverseIncludingBarrier(TraverseMode.CAR));
assertTrue(endVertex_to_bv_forward.canTraverseIncludingBarrier(TraverseMode.BICYCLE));
assertTrue(endVertex_to_bv_forward.canTraverseIncludingBarrier(TraverseMode.WALK));
// tests bollard which doesn't allow cycling
BarrierVertex noBicycleBollard = new BarrierVertex(_graph, "no_bike_bollard", 1.5, 1, 0);
noBicycleBollard.setBarrierPermissions(StreetTraversalPermission.PEDESTRIAN);
StreetEdge no_bike_to_endVertex = edge(noBicycleBollard, endVertex, 100, false);
assertTrue(no_bike_to_endVertex.canTraverse(new TraverseModeSet("CAR")));
assertTrue(no_bike_to_endVertex.canTraverse(new TraverseModeSet("BICYCLE")));
assertTrue(no_bike_to_endVertex.canTraverse(new TraverseModeSet("WALK")));
assertFalse(no_bike_to_endVertex.canTraverseIncludingBarrier(TraverseMode.CAR));
assertFalse(no_bike_to_endVertex.canTraverseIncludingBarrier(TraverseMode.BICYCLE));
assertTrue(no_bike_to_endVertex.canTraverseIncludingBarrier(TraverseMode.WALK));
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class BarrierVertexTest method testBarrierPermissions.
@Test
public void testBarrierPermissions() throws Exception {
OSMNode simpleBarier = new OSMNode();
assertFalse(simpleBarier.isBollard());
simpleBarier.addTag("barrier", "bollard");
assertTrue(simpleBarier.isBollard());
Graph graph = new Graph();
String label = "simpleBarrier";
BarrierVertex bv = new BarrierVertex(graph, label, simpleBarier.lon, simpleBarier.lat, 0);
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(simpleBarier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions());
simpleBarier.addTag("foot", "yes");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(simpleBarier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions());
simpleBarier.addTag("bicycle", "yes");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(simpleBarier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions());
simpleBarier.addTag("access", "no");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(simpleBarier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions());
simpleBarier.addTag("motor_vehicle", "no");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(simpleBarier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions());
simpleBarier.addTag("bicycle", "no");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(simpleBarier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN, bv.getBarrierPermissions());
OSMNode complexBarrier = new OSMNode();
complexBarrier.addTag("barrier", "bollard");
complexBarrier.addTag("access", "no");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(complexBarrier, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.NONE, bv.getBarrierPermissions());
OSMNode noBikeBollard = new OSMNode();
noBikeBollard.addTag("barrier", "bollard");
noBikeBollard.addTag("bicycle", "no");
bv.setBarrierPermissions(OSMFilter.getPermissionsForEntity(noBikeBollard, BarrierVertex.defaultBarrierPermissions));
assertEquals(StreetTraversalPermission.PEDESTRIAN, bv.getBarrierPermissions());
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class PlainStreetEdgeTest method before.
@Before
public void before() {
_graph = new Graph();
// label, X, Y
v0 = vertex("maple_0th", 0.0, 0.0);
v1 = vertex("maple_1st", 2.0, 2.0);
v2 = vertex("maple_2nd", 1.0, 2.0);
proto = new RoutingRequest();
proto.setDummyRoutingContext(_graph);
proto.carSpeed = 15.0f;
proto.walkSpeed = 1.0;
proto.bikeSpeed = 5.0f;
proto.setWalkReluctance(1.0);
proto.stairsReluctance = (1.0);
proto.turnReluctance = (1.0);
proto.setModes(TraverseModeSet.allModes());
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TimetableTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
graph = new Graph();
GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
factory.run(graph);
graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
patternIndex = new HashMap<AgencyAndId, TripPattern>();
for (TransitStopDepart tsd : Iterables.filter(graph.getVertices(), TransitStopDepart.class)) {
for (TransitBoardAlight tba : Iterables.filter(tsd.getOutgoing(), TransitBoardAlight.class)) {
if (!tba.boarding)
continue;
TripPattern pattern = tba.getPattern();
for (Trip trip : pattern.getTrips()) {
patternIndex.put(trip.getId(), pattern);
}
}
}
pattern = patternIndex.get(new AgencyAndId("agency", "1.1"));
timetable = pattern.scheduledTimetable;
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestHopFactory method setUp.
public void setUp() throws Exception {
GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
graph = new Graph();
GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
factory.run(graph);
graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
feedId = context.getFeedId().getId();
}
Aggregations