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.");
}
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;
}
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.");
}
Aggregations