Remove boost fusion dependency in RouteParameters
This commit is contained in:
parent
46185fe9e8
commit
d9c281cd7c
@ -35,11 +35,9 @@ int main(int argc, const char *argv[]) try
|
||||
|
||||
osrm::RouteParameters route_parameters;
|
||||
// route is in Berlin
|
||||
auto start = std::make_pair(52.519930, 13.438640);
|
||||
auto target = std::make_pair(52.513191, 13.415852);
|
||||
route_parameters.service = "viaroute";
|
||||
route_parameters.AddCoordinate({start.first, start.second});
|
||||
route_parameters.AddCoordinate({target.first, target.second});
|
||||
route_parameters.AddCoordinate(52.519930, 13.438640);
|
||||
route_parameters.AddCoordinate(52.513191, 13.415852);
|
||||
|
||||
osrm::json::Object json_result;
|
||||
const int result_code = routing_machine.RunQuery(route_parameters, json_result);
|
||||
|
@ -30,7 +30,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
#include <string>
|
||||
@ -77,8 +76,7 @@ struct RouteParameters
|
||||
|
||||
void AddTimestamp(const unsigned timestamp);
|
||||
|
||||
void AddBearing(const boost::fusion::vector<int, boost::optional<int>> &received_bearing,
|
||||
bool &pass);
|
||||
bool AddBearing(int bearing, boost::optional<int> range);
|
||||
|
||||
void SetLanguage(const std::string &language);
|
||||
|
||||
@ -86,11 +84,11 @@ struct RouteParameters
|
||||
|
||||
void SetCompressionFlag(const bool flag);
|
||||
|
||||
void AddCoordinate(const boost::fusion::vector<double, double> &received_coordinates);
|
||||
void AddCoordinate(const double latitude, const double longitude);
|
||||
|
||||
void AddDestination(const boost::fusion::vector<double, double> &received_coordinates);
|
||||
void AddDestination(const double latitude, const double longitude);
|
||||
|
||||
void AddSource(const boost::fusion::vector<double, double> &received_coordinates);
|
||||
void AddSource(const double latitude, const double longitude);
|
||||
|
||||
void SetCoordinatesFromGeometry(const std::string &geometry_string);
|
||||
|
||||
|
@ -16,6 +16,32 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
|
||||
{
|
||||
explicit APIGrammar(HandlerT *h) : APIGrammar::base_type(api_call), handler(h)
|
||||
{
|
||||
const auto add_bearing_wrapper = [this](
|
||||
const boost::fusion::vector<int, boost::optional<int>> &received_bearing, bool &pass)
|
||||
{
|
||||
const int bearing = boost::fusion::at_c<0>(received_bearing);
|
||||
const boost::optional<int> range = boost::fusion::at_c<1>(received_bearing);
|
||||
pass = handler->AddBearing(bearing, range);
|
||||
};
|
||||
const auto add_coordinate_wrapper =
|
||||
[this](const boost::fusion::vector<double, double> &received_coordinate)
|
||||
{
|
||||
handler->AddCoordinate(boost::fusion::at_c<0>(received_coordinate),
|
||||
boost::fusion::at_c<1>(received_coordinate));
|
||||
};
|
||||
const auto add_source_wrapper =
|
||||
[this](const boost::fusion::vector<double, double> &received_coordinate)
|
||||
{
|
||||
handler->AddSource(boost::fusion::at_c<0>(received_coordinate),
|
||||
boost::fusion::at_c<1>(received_coordinate));
|
||||
};
|
||||
const auto add_destination_wrapper =
|
||||
[this](const boost::fusion::vector<double, double> &received_coordinate)
|
||||
{
|
||||
handler->AddDestination(boost::fusion::at_c<0>(received_coordinate),
|
||||
boost::fusion::at_c<1>(received_coordinate));
|
||||
};
|
||||
|
||||
api_call =
|
||||
qi::lit('/') >> string[boost::bind(&HandlerT::SetService, handler, ::_1)] >> -query;
|
||||
query = ('?') >> +(zoom | output | jsonp | checksum | uturns | location_with_options |
|
||||
@ -50,21 +76,20 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
|
||||
qi::bool_[boost::bind(&HandlerT::SetCompressionFlag, handler, ::_1)];
|
||||
location = (-qi::lit('&')) >> qi::lit("loc") >> '=' >>
|
||||
(qi::double_ >> qi::lit(',') >>
|
||||
qi::double_)[boost::bind(&HandlerT::AddCoordinate, handler, ::_1)];
|
||||
qi::double_)[boost::bind<void>(add_coordinate_wrapper, ::_1)];
|
||||
destination = (-qi::lit('&')) >> qi::lit("dst") >> '=' >>
|
||||
(qi::double_ >> qi::lit(',') >>
|
||||
qi::double_)[boost::bind(&HandlerT::AddDestination, handler, ::_1)];
|
||||
qi::double_)[boost::bind<void>(add_destination_wrapper, ::_1)];
|
||||
source = (-qi::lit('&')) >> qi::lit("src") >> '=' >>
|
||||
(qi::double_ >> qi::lit(',') >>
|
||||
qi::double_)[boost::bind(&HandlerT::AddSource, handler, ::_1)];
|
||||
qi::double_)[boost::bind<void>(add_source_wrapper, ::_1)];
|
||||
hint = (-qi::lit('&')) >> qi::lit("hint") >> '=' >>
|
||||
stringwithDot[boost::bind(&HandlerT::AddHint, handler, ::_1)];
|
||||
timestamp = (-qi::lit('&')) >> qi::lit("t") >> '=' >>
|
||||
qi::uint_[boost::bind(&HandlerT::AddTimestamp, handler, ::_1)];
|
||||
bearing = (-qi::lit('&')) >> qi::lit("b") >> '=' >>
|
||||
(qi::int_ >>
|
||||
-(qi::lit(',') >> qi::int_ |
|
||||
qi::attr(10)))[boost::bind(&HandlerT::AddBearing, handler, ::_1, ::_3)];
|
||||
(qi::int_ >> -(qi::lit(',') >> qi::int_ |
|
||||
qi::attr(10)))[boost::bind<void>(add_bearing_wrapper, ::_1, ::_3)];
|
||||
u = (-qi::lit('&')) >> qi::lit("u") >> '=' >>
|
||||
qi::bool_[boost::bind(&HandlerT::SetUTurn, handler, ::_1)];
|
||||
uturns = (-qi::lit('&')) >> qi::lit("uturns") >> '=' >>
|
||||
|
@ -1,8 +1,3 @@
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/include/at_c.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
|
||||
#include "engine/route_parameters.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
@ -98,19 +93,14 @@ void RouteParameters::AddTimestamp(const unsigned timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
void RouteParameters::AddBearing(
|
||||
const boost::fusion::vector<int, boost::optional<int>> &received_bearing,
|
||||
bool &pass)
|
||||
bool RouteParameters::AddBearing(int bearing, boost::optional<int> range)
|
||||
{
|
||||
pass = false;
|
||||
const int bearing = boost::fusion::at_c<0>(received_bearing);
|
||||
const boost::optional<int> range = boost::fusion::at_c<1>(received_bearing);
|
||||
if (bearing < 0 || bearing > 359)
|
||||
return;
|
||||
return false;
|
||||
if (range && (*range < 0 || *range > 180))
|
||||
return;
|
||||
return false;
|
||||
bearings.emplace_back(std::make_pair(bearing, range));
|
||||
pass = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RouteParameters::SetLanguage(const std::string &language_string)
|
||||
@ -122,33 +112,31 @@ void RouteParameters::SetGeometryFlag(const bool flag) { geometry = flag; }
|
||||
|
||||
void RouteParameters::SetCompressionFlag(const bool flag) { compression = flag; }
|
||||
|
||||
void RouteParameters::AddCoordinate(
|
||||
const boost::fusion::vector<double, double> &received_coordinates)
|
||||
void RouteParameters::AddCoordinate(const double latitude, const double longitude)
|
||||
{
|
||||
coordinates.emplace_back(
|
||||
static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<0>(received_coordinates)),
|
||||
static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<1>(received_coordinates)));
|
||||
static_cast<int>(COORDINATE_PRECISION * latitude),
|
||||
static_cast<int>(COORDINATE_PRECISION * longitude));
|
||||
is_source.push_back(true);
|
||||
is_destination.push_back(true);
|
||||
uturns.push_back(uturn_default);
|
||||
}
|
||||
|
||||
void RouteParameters::AddDestination(
|
||||
const boost::fusion::vector<double, double> &received_coordinates)
|
||||
void RouteParameters::AddDestination(const double latitude, const double longitude)
|
||||
{
|
||||
coordinates.emplace_back(
|
||||
static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<0>(received_coordinates)),
|
||||
static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<1>(received_coordinates)));
|
||||
static_cast<int>(COORDINATE_PRECISION * latitude),
|
||||
static_cast<int>(COORDINATE_PRECISION * longitude));
|
||||
is_source.push_back(false);
|
||||
is_destination.push_back(true);
|
||||
uturns.push_back(uturn_default);
|
||||
}
|
||||
|
||||
void RouteParameters::AddSource(const boost::fusion::vector<double, double> &received_coordinates)
|
||||
void RouteParameters::AddSource(const double latitude, const double longitude)
|
||||
{
|
||||
coordinates.emplace_back(
|
||||
static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<0>(received_coordinates)),
|
||||
static_cast<int>(COORDINATE_PRECISION * boost::fusion::at_c<1>(received_coordinates)));
|
||||
static_cast<int>(COORDINATE_PRECISION * latitude),
|
||||
static_cast<int>(COORDINATE_PRECISION * longitude));
|
||||
is_source.push_back(true);
|
||||
is_destination.push_back(false);
|
||||
uturns.push_back(uturn_default);
|
||||
|
Loading…
Reference in New Issue
Block a user