add minimum-path-length to text_symbolizer - closes #865
This commit is contained in:
parent
7f6d0e30a5
commit
aa5cfad4b7
8 changed files with 44 additions and 2 deletions
|
@ -14,6 +14,8 @@ For a complete change history, see the SVN log.
|
|||
Mapnik Trunk
|
||||
------------
|
||||
|
||||
- Add minimum-path-length property to text_symbolizer to allow labels to be placed only on lines of a certain length (#865)
|
||||
|
||||
- Add support for png quantization using fixed palettes (#843)
|
||||
|
||||
- Add AlsoFilter functionality - http://trac.mapnik.org/wiki/AlsoFilter
|
||||
|
|
|
@ -90,6 +90,7 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
extras.append(t.get_justify_alignment());
|
||||
extras.append(t.get_text_opacity());
|
||||
extras.append(t.get_minimum_padding());
|
||||
extras.append(t.get_minimum_path_length());
|
||||
|
||||
return boost::python::make_tuple(disp,t.get_label_placement(),
|
||||
t.get_vertical_alignment(),t.get_halo_radius(),t.get_halo_fill(),t.get_text_ratio(),
|
||||
|
@ -153,6 +154,7 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
t.set_justify_alignment(extract<justify_alignment_e>(extras[6]));
|
||||
t.set_text_opacity(extract<double>(extras[7]));
|
||||
t.set_minimum_padding(extract<double>(extras[8]));
|
||||
t.set_minimum_path_length(extract<double>(extras[9]));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -276,6 +278,9 @@ void export_text_symbolizer()
|
|||
.add_property("minimum_padding",
|
||||
&text_symbolizer::get_minimum_padding,
|
||||
&text_symbolizer::set_minimum_padding)
|
||||
.add_property("minimum_path_length",
|
||||
&text_symbolizer::get_minimum_path_length,
|
||||
&text_symbolizer::set_minimum_path_length)
|
||||
.add_property("name",&text_symbolizer::get_name,
|
||||
&text_symbolizer::set_name)
|
||||
.add_property("opacity",
|
||||
|
|
|
@ -70,6 +70,7 @@ struct placement : boost::noncopyable
|
|||
double max_char_angle_delta;
|
||||
double minimum_distance;
|
||||
double minimum_padding;
|
||||
double minimum_path_length;
|
||||
bool avoid_edges;
|
||||
bool has_dimensions;
|
||||
bool allow_overlap;
|
||||
|
|
|
@ -110,6 +110,8 @@ struct MAPNIK_DECL text_symbolizer : public symbolizer_base
|
|||
double get_minimum_distance() const;
|
||||
void set_minimum_padding(double distance);
|
||||
double get_minimum_padding() const;
|
||||
void set_minimum_path_length(double size);
|
||||
double get_minimum_path_length() const;
|
||||
void set_allow_overlap(bool overlap);
|
||||
bool get_allow_overlap() const;
|
||||
void set_text_opacity(double opacity);
|
||||
|
@ -146,6 +148,7 @@ private:
|
|||
bool avoid_edges_;
|
||||
double minimum_distance_;
|
||||
double minimum_padding_;
|
||||
double minimum_path_length_;
|
||||
bool overlap_;
|
||||
double text_opacity_;
|
||||
bool wrap_before_;
|
||||
|
|
|
@ -1204,7 +1204,7 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
|
|||
<< "halo-radius,text-ratio,wrap-width,wrap-before,"
|
||||
<< "wrap-character,text-transform,line-spacing,"
|
||||
<< "label-position-tolerance,character-spacing,"
|
||||
<< "spacing,minimum-distance,minimum-padding,"
|
||||
<< "spacing,minimum-distance,minimum-padding,minimum-path-length,"
|
||||
<< "avoid-edges,allow-overlap,opacity,max-char-angle-delta,"
|
||||
<< "horizontal-alignment,justify-alignment,"
|
||||
<< "placements,placement-type,"
|
||||
|
@ -1381,6 +1381,13 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
|
|||
text_symbol.set_minimum_padding(*min_padding);
|
||||
}
|
||||
|
||||
// minimum path length
|
||||
optional<unsigned> min_path_length = get_opt_attr<unsigned>(sym, "minimum-path-length");
|
||||
if (min_path_length)
|
||||
{
|
||||
text_symbol.set_minimum_path_length(*min_path_length);
|
||||
}
|
||||
|
||||
// do not render labels around edges
|
||||
optional<boolean> avoid_edges =
|
||||
get_opt_attr<boolean>(sym, "avoid-edges");
|
||||
|
|
|
@ -66,6 +66,7 @@ placement::placement(string_info & info_,
|
|||
max_char_angle_delta(sym.get_max_char_angle_delta()),
|
||||
minimum_distance(scale_factor_ * sym.get_minimum_distance()),
|
||||
minimum_padding(scale_factor_ * sym.get_minimum_padding()),
|
||||
minimum_path_length(0),
|
||||
avoid_edges(sym.get_avoid_edges()),
|
||||
has_dimensions(has_dimensions_),
|
||||
allow_overlap(false),
|
||||
|
@ -90,6 +91,7 @@ placement::placement(string_info & info_,
|
|||
max_char_angle_delta(sym.get_max_char_angle_delta()),
|
||||
minimum_distance(scale_factor_ * sym.get_minimum_distance()),
|
||||
minimum_padding(scale_factor_ * sym.get_minimum_padding()),
|
||||
minimum_path_length(scale_factor_ * sym.get_minimum_path_length()),
|
||||
avoid_edges(sym.get_avoid_edges()),
|
||||
has_dimensions(false),
|
||||
allow_overlap(sym.get_allow_overlap()),
|
||||
|
@ -517,6 +519,10 @@ void placement_finder<DetectorT>::find_line_placements(placement & p, text_place
|
|||
//Now path_positions is full and total_distance is correct
|
||||
//shape_path shouldn't be used from here
|
||||
|
||||
// Ensure lines have a minimum length.
|
||||
if (total_distance < p.minimum_path_length)
|
||||
return;
|
||||
|
||||
double distance = 0.0;
|
||||
std::pair<double, double> string_dimensions = p.info.get_dimensions();
|
||||
|
||||
|
|
|
@ -532,6 +532,10 @@ private:
|
|||
{
|
||||
set_attr( node, "minimum-padding", sym.get_minimum_padding() );
|
||||
}
|
||||
if (sym.get_minimum_path_length() != dfl.get_minimum_path_length() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( node, "minimum-path-length", sym.get_minimum_path_length() );
|
||||
}
|
||||
if (sym.get_allow_overlap() != dfl.get_allow_overlap() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( node, "allow-overlap", sym.get_allow_overlap() );
|
||||
|
|
|
@ -111,6 +111,7 @@ text_symbolizer::text_symbolizer(expression_ptr name, std::string const& face_na
|
|||
avoid_edges_(false),
|
||||
minimum_distance_(0.0),
|
||||
minimum_padding_(0.0),
|
||||
minimum_path_length_(0.0),
|
||||
overlap_(false),
|
||||
text_opacity_(1.0),
|
||||
wrap_before_(false),
|
||||
|
@ -143,6 +144,7 @@ text_symbolizer::text_symbolizer(expression_ptr name, unsigned size, color const
|
|||
avoid_edges_(false),
|
||||
minimum_distance_(0.0),
|
||||
minimum_padding_(0.0),
|
||||
minimum_path_length_(0.0),
|
||||
overlap_(false),
|
||||
text_opacity_(1.0),
|
||||
wrap_before_(false),
|
||||
|
@ -175,6 +177,7 @@ text_symbolizer::text_symbolizer(text_symbolizer const& rhs)
|
|||
avoid_edges_(rhs.avoid_edges_),
|
||||
minimum_distance_(rhs.minimum_distance_),
|
||||
minimum_padding_(rhs.minimum_padding_),
|
||||
minimum_path_length_(rhs.minimum_path_length_),
|
||||
overlap_(rhs.overlap_),
|
||||
text_opacity_(rhs.text_opacity_),
|
||||
wrap_before_(rhs.wrap_before_),
|
||||
|
@ -206,6 +209,7 @@ text_symbolizer& text_symbolizer::operator=(text_symbolizer const& other)
|
|||
avoid_edges_ = other.avoid_edges_;
|
||||
minimum_distance_ = other.minimum_distance_;
|
||||
minimum_padding_ = other.minimum_padding_;
|
||||
minimum_path_length_ = other.minimum_path_length_;
|
||||
overlap_ = other.overlap_;
|
||||
text_opacity_ = other.text_opacity_;
|
||||
wrap_before_ = other.wrap_before_;
|
||||
|
@ -473,7 +477,17 @@ void text_symbolizer::set_minimum_padding(double distance)
|
|||
{
|
||||
minimum_padding_ = distance;
|
||||
}
|
||||
|
||||
|
||||
double text_symbolizer::get_minimum_path_length() const
|
||||
{
|
||||
return minimum_path_length_;
|
||||
}
|
||||
|
||||
void text_symbolizer::set_minimum_path_length(double size)
|
||||
{
|
||||
minimum_path_length_ = size;
|
||||
}
|
||||
|
||||
void text_symbolizer::set_allow_overlap(bool overlap)
|
||||
{
|
||||
overlap_ = overlap;
|
||||
|
|
Loading…
Reference in a new issue