Merge branch 'MapQuest-min-dist-compatibility'

This commit is contained in:
artemp 2014-09-10 16:36:25 +01:00
commit 2b5b573074
7 changed files with 23 additions and 23 deletions

View file

@ -425,7 +425,7 @@ void export_text_placement()
.def_readwrite("label_spacing", &text_symbolizer_properties::label_spacing) .def_readwrite("label_spacing", &text_symbolizer_properties::label_spacing)
.def_readwrite("label_position_tolerance", &text_symbolizer_properties::label_position_tolerance) .def_readwrite("label_position_tolerance", &text_symbolizer_properties::label_position_tolerance)
.def_readwrite("avoid_edges", &text_symbolizer_properties::avoid_edges) .def_readwrite("avoid_edges", &text_symbolizer_properties::avoid_edges)
.def_readwrite("text_margin", &text_symbolizer_properties::text_margin) .def_readwrite("margin", &text_symbolizer_properties::margin)
.def_readwrite("repeat_distance", &text_symbolizer_properties::repeat_distance) .def_readwrite("repeat_distance", &text_symbolizer_properties::repeat_distance)
.def_readwrite("minimum_distance", &text_symbolizer_properties::minimum_distance) .def_readwrite("minimum_distance", &text_symbolizer_properties::minimum_distance)
.def_readwrite("minimum_padding", &text_symbolizer_properties::minimum_padding) .def_readwrite("minimum_padding", &text_symbolizer_properties::minimum_padding)

View file

@ -139,7 +139,7 @@ struct text_properties_expressions
symbolizer_base::value_type label_spacing = 0.0; symbolizer_base::value_type label_spacing = 0.0;
symbolizer_base::value_type label_position_tolerance = 0.0; symbolizer_base::value_type label_position_tolerance = 0.0;
symbolizer_base::value_type avoid_edges = false; symbolizer_base::value_type avoid_edges = false;
symbolizer_base::value_type text_margin = 0.0; symbolizer_base::value_type margin = 0.0;
symbolizer_base::value_type repeat_distance = 0.0; symbolizer_base::value_type repeat_distance = 0.0;
symbolizer_base::value_type minimum_distance = 0.0; symbolizer_base::value_type minimum_distance = 0.0;
symbolizer_base::value_type minimum_padding = 0.0; symbolizer_base::value_type minimum_padding = 0.0;
@ -183,7 +183,7 @@ struct MAPNIK_DECL text_symbolizer_properties
// distance the label can be moved on the line to fit, if 0 the default is used // distance the label can be moved on the line to fit, if 0 the default is used
double label_position_tolerance; double label_position_tolerance;
bool avoid_edges; bool avoid_edges;
double text_margin; double margin;
double repeat_distance; double repeat_distance;
double minimum_distance; double minimum_distance;
double minimum_padding; double minimum_padding;

View file

@ -313,15 +313,15 @@ double placement_finder::get_spacing(double path_length, double layout_width) co
bool placement_finder::collision(const box2d<double> &box, const value_unicode_string &repeat_key, bool line_placement) const bool placement_finder::collision(const box2d<double> &box, const value_unicode_string &repeat_key, bool line_placement) const
{ {
double text_margin, repeat_distance; double margin, repeat_distance;
if (line_placement) if (line_placement)
{ {
text_margin = info_.properties.text_margin * scale_factor_; margin = info_.properties.margin * scale_factor_;
repeat_distance = (info_.properties.repeat_distance != 0 ? info_.properties.repeat_distance : info_.properties.minimum_distance) * scale_factor_; repeat_distance = (info_.properties.repeat_distance != 0 ? info_.properties.repeat_distance : info_.properties.minimum_distance) * scale_factor_;
} }
else else
{ {
text_margin = (info_.properties.text_margin != 0 ? info_.properties.text_margin : info_.properties.minimum_distance) * scale_factor_; margin = (info_.properties.margin != 0 ? info_.properties.margin : info_.properties.minimum_distance) * scale_factor_;
repeat_distance = info_.properties.repeat_distance * scale_factor_; repeat_distance = info_.properties.repeat_distance * scale_factor_;
} }
return !detector_.extent().intersects(box) return !detector_.extent().intersects(box)
@ -332,9 +332,9 @@ bool placement_finder::collision(const box2d<double> &box, const value_unicode_s
!extent_.contains(box + (scale_factor_ * info_.properties.minimum_padding))) !extent_.contains(box + (scale_factor_ * info_.properties.minimum_padding)))
|| ||
(!info_.properties.allow_overlap && (!info_.properties.allow_overlap &&
((repeat_key.length() == 0 && !detector_.has_placement(box, text_margin)) ((repeat_key.length() == 0 && !detector_.has_placement(box, margin))
|| ||
(repeat_key.length() > 0 && !detector_.has_placement(box, text_margin, repeat_key, repeat_distance)))); (repeat_key.length() > 0 && !detector_.has_placement(box, margin, repeat_key, repeat_distance))));
} }
void placement_finder::set_marker(marker_info_ptr m, box2d<double> box, bool marker_unlocked, pixel_position const& marker_displacement) void placement_finder::set_marker(marker_info_ptr m, box2d<double> box, bool marker_unlocked, pixel_position const& marker_displacement)

