Created
December 5, 2008 00:12
-
-
Save ajturner/32164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct coloriser | |
{ | |
explicit coloriser(mapnik::Color const& c) | |
: c_(c) {} | |
template <typename PixelType> | |
void operator() ( PixelType & p) | |
{ | |
// use c to modify p | |
p[0] = c_.red(); | |
p[1] = c_.green(); | |
p[2] = c_.blue(); | |
} | |
mapnik::Color const& c_; | |
}; | |
template <typename T> | |
void agg_renderer<T>::process(point_symbolizer const& sym, | |
Feature const& feature, | |
proj_transform const& prj_trans) | |
{ | |
double x; | |
double y; | |
double z=0; | |
boost::shared_ptr<ImageData32> const& data = sym.get_image(); | |
if ( data ) | |
{ | |
ImageData32 target(int(floor(data->width() * sym.get_scale())),int(floor(data->height() * sym.get_scale()))); | |
scale_image<ImageData32>(target,*data); | |
// creating a lightweight view from rgba | |
boost::gil::rgba8_view_t view = interleaved_view(target.width(),target.height(), | |
(boost::gil::rgba8_pixel_t*)target.getData(), | |
target.width() * 4); | |
mapnik::Color c(255,0,0); | |
coloriser op(c); | |
for_each_pixel(view,coloriser<ImageData32::pixel_type>(c)); | |
for (unsigned i=0;i<feature.num_geometries();++i) | |
{ | |
geometry2d const& geom = feature.get_geometry(i); | |
geom.label_position(&x,&y); | |
prj_trans.backward(x,y,z); | |
t_.forward(&x,&y); | |
int w = target.width(); | |
int h = target.height(); | |
std::clog << "scale=" << sym.get_scale() << "w=" << w << "h=" << h << "\n"; | |
int px=int(floor(x - 0.5 * w)); | |
int py=int(floor(y - 0.5 * h)); | |
Envelope<double> label_ext (floor(x - 0.5 * w), | |
floor(y - 0.5 * h), | |
ceil (x + 0.5 * w), | |
ceil (y + 0.5 * h)); | |
if (sym.get_allow_overlap() || | |
detector_.has_placement(label_ext)) | |
{ | |
pixmap_.set_rectangle_alpha2(target,px,py,sym.get_opacity()); | |
detector_.insert(label_ext); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment