diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cec140..fe01248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ The changelog lists relevant feature changes between each release. Search GitHub issues and pull requests for smaller issues. +## 2025-08-20 +- add converter for `share_birrer_ch` feed: correct form_factor and propulsion_type + ## 2025-06-25: - add converter for bolt feeds: remove all bicycle entries - note: if future bolt feeds contain bicycles, the bicycle entries must be added again diff --git a/app/converters/gbfs_https_to_http.py b/app/converters/gbfs_https_to_http.py index db508d1..4589ddd 100644 --- a/app/converters/gbfs_https_to_http.py +++ b/app/converters/gbfs_https_to_http.py @@ -22,6 +22,8 @@ class GbfsHttpsToHttpConverter(BaseConverter): 'gbfs.api.ridedott.com', 'zeus.city', 'yoio.rideatom.com', + 'www.share-birrer.ch', + 'auto-birrer.ch', ] def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]: diff --git a/app/converters/gbfs_set_ttl.py b/app/converters/gbfs_set_ttl.py index 1e2e806..dbb6935 100644 --- a/app/converters/gbfs_set_ttl.py +++ b/app/converters/gbfs_set_ttl.py @@ -14,6 +14,8 @@ class GbfsSetTtlConverter(BaseConverter): 'gbfs.prod.sharedmobility.ch', 'api.voiapp.io', 'gbfs.api.ridedott.com', + 'www.share-birrer.ch', + 'auto-birrer.ch', ] def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]: diff --git a/app/converters/gbfs_share_birrer_adjust_bicycle.py b/app/converters/gbfs_share_birrer_adjust_bicycle.py new file mode 100644 index 0000000..9c1f2aa --- /dev/null +++ b/app/converters/gbfs_share_birrer_adjust_bicycle.py @@ -0,0 +1,36 @@ +from typing import Union + +from app.base_converter import BaseConverter + +BICYCLE_ELECTRIC_MAX_RANGE_METERS = 60000 + + +class GbfsShareBirrerAdjustBicycleConverter(BaseConverter): + """ + share_birrer_ch uses invalid form_factor 'bike' + """ + + hostnames = ['www.share-birrer.ch', 'auto-birrer.ch'] + + def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]: + if not isinstance(data, dict): + return data + + if path.endswith('/vehicle_types'): + fields = data.get('data') + if not isinstance(fields, dict): + return data + vehicle_types = fields.get('vehicle_types') + if not isinstance(vehicle_types, list): + return data + for vehicle_type in vehicle_types: + if vehicle_type.get('form_factor') == 'bike': + vehicle_type['form_factor'] = 'bicycle' + vehicle_type['propulsion_type'] = 'electric' + vehicle_type['max_range_meters'] = BICYCLE_ELECTRIC_MAX_RANGE_METERS + vehicle_type['return_constraint'] = 'any_station' # currently, there is only one station for bicycles + if vehicle_type.get('propulsion_type') == 'hydrogen': + vehicle_type['propulsion_type'] = 'electric' # hydrogen_fuel_cell is not available in 2.2 + return data + + return data diff --git a/config_dist_dev.yaml b/config_dist_dev.yaml index 1a08ca5..a08b4d7 100644 --- a/config_dist_dev.yaml +++ b/config_dist_dev.yaml @@ -11,3 +11,5 @@ HTTP_TO_HTTPS_HOSTS: - gbfs.api.ridedott.com - zeus.city - yoio.rideatom.com + - www.share-birrer.ch + - auto-birrer.ch