diff --git a/include/mapnik/symbolizer_enumerations.hpp b/include/mapnik/symbolizer_enumerations.hpp index 8c2477f67..92da37559 100644 --- a/include/mapnik/symbolizer_enumerations.hpp +++ b/include/mapnik/symbolizer_enumerations.hpp @@ -28,9 +28,11 @@ namespace mapnik { enum class line_cap_enum : std::uint8_t { BUTT_CAP, SQUARE_CAP, ROUND_CAP, line_cap_enum_MAX }; + DEFINE_ENUM(line_cap_e, line_cap_enum); enum class line_join_enum : std::uint8_t { MITER_JOIN, MITER_REVERT_JOIN, ROUND_JOIN, BEVEL_JOIN, line_join_enum_MAX }; + DEFINE_ENUM(line_join_e, line_join_enum); enum class line_rasterizer_enum : std::uint8_t { @@ -38,9 +40,11 @@ enum class line_rasterizer_enum : std::uint8_t { RASTERIZER_FAST, // agg::rasterizer_outline_aa, twice as fast but only good for thin lines line_rasterizer_enum_MAX }; + DEFINE_ENUM(line_rasterizer_e, line_rasterizer_enum); enum class halo_rasterizer_enum : std::uint8_t { HALO_RASTERIZER_FULL, HALO_RASTERIZER_FAST, halo_rasterizer_enum_MAX }; + DEFINE_ENUM(halo_rasterizer_e, halo_rasterizer_enum); enum class point_placement_enum : std::uint8_t { @@ -48,6 +52,7 @@ enum class point_placement_enum : std::uint8_t { INTERIOR_POINT_PLACEMENT, point_placement_enum_MAX }; + DEFINE_ENUM(point_placement_e, point_placement_enum); enum class pattern_alignment_enum : std::uint8_t { LOCAL_ALIGNMENT, GLOBAL_ALIGNMENT, pattern_alignment_enum_MAX }; @@ -59,6 +64,7 @@ enum class debug_symbolizer_mode_enum : std::uint8_t { DEBUG_SYM_MODE_RINGS, debug_symbolizer_mode_enum_MAX }; + DEFINE_ENUM(debug_symbolizer_mode_e, debug_symbolizer_mode_enum); // markers @@ -73,6 +79,7 @@ enum class marker_placement_enum : std::uint8_t { MARKER_POLYLABEL_PLACEMENT, marker_placement_enum_MAX }; + DEFINE_ENUM(marker_placement_e, marker_placement_enum); enum class marker_multi_policy_enum : std::uint8_t { @@ -81,6 +88,7 @@ enum class marker_multi_policy_enum : std::uint8_t { MARKER_LARGEST_MULTI, // only the largest component of a multi gets a marker marker_multi_policy_enum_MAX }; + DEFINE_ENUM(marker_multi_policy_e, marker_multi_policy_enum); enum class text_transform_enum : std::uint8_t { @@ -122,9 +130,11 @@ enum class horizontal_alignment_enum : std::uint8_t { H_ADJUST, horizontal_alignment_enum_MAX }; + DEFINE_ENUM(horizontal_alignment_e, horizontal_alignment_enum); enum class justify_alignment_enum : std::uint8_t { J_LEFT = 0, J_MIDDLE, J_RIGHT, J_AUTO, justify_alignment_enum_MAX }; + DEFINE_ENUM(justify_alignment_e, justify_alignment_enum); enum class text_upright_enum : std::uint8_t { @@ -136,6 +146,7 @@ enum class text_upright_enum : std::uint8_t { UPRIGHT_RIGHT_ONLY, text_upright_enum_MAX }; + DEFINE_ENUM(text_upright_e, text_upright_enum); enum class direction_enum : std::uint8_t { @@ -149,6 +160,7 @@ enum class direction_enum : std::uint8_t { DIRECTION_DOWN, direction_enum_MAX }; + DEFINE_ENUM(direction_e, direction_enum); enum class gamma_method_enum : std::uint8_t { @@ -159,9 +171,11 @@ enum class gamma_method_enum : std::uint8_t { GAMMA_MULTIPLY, // agg::gamma_multiply gamma_method_enum_MAX }; + DEFINE_ENUM(gamma_method_e, gamma_method_enum); enum class line_pattern_enum : std::uint8_t { LINE_PATTERN_WARP, LINE_PATTERN_REPEAT, line_pattern_enum_MAX }; + DEFINE_ENUM(line_pattern_e, line_pattern_enum); enum class smooth_algorithm_enum : std::uint8_t { @@ -169,6 +183,7 @@ enum class smooth_algorithm_enum : std::uint8_t { SMOOTH_ALGORITHM_ADAPTIVE, smooth_algorithm_enum_MAX }; + DEFINE_ENUM(smooth_algorithm_e, smooth_algorithm_enum); } // namespace mapnik diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp index bd2c96de4..5c4a96d44 100644 --- a/include/mapnik/symbolizer_utils.hpp +++ b/include/mapnik/symbolizer_utils.hpp @@ -147,25 +147,26 @@ inline std::string symbolizer_name(symbolizer const& sym) return type; } -template +template class symbolizer_property_value_string { -public: - symbolizer_property_value_string (Meta const& meta) - : meta_(meta) {} + public: + symbolizer_property_value_string(Meta const& meta) + : meta_(meta) + {} - std::string operator() ( mapnik::enumeration_wrapper const& e) const + std::string operator()(mapnik::enumeration_wrapper const& e) const { std::stringstream ss; auto const& convert_fun_ptr(std::get<1>(meta_)); - if ( convert_fun_ptr ) + if (convert_fun_ptr) { ss << '\"' << convert_fun_ptr(e) << '\"'; } return ss.str(); } - std::string operator () ( path_expression_ptr const& expr) const + std::string operator()(path_expression_ptr const& expr) const { std::ostringstream ss; if (expr) @@ -175,17 +176,17 @@ public: return ss.str(); } - std::string operator () (text_placements_ptr const& expr) const + std::string operator()(text_placements_ptr const& expr) const { return std::string("\"\""); } - std::string operator () (raster_colorizer_ptr const& expr) const + std::string operator()(raster_colorizer_ptr const& expr) const { return std::string("\"\""); } - std::string operator () (transform_type const& expr) const + std::string operator()(transform_type const& expr) const { std::ostringstream ss; if (expr) @@ -195,43 +196,44 @@ public: return ss.str(); } - std::string operator () (expression_ptr const& expr) const + std::string operator()(expression_ptr const& expr) const { std::ostringstream ss; if (expr) { - ss << '\"' << mapnik::to_expression_string(*expr) << '\"'; + ss << '\"' << mapnik::to_expression_string(*expr) << '\"'; } return ss.str(); } - std::string operator () (color const& c) const + std::string operator()(color const& c) const { std::ostringstream ss; ss << '\"' << c << '\"'; return ss.str(); } - std::string operator () (dash_array const& dash) const + 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 << ','; + if (i + 1 < dash.size()) + ss << ','; } return ss.str(); } - template - std::string operator () ( T const& val ) const + template + std::string operator()(T const& val) const { std::ostringstream ss; ss << '\"' << val << '\"'; return ss.str(); } -private: + private: Meta const& meta_; }; @@ -239,8 +241,8 @@ struct symbolizer_to_json { using result_type = std::string; - template - auto operator() (T const& sym) const -> result_type + template + auto operator()(T const& sym) const -> result_type { std::stringstream ss; ss << "{\"type\":\"" << mapnik::symbolizer_traits::name() << "\","; @@ -249,10 +251,12 @@ struct symbolizer_to_json for (auto const& prop : sym.properties) { auto const& meta = mapnik::get_meta(prop.first); - if (first) first = false; - else ss << ","; - ss << "\"" << std::get<0>(meta) << "\":"; - ss << util::apply_visitor(symbolizer_property_value_string(meta),prop.second); + if (first) + first = false; + else + ss << ","; + ss << "\"" << std::get<0>(meta) << "\":"; + ss << util::apply_visitor(symbolizer_property_value_string(meta), prop.second); } ss << "}}"; return ss.str(); diff --git a/src/symbolizer_keys.cpp b/src/symbolizer_keys.cpp index 439d63057..fbdfc0978 100644 --- a/src/symbolizer_keys.cpp +++ b/src/symbolizer_keys.cpp @@ -103,16 +103,16 @@ static const property_meta_type key_meta[const_max_key] = { [](enumeration_wrapper e) { return label_placement_e(label_placement_enum(e.value)).as_string(); }, property_types::target_placement}, property_meta_type{ - "placement", - [](enumeration_wrapper e) { return marker_placement_e(marker_placement_enum(e.value)).as_string(); }, - property_types::target_markers_placement}, + "placement", + [](enumeration_wrapper e) { return marker_placement_e(marker_placement_enum(e.value)).as_string(); }, + property_types::target_markers_placement}, property_meta_type{ - "multi-policy", - [](enumeration_wrapper e) { return marker_multi_policy_e(marker_multi_policy_enum(e.value)).as_string(); }, - property_types::target_markers_multipolicy}, + "multi-policy", + [](enumeration_wrapper e) { return marker_multi_policy_e(marker_multi_policy_enum(e.value)).as_string(); }, + property_types::target_markers_multipolicy}, property_meta_type{"placement", - [](enumeration_wrapper e) { return point_placement_e(point_placement_enum(e.value)).as_string(); }, - property_types::target_placement}, + [](enumeration_wrapper e) { return point_placement_e(point_placement_enum(e.value)).as_string(); }, + property_types::target_placement}, property_meta_type{"colorizer", nullptr, property_types::target_colorizer}, property_meta_type{"halo-transform", nullptr, property_types::target_transform}, property_meta_type{"num-columns", nullptr, property_types::target_integer},