Search in sources :

Example 1 with BikePark

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);
}
Also used : BikePark(org.opentripplanner.routing.bike_park.BikePark)

Example 2 with BikePark

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());
}
Also used : BikeParkVertex(org.opentripplanner.routing.vertextype.BikeParkVertex) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) State(org.opentripplanner.routing.core.State) GraphPath(org.opentripplanner.routing.spt.GraphPath) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) BikePark(org.opentripplanner.routing.bike_park.BikePark)

Example 3 with BikePark

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.");
}
Also used : BikeParkVertex(org.opentripplanner.routing.vertextype.BikeParkVertex) BikeParkEdge(org.opentripplanner.routing.edgetype.BikeParkEdge) BikeRentalStationService(org.opentripplanner.routing.bike_rental.BikeRentalStationService) BikePark(org.opentripplanner.routing.bike_park.BikePark)

Example 4 with BikePark

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);
}
Also used : BikePark(org.opentripplanner.routing.bike_park.BikePark)

Aggregations

BikePark (org.opentripplanner.routing.bike_park.BikePark)4 BikeParkVertex (org.opentripplanner.routing.vertextype.BikeParkVertex)2 BikeRentalStationService (org.opentripplanner.routing.bike_rental.BikeRentalStationService)1 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)1 State (org.opentripplanner.routing.core.State)1 BikeParkEdge (org.opentripplanner.routing.edgetype.BikeParkEdge)1 GraphPath (org.opentripplanner.routing.spt.GraphPath)1 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)1