From 0eaa393065f3281ce3b5d2adad78c8c4d2beb36d Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 2 Mar 2016 19:59:49 +0100 Subject: [PATCH] Limit tile zoomlevel to 12+ --- include/engine/route_parameters.hpp | 6 +++--- include/server/api_grammar.hpp | 20 ++++++++++++++++---- src/engine/route_parameters.cpp | 23 ++++++++++++++++++++--- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/include/engine/route_parameters.hpp b/include/engine/route_parameters.hpp index e857c882b..401828539 100644 --- a/include/engine/route_parameters.hpp +++ b/include/engine/route_parameters.hpp @@ -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; diff --git a/include/server/api_grammar.hpp b/include/server/api_grammar.hpp index 19d478d16..41563e029 100644 --- a/include/server/api_grammar.hpp +++ b/include/server/api_grammar.hpp @@ -16,6 +16,18 @@ template struct APIGrammar : qi::grammarSetX(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> &received_bearing, bool &pass) { @@ -110,12 +122,12 @@ template struct APIGrammar : qi::grammar> 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(set_x_wrapper, ::_1, ::_3)]; y = (-qi::lit('&')) >> qi::lit("ty") >> '=' >> - qi::int_[boost::bind(&HandlerT::SetY, handler, ::_1)]; + qi::int_[boost::bind(set_y_wrapper, ::_1, ::_3)]; + z = (-qi::lit('&')) >> qi::lit("tz") >> '=' >> + qi::int_[boost::bind(set_z_wrapper, ::_1, ::_3)]; string = +(qi::char_("a-zA-Z")); stringwithDot = +(qi::char_("a-zA-Z0-9_.-")); diff --git a/src/engine/route_parameters.cpp b/src/engine/route_parameters.cpp index 3f2d9f037..6735bcea3 100644 --- a/src/engine/route_parameters.cpp +++ b/src/engine/route_parameters.cpp @@ -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; +} } }