Merge remote-tracking branch 'origin/master'

This commit is contained in:
Artem Pavlenko 2012-03-19 19:45:32 +00:00
commit 9e3e5bb74a
17 changed files with 106 additions and 17 deletions

View file

@ -26,7 +26,9 @@ Mapnik 2.1.0
- Added <layer_by_sql> parameter in OGR plugin to select a layer by SQL query (besides name or index): see http://www.gdal.org/ogr/ogr_sql.html for specifications (kunitoki) (#472)
- Added suppport for output maps as tiff files (addresses #967 partially)
- Added support for output maps as tiff files (addresses #967 partially)
- Added support for justify-alignment=auto. This is the new default. (#1125)
Mapnik 2.0.0

View file

@ -60,7 +60,8 @@ struct markers_symbolizer_pickle_suite : boost::python::pickle_suite
static boost::python::tuple
getstate(markers_symbolizer const& p)
{
return boost::python::make_tuple(p.get_allow_overlap());//,p.get_opacity());
return boost::python::make_tuple(p.get_allow_overlap(),
p.get_ignore_placement());//,p.get_opacity());
}
static void
@ -77,7 +78,8 @@ struct markers_symbolizer_pickle_suite : boost::python::pickle_suite
}
p.set_allow_overlap(extract<bool>(state[0]));
//p.set_opacity(extract<float>(state[1]));
p.set_ignore_placement(extract<bool>(state[1]));
//p.set_opacity(extract<float>(state[2]));
}
@ -108,6 +110,9 @@ void export_markers_symbolizer()
&markers_symbolizer::get_opacity,
&markers_symbolizer::set_opacity,
"Set/get the text opacity")
.add_property("ignore_placement",
&markers_symbolizer::get_ignore_placement,
&markers_symbolizer::set_ignore_placement)
.add_property("transform",
&mapnik::get_svg_transform<markers_symbolizer>,
&mapnik::set_svg_transform<markers_symbolizer>)

View file

@ -329,6 +329,7 @@ void export_text_placement()
.value("LEFT",J_LEFT)
.value("MIDDLE",J_MIDDLE)
.value("RIGHT",J_RIGHT)
.value("AUTO", J_AUTO)
;
enumeration_<text_transform_e>("text_transform")

View file

@ -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_;

View file

@ -137,6 +137,7 @@ private:
double first_line_space_;
vertical_alignment_e valign_;
horizontal_alignment_e halign_;
justify_alignment_e jalign_;
std::vector<unsigned> line_breaks_;
std::vector<std::pair<double, double> > line_sizes_;
std::queue< box2d<double> > envelopes_;

View file

@ -110,6 +110,7 @@ enum justify_alignment
J_LEFT = 0,
J_MIDDLE,
J_RIGHT,
J_AUTO,
justify_alignment_MAX
};

View file

@ -244,7 +244,8 @@ void agg_renderer<T>::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);
}
}

View file

@ -896,7 +896,9 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
optional<double> max_error = sym.get_opt_attr<double>("max-error");
if (max_error) symbol.set_max_error(*max_error);
optional<boolean> allow_overlap = sym.get_opt_attr<boolean>("allow-overlap");
optional<boolean> ignore_placement = sym.get_opt_attr<boolean>("ignore-placement");
if (allow_overlap) symbol.set_allow_overlap(*allow_overlap);
if (ignore_placement) symbol.set_ignore_placement(*ignore_placement);
optional<double> w = sym.get_opt_attr<double>("width");
optional<double> h = sym.get_opt_attr<double>("height");

View file

@ -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;

View file

