2010-06-01 15:31:08 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2011-10-23 15:04:25 +02:00
|
|
|
* Copyright (C) 2011 Artem Pavlenko
|
2010-06-01 15:31:08 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2012-04-08 02:20:56 +02:00
|
|
|
// mapnik
|
|
|
|
#include <mapnik/debug.hpp>
|
2012-05-09 13:39:23 +02:00
|
|
|
#include <mapnik/graphics.hpp>
|
2012-07-19 17:37:54 +02:00
|
|
|
#include <mapnik/geom_util.hpp>
|
2010-06-01 15:31:08 +02:00
|
|
|
#include <mapnik/agg_renderer.hpp>
|
2010-06-13 14:03:42 +02:00
|
|
|
#include <mapnik/agg_rasterizer.hpp>
|
2011-09-01 02:43:46 +02:00
|
|
|
#include <mapnik/expression_evaluator.hpp>
|
2012-07-19 17:37:54 +02:00
|
|
|
#include <mapnik/vertex_converters.hpp>
|
2012-03-08 17:37:58 +01:00
|
|
|
#include <mapnik/marker.hpp>
|
2011-01-26 02:18:40 +01:00
|
|
|
#include <mapnik/marker_cache.hpp>
|
2012-07-11 03:09:19 +02:00
|
|
|
#include <mapnik/marker_helpers.hpp>
|
2010-06-08 12:16:22 +02:00
|
|
|
#include <mapnik/svg/svg_renderer.hpp>
|
2012-07-31 08:20:20 +02:00
|
|
|
#include <mapnik/svg/svg_storage.hpp>
|
|
|
|
#include <mapnik/svg/svg_converter.hpp>
|
2010-06-14 18:38:02 +02:00
|
|
|
#include <mapnik/svg/svg_path_adapter.hpp>
|
2012-07-31 08:20:20 +02:00
|
|
|
#include <mapnik/svg/svg_path_attributes.hpp>
|
2010-06-01 15:31:08 +02:00
|
|
|
#include <mapnik/markers_placement.hpp>
|
2012-01-20 22:43:05 +01:00
|
|
|
#include <mapnik/markers_symbolizer.hpp>
|
2010-06-01 15:31:08 +02:00
|
|
|
|
2012-07-11 03:09:19 +02:00
|
|
|
// agg
|
2010-06-01 15:31:08 +02:00
|
|
|
#include "agg_basics.h"
|
2012-07-31 08:20:20 +02:00
|
|
|
#include "agg_ellipse.h"
|
2010-06-01 15:31:08 +02:00
|
|
|
#include "agg_rendering_buffer.h"
|
|
|
|
#include "agg_pixfmt_rgba.h"
|
|
|
|
#include "agg_rasterizer_scanline_aa.h"
|
|
|
|
#include "agg_scanline_u.h"
|
2010-08-19 19:33:01 +02:00
|
|
|
#include "agg_path_storage.h"
|
2012-03-07 13:48:51 +01:00
|
|
|
#include "agg_conv_clip_polyline.h"
|
2012-06-26 16:00:42 +02:00
|
|
|
#include "agg_conv_transform.h"
|
2012-07-24 15:04:25 +02:00
|
|
|
#include "agg_image_filters.h"
|
|
|
|
#include "agg_trans_bilinear.h"
|
|
|
|
#include "agg_span_allocator.h"
|
|
|
|
#include "agg_image_accessors.h"
|
|
|
|
#include "agg_span_image_filter_rgba.h"
|
2012-07-11 03:09:19 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/optional.hpp>
|
2012-07-09 11:22:19 +02:00
|
|
|
|
2012-07-11 03:09:19 +02:00
|
|
|
namespace mapnik {
|
2012-07-09 11:22:19 +02:00
|
|
|
|
2012-07-19 17:37:54 +02:00
|
|
|
template <typename BufferType, typename SvgRenderer, typename Rasterizer, typename Detector>
|
2012-07-24 15:04:25 +02:00
|
|
|
struct vector_markers_rasterizer_dispatch
|
2012-07-19 17:37:54 +02:00
|
|
|
{
|
|
|
|
typedef agg::rgba8 color_type;
|
|
|
|
typedef agg::order_rgba order_type;
|
|
|
|
typedef agg::pixel32_type pixel_type;
|
|
|
|
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
|
|
|
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
|
|
|
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
|
|
|
|
2012-07-24 15:04:25 +02:00
|
|
|
vector_markers_rasterizer_dispatch(BufferType & image_buffer,
|
2012-07-19 17:37:54 +02:00
|
|
|
SvgRenderer & svg_renderer,
|
|
|
|
Rasterizer & ras,
|
|
|
|
box2d<double> const& bbox,
|
|
|
|
agg::trans_affine const& marker_trans,
|
|
|
|
markers_symbolizer const& sym,
|
|
|
|
Detector & detector,
|
|
|
|
double scale_factor)
|
|
|
|
: buf_(image_buffer.raw_data(), image_buffer.width(), image_buffer.height(), image_buffer.width() * 4),
|
|
|
|
pixf_(buf_),
|
|
|
|
renb_(pixf_),
|
|
|
|
svg_renderer_(svg_renderer),
|
|
|
|
ras_(ras),
|
|
|
|
bbox_(bbox),
|
|
|
|
marker_trans_(marker_trans),
|
|
|
|
sym_(sym),
|
|
|
|
detector_(detector),
|
|
|
|
scale_factor_(scale_factor)
|
|
|
|
{
|
|
|
|
pixf_.comp_op(static_cast<agg::comp_op_e>(sym_.comp_op()));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void add_path(T & path)
|
|
|
|
{
|
|
|
|
marker_placement_e placement_method = sym_.get_marker_placement();
|
2012-07-19 17:59:33 +02:00
|
|
|
|
2012-07-19 17:37:54 +02:00
|
|
|
if (placement_method == MARKER_POINT_PLACEMENT)
|
|
|
|
{
|
|
|
|
double x,y;
|
|
|
|
path.rewind(0);
|
2012-07-20 20:18:33 +02:00
|
|
|
label::interior_position(path, x, y);
|
2012-07-19 17:37:54 +02:00
|
|
|
agg::trans_affine matrix = marker_trans_;
|
|
|
|
matrix.translate(x,y);
|
|
|
|
box2d<double> transformed_bbox = bbox_ * matrix;
|
|
|
|
|
|
|
|
if (sym_.get_allow_overlap() ||
|
|
|
|
detector_.has_placement(transformed_bbox))
|
|
|
|
{
|
2012-07-31 03:31:21 +02:00
|
|
|
svg_renderer_.render(ras_, sl_, renb_, matrix, 1, bbox_);
|
2012-07-19 17:37:54 +02:00
|
|
|
|
|
|
|
if (!sym_.get_ignore_placement())
|
|
|
|
detector_.insert(transformed_bbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
markers_placement<T, label_collision_detector4> placement(path, bbox_, marker_trans_, 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 = marker_trans_;
|
|
|
|
matrix.rotate(angle);
|
|
|
|
matrix.translate(x, y);
|
2012-07-31 03:31:21 +02:00
|
|
|
svg_renderer_.render(ras_, sl_, renb_, matrix, 1, bbox_);
|
2012-07-19 17:37:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
agg::scanline_u8 sl_;
|
|
|
|
agg::rendering_buffer buf_;
|
|
|
|
pixfmt_comp_type pixf_;
|
|
|
|
renderer_base renb_;
|
|
|
|
SvgRenderer & svg_renderer_;
|
|
|
|
Rasterizer & ras_;
|
|
|
|
box2d<double> const& bbox_;
|
|
|
|
agg::trans_affine const& marker_trans_;
|
|
|
|
markers_symbolizer const& sym_;
|
|
|
|
Detector & detector_;
|
|
|
|
double scale_factor_;
|
|
|
|
};
|
|
|
|
|
2012-07-24 15:04:25 +02:00
|
|
|
template <typename Rasterizer, typename RendererBuffer>
|
2012-07-25 12:43:43 +02:00
|
|
|
void render_raster_marker(Rasterizer & ras, RendererBuffer & renb,
|
|
|
|
agg::scanline_u8 & sl, image_data_32 const& src,
|
|
|
|
agg::trans_affine const& marker_tr, double opacity)
|
2012-07-24 15:04:25 +02:00
|
|
|
{
|
|
|
|
double width = src.width();
|
|
|
|
double height = src.height();
|
|
|
|
double p[8];
|
2012-07-25 12:43:43 +02:00
|
|
|
p[0] = 0; p[1] = 0;
|
|
|
|
p[2] = width; p[3] = 0;
|
|
|
|
p[4] = width; p[5] = height;
|
|
|
|
p[6] = 0; p[7] = height;
|
2012-07-24 15:04:25 +02:00
|
|
|
|
|
|
|
marker_tr.transform(&p[0], &p[1]);
|
|
|
|
marker_tr.transform(&p[2], &p[3]);
|
|
|
|
marker_tr.transform(&p[4], &p[5]);
|
|
|
|
marker_tr.transform(&p[6], &p[7]);
|
|
|
|
|
|
|
|
ras.move_to_d(p[0],p[1]);
|
|
|
|
ras.line_to_d(p[2],p[3]);
|
|
|
|
ras.line_to_d(p[4],p[5]);
|
|
|
|
ras.line_to_d(p[6],p[7]);
|
|
|
|
|
|
|
|
typedef agg::rgba8 color_type;
|
|
|
|
agg::span_allocator<color_type> sa;
|
|
|
|
agg::image_filter_bilinear filter_kernel;
|
|
|
|
agg::image_filter_lut filter(filter_kernel, false);
|
|
|
|
|
|
|
|
agg::rendering_buffer marker_buf((unsigned char *)src.getBytes(),
|
|
|
|
src.width(),
|
|
|
|
src.height(),
|
|
|
|
src.width()*4);
|
|
|
|
agg::pixfmt_rgba32_pre pixf(marker_buf);
|
|
|
|
|
|
|
|
typedef agg::image_accessor_clone<agg::pixfmt_rgba32_pre> img_accessor_type;
|
|
|
|
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
|
|
|
|
typedef agg::span_image_filter_rgba_2x2<img_accessor_type,
|
|
|
|
interpolator_type> span_gen_type;
|
2012-07-31 03:31:21 +02:00
|
|
|
typedef agg::order_rgba order_type;
|
|
|
|
typedef agg::pixel32_type pixel_type;
|
|
|
|
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
|
|
|
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
|
|
|
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
|
|
|
typedef agg::renderer_scanline_aa_alpha<renderer_base,
|
|
|
|
agg::span_allocator<agg::rgba8>,
|
|
|
|
span_gen_type> renderer_type;
|
2012-07-24 15:04:25 +02:00
|
|
|
img_accessor_type ia(pixf);
|
|
|
|
interpolator_type interpolator(agg::trans_affine(p, 0, 0, width, height) );
|
|
|
|
span_gen_type sg(ia, interpolator, filter);
|
2012-07-31 03:31:21 +02:00
|
|
|
renderer_type rp(renb,sa, sg, unsigned(opacity*255));
|
|
|
|
agg::render_scanlines(ras, sl, rp);
|
2012-07-24 15:04:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename BufferType, typename Rasterizer, typename Detector>
|
|
|
|
struct raster_markers_rasterizer_dispatch
|
|
|
|
{
|
|
|
|
typedef agg::rgba8 color_type;
|
|
|
|
typedef agg::order_rgba order_type;
|
|
|
|
typedef agg::pixel32_type pixel_type;
|
|
|
|
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
|
|
|
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
|
|
|
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
|
|
|
|
|
|
|
raster_markers_rasterizer_dispatch(BufferType & image_buffer,
|
|
|
|
Rasterizer & ras,
|
|
|
|
image_data_32 const& src,
|
|
|
|
agg::trans_affine const& marker_trans,
|
|
|
|
markers_symbolizer const& sym,
|
|
|
|
Detector & detector,
|
|
|
|
double scale_factor)
|
|
|
|
: buf_(image_buffer.raw_data(), image_buffer.width(), image_buffer.height(), image_buffer.width() * 4),
|
|
|
|
pixf_(buf_),
|
|
|
|
renb_(pixf_),
|
|
|
|
ras_(ras),
|
|
|
|
src_(src),
|
|
|
|
marker_trans_(marker_trans),
|
|
|
|
sym_(sym),
|
|
|
|
detector_(detector),
|
|
|
|
scale_factor_(scale_factor)
|
|
|
|
{
|
|
|
|
pixf_.comp_op(static_cast<agg::comp_op_e>(sym_.comp_op()));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void add_path(T & path)
|
|
|
|
{
|
|
|
|
marker_placement_e placement_method = sym_.get_marker_placement();
|
|
|
|
box2d<double> bbox_(0,0, src_.width(),src_.height());
|
|
|
|
|
|
|
|
if (placement_method == MARKER_POINT_PLACEMENT)
|
|
|
|
{
|
|
|
|
double x,y;
|
|
|
|
path.rewind(0);
|
|
|
|
label::interior_position(path, x, y);
|
|
|
|
agg::trans_affine matrix = marker_trans_;
|
|
|
|
matrix.translate(x,y);
|
|
|
|
box2d<double> transformed_bbox = bbox_ * matrix;
|
|
|
|
|
|
|
|
if (sym_.get_allow_overlap() ||
|
|
|
|
detector_.has_placement(transformed_bbox))
|
|
|
|
{
|
|
|
|
|
2012-07-31 03:31:21 +02:00
|
|
|
float opacity = sym_.get_opacity() ? *sym_.get_opacity() : 1;
|
2012-07-25 12:43:43 +02:00
|
|
|
render_raster_marker(ras_, renb_, sl_, src_,
|
2012-07-31 03:31:21 +02:00
|
|
|
matrix, opacity);
|
2012-07-24 15:04:25 +02:00
|
|
|
if (!sym_.get_ignore_placement())
|
|
|
|
detector_.insert(transformed_bbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
markers_placement<T, label_collision_detector4> placement(path, bbox_, marker_trans_, 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 = marker_trans_;
|
|
|
|
matrix.rotate(angle);
|
2012-07-25 12:43:43 +02:00
|
|
|
matrix.translate(x,y);
|
2012-07-31 03:31:21 +02:00
|
|
|
float opacity = sym_.get_opacity() ? *sym_.get_opacity() : 1;
|
2012-07-25 12:43:43 +02:00
|
|
|
render_raster_marker(ras_, renb_, sl_, src_,
|
2012-07-31 03:31:21 +02:00
|
|
|
matrix, opacity);
|
2012-07-24 15:04:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
agg::scanline_u8 sl_;
|
|
|
|
agg::rendering_buffer buf_;
|
|
|
|
pixfmt_comp_type pixf_;
|
|
|
|
renderer_base renb_;
|
|
|
|
Rasterizer & ras_;
|
|
|
|
image_data_32 const& src_;
|
|
|
|
agg::trans_affine const& marker_trans_;
|
|
|
|
markers_symbolizer const& sym_;
|
|
|
|
Detector & detector_;
|
|
|
|
double scale_factor_;
|
|
|
|
};
|
|
|
|
|
2012-07-19 17:37:54 +02:00
|
|
|
|
2010-06-01 15:31:08 +02:00
|
|
|
template <typename T>
|
|
|
|
void agg_renderer<T>::process(markers_symbolizer const& sym,
|
2012-07-24 15:04:25 +02:00
|
|
|
feature_impl & feature,
|
2010-06-02 13:03:30 +02:00
|
|
|
proj_transform const& prj_trans)
|
2010-06-01 15:31:08 +02:00
|
|
|
{
|
2012-05-15 17:13:08 +02:00
|
|
|
typedef agg::rgba8 color_type;
|
|
|
|
typedef agg::order_rgba order_type;
|
|
|
|
typedef agg::pixel32_type pixel_type;
|
2012-06-19 00:47:30 +02:00
|
|
|
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
2012-05-15 17:13:08 +02:00
|
|
|
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
|
|
|
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
2012-07-24 15:04:25 +02:00
|
|
|
typedef label_collision_detector4 detector_type;
|
|
|
|
typedef boost::mpl::vector<clip_line_tag,transform_tag,smooth_tag> conv_types;
|
2012-06-26 16:00:42 +02:00
|
|
|
|
2012-06-16 04:17:26 +02:00
|
|
|
std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
|
2012-02-02 02:53:35 +01:00
|
|
|
|
2010-06-02 14:53:23 +02:00
|
|
|
if (!filename.empty())
|
|
|
|
{
|
2011-01-26 02:18:40 +01:00
|
|
|
boost::optional<marker_ptr> mark = mapnik::marker_cache::instance()->find(filename, true);
|
2011-06-24 22:34:21 +02:00
|
|
|
if (mark && *mark)
|
2010-06-02 14:53:23 +02:00
|
|
|
{
|
2012-07-11 07:31:51 +02:00
|
|
|
ras_ptr->reset();
|
|
|
|
ras_ptr->gamma(agg::gamma_power());
|
|
|
|
agg::trans_affine geom_tr;
|
|
|
|
evaluate_transform(geom_tr, feature, sym.get_transform());
|
2012-07-09 11:22:19 +02:00
|
|
|
agg::trans_affine tr;
|
2012-07-31 06:45:46 +02:00
|
|
|
tr *= agg::trans_affine_scaling(scale_factor_);
|
2012-06-27 14:46:52 +02:00
|
|
|
|
2012-07-24 15:04:25 +02:00
|
|
|
if ((*mark)->is_vector())
|
|
|
|
{
|
|
|
|
using namespace mapnik::svg;
|
2012-07-31 06:45:46 +02:00
|
|
|
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_type;
|
2012-07-24 15:04:25 +02:00
|
|
|
typedef svg_renderer<svg_path_adapter,
|
|
|
|
agg::pod_bvector<path_attributes>,
|
|
|
|
renderer_type,
|
|
|
|
agg::pixfmt_rgba32 > svg_renderer_type;
|
|
|
|
typedef vector_markers_rasterizer_dispatch<buffer_type, svg_renderer_type, rasterizer, detector_type> dispatch_type;
|
2012-07-19 17:37:54 +02:00
|
|
|
|
2012-07-31 08:20:20 +02:00
|
|
|
boost::optional<svg_path_ptr> const& stock_vector_marker = (*mark)->get_vector_data();
|
|
|
|
expression_ptr const& width_expr = sym.get_width();
|
|
|
|
expression_ptr const& height_expr = sym.get_height();
|
|
|
|
|
|
|
|
// special case for simple ellipse markers
|
|
|
|
// to allow for full control over rx/ry dimensions
|
|
|
|
if (filename == "shape://ellipse"
|
|
|
|
&& (width_expr || height_expr))
|
2012-07-24 15:04:25 +02:00
|
|
|
{
|
2012-07-31 08:20:20 +02:00
|
|
|
double width = 0;
|
|
|
|
double height = 0;
|
|
|
|
if (width_expr && height_expr)
|
|
|
|
{
|
|
|
|
width = boost::apply_visitor(evaluate<Feature,value_type>(feature), *width_expr).to_double();
|
|
|
|
height = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr).to_double();
|
|
|
|
}
|
|
|
|
else if (width_expr)
|
|
|
|
{
|
|
|
|
width = boost::apply_visitor(evaluate<Feature,value_type>(feature), *width_expr).to_double();
|
|
|
|
height = width;
|
|
|
|
}
|
|
|
|
else if (height_expr)
|
|
|
|
{
|
|
|
|
height = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr).to_double();
|
|
|
|
width = height;
|
|
|
|
}
|
|
|
|
// create a new marker
|
|
|
|
svg_storage_type marker_ellipse;
|
|
|
|
vertex_stl_adapter<svg_path_storage> stl_storage(marker_ellipse.source());
|
|
|
|
svg_path_adapter svg_path(stl_storage);
|
|
|
|
svg_converter_type styled_svg(svg_path, marker_ellipse.attributes());
|
|
|
|
styled_svg.push_attr();
|
|
|
|
styled_svg.begin_path();
|
|
|
|
agg::ellipse c(0, 0, width/2.0, height/2.0);
|
|
|
|
styled_svg.storage().concat_path(c);
|
|
|
|
styled_svg.end_path();
|
|
|
|
styled_svg.pop_attr();
|
|
|
|
double lox,loy,hix,hiy;
|
|
|
|
styled_svg.bounding_rect(&lox, &loy, &hix, &hiy);
|
|
|
|
marker_ellipse.set_bounding_box(lox,loy,hix,hiy);
|
|
|
|
agg::pod_bvector<path_attributes> attributes;
|
|
|
|
bool result = push_explicit_style( (*stock_vector_marker)->attributes(), attributes, sym);
|
|
|
|
svg_renderer_type svg_renderer(svg_path, result ? attributes : (*stock_vector_marker)->attributes());
|
|
|
|
evaluate_transform(tr, feature, sym.get_image_transform());
|
|
|
|
box2d<double> bbox = marker_ellipse.bounding_box();
|
|
|
|
coord2d center = bbox.center();
|
|
|
|
agg::trans_affine_translation recenter(-center.x, -center.y);
|
|
|
|
agg::trans_affine marker_trans = recenter * tr;
|
|
|
|
dispatch_type rasterizer_dispatch(*current_buffer_,svg_renderer,*ras_ptr,
|
|
|
|
bbox, marker_trans, sym, *detector_, scale_factor_);
|
|
|
|
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
|
|
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
|
|
|
converter(query_extent_* 1.1,rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
|
|
|
if (sym.clip()) converter.template set<clip_line_tag>(); //optional clip (default: true)
|
|
|
|
converter.template set<transform_tag>(); //always transform
|
|
|
|
if (sym.smooth() > 0.0) converter.template set<smooth_tag>(); // optional smooth converter
|
|
|
|
BOOST_FOREACH(geometry_type & geom, feature.paths())
|
|
|
|
{
|
|
|
|
converter.apply(geom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
box2d<double> const& bbox = (*mark)->bounding_box();
|
|
|
|
setup_label_transform(tr, bbox, feature, sym);
|
|
|
|
coord2d center = bbox.center();
|
|
|
|
agg::trans_affine_translation recenter(-center.x, -center.y);
|
|
|
|
agg::trans_affine marker_trans = recenter * tr;
|
|
|
|
vertex_stl_adapter<svg_path_storage> stl_storage((*stock_vector_marker)->source());
|
|
|
|
svg_path_adapter svg_path(stl_storage);
|
|
|
|
agg::pod_bvector<path_attributes> attributes;
|
|
|
|
bool result = push_explicit_style( (*stock_vector_marker)->attributes(), attributes, sym);
|
|
|
|
svg_renderer_type svg_renderer(svg_path, result ? attributes : (*stock_vector_marker)->attributes());
|
|
|
|
dispatch_type rasterizer_dispatch(*current_buffer_,svg_renderer,*ras_ptr,
|
|
|
|
bbox, marker_trans, sym, *detector_, scale_factor_);
|
|
|
|
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
|
|
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
|
|
|
converter(query_extent_* 1.1,rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
|
|
|
if (sym.clip()) converter.template set<clip_line_tag>(); //optional clip (default: true)
|
|
|
|
converter.template set<transform_tag>(); //always transform
|
|
|
|
if (sym.smooth() > 0.0) converter.template set<smooth_tag>(); // optional smooth converter
|
|
|
|
BOOST_FOREACH(geometry_type & geom, feature.paths())
|
|
|
|
{
|
|
|
|
converter.apply(geom);
|
|
|
|
}
|
2012-07-24 15:04:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // raster markers
|
2010-06-08 13:14:31 +02:00
|
|
|
{
|
2012-07-31 06:45:46 +02:00
|
|
|
box2d<double> const& bbox = (*mark)->bounding_box();
|
|
|
|
setup_label_transform(tr, bbox, feature, sym);
|
|
|
|
coord2d center = bbox.center();
|
|
|
|
agg::trans_affine_translation recenter(-center.x, -center.y);
|
|
|
|
agg::trans_affine marker_trans = recenter * tr;
|
2012-07-24 15:04:25 +02:00
|
|
|
boost::optional<mapnik::image_ptr> marker = (*mark)->get_bitmap_data();
|
|
|
|
typedef raster_markers_rasterizer_dispatch<buffer_type,rasterizer, detector_type> dispatch_type;
|
|
|
|
dispatch_type rasterizer_dispatch(*current_buffer_,*ras_ptr, **marker,
|
|
|
|
marker_trans, sym, *detector_, scale_factor_);
|
|
|
|
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
|
|
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
|
|
|
converter(query_extent_* 1.1, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
2012-07-31 08:20:20 +02:00
|
|
|
|
2012-07-24 15:04:25 +02:00
|
|
|
if (sym.clip()) converter.template set<clip_line_tag>(); //optional clip (default: true)
|
|
|
|
converter.template set<transform_tag>(); //always transform
|
|
|
|
if (sym.smooth() > 0.0) converter.template set<smooth_tag>(); // optional smooth converter
|
|
|
|
|
|
|
|
BOOST_FOREACH(geometry_type & geom, feature.paths())
|
|
|
|
{
|
|
|
|
converter.apply(geom);
|
|
|
|
}
|
2010-08-19 19:33:01 +02:00
|
|
|
}
|
2010-06-01 15:31:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template void agg_renderer<image_32>::process(markers_symbolizer const&,
|
2012-06-16 04:17:26 +02:00
|
|
|
mapnik::feature_impl &,
|
2010-06-02 13:03:30 +02:00
|
|
|
proj_transform const&);
|
2010-06-01 15:31:08 +02:00
|
|
|
}
|