org.opentripplanner.graph_builder.module.bike.BikeParkModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.graph_builder.module.bike;
import org.opentripplanner.graph_builder.DataImportIssueStore;
import org.opentripplanner.graph_builder.services.GraphBuilderModule;
import org.opentripplanner.routing.bike_park.BikePark;
import org.opentripplanner.routing.bike_rental.BikeRentalStationService;
import org.opentripplanner.routing.edgetype.BikeParkEdge;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vertextype.BikeParkVertex;
import org.opentripplanner.updater.bike_park.BikeParkDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.HashMap;
/**
* This graph builder allow one to statically build bike park using the same source as the dynamic
* bike park updater.
*
* Bike park-and-ride and "OV-fiets mode" development has been funded by GoAbout
* (https://goabout.com/).
*
* @author laurent
* @author GoAbout
*/
public class BikeParkModule implements GraphBuilderModule {
private static Logger LOG = LoggerFactory.getLogger(BikeParkModule.class);
private BikeParkDataSource dataSource;
public void setDataSource(BikeParkDataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public void buildGraph(
Graph graph,
HashMap, Object> extra,
DataImportIssueStore issueStore
) {
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 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.");
}
@Override
public void checkInputs() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy