virtual void operator()(vector_marker_render_thunk const& thunk)
    {
        using blender_type = agg::comp_op_adaptor_rgba_pre<agg::rgba8, agg::order_rgba>; // comp blender
        using buf_type = agg::rendering_buffer;
        using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>;
        using renderer_base = agg::renderer_base<pixfmt_comp_type>;
        using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>;
        using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
        using svg_renderer_type = svg::svg_renderer_agg<svg_path_adapter,
                                                        svg_attribute_type,
                                                        renderer_type,
                                                        pixfmt_comp_type>;
        ras_ptr_->reset();
        buf_type render_buffer(buf_->bytes(), buf_->width(), buf_->height(), buf_->row_size());
        pixfmt_comp_type pixf(render_buffer);
        pixf.comp_op(static_cast<agg::comp_op_e>(thunk.comp_op_));
        renderer_base renb(pixf);
        svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(thunk.src_->source());
        svg_path_adapter svg_path(stl_storage);
        svg_renderer_type svg_renderer(svg_path, thunk.attrs_);

        agg::trans_affine offset_tr = thunk.tr_;
        offset_tr.translate(offset_.x, offset_.y);
        render_vector_marker(svg_renderer, *ras_ptr_, renb, thunk.src_->bounding_box(), offset_tr, thunk.opacity_, thunk.snap_to_pixels_);
    }
Ejemplo n.º 2
0
    cairo_surface_ptr operator()(marker_svg const & marker) const
    {
        box2d<double> bbox(marker.bounding_box());
        agg::trans_affine tr(transform(bbox));

        double width = std::max(1.0, std::round(bbox.width()));
        double height = std::max(1.0, std::round(bbox.height()));
        cairo_rectangle_t extent { 0, 0, width, height };
        cairo_surface_ptr surface(
            cairo_recording_surface_create(
                CAIRO_CONTENT_COLOR_ALPHA, &extent),
            cairo_surface_closer());

        cairo_ptr cairo = create_context(surface);
        cairo_context context(cairo);

        svg_storage_type & svg = *marker.get_data();
        svg_attribute_type const& svg_attributes = svg.attributes();
        svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(
            svg.source());
        svg::svg_path_adapter svg_path(stl_storage);

        render_vector_marker(context, svg_path, svg_attributes,
            bbox, tr, opacity_);

        return surface;
    }
Ejemplo n.º 3
0
 virtual void render_marker(svg_path_ptr const& src,
                            svg_path_adapter & path,
                            svg_attribute_type const& attrs,
                            markers_dispatch_params const& params,
                            agg::trans_affine const& marker_tr)
 {
     SvgRenderer svg_renderer(path, attrs);
     render_vector_marker(svg_renderer, ras_, renb_, src->bounding_box(),
                          marker_tr, params.opacity, params.snap_to_pixels);
 }
 virtual void render_marker(svg_path_ptr const& src,
                            svg_path_adapter & path,
                            svg_attribute_type const& attrs,
                            markers_dispatch_params const& params,
                            agg::trans_affine const& marker_tr)
 {
     render_vector_marker(ctx_,
                          path,
                          attrs,
                          src->bounding_box(),
                          marker_tr,
                          params.opacity);
 }
Ejemplo n.º 5
0
 void operator() (marker_svg const& marker)
 {
     mapnik::svg_path_ptr vmarker = marker.get_data();
     if (vmarker)
     {
         box2d<double> bbox = vmarker->bounding_box();
         agg::trans_affine marker_tr = tr_;
         if (recenter_)
         {
             coord<double,2> c = bbox.center();
             marker_tr = agg::trans_affine_translation(-c.x,-c.y);
             marker_tr *= tr_;
         }
         marker_tr *= agg::trans_affine_scaling(common_.scale_factor_);
         agg::pod_bvector<svg::path_attributes> const & attributes = vmarker->attributes();
         svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(vmarker->source());
         svg::svg_path_adapter svg_path(stl_storage);
         marker_tr.translate(pos_.x, pos_.y);
         render_vector_marker(context_, svg_path, attributes, bbox, marker_tr, opacity_);
     }
 }
Ejemplo n.º 6
0
 void add_path(T & path)
 {
     marker_placement_enum placement_method = get<marker_placement_enum>(
         sym_, keys::markers_placement_type, feature_, vars_, MARKER_POINT_PLACEMENT);
     bool ignore_placement = get<bool>(sym_, keys::ignore_placement, feature_, vars_, false);
     bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
     double opacity = get<double>(sym_, keys::opacity, feature_, vars_, 1.0);
     double spacing = get<double>(sym_, keys::spacing, feature_, vars_, 100.0);
     double max_error = get<double>(sym_, keys::max_error, feature_, vars_, 0.2);
     coord2d center = bbox_.center();
     agg::trans_affine_translation recenter(-center.x, -center.y);
     agg::trans_affine tr = recenter * marker_trans_;
     markers_placement_finder<T, label_collision_detector4> placement_finder(
         placement_method,
         path,
         bbox_,
         tr,
         detector_,
         spacing * scale_factor_,
         max_error,
         allow_overlap);
     double x, y, angle = .0;
     while (placement_finder.get_point(x, y, angle, ignore_placement))
     {
         agg::trans_affine matrix = tr;
         matrix.rotate(angle);
         matrix.translate(x, y);
         render_vector_marker(
             ctx_,
             pixel_position(x, y),
             marker_,
             bbox_,
             attributes_,
             matrix,
             opacity,
             false);
     }
 }