Added approach on the opposite side of the road (main C++ files only).
This commit is contained in:
parent
367933fc1a
commit
ce9dd44c2e
@ -52,7 +52,8 @@ namespace osrm::engine::api
|
|||||||
* optional per coordinate
|
* optional per coordinate
|
||||||
* - bearings: limits the search for segments in the road network to given bearing(s) in degree
|
* - 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
|
* 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,
|
* \see OSRM, Coordinate, Hint, Bearing, RouteParameters, TableParameters,
|
||||||
* NearestParameters, TripParameters, MatchParameters and TileParameters
|
* NearestParameters, TripParameters, MatchParameters and TileParameters
|
||||||
|
|||||||
@ -36,7 +36,8 @@ namespace osrm::engine
|
|||||||
enum class Approach : std::uint8_t
|
enum class Approach : std::uint8_t
|
||||||
{
|
{
|
||||||
CURB = 0,
|
CURB = 0,
|
||||||
UNRESTRICTED = 1
|
OPPOSITE = 1,
|
||||||
|
UNRESTRICTED = 2
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace osrm::engine
|
} // namespace osrm::engine
|
||||||
|
|||||||
@ -558,7 +558,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
{
|
{
|
||||||
bool isOnewaySegment =
|
bool isOnewaySegment =
|
||||||
!(segment.data.forward_segment_id.enabled && segment.data.reverse_segment_id.enabled);
|
!(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
|
// Check the counter clockwise
|
||||||
//
|
//
|
||||||
@ -573,6 +573,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
if (datafacade.IsLeftHandDriving(segment.data.forward_segment_id.id))
|
if (datafacade.IsLeftHandDriving(segment.data.forward_segment_id.id))
|
||||||
input_coordinate_is_at_right = !input_coordinate_is_at_right;
|
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(input_coordinate_is_at_right, (!input_coordinate_is_at_right));
|
||||||
}
|
}
|
||||||
return std::make_pair(true, true);
|
return std::make_pair(true, true);
|
||||||
|
|||||||
@ -560,6 +560,10 @@ inline bool argumentsToParameter(const Napi::CallbackInfo &args,
|
|||||||
{
|
{
|
||||||
params->approaches.push_back(osrm::Approach::CURB);
|
params->approaches.push_back(osrm::Approach::CURB);
|
||||||
}
|
}
|
||||||
|
else if (approach_str == "opposite")
|
||||||
|
{
|
||||||
|
params->approaches.push_back(osrm::Approach::OPPOSITE);
|
||||||
|
}
|
||||||
else if (approach_str == "unrestricted")
|
else if (approach_str == "unrestricted")
|
||||||
{
|
{
|
||||||
params->approaches.push_back(osrm::Approach::UNRESTRICTED);
|
params->approaches.push_back(osrm::Approach::UNRESTRICTED);
|
||||||
@ -567,13 +571,13 @@ inline bool argumentsToParameter(const Napi::CallbackInfo &args,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ThrowError(args.Env(),
|
ThrowError(args.Env(),
|
||||||
"'approaches' param must be one of [curb, unrestricted]");
|
"'approaches' param must be one of [curb, opposite, unrestricted]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ThrowError(args.Env(), "Approach must be a string: [curb, unrestricted] or null");
|
ThrowError(args.Env(), "Approach must be a string: [curb, opposite, unrestricted] or null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,7 +167,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
|||||||
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';';
|
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';';
|
||||||
|
|
||||||
approach_type.add("unrestricted", engine::Approach::UNRESTRICTED)("curb",
|
approach_type.add("unrestricted", engine::Approach::UNRESTRICTED)("curb",
|
||||||
engine::Approach::CURB);
|
engine::Approach::CURB)("opposite", engine::Approach::OPPOSITE);
|
||||||
|
|
||||||
approach_rule = qi::lit("approaches=") >
|
approach_rule = qi::lit("approaches=") >
|
||||||
(-approach_type %
|
(-approach_type %
|
||||||
';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1];
|
';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1];
|
||||||
|
|||||||
@ -292,7 +292,7 @@ inline void asyncForTiles(const Napi::CallbackInfo &info,
|
|||||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview and per step). Can also be `geojson`.
|
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview and per step). Can also be `geojson`.
|
||||||
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`).
|
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`).
|
||||||
* @param {Boolean} [options.continue_straight] Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile.
|
* @param {Boolean} [options.continue_straight] Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile.
|
||||||
* @param {Array} [options.approaches] Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
* @param {Array} [options.approaches] Keep waypoints on curb or opposite side of the road. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
||||||
* `null`/`true`/`false`
|
* `null`/`true`/`false`
|
||||||
* @param {Array} [options.waypoints] Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index.
|
* @param {Array} [options.waypoints] Indices to coordinates to treat as waypoints. If not supplied, all coordinates are waypoints. Must include first and last coordinate index.
|
||||||
* @param {String} [options.format] Which output format to use, either `json`, or [`flatbuffers`](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api/flatbuffers).
|
* @param {String} [options.format] Which output format to use, either `json`, or [`flatbuffers`](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api/flatbuffers).
|
||||||
@ -337,7 +337,7 @@ Napi::Value Engine::route(const Napi::CallbackInfo &info)
|
|||||||
* @param {Boolean} [options.generate_hints=true] Whether or not adds a Hint to the response which can be used in subsequent requests.
|
* @param {Boolean} [options.generate_hints=true] Whether or not adds a Hint to the response which can be used in subsequent requests.
|
||||||
* @param {Number} [options.number=1] Number of nearest segments that should be returned.
|
* @param {Number} [options.number=1] Number of nearest segments that should be returned.
|
||||||
* Must be an integer greater than or equal to `1`.
|
* Must be an integer greater than or equal to `1`.
|
||||||
* @param {Array} [options.approaches] Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
* @param {Array} [options.approaches] Keep waypoints on curb or opposite side of the road. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
||||||
* @param {String} [options.format] Which output format to use, either `json`, or [`flatbuffers`](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api/flatbuffers).
|
* @param {String} [options.format] Which output format to use, either `json`, or [`flatbuffers`](https://github.com/Project-OSRM/osrm-backend/tree/master/include/engine/api/flatbuffers).
|
||||||
* @param {String} [options.snapping] Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
* @param {String} [options.snapping] Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
@ -384,7 +384,7 @@ Napi::Value Engine::nearest(const Napi::CallbackInfo &info)
|
|||||||
* @param {Array} [options.sources] An array of `index` elements (`0 <= integer < #coordinates`) to use
|
* @param {Array} [options.sources] An array of `index` elements (`0 <= integer < #coordinates`) to use
|
||||||
* location with given index as source. Default is to use all.
|
* location with given index as source. Default is to use all.
|
||||||
* @param {Array} [options.destinations] An array of `index` elements (`0 <= integer < #coordinates`) to use location with given index as destination. Default is to use all.
|
* @param {Array} [options.destinations] An array of `index` elements (`0 <= integer < #coordinates`) to use location with given index as destination. Default is to use all.
|
||||||
* @param {Array} [options.approaches] Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
* @param {Array} [options.approaches] Keep waypoints on curb or opposite side of the road. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
||||||
* @param {Number} [options.fallback_speed] Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second.
|
* @param {Number} [options.fallback_speed] Replace `null` responses in result with as-the-crow-flies estimates based on `fallback_speed`. Value is in metres/second.
|
||||||
* @param {String} [options.fallback_coordinate] Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies distance between two points.
|
* @param {String} [options.fallback_coordinate] Either `input` (default) or `snapped`. If using a `fallback_speed`, use either the user-supplied coordinate (`input`), or the snapped coordinate (`snapped`) for calculating the as-the-crow-flies distance between two points.
|
||||||
* @param {Number} [options.scale_factor] Multiply the table duration values in the table by this number for more controlled input into a route optimization solver.
|
* @param {Number} [options.scale_factor] Multiply the table duration values in the table by this number for more controlled input into a route optimization solver.
|
||||||
@ -565,7 +565,7 @@ Napi::Value Engine::match(const Napi::CallbackInfo &info)
|
|||||||
* @param {Boolean} [options.roundtrip=true] Return route is a roundtrip.
|
* @param {Boolean} [options.roundtrip=true] Return route is a roundtrip.
|
||||||
* @param {String} [options.source=any] Return route starts at `any` or `first` coordinate.
|
* @param {String} [options.source=any] Return route starts at `any` or `first` coordinate.
|
||||||
* @param {String} [options.destination=any] Return route ends at `any` or `last` coordinate.
|
* @param {String} [options.destination=any] Return route ends at `any` or `last` coordinate.
|
||||||
* @param {Array} [options.approaches] Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
|
* @param {Array} [options.approaches] Keep waypoints on curb or opposite side of the road. Can be `null` (unrestricted, default), `curb` or `opposite`.
|
||||||
* @param {String} [options.snapping] Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
* @param {String} [options.snapping] Which edges can be snapped to, either `default`, or `any`. `default` only snaps to edges marked by the profile as `is_startpoint`, `any` will allow snapping to any edge in the routing graph.
|
||||||
*
|
*
|
||||||
* @returns {Object} containing `waypoints` and `trips`.
|
* @returns {Object} containing `waypoints` and `trips`.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user