Limit tile zoomlevel to 12+

This commit is contained in:
Patrick Niklaus 2016-03-02 19:59:49 +01:00
parent 6d749777fc
commit 0eaa393065
3 changed files with 39 additions and 10 deletions

View File

@ -92,9 +92,9 @@ struct RouteParameters
void SetCoordinatesFromGeometry(const std::string &geometry_string);
void SetX(const int &x);
void SetZ(const int &z);
void SetY(const int &y);
bool SetX(const int x);
bool SetZ(const int z);
bool SetY(const int y);
short zoom_level;
bool print_instructions;

View File

@ -16,6 +16,18 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
{
explicit APIGrammar(HandlerT *h) : APIGrammar::base_type(api_call), handler(h)
{
const auto set_x_wrapper = [this](const int x, bool &pass)
{
pass = handler->SetX(x);
};
const auto set_y_wrapper = [this](const int y, bool &pass)
{
pass = handler->SetY(y);
};
const auto set_z_wrapper = [this](const int z, bool &pass)
{
pass = handler->SetZ(z);
};
const auto add_bearing_wrapper = [this](
const boost::fusion::vector<int, boost::optional<int>> &received_bearing, bool &pass)
{
@ -110,12 +122,12 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
locs = (-qi::lit('&')) >> qi::lit("locs") >> '=' >>
stringforPolyline[boost::bind(&HandlerT::SetCoordinatesFromGeometry, handler, ::_1)];
z = (-qi::lit('&')) >> qi::lit("tz") >> '=' >>
qi::int_[boost::bind(&HandlerT::SetZ, handler, ::_1)];
x = (-qi::lit('&')) >> qi::lit("tx") >> '=' >>
qi::int_[boost::bind(&HandlerT::SetX, handler, ::_1)];
qi::int_[boost::bind<void>(set_x_wrapper, ::_1, ::_3)];
y = (-qi::lit('&')) >> qi::lit("ty") >> '=' >>
qi::int_[boost::bind(&HandlerT::SetY, handler, ::_1)];
qi::int_[boost::bind<void>(set_y_wrapper, ::_1, ::_3)];
z = (-qi::lit('&')) >> qi::lit("tz") >> '=' >>
qi::int_[boost::bind<void>(set_z_wrapper, ::_1, ::_3)];
string = +(qi::char_("a-zA-Z"));
stringwithDot = +(qi::char_("a-zA-Z0-9_.-"));

View File

@ -144,8 +144,25 @@ void RouteParameters::SetCoordinatesFromGeometry(const std::string &geometry_str
coordinates = polylineDecode(geometry_string);
}
void RouteParameters::SetX(const int &x_) { x = x_; }
void RouteParameters::SetZ(const int &z_) { z = z_; }
void RouteParameters::SetY(const int &y_) { y = y_; }
bool RouteParameters::SetX(const int x_)
{
x = x_;
return true;
}
bool RouteParameters::SetZ(const int z_)
{
if (z_ < 12)
{
return false;
}
z = z_;
return true;
}
bool RouteParameters::SetY(const int y_)
{
y = y_;
return true;
}
}
}