Move bearing to public namespace

This commit is contained in:
Patrick Niklaus
2016-03-04 23:17:57 +01:00
parent 556223d43b
commit 64cc7d8aac
7 changed files with 68 additions and 38 deletions
+2 -19
View File
@@ -2,6 +2,7 @@
#define ENGINE_API_BASE_PARAMETERS_HPP
#include "engine/hint.hpp"
#include "engine/bearing.hpp"
#include "util/coordinate.hpp"
#include <boost/optional.hpp>
@@ -17,12 +18,6 @@ namespace api
{
struct BaseParameters
{
struct Bearing
{
short bearing;
short range;
};
std::vector<util::Coordinate> coordinates;
std::vector<boost::optional<Hint>> hints;
std::vector<boost::optional<double>> radiuses;
@@ -39,24 +34,12 @@ struct BaseParameters
{
if (bearing_and_range)
{
return bearing_and_range->bearing >= 0 &&
bearing_and_range->bearing <= 360 &&
bearing_and_range->range >= 0 &&
bearing_and_range->range <= 180;
return bearing_and_range->IsValid();
}
return true;
});
}
};
inline bool operator==(const BaseParameters::Bearing lhs, const BaseParameters::Bearing rhs)
{
return lhs.bearing == rhs.bearing && lhs.range == rhs.range;
}
inline bool operator!=(const BaseParameters::Bearing lhs, const BaseParameters::Bearing rhs)
{
return !(lhs == rhs);
}
}
}
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef OSRM_ENGINE_BEARING_HPP
#define OSRM_ENGINE_BEARING_HPP
namespace osrm
{
namespace engine
{
struct Bearing
{
short bearing;
short range;
bool IsValid() const { return bearing >= 0 && bearing <= 360 && range >= 0 && range <= 180; }
};
inline bool operator==(const Bearing lhs, const Bearing rhs)
{
return lhs.bearing == rhs.bearing && lhs.range == rhs.range;
}
inline bool operator!=(const Bearing lhs, const Bearing rhs) { return !(lhs == rhs); }
}
}
#endif
+11
View File
@@ -0,0 +1,11 @@
#ifndef OSRM_BEARING_HPP
#define OSRM_BEARING_HPP
#include "engine/bearing.hpp"
namespace osrm
{
using engine::Bearing;
}
#endif
+11
View File
@@ -0,0 +1,11 @@
#ifndef GLOBAL_TILE_PARAMETERS_HPP
#define GLOBAL_TILE_PARAMETERS_HPP
#include "engine/api/tile_parameters.hpp"
namespace osrm
{
using engine::api::TileParameters;
}
#endif
@@ -5,6 +5,7 @@
#include "engine/polyline_compressor.hpp"
#include "engine/hint.hpp"
#include "engine/bearing.hpp"
#include <boost/spirit/include/qi_lit.hpp>
#include <boost/spirit/include/qi_char_.hpp>
@@ -39,11 +40,11 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
const auto add_bearing =
[this](boost::optional<boost::fusion::vector2<short, short>> bearing_range)
{
boost::optional<engine::api::BaseParameters::Bearing> bearing;
boost::optional<engine::Bearing> bearing;
if (bearing_range)
{
bearing = engine::api::BaseParameters::Bearing{
boost::fusion::at_c<0>(*bearing_range), boost::fusion::at_c<1>(*bearing_range)};
bearing = engine::Bearing{boost::fusion::at_c<0>(*bearing_range),
boost::fusion::at_c<1>(*bearing_range)};
}
base_parameters.bearings.push_back(std::move(bearing));
};