diff --git a/src/main/java/org/opentripplanner/routing/bike_rental/BikeRentalStation.java b/src/main/java/org/opentripplanner/routing/bike_rental/BikeRentalStation.java index 47161c69ec2..9d631ba2126 100644 --- a/src/main/java/org/opentripplanner/routing/bike_rental/BikeRentalStation.java +++ b/src/main/java/org/opentripplanner/routing/bike_rental/BikeRentalStation.java @@ -52,6 +52,10 @@ public class BikeRentalStation implements Serializable, Cloneable { @JsonSerialize public boolean isFloatingBike = false; + @XmlAttribute + @JsonSerialize + public String state = ""; // additional state info: on, off, closed, etc + /** * List of compatible network names. Null (default) to be compatible with all. */ diff --git a/src/main/java/org/opentripplanner/updater/bike_rental/SmooveBikeRentalDataSource.java b/src/main/java/org/opentripplanner/updater/bike_rental/SmooveBikeRentalDataSource.java index a59a483ce44..b36faaa7322 100644 --- a/src/main/java/org/opentripplanner/updater/bike_rental/SmooveBikeRentalDataSource.java +++ b/src/main/java/org/opentripplanner/updater/bike_rental/SmooveBikeRentalDataSource.java @@ -52,23 +52,15 @@ public SmooveBikeRentalDataSource() { */ public BikeRentalStation makeStation(JsonNode node) { // TODO: final winter maintenance value not known yet - if (node.path("style").asText().equals("Winter state")) { - return null; - } BikeRentalStation station = new BikeRentalStation(); station.id = node.path("name").asText().split("\\s", 2)[0]; station.name = new NonLocalizedString(node.path("name").asText().split("\\s", 2)[1]); + station.state = node.path("style").asText(); try { station.y = Double.parseDouble(node.path("coordinates").asText().split(",")[0].trim()); station.x = Double.parseDouble(node.path("coordinates").asText().split(",")[1].trim()); - if (node.path("operative").asText().equals("true") && - node.path("style").asText().equals("Station on")) { - station.bikesAvailable = node.path("avl_bikes").asInt(); - station.spacesAvailable = node.path("free_slots").asInt(); - } else { - station.bikesAvailable = 0; - station.spacesAvailable = 0; - } + station.bikesAvailable = node.path("avl_bikes").asInt(); + station.spacesAvailable = node.path("free_slots").asInt(); return station; } catch (NumberFormatException e) { // E.g. coordinates is empty diff --git a/src/test/java/org/opentripplanner/updater/bike_rental/TestBikeRentalStationSource.java b/src/test/java/org/opentripplanner/updater/bike_rental/TestBikeRentalStationSource.java index d6c79bfc95c..623074ae7d6 100644 --- a/src/test/java/org/opentripplanner/updater/bike_rental/TestBikeRentalStationSource.java +++ b/src/test/java/org/opentripplanner/updater/bike_rental/TestBikeRentalStationSource.java @@ -1,3 +1,4 @@ + /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of @@ -66,11 +67,9 @@ public void testSmoove() { BikeRentalStation fake = rentalStations.get(1); assertEquals("Fake", fake.name.toString()); assertEquals("B05", fake.id); + assertEquals("Station off", fake.state); assertEquals(24.0, fake.x); assertEquals(60.0, fake.y); - // operative: false overrides available bikes and slots - assertEquals(0, fake.spacesAvailable); - assertEquals(0, fake.bikesAvailable); BikeRentalStation foo = rentalStations.get(2); assertEquals("Foo", foo.name.toString()); diff --git a/src/test/resources/bike/smoove.json b/src/test/resources/bike/smoove.json index 21b18bb1828..b06210d4bee 100644 --- a/src/test/resources/bike/smoove.json +++ b/src/test/resources/bike/smoove.json @@ -13,7 +13,7 @@ "name" : "B05 Fake", "operative" : false, "coordinates" : "60, 24", - "style" : "Station on", + "style" : "Station off", "avl_bikes" : 5, "free_slots" : 5, "total_slots" : 5