update get<>() to use values from symbolizer_default_values.hpp

This commit is contained in:
artemp 2014-10-17 10:39:40 +01:00
parent 9d87f7715b
commit b3e3a4f6bd

View file

@ -41,7 +41,7 @@
#include <mapnik/text/font_feature_settings.hpp>
#include <mapnik/util/dasharray_parser.hpp>
#include <mapnik/util/variant.hpp>
#include <mapnik/symbolizer_default_values.hpp>
// stl
#include <type_traits>
#include <memory>
@ -400,6 +400,14 @@ struct extract_raw_value : public util::static_visitor<T1>
}
};
//
using property_meta_type = std::tuple<const char*, mapnik::symbolizer_base::value_type, std::function<std::string(enumeration_wrapper)>, property_types>;
MAPNIK_DECL property_meta_type const& get_meta(mapnik::keys key);
MAPNIK_DECL mapnik::keys get_key(std::string const& name);
//
template <typename T>
void put(symbolizer_base & sym, keys key, T const& val)
{
@ -413,7 +421,7 @@ inline bool has_key(symbolizer_base const& sym, keys key)
}
template <typename T>
T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars, T const& _default_value = T())
T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
const_iterator itr = sym.properties.find(key);
@ -421,9 +429,34 @@ T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature,
{
return util::apply_visitor(extract_value<T>(feature,vars), itr->second);
}
return _default_value;
return T();//mapnik::symbolizer_default<T,static_cast<std::underlying_type<keys>::type>(key)>::value;
}
template <typename T, keys key>
T get_new(symbolizer_base const& sym, mapnik::feature_impl const& feature, attributes const& vars)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
const_iterator itr = sym.properties.find(key);
if (itr != sym.properties.end())
{
return util::apply_visitor(extract_value<T>(feature,vars), itr->second);
}
return mapnik::symbolizer_default<T,key>::value();
}
template <typename T>
T get(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars, T const& default_value)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
const_iterator itr = sym.properties.find(key);
if (itr != sym.properties.end())
{
return util::apply_visitor(extract_value<T>(feature,vars), itr->second);
}
return default_value;
}
template <typename T>
boost::optional<T> get_optional(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars)
{
@ -437,7 +470,7 @@ boost::optional<T> get_optional(symbolizer_base const& sym, keys key, mapnik::fe
}
template <typename T>
T get(symbolizer_base const& sym, keys key, T const& _default_value = T())
T get(symbolizer_base const& sym, keys key)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
const_iterator itr = sym.properties.find(key);
@ -445,7 +478,20 @@ T get(symbolizer_base const& sym, keys key, T const& _default_value = T())
{
return util::apply_visitor(extract_raw_value<T>(), itr->second);
}
return _default_value;
return T();
}
template <typename T>
T get(symbolizer_base const& sym, keys key, T const& default_value)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
const_iterator itr = sym.properties.find(key);
if (itr != sym.properties.end())
{
return util::apply_visitor(extract_raw_value<T>(), itr->second);
}
return default_value;
}
template <typename T>
@ -460,11 +506,6 @@ boost::optional<T> get_optional(symbolizer_base const& sym, keys key)
return boost::optional<T>();
}
using property_meta_type = std::tuple<const char*, mapnik::symbolizer_base::value_type, std::function<std::string(enumeration_wrapper)>, property_types>;
MAPNIK_DECL property_meta_type const& get_meta(mapnik::keys key);
MAPNIK_DECL mapnik::keys get_key(std::string const& name);
}
#endif // MAPNIK_SYMBOLIZER_HPP