Skip to content

Commit

Permalink
Merge pull request #370 from HSLdevcom/gbfs-update
Browse files Browse the repository at this point in the history
Make GBFS code better suitable for newer GBFS versions
  • Loading branch information
vesameskanen authored Mar 29, 2022
2 parents 56f0905 + fc4fc9e commit 45bcda5
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit 45bcda5

Please sign in to comment.