本文整理汇总了C++中proj_transform类的典型用法代码示例。如果您正苦于以下问题:C++ proj_transform类的具体用法?C++ proj_transform怎么用?C++ proj_transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了proj_transform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: reproject_internal
polygon<T> reproject_internal(polygon<T> const& poly, proj_transform const& proj_trans, unsigned int & n_err)
{
polygon<T> new_poly;
linear_ring<T> new_ext(poly.exterior_ring);
unsigned int err = proj_trans.forward(new_ext);
// If the exterior ring doesn't transform don't bother with the holes.
if (err > 0 || new_ext.empty())
{
n_err += err;
}
else
{
new_poly.set_exterior_ring(std::move(new_ext));
new_poly.interior_rings.reserve(poly.interior_rings.size());
for (auto const& lr : poly.interior_rings)
{
linear_ring<T> new_lr(lr);
err = proj_trans.forward(new_lr);
if (err > 0 || new_lr.empty())
{
n_err += err;
// If there is an error in interior ring drop
// it from polygon.
continue;
}
new_poly.add_hole(std::move(new_lr));
}
}
return new_poly;
}
开发者ID:DavidLiuGitHub,项目名称:mapnik,代码行数:31,代码来源:geometry_reprojection_impl.hpp
示例2: 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);
}
}
}
开发者ID:PierceCountyWA,项目名称:mapnik,代码行数:56,代码来源:process_raster_symbolizer.cpp
示例3: backward
inline box2d<double> backward(box2d<double> const& e,
proj_transform const& prj_trans) const
{
double x0 = e.minx();
double y0 = e.miny();
double x1 = e.maxx();
double y1 = e.maxy();
double z = 0.0;
backward(&x0, &y0);
prj_trans.forward(x0, y0, z);
backward(&x1, &y1);
prj_trans.forward(x1, y1, z);
return box2d<double>(x0, y0, x1, y1);
}
开发者ID:DavidLiuGitHub,项目名称:mapnik,代码行数:14,代码来源:view_transform.hpp
示例4: MAPNIK_LOG_DEBUG
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);
}
开发者ID:GISpecialist,项目名称:mapnik,代码行数:60,代码来源:process_polygon_pattern_symbolizer.cpp
示例5: int
void agg_renderer<T>::process(point_symbolizer const& sym,
Feature const& feature,
proj_transform const& prj_trans)
{
std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() )
{
marker = marker_cache::instance()->find(filename, true);
}
else
{
marker.reset(boost::make_shared<mapnik::marker>());
}
if (marker)
{
for (unsigned i=0; i<feature.num_geometries(); ++i)
{
geometry_type const& geom = feature.get_geometry(i);
double x;
double y;
double z=0;
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
geom.label_position(&x, &y);
else
geom.label_interior_position(&x, &y);
prj_trans.backward(x,y,z);
t_.forward(&x,&y);
int w = (*marker)->width();
int h = (*marker)->height();
int px = int(floor(x - 0.5 * w));
int py = int(floor(y - 0.5 * h));
box2d<double> label_ext (px, py, px + w, py + h);
if (sym.get_allow_overlap() ||
detector_.has_placement(label_ext))
{
agg::trans_affine tr;
boost::array<double,6> const& m = sym.get_transform();
tr.load_from(&m[0]);
render_marker(px,py,**marker,tr, sym.get_opacity());
if (!sym.get_ignore_placement())
detector_.insert(label_ext);
metawriter_with_properties writer = sym.get_metawriter();
if (writer.first) writer.first->add_box(label_ext, feature, t_, writer.second);
}
}
}
}
开发者ID:makinacorpus,项目名称:mapnik2,代码行数:56,代码来源:process_point_symbolizer.cpp
示例6: 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);
}
}
}
开发者ID:NavtechInc,项目名称:mapnik,代码行数:53,代码来源:process_dot_symbolizer.cpp
示例7: 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();
}
}
}
}
开发者ID:1060460048,项目名称:mapnik,代码行数:48,代码来源:process_debug_symbolizer.cpp
示例8: evaluate_transform
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);
}
开发者ID:FlavioFalcao,项目名称:mapnik,代码行数:48,代码来源:process_polygon_symbolizer.cpp
示例9: target_data
void agg_renderer<T>::process(raster_symbolizer const& sym,
mapnik::feature_ptr const& 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 = (int)ext.minx();
int start_y = (int)ext.miny();
int end_x = (int)ceil(ext.maxx());
int end_y = (int)ceil(ext.maxy());
int raster_width = end_x - start_x;
int raster_height = end_y - start_y;
double err_offs_x = ext.minx() - start_x;
double err_offs_y = ext.miny() - start_y;
if (raster_width > 0 && raster_height > 0)
{
double scale_factor = ext.width() / source->data_.width();
image_data_32 target_data(raster_width,raster_height);
raster target(target_ext, target_data);
reproject_raster(target, *source, prj_trans, err_offs_x, err_offs_y,
sym.get_mesh_size(),
sym.calculate_filter_factor(),
scale_factor,
sym.get_scaling());
composite(current_buffer_->data(), target.data_, sym.comp_op(), sym.get_opacity(), start_x, start_y, false, false);
}
}
}
开发者ID:doubleotoo,项目名称:mapnik,代码行数:41,代码来源:process_raster_symbolizer.cpp
示例10: render_group_symbolizer
void render_group_symbolizer(group_symbolizer const& sym,
feature_impl & feature,
attributes const& vars,
proj_transform const& prj_trans,
box2d<double> const& clipping_extent,
renderer_common & common,
F render_thunks)
{
// find all column names referenced in the group rules and symbolizers
std::set<std::string> columns;
group_attribute_collector column_collector(columns, false);
column_collector(sym);
group_symbolizer_properties_ptr props = get<group_symbolizer_properties_ptr>(sym, keys::group_properties);
// create a new context for the sub features of this group
context_ptr sub_feature_ctx = std::make_shared<mapnik::context_type>();
// populate new context with column names referenced in the group rules and symbolizers
for (auto const& col_name : columns)
{
sub_feature_ctx->push(col_name);
}
// keep track of the sub features that we'll want to symbolize
// along with the group rules that they matched
std::vector< std::pair<group_rule_ptr, feature_ptr> > matches;
// create a copied 'virtual' common renderer for processing sub feature symbolizers
// create an empty detector for it, so we are sure we won't hit anything
virtual_renderer_common virtual_renderer(common);
// keep track of which lists of render thunks correspond to
// entries in the group_layout_manager.
std::vector<render_thunk_list> layout_thunks;
size_t num_layout_thunks = 0;
// layout manager to store and arrange bboxes of matched features
group_layout_manager layout_manager(props->get_layout(), pixel_position(common.width_ / 2.0, common.height_ / 2.0));
// run feature or sub feature through the group rules & symbolizers
// for each index value in the range
value_integer start = get<value_integer>(sym, keys::start_column);
value_integer end = start + get<value_integer>(sym, keys::num_columns);
for (value_integer col_idx = start; col_idx < end; ++col_idx)
{
// create sub feature with indexed column values
feature_ptr sub_feature = feature_factory::create(sub_feature_ctx, col_idx);
// copy the necessary columns to sub feature
for(auto const& col_name : columns)
{
if (col_name.find('%') != std::string::npos)
{
if (col_name.size() == 1)
{
// column name is '%' by itself, so give the index as the value
sub_feature->put(col_name, col_idx);
}
else
{
// indexed column
std::string col_idx_str;
if (mapnik::util::to_string(col_idx_str,col_idx))
{
std::string col_idx_name = col_name;
boost::replace_all(col_idx_name, "%", col_idx_str);
sub_feature->put(col_name, feature.get(col_idx_name));
}
}
}
else
{
// non-indexed column
sub_feature->put(col_name, feature.get(col_name));
}
}
// add a single point geometry at pixel origin
double x = common.width_ / 2.0, y = common.height_ / 2.0, z = 0.0;
common.t_.backward(&x, &y);
prj_trans.forward(x, y, z);
// note that we choose a point in the middle of the screen to
// try to ensure that we don't get edge artefacts due to any
// symbolizers with avoid-edges set: only the avoid-edges of
// the group symbolizer itself should matter.
geometry::point<double> origin_pt(x,y);
sub_feature->set_geometry(origin_pt);
// get the layout for this set of properties
for (auto const& rule : props->get_rules())
{
if (util::apply_visitor(evaluate<feature_impl,value_type,attributes>(*sub_feature,common.vars_),
*(rule->get_filter())).to_bool())
{
// add matched rule and feature to the list of things to draw
matches.emplace_back(rule, sub_feature);
// construct a bounding box around all symbolizers for the matched rule
bound_box bounds;
render_thunk_list thunks;
//.........这里部分代码省略.........
开发者ID:Dominik-K,项目名称:mapnik,代码行数:101,代码来源:process_group_symbolizer.hpp
示例11: render_point_symbolizer
void render_point_symbolizer(point_symbolizer const &sym,
mapnik::feature_impl &feature,
proj_transform const &prj_trans,
RendererType &common,
F render_marker)
{
std::string filename = get<std::string>(sym, keys::file, feature, common.vars_);
boost::optional<mapnik::marker_ptr> marker = filename.empty()
? std::make_shared<mapnik::marker>()
: marker_cache::instance().find(filename, true);
if (marker)
{
double opacity = get<double>(sym,keys::opacity,feature, common.vars_, 1.0);
bool allow_overlap = get<bool>(sym, keys::allow_overlap, feature, common.vars_, false);
bool ignore_placement = get<bool>(sym, keys::ignore_placement, feature, common.vars_, false);
point_placement_enum placement= get<point_placement_enum>(sym, keys::point_placement_type, feature, common.vars_, CENTROID_POINT_PLACEMENT);
box2d<double> const& bbox = (*marker)->bounding_box();
coord2d center = bbox.center();
agg::trans_affine tr;
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
if (image_transform) evaluate_transform(tr, feature, common.vars_, *image_transform);
agg::trans_affine_translation recenter(-center.x, -center.y);
agg::trans_affine recenter_tr = recenter * tr;
box2d<double> label_ext = bbox * recenter_tr * agg::trans_affine_scaling(common.scale_factor_);
for (std::size_t i=0; i<feature.num_geometries(); ++i)
{
geometry_type const& geom = feature.get_geometry(i);
double x;
double y;
double z=0;
if (placement == CENTROID_POINT_PLACEMENT)
{
if (!label::centroid(geom, x, y))
return;
}
else
{
if (!label::interior_position(geom ,x, y))
return;
}
prj_trans.backward(x,y,z);
common.t_.forward(&x,&y);
label_ext.re_center(x,y);
if (allow_overlap ||
common.detector_->has_placement(label_ext))
{
render_marker(pixel_position(x, y),
**marker,
tr,
opacity);
if (!ignore_placement)
common.detector_->insert(label_ext);
}
}
}
}
开发者ID:Andrey-VI,项目名称:mapnik,代码行数:64,代码来源:process_point_symbolizer.hpp
示例12: recenter
void agg_renderer<T>::process(point_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<mapnik::marker_ptr> marker;
if ( !filename.empty() )
{
marker = marker_cache::instance()->find(filename, true);
}
else
{
marker.reset(boost::make_shared<mapnik::marker>());
}
if (marker)
{
box2d<double> const& bbox = (*marker)->bounding_box();
coord2d center = bbox.center();
agg::trans_affine tr;
evaluate_transform(tr, feature, sym.get_image_transform());
agg::trans_affine_translation recenter(-center.x, -center.y);
agg::trans_affine recenter_tr = recenter * tr;
box2d<double> label_ext = bbox * recenter_tr;
for (unsigned i=0; i<feature.num_geometries(); ++i)
{
geometry_type const& geom = feature.get_geometry(i);
double x;
double y;
double z=0;
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
{
if (!label::centroid(geom, x, y))
return;
}
else
{
if (!label::interior_position(geom ,x, y))
return;
}
prj_trans.backward(x,y,z);
t_.forward(&x,&y);
label_ext.re_center(x,y);
if (sym.get_allow_overlap() ||
detector_->has_placement(label_ext))
{
render_marker(pixel_position(x, y),
**marker,
tr,
sym.get_opacity(),
sym.comp_op());
if (!sym.get_ignore_placement())
detector_->insert(label_ext);
}
}
}
}
开发者ID:bert,项目名称:mapnik,代码行数:64,代码来源:process_point_symbolizer.cpp
示例13: warp_image
MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const& prj_trans,
box2d<double> const& target_ext, box2d<double> const& source_ext,
double offset_x, double offset_y, unsigned mesh_size, scaling_method_e scaling_method, double filter_factor)
{
using image_type = T;
using pixel_type = typename image_type::pixel_type;
using pixfmt_pre = typename detail::agg_scaling_traits<image_type>::pixfmt_pre;
using color_type = typename detail::agg_scaling_traits<image_type>::color_type;
using renderer_base = agg::renderer_base<pixfmt_pre>;
using interpolator_type = typename detail::agg_scaling_traits<image_type>::interpolator_type;
constexpr std::size_t pixel_size = sizeof(pixel_type);
view_transform ts(source.width(), source.height(),
source_ext);
view_transform tt(target.width(), target.height(),
target_ext, offset_x, offset_y);
std::size_t mesh_nx = std::ceil(source.width()/double(mesh_size) + 1);
std::size_t mesh_ny = std::ceil(source.height()/double(mesh_size) + 1);
image_gray64f xs(mesh_nx, mesh_ny, false);
image_gray64f ys(mesh_nx, mesh_ny, false);
// Precalculate reprojected mesh
for(std::size_t j = 0; j < mesh_ny; ++j)
{
for (std::size_t i=0; i<mesh_nx; ++i)
{
xs(i,j) = std::min(i*mesh_size,source.width());
ys(i,j) = std::min(j*mesh_size,source.height());
ts.backward(&xs(i,j), &ys(i,j));
}
}
prj_trans.backward(xs.getData(), ys.getData(), nullptr, mesh_nx*mesh_ny);
agg::rasterizer_scanline_aa<> rasterizer;
agg::scanline_bin scanline;
agg::rendering_buffer buf(target.getBytes(),
target.width(),
target.height(),
target.width() * pixel_size);
pixfmt_pre pixf(buf);
renderer_base rb(pixf);
rasterizer.clip_box(0, 0, target.width(), target.height());
agg::rendering_buffer buf_tile(
const_cast<unsigned char*>(source.getBytes()),
source.width(),
source.height(),
source.width() * pixel_size);
pixfmt_pre pixf_tile(buf_tile);
using img_accessor_type = agg::image_accessor_clone<pixfmt_pre>;
img_accessor_type ia(pixf_tile);
agg::span_allocator<color_type> sa;
// Project mesh cells into target interpolating raster inside each one
for (std::size_t j = 0; j < mesh_ny - 1; ++j)
{
for (std::size_t i = 0; i < mesh_nx - 1; ++i)
{
double polygon[8] = {xs(i,j), ys(i,j),
xs(i+1,j), ys(i+1,j),
xs(i+1,j+1), ys(i+1,j+1),
xs(i,j+1), ys(i,j+1)};
tt.forward(polygon+0, polygon+1);
tt.forward(polygon+2, polygon+3);
tt.forward(polygon+4, polygon+5);
tt.forward(polygon+6, polygon+7);
rasterizer.reset();
rasterizer.move_to_d(std::floor(polygon[0]), std::floor(polygon[1]));
rasterizer.line_to_d(std::floor(polygon[2]), std::floor(polygon[3]));
rasterizer.line_to_d(std::floor(polygon[4]), std::floor(polygon[5]));
rasterizer.line_to_d(std::floor(polygon[6]), std::floor(polygon[7]));
std::size_t x0 = i * mesh_size;
std::size_t y0 = j * mesh_size;
std::size_t x1 = (i+1) * mesh_size;
std::size_t y1 = (j+1) * mesh_size;
x1 = std::min(x1, source.width());
y1 = std::min(y1, source.height());
agg::trans_affine tr(polygon, x0, y0, x1, y1);
if (tr.is_valid())
{
interpolator_type interpolator(tr);
if (scaling_method == SCALING_NEAR)
{
using span_gen_type = typename detail::agg_scaling_traits<image_type>::span_image_filter;
span_gen_type sg(ia, interpolator);
agg::render_scanlines_bin(rasterizer, scanline, rb, sa, sg);
}
else
{
using span_gen_type = typename detail::agg_scaling_traits<image_type>::span_image_resample_affine;
agg::image_filter_lut filter;
detail::set_scaling_method(filter, scaling_method, filter_factor);
span_gen_type sg(ia, interpolator, filter);
agg::render_scanlines_bin(rasterizer, scanline, rb, sa, sg);
//.........这里部分代码省略.........
开发者ID:MapQuest,项目名称:mapnik,代码行数:101,代码来源:warp.cpp
示例14: target
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>(std::floor(ext.minx()+.5));
int start_y = static_cast<int>(std::floor(ext.miny()+.5));
int end_x = static_cast<int>(std::floor(ext.maxx()+.5));
int end_y = static_cast<int>(std::floor(ext.maxy()+.5));
int raster_width = end_x - start_x;
int raster_height = end_y - start_y;
if (raster_width > 0 && raster_height > 0)
{
raster target(target_ext, raster_width,raster_height);
scaling_method_e scaling_method = sym.get_scaling_method();
double filter_radius = sym.calculate_filter_factor();
bool premultiply_source = !source->premultiplied_alpha_;
boost::optional<bool> is_premultiplied = sym.premultiplied();
if (is_premultiplied)
{
if (*is_premultiplied) premultiply_source = false;
else premultiply_source = true;
}
if (premultiply_source)
{
agg::rendering_buffer buffer(source->data_.getBytes(),
source->data_.width(),
source->data_.height(),
source->data_.width() * 4);
agg::pixfmt_rgba32 pixf(buffer);
pixf.premultiply();
}
if (!prj_trans.equal())
{
double offset_x = ext.minx() - start_x;
double offset_y = ext.miny() - start_y;
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_,
0.0,
0.0);
}
else
{
double image_ratio_x = ext.width() / source->data_.width();
double image_ratio_y = ext.height() / source->data_.height();
scale_image_agg<image_data_32>(target.data_,
source->data_,
scaling_method,
image_ratio_x,
image_ratio_y,
0.0,
0.0,
filter_radius);
}
}
composite(current_buffer_->data(), target.data_,
sym.comp_op(), sym.get_opacity(),
start_x, start_y, false);
}
}
}
开发者ID:Blaxxun,项目名称:mapnik,代码行数:81,代码来源:process_raster_symbolizer.cpp
示例15: reproject_and_scale_raster
void reproject_and_scale_raster(raster & target, raster const& source,
proj_transform const& prj_trans,
double offset_x, double offset_y,
unsigned mesh_size,
double filter_radius,
scaling_method_e scaling_method)
{
CoordTransform ts(source.data_.width(), source.data_.height(),
source.ext_);
CoordTransform tt(target.data_.width(), target.data_.height(),
target.ext_, offset_x, offset_y);
unsigned i, j;
unsigned mesh_nx = ceil(source.data_.width()/double(mesh_size)+1);
unsigned mesh_ny = ceil(source.data_.height()/double(mesh_size)+1);
ImageData<double> xs(mesh_nx, mesh_ny);
ImageData<double> ys(mesh_nx, mesh_ny);
// Precalculate reprojected mesh
for(j=0; j<mesh_ny; j++) {
for (i=0; i<mesh_nx; i++) {
xs(i,j) = i*mesh_size;
ys(i,j) = j*mesh_size;
ts.backward(&xs(i,j), &ys(i,j));
}
}
prj_trans.backward(xs.getData(), ys.getData(), NULL, mesh_nx*mesh_ny);
// Initialize AGG objects
typedef agg::pixfmt_rgba32 pixfmt;
typedef pixfmt::color_type color_type;
typedef agg::renderer_base<pixfmt> renderer_base;
typedef agg::pixfmt_rgba32_pre pixfmt_pre;
typedef agg::renderer_base<pixfmt_pre> renderer_base_pre;
agg::rasterizer_scanline_aa<> rasterizer;
agg::scanline_u8 scanline;
agg::rendering_buffer buf((unsigned char*)target.data_.getData(),
target.data_.width(),
target.data_.height(),
target.data_.width()*4);
pixfmt_pre pixf_pre(buf);
renderer_base_pre rb_pre(pixf_pre);
rasterizer.clip_box(0, 0, target.data_.width(), target.data_.height());
agg::rendering_buffer buf_tile(
(unsigned char*)source.data_.getData(),
source.data_.width(),
source.data_.height(),
source.data_.width() * 4);
pixfmt pixf_tile(buf_tile);
typedef agg::image_accessor_clone<pixfmt> img_accessor_type;
img_accessor_type ia(pixf_tile);
agg::span_allocator<color_type> sa;
// Initialize filter
agg::image_filter_lut filter;
switch(scaling_method)
{
case SCALING_NEAR: break;
case SCALING_BILINEAR8: // TODO - impl this or remove?
case SCALING_BILINEAR:
filter.calculate(agg::image_filter_bilinear(), true); break;
case SCALING_BICUBIC:
filter.calculate(agg::image_filter_bicubic(), true); break;
case SCALING_SPLINE16:
filter.calculate(agg::image_filter_spline16(), true); break;
case SCALING_SPLINE36:
filter.calculate(agg::image_filter_spline36(), true); break;
case SCALING_HANNING:
filter.calculate(agg::image_filter_hanning(), true); break;
case SCALING_HAMMING:
filter.calculate(agg::image_filter_hamming(), true); break;
case SCALING_HERMITE:
filter.calculate(agg::image_filter_hermite(), true); break;
case SCALING_KAISER:
filter.calculate(agg::image_filter_kaiser(), true); break;
case SCALING_QUADRIC:
filter.calculate(agg::image_filter_quadric(), true); break;
case SCALING_CATROM:
filter.calculate(agg::image_filter_catrom(), true); break;
case SCALING_GAUSSIAN:
filter.calculate(agg::image_filter_gaussian(), true); break;
case SCALING_BESSEL:
filter.calculate(agg::image_filter_bessel(), true); break;
case SCALING_MITCHELL:
filter.calculate(agg::image_filter_mitchell(), true); break;
case SCALING_SINC:
filter.calculate(agg::image_filter_sinc(filter_radius), true); break;
case SCALING_LANCZOS:
filter.calculate(agg::image_filter_lanczos(filter_radius), true); break;
case SCALING_BLACKMAN:
filter.calculate(agg::image_filter_blackman(filter_radius), true); break;
}
// Project mesh cells into target interpolating raster inside each one
for(j=0; j<mesh_ny-1; j++) {
for (i=0; i<mesh_nx-1; i++) {
//.........这里部分代码省略.........
开发者ID:PierceCountyWA,项目名称:mapnik,代码行数:101,代码来源:warp.cpp
示例16: buf
void grid_renderer<T>::process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl;
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
mapnik::pixfmt_gray16 pixf(buf);
ren_base renb(pixf);
renderer ren(renb);
ras_ptr->reset();
agg::trans_affine tr;
boost::array<double,6> const& m = sym.get_transform();
tr.load_from(&m[0]);
tr = agg::trans_affine_scaling(scale_factor_*(1.0/pixmap_.get_resolution())) * tr;
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature);
marker_placement_e placement_method = sym.get_marker_placement();
marker_type_e marker_type = sym.get_marker_type();
if (!filename.empty())
{
boost::optional<marker_ptr> mark = mapnik::marker_cache::instance()->find(filename, true);
if (mark && *mark && (*mark)->is_vector())
{
boost::optional<path_ptr> marker = (*mark)->get_vector_data();
box2d<double> const& bbox = (*marker)->bounding_box();
double x1 = bbox.minx();
double y1 = bbox.miny();
double x2 = bbox.maxx();
double y2 = bbox.maxy();
agg::trans_affine recenter = agg::trans_affine_translation(-0.5*(x1+x2),-0.5*(y1+y2));
tr.transform(&x1,&y1);
tr.transform(&x2,&y2);
box2d<double> extent(x1,y1,x2,y2);
using namespace mapnik::svg;
vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source());
svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>,
renderer,
mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes());
bool placed = false;
for (unsigned i=0; i<feature->num_geometries(); ++i)
{
geometry_type & geom = feature->get_geometry(i);
if (geom.num_points() <= 1)
{
std::clog << "### Warning svg markers not supported yet for points within markers_symbolizer\n";
continue;
}
path_type path(t_,geom,prj_trans);
markers_placement<path_type, label_collision_detector4> placement(path, extent, detector_,
sym.get_spacing() * scale_factor_,
|
请发表评论