pre-commit run --show-diff-on-failure --color=always --all-files

This commit is contained in:
Artem Pavlenko 2024-05-15 10:29:13 +01:00
parent 99aa246b73
commit 4114824e6b
3 changed files with 51 additions and 32 deletions

View file

@ -28,9 +28,11 @@
namespace mapnik { namespace mapnik {
enum class line_cap_enum : std::uint8_t { BUTT_CAP, SQUARE_CAP, ROUND_CAP, line_cap_enum_MAX }; 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); 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 }; 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); DEFINE_ENUM(line_join_e, line_join_enum);
enum class line_rasterizer_enum : std::uint8_t { 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 RASTERIZER_FAST, // agg::rasterizer_outline_aa, twice as fast but only good for thin lines
line_rasterizer_enum_MAX line_rasterizer_enum_MAX
}; };
DEFINE_ENUM(line_rasterizer_e, line_rasterizer_enum); 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 }; 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); DEFINE_ENUM(halo_rasterizer_e, halo_rasterizer_enum);
enum class point_placement_enum : std::uint8_t { enum class point_placement_enum : std::uint8_t {
@ -48,6 +52,7 @@ enum class point_placement_enum : std::uint8_t {
INTERIOR_POINT_PLACEMENT, INTERIOR_POINT_PLACEMENT,
point_placement_enum_MAX point_placement_enum_MAX
}; };
DEFINE_ENUM(point_placement_e, point_placement_enum); DEFINE_ENUM(point_placement_e, point_placement_enum);
enum class pattern_alignment_enum : std::uint8_t { LOCAL_ALIGNMENT, GLOBAL_ALIGNMENT, pattern_alignment_enum_MAX }; 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_SYM_MODE_RINGS,
debug_symbolizer_mode_enum_MAX debug_symbolizer_mode_enum_MAX
}; };
DEFINE_ENUM(debug_symbolizer_mode_e, debug_symbolizer_mode_enum); DEFINE_ENUM(debug_symbolizer_mode_e, debug_symbolizer_mode_enum);
// markers // markers
@ -73,6 +79,7 @@ enum class marker_placement_enum : std::uint8_t {
MARKER_POLYLABEL_PLACEMENT, MARKER_POLYLABEL_PLACEMENT,
marker_placement_enum_MAX marker_placement_enum_MAX
}; };
DEFINE_ENUM(marker_placement_e, marker_placement_enum); DEFINE_ENUM(marker_placement_e, marker_placement_enum);
enum class marker_multi_policy_enum : std::uint8_t { 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_LARGEST_MULTI, // only the largest component of a multi gets a marker
marker_multi_policy_enum_MAX marker_multi_policy_enum_MAX
}; };
DEFINE_ENUM(marker_multi_policy_e, marker_multi_policy_enum); DEFINE_ENUM(marker_multi_policy_e, marker_multi_policy_enum);
enum class text_transform_enum : std::uint8_t { enum class text_transform_enum : std::uint8_t {
@ -122,9 +130,11 @@ enum class horizontal_alignment_enum : std::uint8_t {
H_ADJUST, H_ADJUST,
horizontal_alignment_enum_MAX horizontal_alignment_enum_MAX
}; };
DEFINE_ENUM(horizontal_alignment_e, horizontal_alignment_enum); 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 }; 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); DEFINE_ENUM(justify_alignment_e, justify_alignment_enum);
enum class text_upright_enum : std::uint8_t { enum class text_upright_enum : std::uint8_t {
@ -136,6 +146,7 @@ enum class text_upright_enum : std::uint8_t {
UPRIGHT_RIGHT_ONLY, UPRIGHT_RIGHT_ONLY,
text_upright_enum_MAX text_upright_enum_MAX
}; };
DEFINE_ENUM(text_upright_e, text_upright_enum); DEFINE_ENUM(text_upright_e, text_upright_enum);
enum class direction_enum : std::uint8_t { enum class direction_enum : std::uint8_t {
@ -149,6 +160,7 @@ enum class direction_enum : std::uint8_t {
DIRECTION_DOWN, DIRECTION_DOWN,
direction_enum_MAX direction_enum_MAX
}; };
DEFINE_ENUM(direction_e, direction_enum); DEFINE_ENUM(direction_e, direction_enum);
enum class gamma_method_enum : std::uint8_t { 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_MULTIPLY, // agg::gamma_multiply
gamma_method_enum_MAX gamma_method_enum_MAX
}; };
DEFINE_ENUM(gamma_method_e, gamma_method_enum); 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 }; 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); DEFINE_ENUM(line_pattern_e, line_pattern_enum);
enum class smooth_algorithm_enum : std::uint8_t { 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_ADAPTIVE,
smooth_algorithm_enum_MAX smooth_algorithm_enum_MAX
}; };
DEFINE_ENUM(smooth_algorithm_e, smooth_algorithm_enum); DEFINE_ENUM(smooth_algorithm_e, smooth_algorithm_enum);
} // namespace mapnik } // namespace mapnik

