register target type for symbolizer properties

This commit is contained in:
artemp 2013-12-11 17:08:33 -05:00
parent d5a0537471
commit f21152a6a9
2 changed files with 86 additions and 62 deletions

View file

@ -100,6 +100,30 @@ struct MAPNIK_DECL symbolizer_base
cont_type properties; cont_type properties;
}; };
// symbolizer properties target types
enum class property_types : std::uint8_t
{
target_bool = 1,
target_double,
target_integer,
target_color,
target_comp_op,
target_line_cap,
target_line_join,
target_line_rasterizer,
target_halo_rasterizer,
target_point_placement,
target_pattern_alignment,
target_debug_symbolizer_mode,
target_marker_placement,
target_marker_multi_policy,
target_string,
target_transform,
target_placement,
target_dash_array,
target_colorizer
};
inline bool operator==(symbolizer_base const& lhs, symbolizer_base const& rhs) inline bool operator==(symbolizer_base const& lhs, symbolizer_base const& rhs)
{ {
return lhs.properties.size() == rhs.properties.size() && return lhs.properties.size() == rhs.properties.size() &&
@ -376,7 +400,7 @@ constexpr auto to_integral(Enum e) -> typename std::underlying_type<Enum>::type
return static_cast<typename std::underlying_type<Enum>::type>(e); return static_cast<typename std::underlying_type<Enum>::type>(e);
} }
typedef std::tuple<const char*, mapnik::symbolizer_base::value_type, std::function<std::string(enumeration_wrapper)> > property_meta_type; typedef std::tuple<const char*, mapnik::symbolizer_base::value_type, std::function<std::string(enumeration_wrapper)>, property_types> property_meta_type;
property_meta_type const& get_meta(mapnik::keys key); property_meta_type const& get_meta(mapnik::keys key);
mapnik::keys get_key(std::string const& name); mapnik::keys get_key(std::string const& name);

View file

