Remove text_placement_info::initialize() to avoid incorrect usage of this object.
This commit is contained in:
parent
49a3b3c52c
commit
16e5fefb4d
5 changed files with 49 additions and 38 deletions
|
@ -65,8 +65,9 @@ public:
|
||||||
{
|
{
|
||||||
initialize_geometries();
|
initialize_geometries();
|
||||||
if (!geometries_to_process_.size()) return; //TODO: Test this
|
if (!geometries_to_process_.size()) return; //TODO: Test this
|
||||||
placement_ = sym_.get_placement_options()->get_placement_info();
|
placement_ = sym_.get_placement_options()->get_placement_info(
|
||||||
placement_->init(scale_factor, width, height);
|
scale_factor, std::make_pair(width, height), false);
|
||||||
|
//TODO: has_dimensions? Why? When?
|
||||||
if (writer_.first) placement_->collect_extents = true;
|
if (writer_.first) placement_->collect_extents = true;
|
||||||
next_placement();
|
next_placement();
|
||||||
initialize_points();
|
initialize_points();
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace mapnik {
|
||||||
class text_placements;
|
class text_placements;
|
||||||
|
|
||||||
typedef std::pair<double,double> position;
|
typedef std::pair<double,double> position;
|
||||||
|
typedef std::pair<double,double> dimension_type;
|
||||||
|
|
||||||
enum label_placement_enum {
|
enum label_placement_enum {
|
||||||
POINT_PLACEMENT,
|
POINT_PLACEMENT,
|
||||||
|
@ -134,7 +135,8 @@ class text_placement_info : boost::noncopyable
|
||||||
public:
|
public:
|
||||||
/** Constructor. Takes the parent text_placements object as a parameter
|
/** Constructor. Takes the parent text_placements object as a parameter
|
||||||
* to read defaults from it. */
|
* to read defaults from it. */
|
||||||
text_placement_info(text_placements const* parent);
|
text_placement_info(text_placements const* parent,
|
||||||
|
double scale_factor_, dimension_type dim, bool has_dimensions_);
|
||||||
/** Get next placement.
|
/** Get next placement.
|
||||||
* This function is also called before the first placement is tried.
|
* This function is also called before the first placement is tried.
|
||||||
* Each class has to return at least one position!
|
* Each class has to return at least one position!
|
||||||
|
@ -143,11 +145,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool next()=0;
|
virtual bool next()=0;
|
||||||
virtual ~text_placement_info() {}
|
virtual ~text_placement_info() {}
|
||||||
/** Initialize values used by placement finder. Only has to be done once
|
|
||||||
* per object.
|
|
||||||
*/
|
|
||||||
void init(double scale_factor_,
|
|
||||||
unsigned w = 0, unsigned h = 0, bool has_dimensions_ = false);
|
|
||||||
|
|
||||||
/** Properties actually used by placement finder and renderer. Values in
|
/** Properties actually used by placement finder and renderer. Values in
|
||||||
* here are modified each time next() is called. */
|
* here are modified each time next() is called. */
|
||||||
|
@ -158,7 +155,7 @@ public:
|
||||||
/* TODO: Don't know what this is used for. */
|
/* TODO: Don't know what this is used for. */
|
||||||
bool has_dimensions;
|
bool has_dimensions;
|
||||||
/* TODO: Don't know what this is used for. */
|
/* TODO: Don't know what this is used for. */
|
||||||
std::pair<double, double> dimensions;
|
dimension_type dimensions;
|
||||||
/** Set scale factor. */
|
/** Set scale factor. */
|
||||||
void set_scale_factor(double factor) { scale_factor = factor; }
|
void set_scale_factor(double factor) { scale_factor = factor; }
|
||||||
/** Get scale factor. */
|
/** Get scale factor. */
|
||||||
|
@ -204,7 +201,9 @@ public:
|
||||||
* return text_placement_info_ptr(new text_placement_info_XXX(this));
|
* return text_placement_info_ptr(new text_placement_info_XXX(this));
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
virtual text_placement_info_ptr get_placement_info() const =0;
|
virtual text_placement_info_ptr get_placement_info(
|
||||||
|
double scale_factor_, dimension_type dim,
|
||||||
|
bool has_dimensions_) const =0;
|
||||||
/** Get a list of all expressions used in any placement.
|
/** Get a list of all expressions used in any placement.
|
||||||
* This function is used to collect attributes.
|
* This function is used to collect attributes.
|
||||||
*/
|
*/
|
||||||
|
@ -227,7 +226,8 @@ class text_placements_info_dummy;
|
||||||
class MAPNIK_DECL text_placements_dummy: public text_placements
|
class MAPNIK_DECL text_placements_dummy: public text_placements
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
text_placement_info_ptr get_placement_info() const;
|
text_placement_info_ptr get_placement_info(
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions) const;
|
||||||
friend class text_placement_info_dummy;
|
friend class text_placement_info_dummy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -235,7 +235,9 @@ public:
|
||||||
class MAPNIK_DECL text_placement_info_dummy : public text_placement_info
|
class MAPNIK_DECL text_placement_info_dummy : public text_placement_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
text_placement_info_dummy(text_placements_dummy const* parent) : text_placement_info(parent),
|
text_placement_info_dummy(text_placements_dummy const* parent,
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions)
|
||||||
|
: text_placement_info(parent, scale_factor, dim, has_dimensions),
|
||||||
state(0), parent_(parent) {}
|
state(0), parent_(parent) {}
|
||||||
bool next();
|
bool next();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -33,7 +33,8 @@ class text_placements_list: public text_placements
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
text_placements_list();
|
text_placements_list();
|
||||||
text_placement_info_ptr get_placement_info() const;
|
text_placement_info_ptr get_placement_info(
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions) const;
|
||||||
virtual std::set<expression_ptr> get_all_expressions();
|
virtual std::set<expression_ptr> get_all_expressions();
|
||||||
text_symbolizer_properties & add();
|
text_symbolizer_properties & add();
|
||||||
text_symbolizer_properties & get(unsigned i);
|
text_symbolizer_properties & get(unsigned i);
|
||||||
|
@ -48,8 +49,10 @@ private:
|
||||||
class text_placement_info_list : public text_placement_info
|
class text_placement_info_list : public text_placement_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
text_placement_info_list(text_placements_list const* parent) :
|
text_placement_info_list(text_placements_list const* parent,
|
||||||
text_placement_info(parent), state(0), parent_(parent) {}
|
double scale_factor, dimension_type dim, bool has_dimensions) :
|
||||||
|
text_placement_info(parent, scale_factor, dim, has_dimensions),
|
||||||
|
state(0), parent_(parent) {}
|
||||||
bool next();
|
bool next();
|
||||||
private:
|
private:
|
||||||
unsigned state;
|
unsigned state;
|
||||||
|
|
|
@ -49,7 +49,8 @@ class text_placements_simple: public text_placements
|
||||||
public:
|
public:
|
||||||
text_placements_simple();
|
text_placements_simple();
|
||||||
text_placements_simple(std::string positions);
|
text_placements_simple(std::string positions);
|
||||||
text_placement_info_ptr get_placement_info() const;
|
text_placement_info_ptr get_placement_info(
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions) const;
|
||||||
void set_positions(std::string positions);
|
void set_positions(std::string positions);
|
||||||
std::string get_positions();
|
std::string get_positions();
|
||||||
private:
|
private:
|
||||||
|
@ -64,8 +65,12 @@ private:
|
||||||
class text_placement_info_simple : public text_placement_info
|
class text_placement_info_simple : public text_placement_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
text_placement_info_simple(text_placements_simple const* parent) :
|
text_placement_info_simple(text_placements_simple const* parent,
|
||||||
text_placement_info(parent), state(0), position_state(0), parent_(parent) {}
|
double scale_factor, dimension_type dim, bool has_dimensions)
|
||||||
|
: text_placement_info(parent, scale_factor, dim, has_dimensions),
|
||||||
|
state(0), position_state(0), parent_(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
bool next();
|
bool next();
|
||||||
protected:
|
protected:
|
||||||
bool next_position_only();
|
bool next_position_only();
|
||||||
|
|
|
@ -328,10 +328,12 @@ std::set<expression_ptr> text_placements::get_all_expressions()
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
text_placement_info::text_placement_info(text_placements const* parent):
|
text_placement_info::text_placement_info(text_placements const* parent,
|
||||||
properties(parent->properties),
|
double scale_factor_, dimension_type dim, bool has_dimensions_)
|
||||||
scale_factor(1),
|
: properties(parent->properties),
|
||||||
has_dimensions(false),
|
scale_factor(scale_factor_),
|
||||||
|
has_dimensions(has_dimensions_),
|
||||||
|
dimensions(dim),
|
||||||
collect_extents(false)
|
collect_extents(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -344,17 +346,11 @@ bool text_placement_info_dummy::next()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_placement_info_ptr text_placements_dummy::get_placement_info() const
|
text_placement_info_ptr text_placements_dummy::get_placement_info(
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions) const
|
||||||
{
|
{
|
||||||
return text_placement_info_ptr(new text_placement_info_dummy(this));
|
return text_placement_info_ptr(new text_placement_info_dummy(
|
||||||
}
|
this, scale_factor, dim, has_dimensions));
|
||||||
|
|
||||||
void text_placement_info::init(double scale_factor_,
|
|
||||||
unsigned w, unsigned h, bool has_dimensions_)
|
|
||||||
{
|
|
||||||
scale_factor = scale_factor_;
|
|
||||||
dimensions = std::make_pair(w, h);
|
|
||||||
has_dimensions = has_dimensions_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -419,9 +415,11 @@ bool text_placement_info_simple::next_position_only()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_placement_info_ptr text_placements_simple::get_placement_info() const
|
text_placement_info_ptr text_placements_simple::get_placement_info(
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions) const
|
||||||
{
|
{
|
||||||
return text_placement_info_ptr(new text_placement_info_simple(this));
|
return text_placement_info_ptr(new text_placement_info_simple(this,
|
||||||
|
scale_factor, dim, has_dimensions));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Position string: [POS][SIZE]
|
/** Position string: [POS][SIZE]
|
||||||
|
@ -517,9 +515,11 @@ text_symbolizer_properties & text_placements_list::get(unsigned i)
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
text_placement_info_ptr text_placements_list::get_placement_info() const
|
text_placement_info_ptr text_placements_list::get_placement_info(
|
||||||
|
double scale_factor, dimension_type dim, bool has_dimensions) const
|
||||||
{
|
{
|
||||||
return text_placement_info_ptr(new text_placement_info_list(this));
|
return text_placement_info_ptr(new text_placement_info_list(this,
|
||||||
|
scale_factor, dim, has_dimensions));
|
||||||
}
|
}
|
||||||
|
|
||||||
text_placements_list::text_placements_list() : text_placements(), list_(0)
|
text_placements_list::text_placements_list() : text_placements(), list_(0)
|
||||||
|
|
Loading…
Reference in a new issue