We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
preference
Asking for isochrones with default values
isochrones = api.isochrones( locations=(5.86659,45.26936), profile='bicycle', interval_type='time', intervals=[i * 60 for i in (20,50,80,110)], )
and asking for isochrones using the preference attribute (but no options attribute)
options
isochrones_shortest = api.isochrones( locations=(5.86659,45.26936), profile='bicycle', interval_type='time', intervals=[i * 60 for i in (20,50,80,110)], preference="shortest", )
both return the same result. By adding dry_run=True we can see that the preference is not used :
dry_run=True
url: http://localhost:8002/isochrone Parameters: { "headers": { "User-Agent": "routingpy/v1.3.0", "Content-Type": "application/json" }, "timeout": 60, "json": { "locations": [ { "lon": 5.86659, "lat": 45.26936 } ], "costing": "bicycle", "contours": [ { "time": 20.0 }, { "time": 50.0 }, { "time": 80.0 }, { "time": 110.0 } ] } }
However, if you add any values in options, the preference is taken into account :
isochrones_shortest = api.isochrones( locations=(5.86659,45.26936), profile='bicycle', interval_type='time', intervals=[i * 60 for i in (20,50,80,110)], preference="shortest", options={"foo": 12}, dry_run=True, )
Output :
url: http://localhost:8002/isochrone Parameters: { "headers": { "User-Agent": "routingpy/v1.3.0", "Content-Type": "application/json" }, "timeout": 60, "json": { "locations": [ { "lon": 5.86659, "lat": 45.26936 } ], "costing": "bicycle", "contours": [ { "time": 20.0 }, { "time": 50.0 }, { "time": 80.0 }, { "time": 110.0 } ], "costing_options": { "bicycle": { "foo": 12, "shortest": true } } } }
I was expecting the preference parameter to be taken into account, as per the documentation, even if options is None.
After looking at the code and according to my understanding, in isochrones with Valhalla engine, the preference parameter is only read if the options parameter is not None. See https://github.com/gis-ops/routingpy/blob/e5eb103bac330cefdb54aae23deb30f408815911/routingpy/routers/valhalla.py#L441
None
A possible fix could be to do as with directions, and replace if options by if options or preference on line 441 ; cf. https://github.com/gis-ops/routingpy/blob/e5eb103bac330cefdb54aae23deb30f408815911/routingpy/routers/valhalla.py#L232
if options
if options or preference
The text was updated successfully, but these errors were encountered:
Oops, yeah you're absolutely right. Do you time for a PR?
Sorry, something went wrong.
probably worth to look at the isochrones (sorry I meant matrix, this is about isochrones 😅 ..) as well.
Sure, will do !
Successfully merging a pull request may close this issue.
Here's what I did and what I got
Asking for isochrones with default values
and asking for isochrones using the
preference
attribute (but nooptions
attribute)both return the same result.
By adding
dry_run=True
we can see that the preference is not used :However, if you add any values in
options
, thepreference
is taken into account :Output :
Here's what I was expecting
I was expecting the
preference
parameter to be taken into account, as per the documentation, even ifoptions
is None.Here's what I think could be improved
After looking at the code and according to my understanding, in isochrones with Valhalla engine, the
preference
parameter is only read if theoptions
parameter is notNone
. See https://github.com/gis-ops/routingpy/blob/e5eb103bac330cefdb54aae23deb30f408815911/routingpy/routers/valhalla.py#L441A possible fix could be to do as with directions, and replace
if options
byif options or preference
on line 441 ; cf. https://github.com/gis-ops/routingpy/blob/e5eb103bac330cefdb54aae23deb30f408815911/routingpy/routers/valhalla.py#L232The text was updated successfully, but these errors were encountered: