-
Notifications
You must be signed in to change notification settings - Fork 0
Share birrer adjust bicycle #175
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a57643b
add share_birrer_adjust_bicycle converter
ThorstenFroehlinghaus 7d552c8
add 2nd hostname
ThorstenFroehlinghaus 31d678a
replace propulsion_type hydrogen by electric
ThorstenFroehlinghaus f44fbcb
set bicycle return-constraint
ThorstenFroehlinghaus bcfc335
set bicycle return-constraint
ThorstenFroehlinghaus 1289a2c
return_constraint: any_station
ThorstenFroehlinghaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Comment on lines
+27
to
+30
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Besides this, birrer uses an invalid propulsion_type According to v2.3 spec this should be |
||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that converter
gbfs_set_return_constraintevaluates the form_factor to decide on which return constraint should be added. I did not check but assume alphabetic ordering in applying transformations. Asgbfs_share_birrer_adjust_bicycleis alphabetic order behindgbfs_set_return_constraint, I assume that for yet unchanged form_factorbikeno return constraint will be added.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i will set it explicitely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done