View file

@ -147,25 +147,26 @@ inline std::string symbolizer_name(symbolizer const& sym)
return type; return type;
} }
template <typename Meta> template<typename Meta>
class symbolizer_property_value_string class symbolizer_property_value_string
{ {
public: public:
symbolizer_property_value_string (Meta const& meta) symbolizer_property_value_string(Meta const& meta)
: meta_(meta) {} : meta_(meta)
{}
std::string operator() ( mapnik::enumeration_wrapper const& e) const std::string operator()(mapnik::enumeration_wrapper const& e) const
{ {
std::stringstream ss; std::stringstream ss;
auto const& convert_fun_ptr(std::get<1>(meta_)); auto const& convert_fun_ptr(std::get<1>(meta_));
if ( convert_fun_ptr ) if (convert_fun_ptr)
{ {
ss << '\"' << convert_fun_ptr(e) << '\"'; ss << '\"' << convert_fun_ptr(e) << '\"';
} }
return ss.str(); return ss.str();
} }
std::string operator () ( path_expression_ptr const& expr) const std::string operator()(path_expression_ptr const& expr) const
{ {
std::ostringstream ss; std::ostringstream ss;
if (expr) if (expr)
@ -175,17 +176,17 @@ public:
return ss.str(); return ss.str();
} }
std::string operator () (text_placements_ptr const& expr) const std::string operator()(text_placements_ptr const& expr) const
{ {
return std::string("\"<fixme-text-placement-ptr>\""); return std::string("\"<fixme-text-placement-ptr>\"");
} }
std::string operator () (raster_colorizer_ptr const& expr) const std::string operator()(raster_colorizer_ptr const& expr) const
{ {
return std::string("\"<fixme-raster-colorizer-ptr>\""); return std::string("\"<fixme-raster-colorizer-ptr>\"");
} }
std::string operator () (transform_type const& expr) const std::string operator()(transform_type const& expr) const
{ {
std::ostringstream ss; std::ostringstream ss;
if (expr) if (expr)
@ -195,7 +196,7 @@ public:
return ss.str(); return ss.str();
} }
std::string operator () (expression_ptr const& expr) const std::string operator()(expression_ptr const& expr) const
{ {
std::ostringstream ss; std::ostringstream ss;
if (expr) if (expr)
@ -205,33 +206,34 @@ public:
return ss.str(); return ss.str();
} }
std::string operator () (color const& c) const std::string operator()(color const& c) const
{ {
std::ostringstream ss; std::ostringstream ss;
ss << '\"' << c << '\"'; ss << '\"' << c << '\"';
return ss.str(); return ss.str();
} }
std::string operator () (dash_array const& dash) const std::string operator()(dash_array const& dash) const
{ {
std::ostringstream ss; std::ostringstream ss;
for (std::size_t i = 0; i < dash.size(); ++i) for (std::size_t i = 0; i < dash.size(); ++i)
{ {
ss << dash[i].first << "," << dash[i].second; ss << dash[i].first << "," << dash[i].second;
if ( i + 1 < dash.size() ) ss << ','; if (i + 1 < dash.size())
ss << ',';
} }
return ss.str(); return ss.str();
} }
template <typename T> template<typename T>
std::string operator () ( T const& val ) const std::string operator()(T const& val) const
{ {
std::ostringstream ss; std::ostringstream ss;
ss << '\"' << val << '\"'; ss << '\"' << val << '\"';
return ss.str(); return ss.str();
} }
private: private:
Meta const& meta_; Meta const& meta_;
}; };
@ -239,8 +241,8 @@ struct symbolizer_to_json
{ {
using result_type = std::string; using result_type = std::string;
template <typename T> template<typename T>
auto operator() (T const& sym) const -> result_type auto operator()(T const& sym) const -> result_type
{ {
std::stringstream ss; std::stringstream ss;
ss << "{\"type\":\"" << mapnik::symbolizer_traits<T>::name() << "\","; ss << "{\"type\":\"" << mapnik::symbolizer_traits<T>::name() << "\",";
@ -249,10 +251,12 @@ struct symbolizer_to_json
for (auto const& prop : sym.properties) for (auto const& prop : sym.properties)
{ {
auto const& meta = mapnik::get_meta(prop.first); auto const& meta = mapnik::get_meta(prop.first);
if (first) first = false; if (first)
else ss << ","; first = false;
else
ss << ",";
ss << "\"" << std::get<0>(meta) << "\":"; ss << "\"" << std::get<0>(meta) << "\":";
ss << util::apply_visitor(symbolizer_property_value_string<property_meta_type>(meta),prop.second); ss << util::apply_visitor(symbolizer_property_value_string<property_meta_type>(meta), prop.second);
} }
ss << "}}"; ss << "}}";
return ss.str(); return ss.str();