Search in sources :

Example 1 with BikeRentalStationService

use of org.opentripplanner.routing.bike_rental.BikeRentalStationService in project OpenTripPlanner by opentripplanner.

the class BikeRentalModule method buildGraph.

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
    LOG.info("Building bike rental stations from static source...");
    BikeRentalStationService service = graph.getService(BikeRentalStationService.class, true);
    if (!dataSource.update()) {
        LOG.warn("No bike rental found from the data source.");
        return;
    }
    Collection<BikeRentalStation> stations = dataSource.getStations();
    for (BikeRentalStation station : stations) {
        service.addBikeRentalStation(station);
        BikeRentalStationVertex vertex = new BikeRentalStationVertex(graph, station);
        new RentABikeOnEdge(vertex, vertex, station.networks);
        if (station.allowDropoff)
            new RentABikeOffEdge(vertex, vertex, station.networks);
    }
    LOG.info("Created " + stations.size() + " bike rental stations.");
}
Also used : RentABikeOnEdge(org.opentripplanner.routing.edgetype.RentABikeOnEdge) BikeRentalStationVertex(org.opentripplanner.routing.vertextype.BikeRentalStationVertex) BikeRentalStationService(org.opentripplanner.routing.bike_rental.BikeRentalStationService) RentABikeOffEdge(org.opentripplanner.routing.edgetype.RentABikeOffEdge) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 2 with BikeRentalStationService

use of org.opentripplanner.routing.bike_rental.BikeRentalStationService in project OpenTripPlanner by opentripplanner.

the class BikeRental method getBikeRentalStations.

@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + Q, MediaType.TEXT_XML + Q })
public BikeRentalStationList getBikeRentalStations(@QueryParam("lowerLeft") String lowerLeft, @QueryParam("upperRight") String upperRight, @PathParam("routerId") String routerId, @QueryParam("locale") String locale_param) {
    Router router = otpServer.getRouter(routerId);
    if (router == null)
        return null;
    BikeRentalStationService bikeRentalService = router.graph.getService(BikeRentalStationService.class);
    Locale locale;
    locale = ResourceBundleSingleton.INSTANCE.getLocale(locale_param);
    if (bikeRentalService == null)
        return new BikeRentalStationList();
    Envelope envelope;
    if (lowerLeft != null) {
        envelope = getEnvelope(lowerLeft, upperRight);
    } else {
        envelope = new Envelope(-180, 180, -90, 90);
    }
    Collection<BikeRentalStation> stations = bikeRentalService.getBikeRentalStations();
    List<BikeRentalStation> out = new ArrayList<>();
    for (BikeRentalStation station : stations) {
        if (envelope.contains(station.x, station.y)) {
            BikeRentalStation station_localized = station.clone();
            station_localized.locale = locale;
            out.add(station_localized);
        }
    }
    BikeRentalStationList brsl = new BikeRentalStationList();
    brsl.stations = out;
    return brsl;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) Router(org.opentripplanner.standalone.Router) BikeRentalStationService(org.opentripplanner.routing.bike_rental.BikeRentalStationService) Envelope(com.vividsolutions.jts.geom.Envelope) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with BikeRentalStationService

use of org.opentripplanner.routing.bike_rental.BikeRentalStationService 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)

Aggregations

BikeRentalStationService (org.opentripplanner.routing.bike_rental.BikeRentalStationService)3 BikeRentalStation (org.opentripplanner.routing.bike_rental.BikeRentalStation)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 BikePark (org.opentripplanner.routing.bike_park.BikePark)1 BikeParkEdge (org.opentripplanner.routing.edgetype.BikeParkEdge)1 RentABikeOffEdge (org.opentripplanner.routing.edgetype.RentABikeOffEdge)1 RentABikeOnEdge (org.opentripplanner.routing.edgetype.RentABikeOnEdge)1 BikeParkVertex (org.opentripplanner.routing.vertextype.BikeParkVertex)1 BikeRentalStationVertex (org.opentripplanner.routing.vertextype.BikeRentalStationVertex)1 Router (org.opentripplanner.standalone.Router)1