-
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
Parameter for keep waypoints on the left/right #4039
Conversation
61548fd
to
078b238
Compare
Thank you for taking a stab at this! 🎉 I just skimmed the diff quickly some things that I noticed:
I can put a real review on my TODO for later today, I need to think a little bit about parameter naming and such. |
Hi @TheMarex |
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! AFAIU, DEFAULT side should be used as a parameter for re-routing
@@ -149,10 +159,13 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature> | |||
qi::lit("bearings=") > | |||
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';'; | |||
|
|||
sides_rule = qi::lit("sides=") > |
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.
sides_rule
can be qi::symbols
, so add_side
is not needed.
Also BOTH
can be used for empty boost::optional
values with std::vector<Side> sides
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 tryed to change by this code :
side_default = qi::char_("a-zA-Z")[qi::_val = engine::Side{engine::BOTH}];
struct StartSideValues: qi::symbols<char, engine::Side>
{
StartSideValues() {add("b", engine::Side{engine::BOTH})("d", engine::Side{engine::DEFAULT})("o", engine::Side{engine::OPPOSITE})("", engine::Side{engine::OPPOSITE}); }
};
StartSideValues values;
sides_rule = qi::lit("sides=") >
(-(values | side_default) %
';')[ph::bind(&engine::api::BaseParameters::sides, qi::_r1) = qi::_1];
But it provokes segfault.
I am trying to analyse with gdb but it's a really complicated backtrace.
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.
@fijemax it crashes because grammars are local variables in the constructor.
What i suggest is to use in the way as in commit oxidase@301a1cc It contains more restrictive grammar [bod|eps]
Please add also some unit tests for parsing incorrect URLs as suggested by @TheMarex
features/testbot/side_param.feature
Outdated
|
||
When I route I should get | ||
| from | to | sides | route | | ||
| s | e | b o | ab,bc,bc | |
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.
is it possible to add a turn instructions check? to see explicitly a u-turn
include/engine/geospatial_query.hpp
Outdated
// | | ||
// input_coordinate | ||
|
||
bool input_coordinate_is_at_right = !util::coordinate_calculation::isCCW( |
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.
util::coordinate_calculation::isCCW(coordinates[segment.data.u], input_coordinate, coordinates[segment.data.v]);
to correspond the figure above
I just added the nodeJS binding and url tests. |
d2b3514
to
6e55692
Compare
Hi @oxidase, thanks for parser example.
|
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, some small cleanup comments
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(invalid_route_urls) | |||
BOOST_CHECK_EQUAL(testInvalidOptions<RouteParameters>("1,2;3,4?overview=false&radiuses=foo"), | |||
32UL); | |||
BOOST_CHECK_EQUAL(testInvalidOptions<RouteParameters>("1,2;3,4?overview=false&sides=foo"), | |||
30UL); | |||
29UL); |
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.
👍
include/engine/side.hpp
Outdated
#ifndef OSRM_ENGINE_SIDE_HPP | ||
#define OSRM_ENGINE_SIDE_HPP | ||
|
||
#include <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.
It is not needed
sides_rule = qi::lit("sides=") > | ||
(-(side_type | qi::attr(engine::Side::BOTH)) % | ||
';')[ph::bind(&engine::api::BaseParameters::sides, qi::_r1) = qi::_1]; | ||
//(-qi::symbols[qi::char_("aA-zZ")])[ph::bind(add_side, qi::_r1, qi::_1)] % ';'; |
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.
not needed
@@ -149,10 +149,17 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature> | |||
qi::lit("bearings=") > | |||
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';'; | |||
|
|||
side_type.add("d", engine::Side::DEFAULT)("o", engine::Side::OPPOSITE)("b", engine::Side::BOTH); | |||
sides_rule = qi::lit("sides=") > | |||
(-(side_type | qi::attr(engine::Side::BOTH)) % |
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 must be either -
for vector<optional<Side>>
or qi::attr(engine::Side::BOTH)
for vector<Side>
-
will place empty optionals for empty values, but attr(BOTH)
will place BOTH
.
(-side_type %';')[...]
is enough for vector of optionals
Thanks for adding the tests! Some API features need a quick discussion:
|
Yes we build it for a use case where we need the curb approach. We do not have use case the opposite. But why implement half an option as we can easily make it for both sides? Nevertheless we can remove opposite if you want.
We need it per waypoint. E.g. on garbage pickup, the pickup point must be done with the curb approach, but at the depot the side does not matter. We also plan to add to this PR the support of the approach to other plugins. Especially on the table plugin (approach per waypoint make even more sens on it). |
33b0389
to
1f83b36
Compare
One of the main concerns with adding stuff is usually API-surface area. The fewer options we have, the less likely it is that we need to do a breaking API change. Would be cool if we could limit this to only
Okay thanks for the explanation. /cc @daniel-j-h because he has been doing a lot of VRP stuff lately and this might be useful for him too?
🤔 I think that should already work if the right method was extended, all plugins rely on I would like to propose the following API: HTTP
Example: Node JS
Example: |
Hi @TheMarex , |
Ah this is part of It can be configured in the profile via |
Yeah I can totally see how this is useful. You can somewhat fake it already setting bearings - but then you need to do some pre-processing / set the bearing constraints manually. |
note that ProfileProperties::left_hand_driving is a global property set once by the profile. it doesn't take into account what country the current request (and and waypoint) is located in. so if you're working with a g planet dataset, the api will be wrong in some countries, and right in others. |
- Adding sides parameter into base parameters, it can take the values SIDE, OPPOSITE or DEFAULT. - Adding url parser for "sides" parameter, url values are "s" for SIDE, "o" for OPPOSITE and "d" for DEFAULT, example : "sides=s;s". - Checking parameters, if "sides" parameter is used, the number of parameter is the same as number of location. - Create a phantom to start at side driving or Opposite side driving. Signed-off-by: FILLAU Jean-Maxime <[email protected]>
Signed-off-by: FILLAU Jean-Maxime <[email protected]>
Signed-off-by: FILLAU Jean-Maxime <[email protected]>
Signed-off-by: FILLAU Jean-Maxime <[email protected]>
Propagating approach parameter for plugins : - tabler - nearest - trip Signed-off-by: FILLAU Jean-Maxime <[email protected]>
@oxidase |
@fijemax looks like the only thing that is failing right now is the formating check. Can you try:
That requires |
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.
Some minor things need to be fixed. A test for the node bindings would be great too, there seems to be a bug right now.
Thanks for this! Looking forward to shipping this in 5.8
.
include/engine/approach.hpp
Outdated
namespace engine | ||
{ | ||
|
||
enum Approach |
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.
enum class Approach : std::uint8_t
would be better here, for one to remove implicit conversions and to limit the storage requirements to one byte per coordinate.
} | ||
|
||
std::vector<PhantomNodeWithDistance> | ||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, | ||
const float max_distance, | ||
const int bearing, | ||
const int bearing_range) const override final | ||
const int bearing_range, | ||
const engine::Approach approach) const override final |
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.
engine::
is unnecessary.
} | ||
|
||
std::vector<PhantomNodeWithDistance> | ||
NearestPhantomNodes(const util::Coordinate input_coordinate, | ||
const unsigned max_results) const override final | ||
const unsigned max_results, | ||
const engine::Approach approach) const override final |
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.
engine::
} | ||
|
||
std::vector<PhantomNodeWithDistance> | ||
NearestPhantomNodes(const util::Coordinate input_coordinate, | ||
const unsigned max_results, | ||
const double max_distance) const override final | ||
const double max_distance, | ||
const engine::Approach approach) const override final |
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.
engine::
} | ||
|
||
std::vector<PhantomNodeWithDistance> | ||
NearestPhantomNodes(const util::Coordinate input_coordinate, | ||
const unsigned max_results, | ||
const int bearing, | ||
const int bearing_range) const override final | ||
const int bearing_range, | ||
const engine::Approach approach) const override final |
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.
engine::
include/engine/geospatial_query.hpp
Outdated
@@ -15,6 +16,8 @@ | |||
#include <memory> | |||
#include <vector> | |||
|
|||
#include <util/log.hpp> |
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.
not needed anymore?
include/engine/geospatial_query.hpp
Outdated
@@ -545,6 +578,32 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery | |||
return datafacade.GetComponentID(data.forward_segment_id.id).is_tiny; | |||
} | |||
|
|||
std::pair<bool, bool> approach_usage(const util::Coordinate &input_coordinate, |
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.
Rename to ApproachUsage
for camel-case. A better name could be CheckApproach
.
include/nodejs/node_osrm_support.hpp
Outdated
|
||
if (approach_raw->IsNull()) | ||
{ | ||
params->bearings.emplace_back(); |
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.
Copy&Paste error, should be params->approaches
.
include/nodejs/node_osrm_support.hpp
Outdated
|
||
if (!approaches->IsArray()) | ||
{ | ||
Nan::ThrowError("Approaches must be an array of arrays of numbers"); |
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.
Error message is wrong: Should be arrays of strings
include/nodejs/node_osrm_support.hpp
Outdated
} | ||
else | ||
{ | ||
Nan::ThrowError("'approach' param must be one of [curb, unrestricted]"); |
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.
approach
-> approaches
Signed-off-by: FILLAU Jean-Maxime <[email protected]>
Suppress "engine::" Signed-off-by: FILLAU Jean-Maxime <[email protected]>
Hi @TheMarex |
@fijemax for some examples look at |
@TheMarex When I run |
It's ok, I hadn't activate ENABLE_NODE_BINDINGS during cmake compilation. |
Signed-off-by: FILLAU Jean-Maxime <[email protected]>
@TheMarex the nodejs binding tests was done |
@fijemax awesome, this looks good to merge for me. 🎉 |
Very cool - looking forward to having this in a stable release! What I just now realized after this was merged is we need
could you run this out or ticket and tag it for the next release @fijemax so we don't forget about it. (also feel free to write a osm diary / blog post about this if you have the time for it, I can totally see people being interested in this feature :) I wrote a bit about bearings - this one would fit right in) |
@daniel-j-h I just created this PR #4104. |
Hi @daniel-j-h, i wrote this about the new feature. |
Sweet, thank you! |
We have tried to describe our use case for opposite in #5616, which is needed for solving a VRP problem. |
Is there a reason why this great feature is not in the stable release of OSRM?? I mean 6,5 years have passed now and many many people are waiting for it. Would be great if someone would bring it to stable release. |
It was released in 5.8.0 |
Description :
This PR adds a parameter for each point to chose the start/stop side.
Three option can be used :
The default depending at the country.
Issue
This pull request is linking to this issue :
#2201
Tasklist
For the moment the country's drive side is set to right by default, we can find this parameter in the lua file.
How can access this parameter in the osrm-routed ?
Example for DEFAULT on start and stop route point value :
Here start and stop
Another example :
For the one-way roads :
The algorythm do not use the "side" parameter for the phantom node option because the driver hasn't the choice.