-
Notifications
You must be signed in to change notification settings - Fork 3
Bike Rental
OTP supports dynamic bike rental/bike sharing systems like Bixi. Station location and availability data is loaded on the fly from the various APIs. OTP does not recheck bike availability (make a web-request to an external page) every time someone makes an OTP request. OTP has a component that will periodically run updater modules listed in its Spring configuration. The updater component has an updateFrequency property which if unspecified defaults to 5 minutes. Updater modules will be run once at OTP startup, then at the specified frequency thereafter.
To use it, edit your application-context.xml in opentripplanner-api-webapp thus:
<bean id="periodicGraphUpdater" class="org.opentripplanner.api.servlet.PeriodicGraphUpdater">
<property name="updateFrequency" value="[some number of milliseconds]" />
<property name="updaters">
<list>
<bean class="org.opentripplanner.updater.bike_rental.BikeRentalUpdater">
<property name="bikeRentalDataSource">
<bean class="org.opentripplanner.updater.bike_rental.KeolisRennesBikeRentalDataSource">
<property name="url" value="[some URL]" />
</bean>
</property>
<property name="routerId" value="[this property is optional, but allows multiple graphs to be used with bike rental]" />
</bean>
</list>
</property>
</bean>
If your config XML already defines a periodic updater component to fetch GTFS-realtime updates, you can just add the bike rental updater module to the existing "updaters" list.
If OTP cannot reach the bike rental API or the response data is corrupted, it generally interprets this as there being no new information available. Bike rental stations and availability information are then left as they were after the last successful update.
We support three bike rental APIs at present: KeolisRennesBikeRentalDataSource, BixiBikeRentalDataSource (used in DC, for instance), and CityBikesBikeRentalDataSource (for http://api.citybik.es/). Just change the class and URL above.
If your city's bike rental API is anything like Bixi or Keolis, it's trivial to add support for it.
If your city's bike rental API is like Velib (with a separate query needed for availability data, for no good reason), I would recommend simply not providing any availability data and assuming that all stops are available for pickup/dropoff. We haven't implemented Velib as apparently the people who run it get cranky when people use their API.
Realtime availability is only used for trips planned for times near now anyway; for future trips, we assume that everything is available.
You can also enable static bike rental data from OSM at graph build time, if you prefer. Just set the staticBikeRental property on OpenStreetMapGraphBuilderImpl to true, and OTP will do the rest.
When building your graph, you can also describe a bike rental system's fare structure. Here's an example:
<bean class="org.opentripplanner.graph_builder.impl.FareServiceGraphBuilderImpl" id ="fareBuilder">
<property name="service">
<bean class="org.opentripplanner.routing.bike_rental.TimeBasedBikeRentalFareService">
<property name="currency" value="USD" />
<property name="pricing">
<list value-type="java.lang.String">
<value>30:00,0</value>
<value>1:00:00,200</value>
<value>24:00:00,9400</value>
</list>
</property>
</bean>
</property>
</bean>
This says that trips 30 minutes or less are free; trips of an hour or less cost $2, and trips less than 24 hours cost $94. Later, we'll probably add support for cost-per-minute systems.