-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Parse table annotations param correctly #5050
Conversation
51a634d
to
32c42f8
Compare
@@ -66,8 +66,12 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature | |||
annotations.add("duration", AnnotationsType::Duration)("distance", | |||
AnnotationsType::Distance); | |||
|
|||
const auto reset_annotations = [](engine::api::TableParameters &table_parameters) { |
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.
@ghoshkaj minor thing: you can avoid using explicit lambdas by using a rule for an annotations list as
annotations.add
("duration", AnnotationsType::Duration)
("distance", AnnotationsType::Distance)
;
annotations_list = annotations[qi::_val = qi::_val | qi::_1] % ','
;
base_rule = BaseGrammar::base_rule(qi::_r1)
| (qi::lit("annotations=") > annotations_list
[ph::bind(&engine::api::TableParameters::annotations, qi::_r1) = qi::_1])
;
and below in the members section
qi::rule<Iterator, engine::api::TableParameters::AnnotationsType()> annotations_list;
It is also possible to use qi::_val |= qi::_1
instead of qi::_val = qi::_val | qi::_1
in the semantic action for annotations_list
, but it requires a fix at
inline TableParameters::AnnotationsType operator|=(TableParameters::AnnotationsType lhs, |
as
inline TableParameters::AnnotationsType& operator|=(TableParameters::AnnotationsType& lhs,
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.
looks good! 👍 only some doc phrasing english questions in here
docs/http.md
Outdated
@@ -236,7 +236,7 @@ In addition to the [general options](#general-options) the following options are | |||
|------------|--------------------------------------------------|---------------------------------------------| | |||
|sources |`{index};{index}[;{index} ...]` or `all` (default)|Use location with given index as source. | | |||
|destinations|`{index};{index}[;{index} ...]` or `all` (default)|Use location with given index as destination.| | |||
|annotations |`duration` (default), `distance`, or `duration,distance`|Return additional table with distances to the response. Whether requested or not, the duration table is always returned.| | |||
|annotations |`duration` (default), `distance`, or `duration,distance`|Return additional table with distances to the response. Whether requested or not, the duration table is always returned. Note that `distance` is only currently implemented for CH. Requesting it with MLD algorithm flag will return a `NotImplemented` error.| |
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.
with MLD algorithm flag
?
is that English?
with the MLD algorithm flag
?
with the MLD algorithm
?
with MLD
?
docs/http.md
Outdated
@@ -279,7 +279,7 @@ curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397 | |||
- `durations` array of arrays that stores the matrix in row-major order. `durations[i][j]` gives the travel time from | |||
the i-th waypoint to the j-th waypoint. Values are given in seconds. Can be `null` if no route between `i` and `j` can be found. | |||
- `distances` array of arrays that stores the matrix in row-major order. `distances[i][j]` gives the travel distance from | |||
the i-th waypoint to the j-th waypoint. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. | |||
the i-th waypoint to the j-th waypoint. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. Note that `distance` is only currently implemented for CH. Requesting it with MLD algorithm flag will return a `NotImplemented` error. |
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.
same
docs/nodejs/api.md
Outdated
@@ -126,7 +126,7 @@ tables. Optionally returns distance table. | |||
location with given index as source. Default is to use all. | |||
- `options.destinations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < | |||
#coordinates`) to use location with given index as destination. Default is to use all. | |||
- `options.annotations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of the table types to return. Values can be `duration` or `distance` or both. Default is to return only duration table. | |||
- `options.annotations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of the table types to return. Values can be `duration` or `distance` or both. Default is to return only duration table. Note: Currently, requesting a `distance` annotations is only supported for CH. If `annotations=distance` or `annotations=duration,distance` is requested, a `NotImplemented` error will be returned. |
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.
If `annotations=distance` or `annotations=duration,distance` is requested, a `NotImplemented` error will be returned.
to
If `annotations=distance` or `annotations=duration,distance` is requested when running a MLD router, a `NotImplemented` error will be returned.
docs/nodejs/api.md
Outdated
@@ -152,6 +152,8 @@ osrm.table(options, function(err, response) { | |||
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `durations`, `sources`, and `destinations`. | |||
**`durations`**: array of arrays that stores the matrix in row-major order. `durations[i][j]` gives the travel time from the i-th waypoint to the j-th waypoint. | |||
Values are given in seconds. | |||
**`distances`**: array of arrays that stores the matrix in row-major order. `distances[i][j]` gives the travel time from the i-th waypoint to the j-th waypoint. | |||
Values are given in meters. Note: Currently, returning a `distances` result is only supported for CH. If `annotations=distance` or `annotations=duration,distance` is requested, a `NotImplemented` error will be returned. |
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.
same
change grammer parsing according to review
…n table plugin format
32c42f8
to
efd426d
Compare
efd426d
to
1f21b86
Compare
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.
lgtm
Issue
The annotations parameter for the table plugin does not parse as documented in #4990.
This PR fixes the following:
annotations=distance
orannotations=distance,duration
is requested for MLD in ./osrm-routed.distance
table ifannotations=distance
is requested (as opposed to returning bothdistances
table anddurations
table in ./osrm-routed.Tasklist
Requirements / Relations
#4990