Skip to content
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

Nextbike: vehicle_types_available fill-in #39

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

hbruch
Copy link
Collaborator

@hbruch hbruch commented Dec 16, 2023

Nextbike feeds are currently invalid, as the station_statusdoes not provide the propery vehicle_types_available.

This PR fills them in, as bikes at stations in free_bike_status.json have their station's id assigned.

The GbfsNextbikeVehicleAvailabilityConverter counts the number of vehicles per vehicle_type_id at each station and constructs the vehicle_types_available from this information.

In cases not a single vehicle is assigned to a station, we add a single vehicle_types_id with count == 0 as vehicle_types_available.

Note that this is a workaround and might be a vehicle_type that will never be available at this station, or a vehicle_type which could be available sometimes will not appear in vehicle_types_available.

@hbruch hbruch requested a review from the-infinity December 16, 2023 16:45
@hbruch hbruch force-pushed the nextbike-vehicle-availability-fixes branch from 0b2701d to cf781c6 Compare December 16, 2023 16:47
if 'num_bikes_available' in station_status:
if num_bikes_available != station_status['num_bikes_available']:
logging.warn(
f"Official num_bikes_available ({station_status['num_bikes_available']}) does not match count deduced from vehicle_types_available ({num_bikes_available}) at stationn {station_status['station_id']}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? Why does this line work in our linter? It should not? :o

station['vehicle_types_available'] = default_vehicle_types_available


def _count_vehicle_types_at_station(vehicles, filter) -> Counter:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typing :)

@hbruch hbruch force-pushed the nextbike-vehicle-availability-fixes branch 2 times, most recently from 731006f to 87d44fc Compare December 18, 2023 11:59
@hbruch hbruch force-pushed the nextbike-vehicle-availability-fixes branch from 87d44fc to f76375e Compare December 18, 2023 12:00
@hbruch hbruch merged commit c80fc10 into main Dec 18, 2023
2 checks passed
@hbruch hbruch deleted the nextbike-vehicle-availability-fixes branch April 23, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants