Change qi::lit for qi::symbols for the sides parameter parser.

Refactor code :
 - Suppress StartSide Enum
 - Change Side Structure for Enum

Signed-off-by: FILLAU Jean-Maxime <jean-maxime.fillau@mapotempo.com>
This commit is contained in:
FILLAU Jean-Maxime
2017-05-22 12:10:43 +02:00
committed by Patrick Niklaus
parent 2de17f3fd0
commit ec7934ea33
9 changed files with 40 additions and 86 deletions
@@ -714,14 +714,14 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
input_coordinate, max_results, max_distance, bearing, bearing_range);
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate,
const engine::SideValue side_value) const override final
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const engine::Side side) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
input_coordinate, side_value);
input_coordinate, side);
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
@@ -120,7 +120,7 @@ class BaseDataFacade
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const engine::SideValue side_value) const = 0;
const engine::Side side) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) const = 0;
+6 -5
View File
@@ -212,19 +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::SideValue side_value) const
const engine::Side side) const
{
bool has_small_component = false;
bool has_big_component = false;
auto results = rtree.Nearest(
input_coordinate,
[this, &side_value, &input_coordinate, &has_big_component, &has_small_component](const CandidateSegment &segment) {
[this, &side, &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_value != BOTH)
if (!isOnewaySegment && side != BOTH)
{
// Check the counter clockwise
//
@@ -241,8 +242,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// if drive left
// input_coordinate_is_at_right = !input_coordinate_is_at_right
// We reverse goCountrySide if side_value is OPPOSITE
if (side_value == OPPOSITE)
// We reverse goCountrySide if side is OPPOSITE
if (side == OPPOSITE)
input_coordinate_is_at_right = !input_coordinate_is_at_right;
// Apply the side.
+4 -4
View File
@@ -231,11 +231,11 @@ class BasePlugin
BOOST_ASSERT(parameters.IsValid());
for (const auto i : util::irange<std::size_t>(0UL, parameters.coordinates.size()))
{
SideValue sideValue = engine::SideValue::BOTH;
Side side = engine::Side::BOTH;
// TODO init at SIDE for test
// SideValue sideValue = engine::SideValue::DEFAULT;
// SideValue side = engine::SideValue::DEFAULT;
if (use_sides && parameters.sides[i])
sideValue = parameters.sides[i]->side;
side = parameters.sides[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], sideValue);
parameters.coordinates[i], side);
}
}
+1 -39
View File
@@ -28,56 +28,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OSRM_ENGINE_SIDE_HPP
#define OSRM_ENGINE_SIDE_HPP
#include <string>
namespace osrm
{
namespace engine
{
enum SideValue
enum Side
{
DEFAULT,
OPPOSITE,
BOTH
};
struct Side
{
SideValue side;
static SideValue fromString(const std::string &str)
{
if (str == "d")
return DEFAULT;
else if (str == "o")
return OPPOSITE;
else
return BOTH;
}
static std::string toString(const Side &side)
{
switch(side.side)
{
case(DEFAULT) :
return "0";
case(OPPOSITE) :
return "d";
case(BOTH) :
return "b";
default :
//TODO I don't know what to do here.
return "b";
}
}
};
inline bool operator==(const Side lhs, const Side rhs)
{
return lhs.side == rhs.side;
}
inline bool operator!=(const Side lhs, const Side rhs) { return !(lhs == rhs); }
}
}
#endif