From 1542e3e5137daf370a687901287d9d4108f3a118 Mon Sep 17 00:00:00 2001 From: ldp Date: Sun, 18 Mar 2012 22:35:02 +0100 Subject: [PATCH] add ignore-placement to MarkersSymbolizer --- include/mapnik/markers_symbolizer.hpp | 3 +++ src/agg/process_markers_symbolizer.cpp | 3 ++- src/load_map.cpp | 2 ++ src/markers_symbolizer.cpp | 13 +++++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/mapnik/markers_symbolizer.hpp b/include/mapnik/markers_symbolizer.hpp index b6e78a8c2..ccd249da9 100644 --- a/include/mapnik/markers_symbolizer.hpp +++ b/include/mapnik/markers_symbolizer.hpp @@ -56,6 +56,8 @@ public: explicit markers_symbolizer(); markers_symbolizer(path_expression_ptr filename); markers_symbolizer(markers_symbolizer const& rhs); + void set_ignore_placement(bool ignore_placement); + bool get_ignore_placement() const; void set_allow_overlap(bool overlap); bool get_allow_overlap() const; void set_spacing(double spacing); @@ -76,6 +78,7 @@ public: marker_type_e get_marker_type() const; private: + bool ignore_placement_; bool allow_overlap_; color fill_; double spacing_; diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index 57a01448e..ae7725bf1 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -244,7 +244,8 @@ void agg_renderer::process(markers_symbolizer const& sym, ren.color(agg::rgba8(s_r, s_g, s_b, int(s_a*stroke_.get_opacity()))); agg::render_scanlines(*ras_ptr, sl_line, ren); } - detector_->insert(label_ext); + if (!sym.get_ignore_placement()) + detector_->insert(label_ext); if (writer.first) writer.first->add_box(label_ext, *feature, t_, writer.second); } } diff --git a/src/load_map.cpp b/src/load_map.cpp index 2f77db471..38bcfbff7 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -896,7 +896,9 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym) optional max_error = sym.get_opt_attr("max-error"); if (max_error) symbol.set_max_error(*max_error); optional allow_overlap = sym.get_opt_attr("allow-overlap"); + optional ignore_placement = sym.get_opt_attr("ignore-placement"); if (allow_overlap) symbol.set_allow_overlap(*allow_overlap); + if (ignore_placement) symbol.set_ignore_placement(*ignore_placement); optional w = sym.get_opt_attr("width"); optional h = sym.get_opt_attr("height"); diff --git a/src/markers_symbolizer.cpp b/src/markers_symbolizer.cpp index 02afffdd4..a2ccd70ab 100644 --- a/src/markers_symbolizer.cpp +++ b/src/markers_symbolizer.cpp @@ -47,6 +47,7 @@ markers_symbolizer::markers_symbolizer() : symbolizer_with_image(path_expression_ptr(new path_expression)), symbolizer_base(), allow_overlap_(false), + ignore_placement_(false), fill_(color(0,0,255)), spacing_(100.0), max_error_(0.2), @@ -60,6 +61,7 @@ markers_symbolizer::markers_symbolizer(path_expression_ptr filename) : symbolizer_with_image(filename), symbolizer_base(), allow_overlap_(false), + ignore_placement_(false), fill_(color(0,0,255)), spacing_(100.0), max_error_(0.2), @@ -73,6 +75,7 @@ markers_symbolizer::markers_symbolizer(markers_symbolizer const& rhs) : symbolizer_with_image(rhs), symbolizer_base(rhs), allow_overlap_(rhs.allow_overlap_), + ignore_placement_(rhs.ignore_placement_), fill_(rhs.fill_), spacing_(rhs.spacing_), max_error_(rhs.max_error_), @@ -82,6 +85,16 @@ markers_symbolizer::markers_symbolizer(markers_symbolizer const& rhs) marker_p_(rhs.marker_p_), marker_type_(rhs.marker_type_) {} +void markers_symbolizer::set_ignore_placement(bool ignore_placement) +{ + ignore_placement_ = ignore_placement; +} + +bool markers_symbolizer::get_ignore_placement() const +{ + return ignore_placement_; +} + void markers_symbolizer::set_allow_overlap(bool overlap) { allow_overlap_ = overlap;