From dc2d094c1977f2176ed910f3b77c810e143ce952 Mon Sep 17 00:00:00 2001 From: Joel Lappalainen Date: Mon, 2 May 2022 17:16:54 +0300 Subject: [PATCH] Add new option for gbfs updaters to not have .json in filenames --- .../updater/bike_rental/BikeRentalUpdater.java | 5 +++-- .../bike_rental/GbfsBikeRentalDataSource.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opentripplanner/updater/bike_rental/BikeRentalUpdater.java b/src/main/java/org/opentripplanner/updater/bike_rental/BikeRentalUpdater.java index d4f7494e431..283a21ea6b7 100644 --- a/src/main/java/org/opentripplanner/updater/bike_rental/BikeRentalUpdater.java +++ b/src/main/java/org/opentripplanner/updater/bike_rental/BikeRentalUpdater.java @@ -63,7 +63,7 @@ protected void configurePolling (Graph graph, JsonNode config) throws Exception // Each updater can be assigned a unique network ID in the configuration to prevent returning bikes at // stations for another network. TODO shouldn't we give each updater a unique network ID by default? String networkName = config.path("network").asText(); - boolean allowOverloading = config.path("allowOverloading").asText().equals("true"); + boolean allowOverloading = config.path("allowOverloading").asText().equals("true"); BikeRentalDataSource source = null; if (sourceType != null) { @@ -94,7 +94,8 @@ protected void configurePolling (Graph graph, JsonNode config) throws Exception } else if (sourceType.equals("uip-bike")) { source = new UIPBikeRentalDataSource(apiKey); } else if (sourceType.equals("gbfs")) { - source = new GbfsBikeRentalDataSource(networkName, allowOverloading); + boolean missesFileExtension = config.path("missesFileExtension").asText().equals("true"); + source = new GbfsBikeRentalDataSource(networkName, allowOverloading, missesFileExtension); } else if (sourceType.equals("smoove")) { source = new SmooveBikeRentalDataSource(networkName, allowOverloading); } else if (sourceType.equals("bicimad")) { diff --git a/src/main/java/org/opentripplanner/updater/bike_rental/GbfsBikeRentalDataSource.java b/src/main/java/org/opentripplanner/updater/bike_rental/GbfsBikeRentalDataSource.java index 37647fc8b11..c0e12e73246 100644 --- a/src/main/java/org/opentripplanner/updater/bike_rental/GbfsBikeRentalDataSource.java +++ b/src/main/java/org/opentripplanner/updater/bike_rental/GbfsBikeRentalDataSource.java @@ -26,10 +26,12 @@ public class GbfsBikeRentalDataSource implements BikeRentalDataSource, JsonConfi private String networkName; + private boolean missesFileExtension; + /** Some car rental systems and flex transit systems work exactly like bike rental, but with cars. */ private boolean routeAsCar; - public GbfsBikeRentalDataSource (String networkName, boolean allowOverloading) { + public GbfsBikeRentalDataSource (String networkName, boolean allowOverloading, boolean missesFileExtension) { stationInformationSource = new GbfsStationDataSource(allowOverloading); stationStatusSource = new GbfsStationStatusDataSource(); // floatingBikeSource = new GbfsFloatingBikeDataSource(); @@ -38,14 +40,16 @@ public GbfsBikeRentalDataSource (String networkName, boolean allowOverloading) { } else { this.networkName = "GBFS"; } + this.missesFileExtension = missesFileExtension; } public void setBaseUrl (String url) { baseUrl = url; if (!baseUrl.endsWith("/")) baseUrl += "/"; - stationInformationSource.setUrl(baseUrl + "station_information.json"); - stationStatusSource.setUrl(baseUrl + "station_status.json"); - // floatingBikeSource.setUrl(baseUrl + "free_bike_status.json"); + String fileExtension = missesFileExtension ? "" : ".json"; + stationInformationSource.setUrl(baseUrl + "station_information" + fileExtension); + stationStatusSource.setUrl(baseUrl + "station_status" + fileExtension); + // floatingBikeSource.setUrl(baseUrl + "free_bike_status" + fileExtension); } @Override