1. return shared_ptr from point_symbolizer
2. small cleanup
This commit is contained in:
parent
53193826a8
commit
ffe47e4816
4 changed files with 41 additions and 30 deletions
|
@ -25,12 +25,13 @@
|
|||
#ifndef DATASOURCE_CACHE_HPP
|
||||
#define DATASOURCE_CACHE_HPP
|
||||
|
||||
#include <map>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "params.hpp"
|
||||
#include "plugin.hpp"
|
||||
#include "datasource.hpp"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
@ -38,16 +39,16 @@ namespace mapnik
|
|||
{
|
||||
friend class CreateStatic<datasource_cache>;
|
||||
private:
|
||||
datasource_cache();
|
||||
~datasource_cache();
|
||||
datasource_cache(const datasource_cache&);
|
||||
datasource_cache& operator=(const datasource_cache&);
|
||||
static std::map<std::string,boost::shared_ptr<PluginInfo> > plugins_;
|
||||
static bool registered_;
|
||||
static bool insert(const std::string& name,const lt_dlhandle module);
|
||||
datasource_cache();
|
||||
~datasource_cache();
|
||||
datasource_cache(const datasource_cache&);
|
||||
datasource_cache& operator=(const datasource_cache&);
|
||||
static std::map<std::string,boost::shared_ptr<PluginInfo> > plugins_;
|
||||
static bool registered_;
|
||||
static bool insert(const std::string& name,const lt_dlhandle module);
|
||||
public:
|
||||
static void register_datasources(const std::string& path);
|
||||
static boost::shared_ptr<datasource> create(parameters const& params);
|
||||
static void register_datasources(const std::string& path);
|
||||
static boost::shared_ptr<datasource> create(parameters const& params);
|
||||
};
|
||||
}
|
||||
#endif //DATASOURCE_CACHE_HPP
|
||||
|
|
|
@ -36,9 +36,11 @@ namespace mapnik
|
|||
std::string const& type,
|
||||
unsigned width,unsigned height);
|
||||
point_symbolizer(point_symbolizer const& rhs);
|
||||
ImageData32 const& get_data() const;
|
||||
void set_data (boost::shared_ptr<ImageData32> symbol);
|
||||
boost::shared_ptr<ImageData32> const& get_data() const;
|
||||
void set_allow_overlap(bool overlap);
|
||||
bool get_allow_overlap() const;
|
||||
|
||||
private:
|
||||
boost::shared_ptr<ImageData32> symbol_;
|
||||
bool overlap_;
|
||||
|
|
|
@ -275,22 +275,25 @@ namespace mapnik
|
|||
{
|
||||
double x;
|
||||
double y;
|
||||
ImageData32 const& data = sym.get_data();
|
||||
geom->label_position(&x,&y);
|
||||
t_.forward_x(&x);
|
||||
t_.forward_y(&y);
|
||||
int w = data.width();
|
||||
int h = data.height();
|
||||
int px=int(floor(x - 0.5 * w));
|
||||
int py=int(floor(y - 0.5 * h));
|
||||
|
||||
if (sym.get_allow_overlap() ||
|
||||
detector_.has_placement(Envelope<double>(floor(x - 0.5 * w),
|
||||
floor(y - 0.5 * h),
|
||||
ceil (x + 0.5 * w),
|
||||
ceil (y + 0.5 * h))))
|
||||
{
|
||||
pixmap_.set_rectangle_alpha(px,py,data);
|
||||
boost::shared_ptr<ImageData32> const& data = sym.get_data();
|
||||
if ( data )
|
||||
{
|
||||
geom->label_position(&x,&y);
|
||||
t_.forward_x(&x);
|
||||
t_.forward_y(&y);
|
||||
int w = data->width();
|
||||
int h = data->height();
|
||||
int px=int(floor(x - 0.5 * w));
|
||||
int py=int(floor(y - 0.5 * h));
|
||||
|
||||
if (sym.get_allow_overlap() ||
|
||||
detector_.has_placement(Envelope<double>(floor(x - 0.5 * w),
|
||||
floor(y - 0.5 * h),
|
||||
ceil (x + 0.5 * w),
|
||||
ceil (y + 0.5 * h))))
|
||||
{
|
||||
pixmap_.set_rectangle_alpha(px,py,*data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,9 +61,14 @@ namespace mapnik
|
|||
overlap_(rhs.overlap_)
|
||||
{}
|
||||
|
||||
ImageData32 const& point_symbolizer::get_data() const
|
||||
void point_symbolizer::set_data( boost::shared_ptr<ImageData32> symbol)
|
||||
{
|
||||
return *(symbol_.get());
|
||||
symbol_ = symbol;
|
||||
}
|
||||
|
||||
boost::shared_ptr<ImageData32> const& point_symbolizer::get_data() const
|
||||
{
|
||||
return symbol_;
|
||||
}
|
||||
|
||||
void point_symbolizer::set_allow_overlap(bool overlap)
|
||||
|
|
Loading…
Reference in a new issue