symbolizers: set_property helper
This commit is contained in:
parent
f21152a6a9
commit
5dae2999b1
2 changed files with 67 additions and 5 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/symbolizer_utils.hpp>
|
||||
#include <mapnik/json/generic_json.hpp>
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
@ -63,8 +64,7 @@ struct json_value_visitor : boost::static_visitor<>
|
|||
|
||||
void operator() (std::string const& val) const
|
||||
{
|
||||
std::cerr << std::get<0>(get_meta(key_)) << ":" << val << std::endl;
|
||||
put<std::string>(sym_, key_, val);
|
||||
set_property(sym_, key_, val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
#define MAPNIK_SYMBOLIZER_UTILS_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/transform_processor.hpp>
|
||||
#include <mapnik/expression_string.hpp>
|
||||
#include <mapnik/transform_processor.hpp>
|
||||
#include <mapnik/color_factory.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
|
@ -180,7 +181,7 @@ public:
|
|||
std::ostringstream ss;
|
||||
if (expr)
|
||||
{
|
||||
ss << '\"' << mapnik::to_expression_string(*expr) << '\"';
|
||||
ss << '\"' << "FIXME" /*mapnik::to_expression_string(*expr)*/ << '\"';
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -239,6 +240,67 @@ struct symbolizer_to_json : public boost::static_visitor<std::string>
|
|||
}
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename Symbolizer, typename T>
|
||||
struct set_property_impl
|
||||
{
|
||||
static void apply(Symbolizer & sym, mapnik::keys key, std::string const& val)
|
||||
{
|
||||
std::cerr << "do nothing" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Symbolizer>
|
||||
struct set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_color> >
|
||||
{
|
||||
static void apply(Symbolizer & sym, mapnik::keys key, std::string const& val)
|
||||
{
|
||||
put(sym, key, mapnik::parse_color(val));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Symbolizer>
|
||||
struct set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_double> >
|
||||
{
|
||||
static void apply(Symbolizer & sym, mapnik::keys key, std::string const& val)
|
||||
{
|
||||
std::cerr << " expects double" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Symbolizer>
|
||||
struct set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_bool> >
|
||||
{
|
||||
static void apply(Symbolizer & sym, mapnik::keys key, std::string const& val)
|
||||
{
|
||||
std::cerr << " expects bool" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename Symbolizer, typename T>
|
||||
inline void set_property(Symbolizer & sym, mapnik::keys key, T const& val)
|
||||
{
|
||||
switch (std::get<3>(get_meta(key)))
|
||||
{
|
||||
case property_types::target_bool:
|
||||
set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_bool> >::apply(sym,key,val);
|
||||
break;
|
||||
case property_types::target_integer:
|
||||
set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_integer> >::apply(sym,key,val);
|
||||
break;
|
||||
case property_types::target_double:
|
||||
set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_double> >::apply(sym,key,val);
|
||||
break;
|
||||
case property_types::target_color:
|
||||
set_property_impl<Symbolizer, std::integral_constant<property_types, property_types::target_color> >::apply(sym,key,val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue