osrm-backend/include/server/api/tile_parameter_grammar.hpp

49 lines
1.2 KiB
C++
Raw Normal View History

2016-03-02 19:48:30 -05:00
#ifndef SERVER_API_TILE_PARAMETERS_GRAMMAR_HPP
#define SERVER_API_TILE_PARAMETERS_GRAMMAR_HPP
#include "engine/api/tile_parameters.hpp"
#include "engine/hint.hpp"
#include "engine/polyline_compressor.hpp"
2016-03-02 19:48:30 -05:00
//#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/include/qi.hpp>
2016-03-02 19:48:30 -05:00
#include <string>
namespace osrm
{
namespace server
{
namespace api
{
namespace qi = boost::spirit::qi;
struct TileParametersGrammar final : boost::spirit::qi::grammar<std::string::iterator>
{
using Iterator = std::string::iterator;
2016-03-03 08:26:13 -05:00
TileParametersGrammar() : TileParametersGrammar::base_type(root_rule)
2016-03-02 19:48:30 -05:00
{
const auto set_x = [this](const unsigned x_) { parameters.x = x_; };
const auto set_y = [this](const unsigned y_) { parameters.y = y_; };
const auto set_z = [this](const unsigned z_) { parameters.z = z_; };
2016-03-03 08:26:13 -05:00
query_rule = qi::lit("tile(") > qi::uint_[set_x] //
> qi::lit(",") > qi::uint_[set_y] > //
qi::lit(",") > qi::uint_[set_z] > qi::lit(")"); //
2016-03-02 19:48:30 -05:00
root_rule = query_rule > qi::lit(".mvt");
2016-03-02 19:48:30 -05:00
}
engine::api::TileParameters parameters;
2016-03-03 08:26:13 -05:00
private:
2016-03-02 19:48:30 -05:00
qi::rule<Iterator> root_rule;
qi::rule<Iterator> query_rule;
};
}
}
}
#endif