From 7245a6f5bdd69893cbb6016c64f69400b97f8137 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 5 Dec 2013 16:28:44 +0000 Subject: [PATCH] symbolizer property value to string --- include/mapnik/symbolizer_utils.hpp | 82 +++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp index b064fe091..e5802ebf4 100644 --- a/include/mapnik/symbolizer_utils.hpp +++ b/include/mapnik/symbolizer_utils.hpp @@ -25,6 +25,9 @@ // mapnik #include +#include +#include + // boost #include @@ -123,6 +126,85 @@ std::string symbolizer_name(symbolizer const& sym) return type; } + +template +class symbolizer_property_value_string : public boost::static_visitor +{ +public: + symbolizer_property_value_string (Meta const& meta) + : meta_(meta) {} + + std::string operator() ( mapnik::enumeration_wrapper const& e) const + { + std::stringstream ss; + auto const& convert_fun_ptr(std::get<2>(meta_)); + if ( convert_fun_ptr ) + { + ss << convert_fun_ptr(e); + } + return ss.str(); + } + + std::string operator () ( path_expression_ptr const& expr) const + { + if (expr) + { + return path_processor::to_string(*expr); + } + return std::string(); + } + + std::string operator () (text_placements_ptr const& expr) const + { + return std::string("\"\""); + } + + std::string operator () (raster_colorizer_ptr const& expr) const + { + return std::string("\"\""); + } + + std::string operator () (transform_type const& expr) const + { + if (expr) + { + return transform_processor_type::to_string(*expr); + } + return std::string(); + } + + std::string operator () (expression_ptr const& expr) const + { + if (expr) + { + return mapnik::to_expression_string(*expr); + } + return std::string(); + } + + std::string operator () (dash_array const& dash) const + { + std::ostringstream ss; + for (std::size_t i = 0; i < dash.size(); ++i) + { + ss << dash[i].first << ", " << dash[i].second; + if ( i + 1 < dash.size() ) ss << ","; + } + return ss.str(); + } + + template + std::string operator () ( T const& val ) const + { + std::ostringstream ss; + ss << val; + return ss.str(); + } + +private: + Meta const& meta_; +}; + }; #endif // MAPNIK_SYMBOLIZER_UTILS_HPP