-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Filter import of rental data by pickup type #6240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
3a1f3de
55e7913
985817a
e516350
993bed1
49a0f78
42c318f
39750a2
f148008
7735de7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,12 @@ | |
| import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_1; | ||
| import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_2; | ||
| import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_3; | ||
| import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_7; | ||
|
|
||
| import org.opentripplanner.ext.smoovebikerental.SmooveBikeRentalDataSourceParameters; | ||
| import org.opentripplanner.standalone.config.framework.json.NodeAdapter; | ||
| import org.opentripplanner.standalone.config.routerconfig.updaters.HttpHeadersConfig; | ||
| import org.opentripplanner.updater.AllowedRentalType; | ||
| import org.opentripplanner.updater.spi.HttpHeaders; | ||
| import org.opentripplanner.updater.vehicle_rental.VehicleRentalSourceType; | ||
| import org.opentripplanner.updater.vehicle_rental.datasources.params.GbfsVehicleRentalDataSourceParameters; | ||
|
|
@@ -43,13 +45,15 @@ public VehicleRentalDataSourceParameters create() { | |
| headers(), | ||
| network(), | ||
| geofencingZones(), | ||
| overloadingAllowed() | ||
| overloadingAllowed(), | ||
| allowedRentalType() | ||
| ); | ||
| case SMOOVE -> new SmooveBikeRentalDataSourceParameters( | ||
| url(), | ||
| network(), | ||
| overloadingAllowed(), | ||
| headers() | ||
| headers(), | ||
| allowedRentalType() | ||
| ); | ||
| }; | ||
| } | ||
|
|
@@ -121,4 +125,21 @@ private boolean geofencingZones() { | |
| ) | ||
| .asBoolean(false); | ||
| } | ||
|
|
||
| private AllowedRentalType allowedRentalType() { | ||
| return c | ||
| .of("allowedRentalType") | ||
| .since(V2_7) | ||
| .summary("The type of rental data to include.") | ||
| .description( | ||
| """ | ||
| The type of rental data to include. This can be one of the following: | ||
|
||
|
|
||
| - `ALL`: Include all data types. | ||
| - `STATIONS`: Include station data only. | ||
| - `VEHICLES`: Include floating vehicle data only. | ||
| """ | ||
| ) | ||
| .asEnum(AllowedRentalType.ALL); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package org.opentripplanner.updater; | ||
|
|
||
| public enum AllowedRentalType { | ||
|
||
| STATIONS, | ||
| VEHICLES, | ||
| ALL, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import org.opentripplanner.service.vehiclerental.model.RentalVehicleType; | ||
| import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace; | ||
| import org.opentripplanner.service.vehiclerental.model.VehicleRentalSystem; | ||
| import org.opentripplanner.updater.AllowedRentalType; | ||
| import org.opentripplanner.updater.vehicle_rental.datasources.params.GbfsVehicleRentalDataSourceParameters; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
@@ -76,60 +77,72 @@ public List<VehicleRentalPlace> getUpdates() { | |
|
|
||
| List<VehicleRentalPlace> stations = new LinkedList<>(); | ||
|
|
||
| // Both station information and status are required for all systems using stations | ||
| GBFSStationInformation stationInformation = loader.getFeed(GBFSStationInformation.class); | ||
| GBFSStationStatus stationStatus = loader.getFeed(GBFSStationStatus.class); | ||
| if (stationInformation != null && stationStatus != null) { | ||
| // Index all the station status entries on their station ID. | ||
| Map<String, GBFSStation> statusLookup = stationStatus | ||
| .getData() | ||
| .getStations() | ||
| .stream() | ||
| .collect(Collectors.toMap(GBFSStation::getStationId, Function.identity())); | ||
| GbfsStationStatusMapper stationStatusMapper = new GbfsStationStatusMapper( | ||
| statusLookup, | ||
| vehicleTypes | ||
| ); | ||
| GbfsStationInformationMapper stationInformationMapper = new GbfsStationInformationMapper( | ||
| system, | ||
| vehicleTypes, | ||
| params.allowKeepingRentedVehicleAtDestination(), | ||
| params.overloadingAllowed() | ||
| ); | ||
|
|
||
| // Iterate over all known stations, and if we have any status information add it to those station objects. | ||
| stations.addAll( | ||
| stationInformation | ||
| if ( | ||
| params.allowedRentalType() == null || | ||
| params.allowedRentalType() == AllowedRentalType.ALL || | ||
| params.allowedRentalType() == AllowedRentalType.STATIONS | ||
|
||
| ) { | ||
| // Both station information and status are required for all systems using stations | ||
| GBFSStationInformation stationInformation = loader.getFeed(GBFSStationInformation.class); | ||
| GBFSStationStatus stationStatus = loader.getFeed(GBFSStationStatus.class); | ||
| if (stationInformation != null && stationStatus != null) { | ||
| // Index all the station status entries on their station ID. | ||
| Map<String, GBFSStation> statusLookup = stationStatus | ||
| .getData() | ||
| .getStations() | ||
| .stream() | ||
| .map(stationInformationMapper::mapStationInformation) | ||
| .filter(Objects::nonNull) | ||
| .peek(stationStatusMapper::fillStationStatus) | ||
| .toList() | ||
| ); | ||
| } | ||
|
|
||
| // Append the floating bike stations. | ||
| if (OTPFeature.FloatingBike.isOn()) { | ||
| GBFSFreeBikeStatus freeBikeStatus = loader.getFeed(GBFSFreeBikeStatus.class); | ||
| if (freeBikeStatus != null) { | ||
| GbfsFreeVehicleStatusMapper freeVehicleStatusMapper = new GbfsFreeVehicleStatusMapper( | ||
| system, | ||
| .collect(Collectors.toMap(GBFSStation::getStationId, Function.identity())); | ||
| GbfsStationStatusMapper stationStatusMapper = new GbfsStationStatusMapper( | ||
| statusLookup, | ||
| vehicleTypes | ||
| ); | ||
| GbfsStationInformationMapper stationInformationMapper = new GbfsStationInformationMapper( | ||
| system, | ||
| vehicleTypes, | ||
| params.allowKeepingRentedVehicleAtDestination(), | ||
| params.overloadingAllowed() | ||
| ); | ||
|
|
||
| // Iterate over all known stations, and if we have any status information add it to those station objects. | ||
| stations.addAll( | ||
| freeBikeStatus | ||
| stationInformation | ||
| .getData() | ||
| .getBikes() | ||
| .getStations() | ||
| .stream() | ||
| .map(freeVehicleStatusMapper::mapFreeVehicleStatus) | ||
| .map(stationInformationMapper::mapStationInformation) | ||
| .filter(Objects::nonNull) | ||
| .peek(stationStatusMapper::fillStationStatus) | ||
| .toList() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| if ( | ||
| params.allowedRentalType() == null || | ||
| params.allowedRentalType() == AllowedRentalType.ALL || | ||
| params.allowedRentalType() == AllowedRentalType.VEHICLES | ||
|
||
| ) { | ||
| // Append the floating bike stations. | ||
| if (OTPFeature.FloatingBike.isOn()) { | ||
| GBFSFreeBikeStatus freeBikeStatus = loader.getFeed(GBFSFreeBikeStatus.class); | ||
| if (freeBikeStatus != null) { | ||
| GbfsFreeVehicleStatusMapper freeVehicleStatusMapper = new GbfsFreeVehicleStatusMapper( | ||
| system, | ||
| vehicleTypes | ||
| ); | ||
| stations.addAll( | ||
| freeBikeStatus | ||
| .getData() | ||
| .getBikes() | ||
| .stream() | ||
| .map(freeVehicleStatusMapper::mapFreeVehicleStatus) | ||
| .filter(Objects::nonNull) | ||
| .toList() | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (params.geofencingZones()) { | ||
| var zones = loader.getFeed(GBFSGeofencingZones.class); | ||
| if (zones != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||
| package org.opentripplanner.updater.vehicle_rental.datasources.params; | ||||||||
|
|
||||||||
| import org.opentripplanner.updater.AllowedRentalType; | ||||||||
| import org.opentripplanner.updater.spi.HttpHeaders; | ||||||||
| import org.opentripplanner.updater.vehicle_rental.VehicleRentalSourceType; | ||||||||
|
|
||||||||
|
|
@@ -10,11 +11,17 @@ public record GbfsVehicleRentalDataSourceParameters( | |||||||
| HttpHeaders httpHeaders, | ||||||||
| String network, | ||||||||
| boolean geofencingZones, | ||||||||
| boolean overloadingAllowed | ||||||||
| boolean overloadingAllowed, | ||||||||
| AllowedRentalType allowedRentalType | ||||||||
|
||||||||
| public AlertUrl { | |
| Objects.requireNonNull(uri); | |
| } |
Uh oh!
There was an error while loading. Please reload this page.