use of org.opentripplanner.routing.bike_park.BikePark in project OpenTripPlanner by opentripplanner.
the class TestKmlBikeParkSource method testKMLWithFolder.
public void testKMLWithFolder() {
KmlBikeParkDataSource kmlDataSource = new KmlBikeParkDataSource();
kmlDataSource.setUrl("file:src/test/resources/bike/NSFietsenstallingen_folder.kml");
assertTrue(kmlDataSource.update());
List<BikePark> bikeParks = kmlDataSource.getBikeParks();
assertEquals(5, bikeParks.size());
BikePark alkmaar = bikeParks.get(0);
BikePark almere = bikeParks.get(4);
assertEquals("Station Alkmaar", alkmaar.name);
assertEquals("Station Almere Centrum", almere.name);
assertTrue(alkmaar.x >= 4.739850 && alkmaar.x <= 4.739851);
assertTrue(alkmaar.y >= 52.637531 && alkmaar.y <= 52.637532);
assertTrue(almere.x >= 5.21780 && almere.x <= 5.21782);
assertTrue(almere.y >= 52.3746190 && almere.y <= 52.3746191);
}
use of org.opentripplanner.routing.bike_park.BikePark in project OpenTripPlanner by opentripplanner.
the class TestParkAndRide method testBike.
public void testBike() throws Exception {
AStar aStar = new AStar();
// Impossible to get from B to D in BIKE+WALK (no bike P+R).
RoutingRequest options = new RoutingRequest("BICYCLE_PARK,TRANSIT");
options.freezeTraverseMode();
options.setRoutingContext(graph, B, D);
ShortestPathTree tree = aStar.getShortestPathTree(options);
GraphPath path = tree.getPath(D, false);
assertNull(path);
// So we add a bike P+R at C.
BikePark bpc = new BikePark();
bpc.id = "bpc";
bpc.name = "Bike Park C";
bpc.x = 0.002;
bpc.y = 45.00001;
bpc.spacesAvailable = 1;
BikeParkVertex BPRC = new BikeParkVertex(graph, bpc);
new BikeParkEdge(BPRC);
new StreetBikeParkLink(BPRC, C);
new StreetBikeParkLink(C, BPRC);
// Still impossible from B to D by bike only (CD is WALK only).
options = new RoutingRequest("BICYCLE");
options.setRoutingContext(graph, B, D);
tree = aStar.getShortestPathTree(options);
path = tree.getPath(D, false);
assertNotNull(path);
State s = tree.getState(D);
assertFalse(s.isBikeParked());
// TODO backWalkingBike flag is broken
// assertTrue(s.isBackWalkingBike());
assertTrue(s.getBackMode() == TraverseMode.WALK);
// But we can go from B to D using bike P+R.
options = new RoutingRequest("BICYCLE_PARK,WALK,TRANSIT");
options.setRoutingContext(graph, B, D);
tree = aStar.getShortestPathTree(options);
path = tree.getPath(D, false);
assertNotNull(path);
s = tree.getState(D);
assertTrue(s.isBikeParked());
assertFalse(s.isBackWalkingBike());
}
use of org.opentripplanner.routing.bike_park.BikePark in project OpenTripPlanner by opentripplanner.
the class BikeParkModule method buildGraph.
@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
LOG.info("Building bike parks from static source...");
BikeRentalStationService service = graph.getService(BikeRentalStationService.class, true);
if (!dataSource.update()) {
LOG.warn("No bike parks found from the data source.");
return;
}
Collection<BikePark> bikeParks = dataSource.getBikeParks();
for (BikePark bikePark : bikeParks) {
service.addBikePark(bikePark);
BikeParkVertex bikeParkVertex = new BikeParkVertex(graph, bikePark);
new BikeParkEdge(bikeParkVertex);
}
LOG.info("Created " + bikeParks.size() + " bike parks.");
}
use of org.opentripplanner.routing.bike_park.BikePark in project OpenTripPlanner by opentripplanner.
the class TestKmlBikeParkSource method testKML.
public void testKML() {
KmlBikeParkDataSource kmlDataSource = new KmlBikeParkDataSource();
kmlDataSource.setUrl("file:src/test/resources/bike/NSFietsenstallingen.kml");
assertTrue(kmlDataSource.update());
List<BikePark> bikeParks = kmlDataSource.getBikeParks();
assertEquals(5, bikeParks.size());
BikePark alkmaar = bikeParks.get(0);
BikePark zwolle = bikeParks.get(4);
assertEquals("Station Alkmaar", alkmaar.name);
assertEquals("Station Zwolle", zwolle.name);
assertTrue(alkmaar.x >= 4.739850 && alkmaar.x <= 4.739851);
assertTrue(alkmaar.y >= 52.637531 && alkmaar.y <= 52.637532);
assertTrue(zwolle.x >= 6.091060 && zwolle.x <= 6.091061);
assertTrue(zwolle.y >= 52.504990 && zwolle.y <= 52.504991);
}
Aggregations