Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GBFS code better suitable for newer GBFS versions #370

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public List<BikeRentalStation> getStations() {
BikeRentalStation status = statusLookup.get(station.id);
station.bikesAvailable = status.bikesAvailable;
station.spacesAvailable = status.spacesAvailable;
station.state = status.state;
if (station.capacity == 0) {
station.capacity = station.bikesAvailable + station.spacesAvailable;
}
Expand Down Expand Up @@ -120,7 +121,7 @@ public GbfsStationDataSource (boolean allowOverloading) {
@Override
public BikeRentalStation makeStation(JsonNode stationNode) {
BikeRentalStation brstation = new BikeRentalStation();
brstation.id = stationNode.path("station_id").toString();
brstation.id = stationNode.path("station_id").asText();
brstation.x = stationNode.path("lon").asDouble();
brstation.y = stationNode.path("lat").asDouble();
brstation.name = new NonLocalizedString(stationNode.path("name").asText());
Expand All @@ -140,9 +141,18 @@ public GbfsStationStatusDataSource () {
@Override
public BikeRentalStation makeStation(JsonNode stationNode) {
BikeRentalStation brstation = new BikeRentalStation();
brstation.id = stationNode.path("station_id").toString();
brstation.id = stationNode.path("station_id").asText();
brstation.bikesAvailable = stationNode.path("num_bikes_available").asInt();
brstation.spacesAvailable = stationNode.path("num_docks_available").asInt();
if (
stationNode.path("is_installed").asBoolean(false) &&
stationNode.path("is_renting").asBoolean(false) &&
stationNode.path("is_returning").asBoolean(false)
) {
brstation.state = "Station on";
} else {
brstation.state = "Station off";
}
brstation.isCarStation = routeAsCar;
return brstation;
}
Expand Down