Add support for opposite approach request parameter (#6842)
* Added approach on the opposite side of the road. * Additional test and docs coverage for opposite approach --------- Co-authored-by: Aleksandrs Saveljevs <Aleksandrs.Saveljevs@gmail.com>
This commit is contained in:
@@ -52,7 +52,8 @@ namespace osrm::engine::api
|
||||
* optional per coordinate
|
||||
* - bearings: limits the search for segments in the road network to given bearing(s) in degree
|
||||
* towards true north in clockwise direction, optional per coordinate
|
||||
* - approaches: force the phantom node to start towards the node with the road country side.
|
||||
* - approaches: force the phantom node to start towards the node with the road country side or
|
||||
* its opposite
|
||||
*
|
||||
* \see OSRM, Coordinate, Hint, Bearing, RouteParameters, TableParameters,
|
||||
* NearestParameters, TripParameters, MatchParameters and TileParameters
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace osrm::engine
|
||||
enum class Approach : std::uint8_t
|
||||
{
|
||||
CURB = 0,
|
||||
UNRESTRICTED = 1
|
||||
UNRESTRICTED = 1,
|
||||
OPPOSITE = 2
|
||||
|
||||
};
|
||||
} // namespace osrm::engine
|
||||
|
||||
@@ -558,7 +558,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
{
|
||||
bool isOnewaySegment =
|
||||
!(segment.data.forward_segment_id.enabled && segment.data.reverse_segment_id.enabled);
|
||||
if (!isOnewaySegment && approach == Approach::CURB)
|
||||
if (!isOnewaySegment && (approach == Approach::CURB || approach == Approach::OPPOSITE))
|
||||
{
|
||||
// Check the counter clockwise
|
||||
//
|
||||
@@ -573,6 +573,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
if (datafacade.IsLeftHandDriving(segment.data.forward_segment_id.id))
|
||||
input_coordinate_is_at_right = !input_coordinate_is_at_right;
|
||||
|
||||
if (approach == Approach::OPPOSITE)
|
||||
input_coordinate_is_at_right = !input_coordinate_is_at_right;
|
||||
|
||||
return std::make_pair(input_coordinate_is_at_right, (!input_coordinate_is_at_right));
|
||||
}
|
||||
return std::make_pair(true, true);
|
||||
|
||||
Reference in New Issue
Block a user