@ -305,23 +305,47 @@ template <typename DetectorT>
void placement_finder<DetectorT>::init_alignment()
{
valign_ = p.valign;
if (valign_ == V_AUTO) {
if (valign_ == V_AUTO)
{
if (p.displacement.second > 0.0)
{
valign_ = V_BOTTOM;
else if (p.displacement.second < 0.0)
} else if (p.displacement.second < 0.0)
{
valign_ = V_TOP;
else
} else
{
valign_ = V_MIDDLE;
}
}
halign_ = p.halign;
if (halign_ == H_AUTO) {
if (halign_ == H_AUTO)
{
if (p.displacement.first > 0.0)
{
halign_ = H_RIGHT;
else if (p.displacement.first < 0.0)
} else if (p.displacement.first < 0.0)
{
halign_ = H_LEFT;
else
} else
{
halign_ = H_MIDDLE;
}
}
jalign_ = p.jalign;
if (jalign_ == J_AUTO)
{
if (p.displacement.first > 0.0)
{
jalign_ = J_LEFT;
} else if (p.displacement.first < 0.0)
{
jalign_ = J_RIGHT;
} else {
jalign_ = J_MIDDLE;
}
}
}
@ -389,9 +413,9 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
if (info_.get_rtl()) y = -y;
// adjust for desired justification
if (p.jalign == J_LEFT)
if (jalign_ == J_LEFT)
x = -(string_width_ / 2.0);
else if (p.jalign == J_RIGHT)
else if (jalign_ == J_RIGHT)
x = (string_width_ / 2.0) - line_width;
else /* J_MIDDLE */
x = -(line_width / 2.0);
@ -420,9 +444,9 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
}
// reset to begining of line position
if (p.jalign == J_LEFT)
if (jalign_ == J_LEFT)
x = -(string_width_ / 2.0);
else if (p.jalign == J_RIGHT)
else if (jalign_ == J_RIGHT)
x = (string_width_ / 2.0) - line_width;
else
x = -(line_width / 2.0);

View file

@ -273,6 +273,10 @@ public:
{
set_attr( sym_node, "allow-overlap", sym.get_allow_overlap() );
}
if (sym.get_ignore_placement() != dfl.get_ignore_placement() || explicit_defaults_)
{
set_attr( sym_node, "ignore-placement", sym.get_ignore_placement() );
}
if (sym.get_spacing() != dfl.get_spacing() || explicit_defaults_)
{
set_attr( sym_node, "spacing", sym.get_spacing() );

View file

@ -40,7 +40,7 @@ text_symbolizer_properties::text_symbolizer_properties() :
displacement(0,0),
label_placement(POINT_PLACEMENT),
halign(H_AUTO),
jalign(J_MIDDLE),
jalign(J_AUTO),
valign(V_AUTO),
label_spacing(0),
label_position_tolerance(0),

View file

@ -69,6 +69,7 @@ static const char * justify_alignment_strings[] = {
"left",
"center",
"right",
"auto",
""
};

View file

@ -54,7 +54,7 @@ def test_shieldsymbolizer_init():
# r1341
eq_(s.wrap_before, False)
eq_(s.horizontal_alignment, mapnik.horizontal_alignment.AUTO)
eq_(s.justify_alignment, mapnik.justify_alignment.MIDDLE)
eq_(s.justify_alignment, mapnik.justify_alignment.AUTO)
eq_(s.opacity, 1.0)
# r2300

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
<Layer name="layer" srs="+proj=latlong +datum=WGS84">
<StyleName>My Style</StyleName>
<Datasource>
<Parameter name="type">shape</Parameter>
<Parameter name="file">points.shp</Parameter>
</Datasource>
</Layer>
<Style name="My Style">
<Rule>
<Filter>[nr] = '5'</Filter>
<PointSymbolizer/>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="-30" dy="-30" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="0" dy="-30" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="30" dy="-30" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="30" dy="0" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="-30" dy="0" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="-30" dy="30" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="0" dy="30" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="30" dy="30" justify-alignment="auto">'Text line 1&#10;line 2'</TextSymbolizer>
</Rule>
</Style>
</Map>

View file

@ -28,7 +28,8 @@ files = [
("formating-4", 500),
("shieldsymbolizer-1", 490, 495, 497, 498, 499, 500, 501, 502, 505, 510),
("expressionformat", 500),
("rtl-point", (200, 200))
("rtl-point", (200, 200)),
("jalign-auto", (200, 200))
]
def render(filename, width, height=100):