Rename side API

Side -> Approach
 - DEFAULT -> CURB
 - BOTH -> UNRESTRICTED
 - remove OPPOSITE param

Signed-off-by: FILLAU Jean-Maxime <jean-maxime.fillau@mapotempo.com>
This commit is contained in:
FILLAU Jean-Maxime
2017-05-22 16:07:12 +02:00
committed by Patrick Niklaus
parent f782dfbfd9
commit f65299d665
16 changed files with 272 additions and 330 deletions
+6 -6
View File
@@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "engine/bearing.hpp"
#include "engine/hint.hpp"
#include "engine/side.hpp"
#include "engine/approach.hpp"
#include "util/coordinate.hpp"
#include <boost/optional.hpp>
@@ -56,7 +56,7 @@ namespace 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
* - sides: 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.
*
* \see OSRM, Coordinate, Hint, Bearing, RouteParame, RouteParameters, TableParameters,
* NearestParameters, TripParameters, MatchParameters and TileParameters
@@ -67,7 +67,7 @@ struct BaseParameters
std::vector<boost::optional<Hint>> hints;
std::vector<boost::optional<double>> radiuses;
std::vector<boost::optional<Bearing>> bearings;
std::vector<boost::optional<Side>> sides;
std::vector<boost::optional<Approach>> approaches;
// Adds hints to response which can be included in subsequent requests, see `hints` above.
bool generate_hints = true;
@@ -76,10 +76,10 @@ struct BaseParameters
const std::vector<boost::optional<Hint>> hints_ = {},
std::vector<boost::optional<double>> radiuses_ = {},
std::vector<boost::optional<Bearing>> bearings_ = {},
std::vector<boost::optional<Side>> sides_ = {},
std::vector<boost::optional<Approach>> approaches_ = {},
bool generate_hints_ = true)
: coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_),
sides(sides_), generate_hints(generate_hints_)
approaches(approaches_), generate_hints(generate_hints_)
{
}
@@ -89,7 +89,7 @@ struct BaseParameters
return (hints.empty() || hints.size() == coordinates.size()) &&
(bearings.empty() || bearings.size() == coordinates.size()) &&
(radiuses.empty() || radiuses.size() == coordinates.size()) &&
(sides.empty() || sides.size() == coordinates.size()) &&
(approaches.empty() || approaches.size() == coordinates.size()) &&
std::all_of(bearings.begin(),
bearings.end(),
[](const boost::optional<Bearing> bearing_and_range) {
@@ -25,19 +25,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OSRM_ENGINE_SIDE_HPP
#define OSRM_ENGINE_SIDE_HPP
#ifndef OSRM_ENGINE_APPROACH_HPP
#define OSRM_ENGINE_APPROACH_HPP
namespace osrm
{
namespace engine
{
enum Side
enum Approach
{
DEFAULT,
OPPOSITE,
BOTH
CURB,
UNRESTRICTED
};
}
@@ -7,7 +7,7 @@
#include "engine/algorithm.hpp"
#include "engine/geospatial_query.hpp"
#include "engine/side.hpp"
#include "engine/approach.hpp"
#include "customizer/edge_based_graph.hpp"
@@ -716,12 +716,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const engine::Side side) const override final
const engine::Approach approach) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
input_coordinate, side);
input_coordinate, approach);
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
@@ -10,7 +10,7 @@
#include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/original_edge_data.hpp"
#include "engine/phantom_node.hpp"
#include "engine/side.hpp"
#include "engine/approach.hpp"
#include "util/exception.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
@@ -120,7 +120,7 @@ class BaseDataFacade
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const engine::Side side) const = 0;
const engine::Approach approach) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) const = 0;
+7 -11
View File
@@ -2,7 +2,7 @@
#define GEOSPATIAL_QUERY_HPP
#include "engine/phantom_node.hpp"
#include "engine/side.hpp"
#include "engine/approach.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/rectangle.hpp"
@@ -212,20 +212,20 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// a second phantom node is return that is the nearest coordinate in a big component.
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const engine::Side side) const
const engine::Approach approach) const
{
bool has_small_component = false;
bool has_big_component = false;
auto results = rtree.Nearest(
input_coordinate,
[this, &side, &input_coordinate, &has_big_component, &has_small_component](
[this, &approach, &input_coordinate, &has_big_component, &has_small_component](
const CandidateSegment &segment) {
auto use_segment =
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
auto use_directions = std::make_pair(use_segment, use_segment);
bool isOnewaySegment = !(segment.data.forward_segment_id.enabled &&
segment.data.reverse_segment_id.enabled);
if (!isOnewaySegment && side != BOTH)
if (!isOnewaySegment && approach != UNRESTRICTED)
{
// Check the counter clockwise
//
@@ -237,16 +237,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool input_coordinate_is_at_right = !util::coordinate_calculation::isCCW(
coordinates[segment.data.u], coordinates[segment.data.v], input_coordinate);
// TODO Check the country side, for the moment right is the default country
// side.
// TODO Check the country approach, for the moment right is the default country
// approach.
// if drive left
// input_coordinate_is_at_right = !input_coordinate_is_at_right
// We reverse goCountrySide if side is OPPOSITE
if (side == OPPOSITE)
input_coordinate_is_at_right = !input_coordinate_is_at_right;
// Apply the side.
// Apply the approach.
use_directions.first = use_directions.first && input_coordinate_is_at_right;
use_directions.second = use_directions.second && !input_coordinate_is_at_right;
}
+5 -5
View File
@@ -226,16 +226,16 @@ class BasePlugin
const bool use_hints = !parameters.hints.empty();
const bool use_bearings = !parameters.bearings.empty();
const bool use_radiuses = !parameters.radiuses.empty();
const bool use_sides = !parameters.sides.empty();
const bool use_approaches = !parameters.approaches.empty();
BOOST_ASSERT(parameters.IsValid());
for (const auto i : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
{
Side side = engine::Side::BOTH;
Approach approach = engine::Approach::UNRESTRICTED;
// TODO init at SIDE for test
// SideValue side = engine::SideValue::DEFAULT;
if (use_sides && parameters.sides[i])
side = parameters.sides[i].get();
if (use_approaches && parameters.approaches[i])
approach = parameters.approaches[i].get();
if (use_hints && parameters.hints[i] &&
parameters.hints[i]->IsValid(parameters.coordinates[i], facade))
@@ -277,7 +277,7 @@ class BasePlugin
{
phantom_node_pairs[i] =
facade.NearestPhantomNodeWithAlternativeFromBigComponent(
parameters.coordinates[i], side);
parameters.coordinates[i], approach);
}
}