add support for rendering svg icons with point placement in markers symbolizer (originally markers just supported special line placement) - closes #953 - refs #952

This commit is contained in:
Dane Springmeyer 2011-11-16 09:56:35 -08:00
parent baebf4f1f2
commit efa1b95cb8
2 changed files with 42 additions and 18 deletions

View file

@ -86,6 +86,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
double y1 = bbox.miny();
double x2 = bbox.maxx();
double y2 = bbox.maxy();
int w = (*mark)->width();
int h = (*mark)->height();
agg::trans_affine recenter = agg::trans_affine_translation(-0.5*(x1+x2),-0.5*(y1+y2));
tr.transform(&x1,&y1);
@ -102,26 +104,47 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
for (unsigned i=0; i<feature.num_geometries(); ++i)
{
geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() <= 1)
// TODO - merge this code with point_symbolizer rendering
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{
std::clog << "### Warning svg markers not supported yet for points within markers_symbolizer\n";
continue;
}
double x;
double y;
double z=0;
geom.label_interior_position(&x, &y);
prj_trans.backward(x,y,z);
t_.forward(&x,&y);
extent.re_center(x,y);
if (sym.get_allow_overlap() ||
detector_->has_placement(extent))
{
render_marker(floor(x - 0.5 * w),floor(y - 0.5 * h) ,**mark,tr, sym.get_opacity());
// TODO - impl this for markers?
//if (!sym.get_ignore_placement())
// detector_->insert(label_ext);
metawriter_with_properties writer = sym.get_metawriter();
if (writer.first) writer.first->add_box(extent, feature, t_, writer.second);
}
}
else
{
path_type path(t_,geom,prj_trans);
markers_placement<path_type, label_collision_detector4> placement(path, extent, *detector_,
sym.get_spacing() * scale_factor_,
sym.get_max_error(),
sym.get_allow_overlap());
double x, y, angle;
path_type path(t_,geom,prj_trans);
markers_placement<path_type, label_collision_detector4> placement(path, extent, *detector_,
sym.get_spacing() * scale_factor_,
sym.get_max_error(),
sym.get_allow_overlap());
double x, y, angle;
while (placement.get_point(&x, &y, &angle))
{
agg::trans_affine matrix = recenter * tr *agg::trans_affine_rotation(angle) * agg::trans_affine_translation(x, y);
svg_renderer.render(*ras_ptr, sl, renb, matrix, sym.get_opacity(),bbox);
if (writer.first)
//writer.first->add_box(label_ext, feature, t_, writer.second);
std::clog << "### Warning metawriter not yet supported for LINE placement\n";
while (placement.get_point(&x, &y, &angle))
{
agg::trans_affine matrix = recenter * tr *agg::trans_affine_rotation(angle) * agg::trans_affine_translation(x, y);
svg_renderer.render(*ras_ptr, sl, renb, matrix, sym.get_opacity(),bbox);
if (writer.first)
//writer.first->add_box(label_ext, feature, t_, writer.second);
std::clog << "### Warning metawriter not yet supported for LINE placement\n";
}
}
}
}

View file

@ -1419,6 +1419,7 @@ void cairo_renderer_base::process(raster_symbolizer const& sym,
}
}
// TODO - this is woefully behind the AGG version.
void cairo_renderer_base::process(markers_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)