org.opentripplanner.updater.bike_rental.CitiBikeNycBikeRentalDataSource Maven / Gradle / Ivy
package org.opentripplanner.updater.bike_rental;
import java.util.HashSet;
import org.opentripplanner.routing.bike_rental.BikeRentalStation;
import org.opentripplanner.updater.UpdaterDataSourceParameters;
import org.opentripplanner.util.NonLocalizedString;
import com.fasterxml.jackson.databind.JsonNode;
/**
* Build a BikeRentalStation object from CitiBike data source JsonNode object.
*
* @see GenericJsonBikeRentalDataSource
*/
public class CitiBikeNycBikeRentalDataSource extends GenericJsonBikeRentalDataSource {
private String networkName;
public CitiBikeNycBikeRentalDataSource(
UpdaterDataSourceParameters config,
String networkName)
{
super(config, "stationBeanList");
if (networkName != null && !networkName.isEmpty()) {
this.networkName = networkName;
} else {
this.networkName = "CitiBike";
}
}
public BikeRentalStation makeStation(JsonNode stationNode) {
if (!stationNode.path("statusValue").asText().equals("In Service")) {
return null;
}
if (stationNode.path("testStation").asText().equals("true")) {
return null;
}
BikeRentalStation brstation = new BikeRentalStation();
brstation.networks = new HashSet();
brstation.networks.add(this.networkName);
brstation.id = stationNode.path("id").asText();
brstation.x = stationNode.path("longitude").asDouble();
brstation.y = stationNode.path("latitude").asDouble();
brstation.name = new NonLocalizedString(stationNode.path("stationName").asText());
brstation.bikesAvailable = stationNode.path("availableBikes").asInt();
brstation.spacesAvailable = stationNode.path("availableDocks").asInt();
return brstation;
}
}