@ -30,66 +30,66 @@
namespace mapnik { namespace mapnik {
// tuple -> name, default value, enumeration to string converter lambda // tuple -> name, default value, enumeration to string converter lambda, target property type
static const property_meta_type key_meta[static_cast<unsigned>(keys::MAX_SYMBOLIZER_KEY)] = static const property_meta_type key_meta[to_integral(keys::MAX_SYMBOLIZER_KEY)] =
{ {
property_meta_type{ "gamma", 1.0, nullptr}, property_meta_type{ "gamma", 1.0, nullptr, property_types::target_double},
property_meta_type{ "gamma-method", static_cast<value_integer>(GAMMA_POWER), nullptr}, property_meta_type{ "gamma-method", static_cast<value_integer>(GAMMA_POWER), nullptr, property_types::target_integer},
property_meta_type{ "opacity", 1.0, nullptr}, property_meta_type{ "opacity", 1.0, nullptr, property_types::target_double},
property_meta_type{ "alignment", enumeration_wrapper(LOCAL_ALIGNMENT), property_meta_type{ "alignment", enumeration_wrapper(LOCAL_ALIGNMENT),
[](enumeration_wrapper e) { return enumeration<pattern_alignment_enum,pattern_alignment_enum_MAX>(pattern_alignment_enum(e.value)).as_string();}}, [](enumeration_wrapper e) { return enumeration<pattern_alignment_enum,pattern_alignment_enum_MAX>(pattern_alignment_enum(e.value)).as_string();}, property_types::target_pattern_alignment},
property_meta_type{ "offset", 0.0, nullptr}, property_meta_type{ "offset", 0.0, nullptr, property_types::target_double},
property_meta_type{ "comp-op", enumeration_wrapper(src_over), property_meta_type{ "comp-op", enumeration_wrapper(src_over),
[](enumeration_wrapper e) { return *comp_op_to_string(composite_mode_e(e.value)); }}, [](enumeration_wrapper e) { return *comp_op_to_string(composite_mode_e(e.value)); }, property_types::target_comp_op},
property_meta_type{ "clip", false, nullptr}, property_meta_type{ "clip", false, nullptr, property_types::target_bool},
property_meta_type{ "fill", mapnik::color("gray"), nullptr}, property_meta_type{ "fill", mapnik::color("gray"), nullptr, property_types::target_color},
property_meta_type{ "fill-opacity", 1.0 , nullptr}, property_meta_type{ "fill-opacity", 1.0 , nullptr, property_types::target_double},
property_meta_type{ "stroke", mapnik::color("black"), nullptr}, property_meta_type{ "stroke", mapnik::color("black"), nullptr, property_types::target_color},
property_meta_type{ "stroke-width", 1.0 , nullptr}, property_meta_type{ "stroke-width", 1.0 , nullptr, property_types::target_double},
property_meta_type{ "stroke-opacity", 1.0, nullptr}, property_meta_type{ "stroke-opacity", 1.0, nullptr, property_types::target_double},
property_meta_type{ "stroke-linejoin", enumeration_wrapper(MITER_JOIN), property_meta_type{ "stroke-linejoin", enumeration_wrapper(MITER_JOIN),
[](enumeration_wrapper e) { return enumeration<line_join_enum,line_join_enum_MAX>(line_join_enum(e.value)).as_string();}}, [](enumeration_wrapper e) { return enumeration<line_join_enum,line_join_enum_MAX>(line_join_enum(e.value)).as_string();}, property_types::target_double },
property_meta_type{ "stroke-linecap", enumeration_wrapper(BUTT_CAP), property_meta_type{ "stroke-linecap", enumeration_wrapper(BUTT_CAP),
[](enumeration_wrapper e) { return enumeration<line_cap_enum,line_cap_enum_MAX>(line_cap_enum(e.value)).as_string();}}, [](enumeration_wrapper e) { return enumeration<line_cap_enum,line_cap_enum_MAX>(line_cap_enum(e.value)).as_string();}, property_types::target_double },
property_meta_type{ "stroke-gamma", 1.0, nullptr}, property_meta_type{ "stroke-gamma", 1.0, nullptr, property_types::target_double },
property_meta_type{ "stroke-gamma-method",static_cast<value_integer>(GAMMA_POWER), nullptr}, property_meta_type{ "stroke-gamma-method",static_cast<value_integer>(GAMMA_POWER), nullptr, property_types::target_double },
property_meta_type{ "stroke-dashoffset", static_cast<value_integer>(0), nullptr}, property_meta_type{ "stroke-dashoffset", static_cast<value_integer>(0), nullptr, property_types::target_double },
property_meta_type{ "stroke-dasharray", false, nullptr}, property_meta_type{ "stroke-dasharray", false, nullptr, property_types::target_double },
property_meta_type{ "stroke-miterlimit", 4.0, nullptr}, property_meta_type{ "stroke-miterlimit", 4.0, nullptr, property_types::target_double },
property_meta_type{ "geometry-transform", false, nullptr}, property_meta_type{ "geometry-transform", false, nullptr, property_types::target_transform },
property_meta_type{ "line-rasterizer", enumeration_wrapper(RASTERIZER_FULL), property_meta_type{ "line-rasterizer", enumeration_wrapper(RASTERIZER_FULL),
[](enumeration_wrapper e) { return enumeration<line_rasterizer_enum,line_rasterizer_enum_MAX>(line_rasterizer_enum(e.value)).as_string();}}, [](enumeration_wrapper e) { return enumeration<line_rasterizer_enum,line_rasterizer_enum_MAX>(line_rasterizer_enum(e.value)).as_string();}, property_types::target_double },
property_meta_type{ "transform", false, nullptr}, property_meta_type{ "transform", false, nullptr, property_types::target_transform },
property_meta_type{ "spacing", 0.0, nullptr}, property_meta_type{ "spacing", 0.0, nullptr, property_types::target_double },
property_meta_type{ "max-error", 0.0, nullptr}, property_meta_type{ "max-error", 0.0, nullptr, property_types::target_double },
property_meta_type{ "allow-overlap",false, nullptr}, property_meta_type{ "allow-overlap",false, nullptr, property_types::target_bool },
property_meta_type{ "ignore-placement", false, nullptr}, property_meta_type{ "ignore-placement", false, nullptr, property_types::target_bool },
property_meta_type{ "width",static_cast<value_integer>(0), nullptr}, property_meta_type{ "width",static_cast<value_integer>(0), nullptr, property_types::target_double },
property_meta_type{ "height",static_cast<value_integer>(0), nullptr}, property_meta_type{ "height",static_cast<value_integer>(0), nullptr, property_types::target_double },
property_meta_type{ "file", "", nullptr}, property_meta_type{ "file", "", nullptr, property_types::target_string },
property_meta_type{ "shield-dx", 0.0, nullptr}, property_meta_type{ "shield-dx", 0.0, nullptr, property_types::target_double },
property_meta_type{ "shield-dy", 0.0, nullptr}, property_meta_type{ "shield-dy", 0.0, nullptr, property_types::target_double },
property_meta_type{ "unlock-image",false, nullptr}, property_meta_type{ "unlock-image",false, nullptr, property_types::target_bool },
property_meta_type{ "text-opacity", 1.0, nullptr}, property_meta_type{ "text-opacity", 1.0, nullptr, property_types::target_double },
property_meta_type{ "mode",false, nullptr}, property_meta_type{ "mode",false, nullptr, property_types::target_double },
property_meta_type{ "scaling", 1.0, nullptr}, property_meta_type{ "scaling", 1.0, nullptr, property_types::target_double },
property_meta_type{ "filter-factor", 1.0, nullptr}, property_meta_type{ "filter-factor", 1.0, nullptr, property_types::target_double },
property_meta_type{ "mesh-size", static_cast<value_integer>(0), nullptr}, property_meta_type{ "mesh-size", static_cast<value_integer>(0), nullptr, property_types::target_double },
property_meta_type{ "premultiplied", false, nullptr}, property_meta_type{ "premultiplied", false, nullptr, property_types::target_bool },
property_meta_type{ "smooth", false, nullptr}, property_meta_type{ "smooth", false, nullptr, property_types::target_double },
property_meta_type{ "simplify-algorithm", enumeration_wrapper(radial_distance), property_meta_type{ "simplify-algorithm", enumeration_wrapper(radial_distance),
[](enumeration_wrapper e) { return *simplify_algorithm_to_string(simplify_algorithm_e(e.value));}}, [](enumeration_wrapper e) { return *simplify_algorithm_to_string(simplify_algorithm_e(e.value));}, property_types::target_double },
property_meta_type{ "simplify-tolerance", 0.0, nullptr}, property_meta_type{ "simplify-tolerance", 0.0, nullptr, property_types::target_double },
property_meta_type{ "halo-rasterizer", enumeration_wrapper(HALO_RASTERIZER_FULL), property_meta_type{ "halo-rasterizer", enumeration_wrapper(HALO_RASTERIZER_FULL),
[](enumeration_wrapper e) { return enumeration<halo_rasterizer_enum,halo_rasterizer_enum_MAX>(halo_rasterizer_enum(e.value)).as_string();}}, [](enumeration_wrapper e) { return enumeration<halo_rasterizer_enum,halo_rasterizer_enum_MAX>(halo_rasterizer_enum(e.value)).as_string();}, property_types::target_double },
property_meta_type{ "text-placements", false, nullptr}, property_meta_type{ "text-placements", false, nullptr, property_types::target_double },
property_meta_type{ "placement", enumeration_wrapper(MARKER_POINT_PLACEMENT), property_meta_type{ "placement", enumeration_wrapper(MARKER_POINT_PLACEMENT),
[](enumeration_wrapper e) { return enumeration<marker_placement_enum,marker_placement_enum_MAX>(marker_placement_enum(e.value)).as_string();}}, // FIXME - rename to "markers-placement-type" [](enumeration_wrapper e) { return enumeration<marker_placement_enum,marker_placement_enum_MAX>(marker_placement_enum(e.value)).as_string();}, property_types::target_double }, // FIXME - rename to "markers-placement-type"
property_meta_type{ "multi-policy", enumeration_wrapper(MARKER_EACH_MULTI), property_meta_type{ "multi-policy", enumeration_wrapper(MARKER_EACH_MULTI),
[](enumeration_wrapper e) { return enumeration<marker_multi_policy_enum,marker_multi_policy_enum_MAX>(marker_multi_policy_enum(e.value)).as_string();}}, // FIXME - better naming ^^ [](enumeration_wrapper e) { return enumeration<marker_multi_policy_enum,marker_multi_policy_enum_MAX>(marker_multi_policy_enum(e.value)).as_string();}, property_types::target_double }, // FIXME - better naming ^^
property_meta_type{ "placement", enumeration_wrapper(CENTROID_POINT_PLACEMENT), property_meta_type{ "placement", enumeration_wrapper(CENTROID_POINT_PLACEMENT),
[](enumeration_wrapper e) { return enumeration<point_placement_enum,point_placement_enum_MAX>(point_placement_enum(e.value)).as_string();}}, [](enumeration_wrapper e) { return enumeration<point_placement_enum,point_placement_enum_MAX>(point_placement_enum(e.value)).as_string();}, property_types::target_double },
property_meta_type{ "raster-colorizer", nullptr, nullptr } property_meta_type{ "raster-colorizer", nullptr, nullptr, property_types::target_colorizer}
}; };
property_meta_type const& get_meta(mapnik::keys key) property_meta_type const& get_meta(mapnik::keys key)