View file

@ -44,7 +44,7 @@ text_symbolizer_properties::text_symbolizer_properties()
label_spacing(0.0), label_spacing(0.0),
label_position_tolerance(0.0), label_position_tolerance(0.0),
avoid_edges(false), avoid_edges(false),
text_margin(0.0), margin(0.0),
repeat_distance(0.0), repeat_distance(0.0),
minimum_distance(0.0), minimum_distance(0.0),
minimum_padding(0.0), minimum_padding(0.0),
@ -64,7 +64,7 @@ void text_symbolizer_properties::evaluate_text_properties(feature_impl const& fe
label_spacing = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.label_spacing); label_spacing = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.label_spacing);
label_position_tolerance = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.label_position_tolerance); label_position_tolerance = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.label_position_tolerance);
avoid_edges = util::apply_visitor(extract_value<value_bool>(feature,attrs), expressions.avoid_edges); avoid_edges = util::apply_visitor(extract_value<value_bool>(feature,attrs), expressions.avoid_edges);
text_margin = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.text_margin); margin = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.margin);
repeat_distance = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.repeat_distance); repeat_distance = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.repeat_distance);
minimum_distance = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.minimum_distance); minimum_distance = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.minimum_distance);
minimum_padding = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.minimum_padding); minimum_padding = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.minimum_padding);
@ -114,16 +114,16 @@ formatting::node_ptr text_symbolizer_properties::format_tree() const
void text_symbolizer_properties::text_properties_from_xml(xml_node const& node) void text_symbolizer_properties::text_properties_from_xml(xml_node const& node)
{ {
// The options 'text-margin' and 'repeat-distance' replace 'minimum-distance'. // The options 'margin' and 'repeat-distance' replace 'minimum-distance'.
// Only allow one or the other to be defined here. // Only allow one or the other to be defined here.
if (node.has_attribute("text-margin") || node.has_attribute("repeat-distance")) if (node.has_attribute("margin") || node.has_attribute("repeat-distance"))
{ {
if (node.has_attribute("minimum-distance")) if (node.has_attribute("minimum-distance"))
{ {
throw config_error(std::string("Cannot use deprecated option minimum-distance with " throw config_error(std::string("Cannot use deprecated option minimum-distance with "
"new options text-margin and repeat-distance.")); "new options margin and repeat-distance."));
} }
set_property_from_xml<value_double>(expressions.text_margin, "text-margin", node); set_property_from_xml<value_double>(expressions.margin, "margin", node);
set_property_from_xml<value_double>(expressions.repeat_distance, "repeat-distance", node); set_property_from_xml<value_double>(expressions.repeat_distance, "repeat-distance", node);
} }
else else
@ -174,9 +174,9 @@ void text_symbolizer_properties::to_xml(boost::property_tree::ptree &node,
{ {
serialize_property("spacing", expressions.label_spacing, node); serialize_property("spacing", expressions.label_spacing, node);
} }
if (!(expressions.text_margin == dfl.expressions.text_margin) || explicit_defaults) if (!(expressions.margin == dfl.expressions.margin) || explicit_defaults)
{ {
serialize_property("text-margin", expressions.text_margin, node); serialize_property("margin", expressions.margin, node);
} }
if (!(expressions.repeat_distance == dfl.expressions.repeat_distance) || explicit_defaults) if (!(expressions.repeat_distance == dfl.expressions.repeat_distance) || explicit_defaults)
{ {
@ -227,7 +227,7 @@ void text_symbolizer_properties::add_expressions(expression_set & output) const
if (is_expression(expressions.label_spacing)) output.insert(util::get<expression_ptr>(expressions.label_spacing)); if (is_expression(expressions.label_spacing)) output.insert(util::get<expression_ptr>(expressions.label_spacing));
if (is_expression(expressions.label_position_tolerance)) output.insert(util::get<expression_ptr>(expressions.label_position_tolerance)); if (is_expression(expressions.label_position_tolerance)) output.insert(util::get<expression_ptr>(expressions.label_position_tolerance));
if (is_expression(expressions.avoid_edges)) output.insert(util::get<expression_ptr>(expressions.avoid_edges)); if (is_expression(expressions.avoid_edges)) output.insert(util::get<expression_ptr>(expressions.avoid_edges));
if (is_expression(expressions.text_margin)) output.insert(util::get<expression_ptr>(expressions.text_margin)); if (is_expression(expressions.margin)) output.insert(util::get<expression_ptr>(expressions.margin));
if (is_expression(expressions.repeat_distance)) output.insert(util::get<expression_ptr>(expressions.repeat_distance)); if (is_expression(expressions.repeat_distance)) output.insert(util::get<expression_ptr>(expressions.repeat_distance));
if (is_expression(expressions.minimum_distance)) output.insert(util::get<expression_ptr>(expressions.minimum_distance)); if (is_expression(expressions.minimum_distance)) output.insert(util::get<expression_ptr>(expressions.minimum_distance));
if (is_expression(expressions.minimum_padding)) output.insert(util::get<expression_ptr>(expressions.minimum_padding)); if (is_expression(expressions.minimum_padding)) output.insert(util::get<expression_ptr>(expressions.minimum_padding));

View file

@ -18,14 +18,14 @@
<Style name="shield"> <Style name="shield">
<Rule> <Rule>
<Filter>[type] = 'motorway'</Filter> <Filter>[type] = 'motorway'</Filter>
<ShieldSymbolizer text-margin="60" spacing="120" placement="line" face-name="DejaVu Sans Book" size="10" fill="white" file="../../data/svg/rect.svg" transform="scale(0.75)">[ref]</ShieldSymbolizer> <ShieldSymbolizer margin="60" spacing="120" placement="line" face-name="DejaVu Sans Book" size="10" fill="white" file="../../data/svg/rect.svg" transform="scale(0.75)">[ref]</ShieldSymbolizer>
</Rule> </Rule>
</Style> </Style>
<Style name="text"> <Style name="text">
<Rule> <Rule>
<Filter>[type] != 'poi'</Filter> <Filter>[type] != 'poi'</Filter>
<TextSymbolizer text-margin="50" spacing="70" placement="line" face-name="DejaVu Sans Book" size="12">[name]</TextSymbolizer> <TextSymbolizer margin="50" spacing="70" placement="line" face-name="DejaVu Sans Book" size="12">[name]</TextSymbolizer>
</Rule> </Rule>
</Style> </Style>

View file

@ -18,14 +18,14 @@
<Style name="shield"> <Style name="shield">
<Rule> <Rule>
<Filter>[type] = 'motorway'</Filter> <Filter>[type] = 'motorway'</Filter>
<ShieldSymbolizer text-margin="0" repeat-distance="60" spacing="120" placement="line" face-name="DejaVu Sans Book" size="10" fill="white" file="../../data/svg/rect.svg" transform="scale(0.75)">[ref]</ShieldSymbolizer> <ShieldSymbolizer margin="0" repeat-distance="60" spacing="120" placement="line" face-name="DejaVu Sans Book" size="10" fill="white" file="../../data/svg/rect.svg" transform="scale(0.75)">[ref]</ShieldSymbolizer>
</Rule> </Rule>
</Style> </Style>
<Style name="text"> <Style name="text">
<Rule> <Rule>
<Filter>[type] != 'poi'</Filter> <Filter>[type] != 'poi'</Filter>
<TextSymbolizer text-margin="0" repeat-distance="40" spacing="70" placement="line" face-name="DejaVu Sans Book" size="12">[name]</TextSymbolizer> <TextSymbolizer margin="0" repeat-distance="40" spacing="70" placement="line" face-name="DejaVu Sans Book" size="12">[name]</TextSymbolizer>
</Rule> </Rule>
</Style> </Style>

View file

@ -18,14 +18,14 @@
<Style name="shield"> <Style name="shield">
<Rule> <Rule>
<Filter>[type] = 'motorway'</Filter> <Filter>[type] = 'motorway'</Filter>
<ShieldSymbolizer text-margin="10" repeat-distance="60" spacing="120" placement="line" face-name="DejaVu Sans Book" size="10" fill="white" file="../../data/svg/rect.svg" transform="scale(0.75)">[ref]</ShieldSymbolizer> <ShieldSymbolizer margin="10" repeat-distance="60" spacing="120" placement="line" face-name="DejaVu Sans Book" size="10" fill="white" file="../../data/svg/rect.svg" transform="scale(0.75)">[ref]</ShieldSymbolizer>
</Rule> </Rule>
</Style> </Style>
<Style name="text"> <Style name="text">
<Rule> <Rule>
<Filter>[type] != 'poi'</Filter> <Filter>[type] != 'poi'</Filter>
<TextSymbolizer text-margin="3" repeat-distance="40" spacing="70" placement="line" face-name="DejaVu Sans Book" size="12">[name]</TextSymbolizer> <TextSymbolizer margin="3" repeat-distance="40" spacing="70" placement="line" face-name="DejaVu Sans Book" size="12">[name]</TextSymbolizer>
</Rule> </Rule>
</Style> </Style>