Skip to content

Commit 04457f7

Browse files
authored
Merge pull request #196 from HSLdevcom/DT-2541
DT-2541
2 parents f96469a + b8cc71f commit 04457f7

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/main/java/org/opentripplanner/index/IndexGraphQLSchema.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,11 @@ public IndexGraphQLSchema(GraphIndex index) {
18231823
.type(Scalars.GraphQLInt)
18241824
.dataFetcher(environment -> ((BikeRentalStation) environment.getSource()).spacesAvailable)
18251825
.build())
1826+
.field(GraphQLFieldDefinition.newFieldDefinition()
1827+
.name("state")
1828+
.type(Scalars.GraphQLString)
1829+
.dataFetcher(environment -> ((BikeRentalStation) environment.getSource()).state)
1830+
.build())
18261831
.field(GraphQLFieldDefinition.newFieldDefinition()
18271832
.name("realtime")
18281833
.type(Scalars.GraphQLBoolean)

src/main/java/org/opentripplanner/routing/bike_rental/BikeRentalStation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public class BikeRentalStation implements Serializable, Cloneable {
5252
@JsonSerialize
5353
public boolean isFloatingBike = false;
5454

55+
@XmlAttribute
56+
@JsonSerialize
57+
public String state = ""; // additional state info: on, off, closed, etc
58+
5559
/**
5660
* List of compatible network names. Null (default) to be compatible with all.
5761
*/

src/main/java/org/opentripplanner/updater/bike_rental/SmooveBikeRentalDataSource.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,15 @@ public SmooveBikeRentalDataSource() {
5252
*/
5353
public BikeRentalStation makeStation(JsonNode node) {
5454
// TODO: final winter maintenance value not known yet
55-
if (node.path("style").asText().equals("Winter state")) {
56-
return null;
57-
}
5855
BikeRentalStation station = new BikeRentalStation();
5956
station.id = node.path("name").asText().split("\\s", 2)[0];
6057
station.name = new NonLocalizedString(node.path("name").asText().split("\\s", 2)[1]);
58+
station.state = node.path("style").asText();
6159
try {
6260
station.y = Double.parseDouble(node.path("coordinates").asText().split(",")[0].trim());
6361
station.x = Double.parseDouble(node.path("coordinates").asText().split(",")[1].trim());
64-
if (node.path("operative").asText().equals("true") &&
65-
node.path("style").asText().equals("Station on")) {
66-
station.bikesAvailable = node.path("avl_bikes").asInt();
67-
station.spacesAvailable = node.path("free_slots").asInt();
68-
} else {
69-
station.bikesAvailable = 0;
70-
station.spacesAvailable = 0;
71-
}
62+
station.bikesAvailable = node.path("avl_bikes").asInt();
63+
station.spacesAvailable = node.path("free_slots").asInt();
7264
return station;
7365
} catch (NumberFormatException e) {
7466
// E.g. coordinates is empty

src/test/java/org/opentripplanner/updater/bike_rental/TestBikeRentalStationSource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/* This program is free software: you can redistribute it and/or
23
modify it under the terms of the GNU Lesser General Public License
34
as published by the Free Software Foundation, either version 3 of
@@ -66,11 +67,9 @@ public void testSmoove() {
6667
BikeRentalStation fake = rentalStations.get(1);
6768
assertEquals("Fake", fake.name.toString());
6869
assertEquals("B05", fake.id);
70+
assertEquals("Station off", fake.state);
6971
assertEquals(24.0, fake.x);
7072
assertEquals(60.0, fake.y);
71-
// operative: false overrides available bikes and slots
72-
assertEquals(0, fake.spacesAvailable);
73-
assertEquals(0, fake.bikesAvailable);
7473

7574
BikeRentalStation foo = rentalStations.get(2);
7675
assertEquals("Foo", foo.name.toString());

src/test/resources/bike/smoove.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name" : "B05 Fake",
1414
"operative" : false,
1515
"coordinates" : "60, 24",
16-
"style" : "Station on",
16+
"style" : "Station off",
1717
"avl_bikes" : 5,
1818
"free_slots" : 5,
1919
"total_slots" : 5

0 commit comments

Comments
 (0)