本文整理汇总了C++中mapnik::feature_impl类的典型用法代码示例。如果您正苦于以下问题:C++ feature_impl类的具体用法?C++ feature_impl怎么用?C++ feature_impl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了feature_impl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buf
void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<marker_ptr> mark = marker_cache::instance().find(filename,true);
if (!mark) return;
if (!(*mark)->is_bitmap())
{
MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Only images (not '" << filename << "') are supported in the line_pattern_symbolizer";
return;
}
boost::optional<image_ptr> pat = (*mark)->get_bitmap_data();
if (!pat) return;
ras_ptr->reset();
agg::trans_affine tr;
evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, grid_rasterizer, polygon_pattern_symbolizer,
CoordTransform, proj_transform, agg::trans_affine, conv_types>
converter(query_extent_,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
if (prj_trans.equal() && sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
converter.set<transform_tag>(); //always transform
converter.set<affine_transform_tag>();
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{
converter.apply(geom);
}
}
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
pixfmt_type pixf(buf);
grid_renderer_base_type renb(pixf);
renderer_type ren(renb);
// render id
ren.color(color_type(feature.id()));
agg::scanline_bin sl;
ras_ptr->filling_rule(agg::fill_even_odd);
agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache
pixmap_.add_feature(feature);
}
示例2: if
void agg_renderer<T0,T1>::process(debug_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
debug_symbolizer_mode_enum mode = get<debug_symbolizer_mode_enum>(sym, keys::mode, feature, common_.vars_, DEBUG_SYM_MODE_COLLISION);
ras_ptr->reset();
if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
{
ras_ptr->gamma(agg::gamma_power());
gamma_method_ = GAMMA_POWER;
gamma_ = 1.0;
}
if (mode == DEBUG_SYM_MODE_RINGS)
{
RingRenderer<buffer_type> renderer(*ras_ptr,*current_buffer_,common_.t_,prj_trans);
render_ring_visitor<buffer_type> apply(renderer);
mapnik::util::apply_visitor(apply,feature.get_geometry());
}
else if (mode == DEBUG_SYM_MODE_COLLISION)
{
for (auto const& n : *common_.detector_)
{
draw_rect(pixmap_, n.get().box);
}
}
else if (mode == DEBUG_SYM_MODE_VERTEX)
{
using apply_vertex_mode = apply_vertex_mode<buffer_type>;
apply_vertex_mode apply(pixmap_, common_.t_, prj_trans);
util::apply_visitor(geometry::vertex_processor<apply_vertex_mode>(apply), feature.get_geometry());
}
}
示例3: start_tile_feature
void start_tile_feature(mapnik::feature_impl const& feature)
{
current_feature_ = current_layer_->add_features();
x_ = y_ = 0;
// TODO - encode as sint64: (n << 1) ^ ( n >> 63)
// test current behavior with negative numbers
current_feature_->set_id(feature.id());
feature_kv_iterator itr = feature.begin();
feature_kv_iterator end = feature.end();
for ( ;itr!=end; ++itr)
{
std::string const& name = MAPNIK_GET<0>(*itr);
mapnik::value const& val = MAPNIK_GET<1>(*itr);
if (!val.is_null())
{
// Insert the key index
keys_container::const_iterator key_itr = keys_.find(name);
if (key_itr == keys_.end())
{
// The key doesn't exist yet in the dictionary.
current_layer_->add_keys(name.c_str(), name.length());
size_t index = keys_.size();
keys_.insert(keys_container::value_type(name, index));
current_feature_->add_tags(index);
}
else
{
current_feature_->add_tags(key_itr->second);
}
// Insert the value index
values_container::const_iterator val_itr = values_.find(val);
if (val_itr == values_.end())
{
// The value doesn't exist yet in the dictionary.
to_tile_value visitor(current_layer_->add_values());
#if MAPNIK_VERSION >= 300000
MAPNIK_APPLY_VISITOR(visitor, val);
#else
MAPNIK_APPLY_VISITOR(visitor, val.base());
#endif
size_t index = values_.size();
values_.insert(values_container::value_type(val, index));
current_feature_->add_tags(index);
}
else
{
current_feature_->add_tags(val_itr->second);
}
}
}
}
示例4: buf
void grid_renderer<T>::process(building_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
using pixfmt_type = typename grid_renderer_base_type::pixfmt_type;
using color_type = typename grid_renderer_base_type::pixfmt_type::color_type;
using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>;
using transform_path_type = transform_path_adapter<view_transform, vertex_adapter>;
agg::scanline_bin sl;
grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_);
pixfmt_type pixf(buf);
grid_renderer_base_type renb(pixf);
renderer_type ren(renb);
ras_ptr->reset();
double height = get<value_double>(sym, keys::height, feature, common_.vars_, 0.0);
render_building_symbolizer(
feature, height,
[&](path_type const& faces)
{
vertex_adapter va(faces);
transform_path_type faces_path (common_.t_,va,prj_trans);
ras_ptr->add_path(faces_path);
ren.color(color_type(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren);
ras_ptr->reset();
},
[&](path_type const& frame)
{
vertex_adapter va(frame);
transform_path_type path(common_.t_,va,prj_trans);
agg::conv_stroke<transform_path_type> stroke(path);
ras_ptr->add_path(stroke);
ren.color(color_type(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren);
ras_ptr->reset();
},
[&](path_type const& roof)
{
vertex_adapter va(roof);
transform_path_type roof_path (common_.t_,va,prj_trans);
ras_ptr->add_path(roof_path);
ren.color(color_type(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren);
});
pixmap_.add_feature(feature);
}
示例5: buf
void grid_renderer<T>::process(polygon_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
ras_ptr->reset();
agg::trans_affine tr;
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, grid_rasterizer, polygon_symbolizer,
CoordTransform, proj_transform, agg::trans_affine, conv_types>
converter(query_extent_,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
if (prj_trans.equal() && sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
converter.set<transform_tag>(); //always transform
converter.set<affine_transform_tag>();
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{
converter.apply(geom);
}
}
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
pixfmt_type pixf(buf);
grid_renderer_base_type renb(pixf);
renderer_type ren(renb);
// render id
ren.color(color_type(feature.id()));
agg::scanline_bin sl;
ras_ptr->filling_rule(agg::fill_even_odd);
agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache
pixmap_.add_feature(feature);
}
示例6: guard
void cairo_renderer<T>::process(debug_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
cairo_save_restore guard(context_);
debug_symbolizer_mode_enum mode = get<debug_symbolizer_mode_enum>(sym, keys::mode, feature, common_.vars_, DEBUG_SYM_MODE_COLLISION);
context_.set_operator(src_over);
context_.set_color(mapnik::color(255, 0, 0), 1.0);
context_.set_line_join(MITER_JOIN);
context_.set_line_cap(BUTT_CAP);
context_.set_miter_limit(4.0);
context_.set_line_width(1.0);
if (mode == DEBUG_SYM_MODE_COLLISION)
{
for (auto & n : *common_.detector_)
{
render_debug_box(context_, n.get().box);
}
}
else if (mode == DEBUG_SYM_MODE_VERTEX)
{
using apply_vertex_mode = apply_vertex_mode<cairo_context>;
apply_vertex_mode apply(context_, common_.t_, prj_trans);
util::apply_visitor(geometry::vertex_processor<apply_vertex_mode>(apply), feature.get_geometry());
}
}
示例7: helper
void grid_renderer<T>::process(text_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
text_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper(
sym, feature, prj_trans,
width_, height_,
scale_factor_ * (1.0/pixmap_.get_resolution()),
t_, font_manager_, *detector_,
query_extent_);
bool placement_found = false;
text_renderer<T> ren(pixmap_,
font_manager_,
sym.get_halo_rasterizer(),
sym.comp_op(),
scale_factor_);
while (helper.next()) {
placement_found = true;
placements_type const& placements = helper.placements();
for (unsigned int ii = 0; ii < placements.size(); ++ii)
{
ren.prepare_glyphs(placements[ii]);
ren.render_id(feature.id(), placements[ii].center);
}
}
if (placement_found) pixmap_.add_feature(feature);
}
示例8: render_raster_marker
void render_raster_marker(RendererType ren,
RasterizerType & ras,
image_data_rgba8 & src,
mapnik::feature_impl const& feature,
agg::trans_affine const& marker_tr,
double opacity)
{
using color_type = typename RendererType::color_type;
agg::scanline_bin sl;
double width = src.width();
double height = src.height();
double p[8];
p[0] = 0; p[1] = 0;
p[2] = width; p[3] = 0;
p[4] = width; p[5] = height;
p[6] = 0; p[7] = height;
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]);
ren.color(color_type(feature.id()));
agg::render_scanlines(ras, sl, ren);
}
示例9: helper
void grid_renderer<T>::process(text_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
agg::trans_affine tr;
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
text_symbolizer_helper helper(
sym, feature, common_.vars_, prj_trans,
common_.width_, common_.height_,
common_.scale_factor_ * (1.0/pixmap_.get_resolution()),
common_.t_, common_.font_manager_, *common_.detector_,
common_.query_extent_, tr);
bool placement_found = false;
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
grid_text_renderer<T> ren(pixmap_,
comp_op,
common_.scale_factor_);
placements_list const& placements = helper.get();
value_integer feature_id = feature.id();
for (glyph_positions_ptr glyphs : placements)
{
ren.render(*glyphs, feature_id);
placement_found = true;
}
if (placement_found)
{
pixmap_.add_feature(feature);
}
}
示例10: target_data
void agg_renderer<T>::process(raster_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
raster_ptr const& source = feature.get_raster();
if (source)
{
// If there's a colorizer defined, use it to color the raster in-place
raster_colorizer_ptr colorizer = sym.get_colorizer();
if (colorizer)
colorizer->colorize(source,feature);
box2d<double> target_ext = box2d<double>(source->ext_);
prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS);
box2d<double> ext = t_.forward(target_ext);
int start_x = static_cast<int>(ext.minx());
int start_y = static_cast<int>(ext.miny());
int end_x = static_cast<int>(ceil(ext.maxx()));
int end_y = static_cast<int>(ceil(ext.maxy()));
int raster_width = end_x - start_x;
int raster_height = end_y - start_y;
if (raster_width > 0 && raster_height > 0)
{
image_data_32 target_data(raster_width,raster_height);
raster target(target_ext, target_data);
scaling_method_e scaling_method = sym.get_scaling_method();
double filter_radius = sym.calculate_filter_factor();
double offset_x = ext.minx() - start_x;
double offset_y = ext.miny() - start_y;
if (!prj_trans.equal())
{
reproject_and_scale_raster(target, *source, prj_trans,
offset_x, offset_y,
sym.get_mesh_size(),
filter_radius,
scaling_method);
}
else
{
if (scaling_method == SCALING_BILINEAR8){
scale_image_bilinear8<image_data_32>(target.data_,source->data_, offset_x, offset_y);
} else {
double scaling_ratio = ext.width() / source->data_.width();
scale_image_agg<image_data_32>(target.data_,
source->data_,
scaling_method,
scaling_ratio,
offset_x,
offset_y,
filter_radius);
}
}
composite(current_buffer_->data(), target.data_, sym.comp_op(), sym.get_opacity(), start_x, start_y, true);
}
}
}
示例11: if
void agg_renderer<T0,T1>::process(dot_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
double width = 0.0;
double height = 0.0;
bool has_width = has_key(sym,keys::width);
bool has_height = has_key(sym,keys::height);
if (has_width && has_height)
{
width = get<double>(sym, keys::width, feature, common_.vars_, 0.0);
height = get<double>(sym, keys::height, feature, common_.vars_, 0.0);
}
else if (has_width)
{
width = height = get<double>(sym, keys::width, feature, common_.vars_, 0.0);
}
else if (has_height)
{
width = height = get<double>(sym, keys::height, feature, common_.vars_, 0.0);
}
double rx = width/2.0;
double ry = height/2.0;
double opacity = get<double>(sym, keys::opacity, feature, common_.vars_, 1.0);
color const& fill = get<mapnik::color>(sym, keys::fill, feature, common_.vars_, mapnik::color(128,128,128));
ras_ptr->reset();
agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(),current_buffer_->width() * 4);
using blender_type = agg::comp_op_adaptor_rgba_pre<agg::rgba8, agg::order_rgba>;
using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
using renderer_base = agg::renderer_base<pixfmt_comp_type>;
using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>;
pixfmt_comp_type pixf(buf);
pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over)));
renderer_base renb(pixf);
renderer_type ren(renb);
agg::scanline_u8 sl;
ren.color(agg::rgba8_pre(fill.red(), fill.green(), fill.blue(), int(fill.alpha() * opacity)));
agg::ellipse el(0,0,rx,ry);
unsigned num_steps = el.num_steps();
for (geometry_type const& geom : feature.paths()) {
double x,y,z = 0;
unsigned cmd = 1;
geom.rewind(0);
while ((cmd = geom.vertex(&x, &y)) != mapnik::SEG_END) {
if (cmd == SEG_CLOSE) continue;
prj_trans.backward(x,y,z);
common_.t_.forward(&x,&y);
el.init(x,y,rx,ry,num_steps);
ras_ptr->add_path(el);
agg::render_scanlines(*ras_ptr, sl, ren);
}
}
}
示例12:
void hit_grid<T>::add_feature(mapnik::feature_impl const& feature)
{
value_type feature_id = feature.id();
// avoid adding duplicate features (e.g. in the case of both a line symbolizer and a polygon symbolizer)
typename feature_key_type::const_iterator feature_pos = f_keys_.find(feature_id);
if (feature_pos != f_keys_.end())
{
return;
}
if (ctx_->size() == 0)
{
context_type::map_type::const_iterator itr = feature.context()->begin();
context_type::map_type::const_iterator end = feature.context()->end();
for ( ;itr!=end; ++itr)
{
ctx_->add(itr->first,itr->second);
}
}
// NOTE: currently lookup keys must be strings,
// but this should be revisited
lookup_type lookup_value;
if (key_ == id_name_)
{
mapnik::util::to_string(lookup_value,feature_id);
}
else
{
if (feature.has_key(key_))
{
lookup_value = feature.get(key_).to_string();
}
else
{
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Should not get here: key '" << key_ << "' not found in feature properties";
}
}
if (!lookup_value.empty())
{
// TODO - consider shortcutting f_keys if feature_id == lookup_value
// create a mapping between the pixel id and the feature key
f_keys_.emplace(feature_id,lookup_value);
// if extra fields have been supplied, push them into grid memory
if (!names_.empty())
{
// it is ~ 2x faster to copy feature attributes compared
// to building up a in-memory cache of feature_ptrs
// https://github.com/mapnik/mapnik/issues/1198
mapnik::feature_ptr feature2(mapnik::feature_factory::create(ctx_,feature_id));
feature2->set_data(feature.get_data());
features_.emplace(lookup_value,feature2);
}
}
else
{
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Warning - key '" << key_ << "' was blank for " << feature;
}
}
示例13: path
bool svg_renderer<OutputIterator>::process(rule::symbolizers const& syms,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
// svg renderer supports processing of multiple symbolizers.
typedef coord_transform<CoordTransform, geometry_type> path_type;
bool process_path = false;
// process each symbolizer to collect its (path) information.
// path information (attributes from line_ and polygon_ symbolizers)
// is collected with the path_attributes_ data member.
for (symbolizer const& sym : syms)
{
if (is_path_based(sym))
{
process_path = true;
}
boost::apply_visitor(symbol_dispatch(*this, feature, prj_trans), sym);
}
if (process_path)
{
// generate path output for each geometry of the current feature.
for(std::size_t i=0; i<feature.num_geometries(); ++i)
{
geometry_type & geom = feature.get_geometry(i);
if(geom.size() > 0)
{
path_type path(t_, geom, prj_trans);
generator_.generate_path(path, path_attributes_);
}
}
// set the previously collected values back to their defaults
// for the feature that will be processed next.
path_attributes_.reset();
}
return true;
}
示例14: helper
void grid_renderer<T>::process(shield_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
shield_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper(
sym, feature, prj_trans,
width_, height_,
scale_factor_,
t_, font_manager_, *detector_,
query_extent_);
bool placement_found = false;
text_renderer<T> ren(pixmap_,
font_manager_,
sym.get_halo_rasterizer(),
sym.comp_op(),
scale_factor_);
text_placement_info_ptr placement;
while (helper.next())
{
placement_found = true;
placements_type const& placements = helper.placements();
for (unsigned int ii = 0; ii < placements.size(); ++ii)
{
// get_marker_position returns (minx,miny) corner position,
// while (currently only) agg_renderer::render_marker newly
// expects center position;
// until all renderers and shield_symbolizer_helper are
// modified accordingly, we must adjust the position here
pixel_position pos = helper.get_marker_position(placements[ii]);
pos.x += 0.5 * helper.get_marker_width();
pos.y += 0.5 * helper.get_marker_height();
render_marker(feature,
pixmap_.get_resolution(),
pos,
helper.get_marker(),
helper.get_image_transform(),
sym.get_opacity(),
sym.comp_op());
ren.prepare_glyphs(placements[ii]);
ren.render_id(feature.id(), placements[ii].center);
}
}
if (placement_found)
pixmap_.add_feature(feature);
}
示例15: guard
void cairo_renderer<T>::process(debug_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
using detector_type = label_collision_detector4;
cairo_save_restore guard(context_);
debug_symbolizer_mode_enum mode = get<debug_symbolizer_mode_enum>(sym, keys::mode, feature, common_.vars_, DEBUG_SYM_MODE_COLLISION);
context_.set_operator(src_over);
context_.set_color(mapnik::color(255, 0, 0), 1.0);
context_.set_line_join(MITER_JOIN);
context_.set_line_cap(BUTT_CAP);
context_.set_miter_limit(4.0);
context_.set_line_width(1.0);
if (mode == DEBUG_SYM_MODE_COLLISION)
{
typename detector_type::query_iterator itr = common_.detector_->begin();
typename detector_type::query_iterator end = common_.detector_->end();
for ( ;itr!=end; ++itr)
{
render_debug_box(context_, itr->box);
}
}
else if (mode == DEBUG_SYM_MODE_VERTEX)
{
for (auto const& geom : feature.paths())
{
double x;
double y;
double z = 0;
geom.rewind(0);
unsigned cmd = 1;
while ((cmd = geom.vertex(&x, &y)) != mapnik::SEG_END)
{
if (cmd == SEG_CLOSE) continue;
prj_trans.backward(x,y,z);
common_.t_.forward(&x,&y);
context_.move_to(std::floor(x) - 0.5, std::floor(y) + 0.5);
context_.line_to(std::floor(x) + 1.5, std::floor(y) + 0.5);
context_.move_to(std::floor(x) + 0.5, std::floor(y) - 0.5);
context_.line_to(std::floor(x) + 0.5, std::floor(y) + 1.5);
context_.stroke();
}
}
}
}