-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: multiple avoid problem #417
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I have now signed the CLA, so that tag can be removed. |
@shaiguelman do you need to add another label describing the pr to have it merged? |
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.
Thank you for offering this fix and for your patience. Let me know if you're willing to make these changes, or if you'd prefer me to submit a patch to your fork.
Please also add this parameter to the distance matrix test, which you can model off the test of the multi-argument parameter in test_directions.py
@@ -51,7 +51,8 @@ def distance_matrix(client, origins, destinations, | |||
:type language: string | |||
|
|||
:param avoid: Indicates that the calculated route(s) should avoid the | |||
indicated features. Valid values are "tolls", "highways" or "ferries". | |||
indicated features. Valid values are "tolls", "highways" or "ferries" |
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.
Add "indoor"
@@ -51,7 +51,8 @@ def distance_matrix(client, origins, destinations, | |||
:type language: string | |||
|
|||
:param avoid: Indicates that the calculated route(s) should avoid the | |||
indicated features. Valid values are "tolls", "highways" or "ferries". | |||
indicated features. Valid values are "tolls", "highways" or "ferries" | |||
as well as any combination of them separated by "|". | |||
:type avoid: string |
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.
To mirror the implementation in directions.py, let's update this to list or string
@@ -107,8 +108,12 @@ def distance_matrix(client, origins, destinations, | |||
params["language"] = language | |||
|
|||
if avoid: | |||
if avoid not in ["tolls", "highways", "ferries"]: | |||
raise ValueError("Invalid route restriction.") | |||
valid_avoids = ["tolls", "highways", "ferries"] |
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.
add "indoor"
for token in avoid_tokens: | ||
if token not in valid_avoids: | ||
raise ValueError("Invalid route restriction.") | ||
valid_avoids.remove(token) |
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.
I think you mean to remove from avoid_tokens
for token in avoid_tokens: | ||
if token not in valid_avoids: | ||
raise ValueError("Invalid route restriction.") | ||
valid_avoids.remove(token) | ||
params["avoid"] = avoid |
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.
We want to set it to the value of avoid_tokens
right?
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.
Here's where we could do parallel implementation with directions.py.
How about:
params["avoid"] = convert.join_list("|", avoid_tokens)
Fixes #382
Modified distance_matrix so that the parameter "avoid" accepts multiple values, such as "tolls|highways".