Skip to content

Commit

Permalink
Reset bike station capacity values to zero for non-open stations
Browse files Browse the repository at this point in the history
Smoove api does not do that, so let's handle it again in importer.
Otherwiose OTP will use closed stations in routing.
  • Loading branch information
vesameskanen committed May 16, 2018
1 parent 0ae155c commit f7007c6
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ public BikeRentalStation makeStation(JsonNode node) {
try {
station.y = Double.parseDouble(node.path("coordinates").asText().split(",")[0].trim());
station.x = Double.parseDouble(node.path("coordinates").asText().split(",")[1].trim());
station.bikesAvailable = node.path("avl_bikes").asInt();
station.spacesAvailable = node.path("free_slots").asInt();
if (station.state.equals("Station on")) {
station.bikesAvailable = node.path("avl_bikes").asInt();
station.spacesAvailable = node.path("free_slots").asInt();
} else {
station.bikesAvailable = 0;
station.spacesAvailable = 0;
}
return station;
} catch (NumberFormatException e) {
// E.g. coordinates is empty
Expand Down

0 comments on commit f7007c6

Please sign in to comment.