start marking as much of the text structures as const as possible - refs #2516
This commit is contained in:
parent
2d88f736fe
commit
c6ed108a72
13 changed files with 38 additions and 39 deletions
|
@ -74,7 +74,7 @@ public:
|
||||||
box_elements_.clear();
|
box_elements_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline text_symbolizer_properties const& get_properties()
|
inline text_symbolizer_properties const& get_properties() const
|
||||||
{
|
{
|
||||||
return placement_->properties;
|
return placement_->properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
attributes const& attr,
|
attributes const& attr,
|
||||||
DetectorType & detector,
|
DetectorType & detector,
|
||||||
box2d<double> const& extent,
|
box2d<double> const& extent,
|
||||||
text_placement_info & placement_info,
|
text_placement_info const& placement_info,
|
||||||
face_manager_freetype & font_manager,
|
face_manager_freetype & font_manager,
|
||||||
double scale_factor);
|
double scale_factor);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ private:
|
||||||
attributes const& attr_;
|
attributes const& attr_;
|
||||||
DetectorType & detector_;
|
DetectorType & detector_;
|
||||||
box2d<double> const& extent_;
|
box2d<double> const& extent_;
|
||||||
text_placement_info & info_;
|
text_placement_info const& info_;
|
||||||
layout_container layouts_;
|
layout_container layouts_;
|
||||||
|
|
||||||
double scale_factor_;
|
double scale_factor_;
|
||||||
|
|
|
@ -49,12 +49,12 @@ public:
|
||||||
// If this functions returns false the placement data should be
|
// If this functions returns false the placement data should be
|
||||||
// considered invalid!
|
// considered invalid!
|
||||||
|
|
||||||
virtual bool next() = 0;
|
virtual bool next() const = 0;
|
||||||
virtual ~text_placement_info() {}
|
virtual ~text_placement_info() {}
|
||||||
|
|
||||||
// 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.
|
||||||
text_symbolizer_properties properties;
|
mutable text_symbolizer_properties properties;
|
||||||
|
|
||||||
// Scale factor used by the renderer.
|
// Scale factor used by the renderer.
|
||||||
double scale_factor;
|
double scale_factor;
|
||||||
|
|
|
@ -46,9 +46,9 @@ public:
|
||||||
text_placement_info_dummy(text_placements_dummy const* parent, double scale_factor)
|
text_placement_info_dummy(text_placements_dummy const* parent, double scale_factor)
|
||||||
: text_placement_info(parent, scale_factor),
|
: text_placement_info(parent, scale_factor),
|
||||||
state(0) {}
|
state(0) {}
|
||||||
bool next();
|
bool next() const;
|
||||||
private:
|
private:
|
||||||
unsigned state;
|
mutable unsigned state;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //ns mapnik
|
} //ns mapnik
|
||||||
|
|
|
@ -52,9 +52,9 @@ public:
|
||||||
text_placement_info_list(text_placements_list const* parent, double scale_factor) :
|
text_placement_info_list(text_placements_list const* parent, double scale_factor) :
|
||||||
text_placement_info(parent, scale_factor),
|
text_placement_info(parent, scale_factor),
|
||||||
state(0), parent_(parent) {}
|
state(0), parent_(parent) {}
|
||||||
bool next();
|
bool next() const;
|
||||||
private:
|
private:
|
||||||
unsigned state;
|
mutable unsigned state;
|
||||||
text_placements_list const* parent_;
|
text_placements_list const* parent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,11 @@ public:
|
||||||
double scale_factor)
|
double scale_factor)
|
||||||
: text_placement_info(parent, scale_factor),
|
: text_placement_info(parent, scale_factor),
|
||||||
state(0), position_state(0), parent_(parent) {}
|
state(0), position_state(0), parent_(parent) {}
|
||||||
bool next();
|
bool next() const;
|
||||||
protected:
|
protected:
|
||||||
bool next_position_only();
|
bool next_position_only() const;
|
||||||
unsigned state;
|
mutable unsigned state;
|
||||||
unsigned position_state;
|
mutable unsigned position_state;
|
||||||
text_placements_simple const* parent_;
|
text_placements_simple const* parent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ public:
|
||||||
box2d<double> const& query_extent);
|
box2d<double> const& query_extent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initialize_geometries();
|
void initialize_geometries() const;
|
||||||
void initialize_points();
|
void initialize_points() const;
|
||||||
|
|
||||||
//Input
|
//Input
|
||||||
symbolizer_base const& sym_;
|
symbolizer_base const& sym_;
|
||||||
|
@ -87,16 +87,15 @@ protected:
|
||||||
//Processing
|
//Processing
|
||||||
// Using list instead of vector, because we delete random elements and need iterators to stay valid.
|
// Using list instead of vector, because we delete random elements and need iterators to stay valid.
|
||||||
// Remaining geometries to be processed.
|
// Remaining geometries to be processed.
|
||||||
std::list<geometry_type*> geometries_to_process_;
|
mutable std::list<geometry_type*> geometries_to_process_;
|
||||||
// Remaining points to be processed.
|
// Remaining points to be processed.
|
||||||
std::list<pixel_position> points_;
|
mutable std::list<pixel_position> points_;
|
||||||
// Geometry currently being processed.
|
// Geometry currently being processed.
|
||||||
std::list<geometry_type*>::iterator geo_itr_;
|
mutable std::list<geometry_type*>::iterator geo_itr_;
|
||||||
// Point currently being processed.
|
// Point currently being processed.
|
||||||
std::list<pixel_position>::iterator point_itr_;
|
mutable std::list<pixel_position>::iterator point_itr_;
|
||||||
// Use point placement. Otherwise line placement is used.
|
// Use point placement. Otherwise line placement is used.
|
||||||
bool point_placement_;
|
mutable bool point_placement_;
|
||||||
|
|
||||||
text_placement_info_ptr placement_;
|
text_placement_info_ptr placement_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,17 +134,17 @@ public:
|
||||||
agg::trans_affine const&);
|
agg::trans_affine const&);
|
||||||
|
|
||||||
// Return all placements.
|
// Return all placements.
|
||||||
placements_list const& get();
|
placements_list const& get() const;
|
||||||
protected:
|
protected:
|
||||||
bool next_point_placement();
|
bool next_point_placement() const;
|
||||||
bool next_line_placement();
|
bool next_line_placement() const;
|
||||||
|
|
||||||
placement_finder finder_;
|
mutable placement_finder finder_;
|
||||||
|
|
||||||
placement_finder_adapter<placement_finder> adapter_;
|
placement_finder_adapter<placement_finder> adapter_;
|
||||||
vertex_converter_type converter_;
|
mutable vertex_converter_type converter_;
|
||||||
//ShieldSymbolizer only
|
//ShieldSymbolizer only
|
||||||
void init_marker();
|
void init_marker() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
|
@ -44,7 +44,7 @@ placement_finder::placement_finder(feature_impl const& feature,
|
||||||
attributes const& attr,
|
attributes const& attr,
|
||||||
DetectorType &detector,
|
DetectorType &detector,
|
||||||
box2d<double> const& extent,
|
box2d<double> const& extent,
|
||||||
text_placement_info & placement_info,
|
text_placement_info const& placement_info,
|
||||||
face_manager_freetype & font_manager,
|
face_manager_freetype & font_manager,
|
||||||
double scale_factor)
|
double scale_factor)
|
||||||
: feature_(feature),
|
: feature_(feature),
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
bool text_placement_info_dummy::next()
|
bool text_placement_info_dummy::next() const
|
||||||
{
|
{
|
||||||
if (state) return false;
|
if (state) return false;
|
||||||
++state;
|
++state;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
bool text_placement_info_list::next()
|
bool text_placement_info_list::next() const
|
||||||
{
|
{
|
||||||
if (state == 0)
|
if (state == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace phoenix = boost::phoenix;
|
||||||
using phoenix::push_back;
|
using phoenix::push_back;
|
||||||
using phoenix::ref;
|
using phoenix::ref;
|
||||||
|
|
||||||
bool text_placement_info_simple::next()
|
bool text_placement_info_simple::next() const
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ bool text_placement_info_simple::next()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool text_placement_info_simple::next_position_only()
|
bool text_placement_info_simple::next_position_only() const
|
||||||
{
|
{
|
||||||
if (position_state >= parent_->direction_.size()) return false;
|
if (position_state >= parent_->direction_.size()) return false;
|
||||||
//directions_e dir = parent_->direction_[position_state];
|
//directions_e dir = parent_->direction_[position_state];
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct largest_bbox_first
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void base_symbolizer_helper::initialize_geometries()
|
void base_symbolizer_helper::initialize_geometries() const
|
||||||
{
|
{
|
||||||
bool largest_box_only = placement_->properties.largest_bbox_only;
|
bool largest_box_only = placement_->properties.largest_bbox_only;
|
||||||
double minimum_path_length = placement_->properties.minimum_path_length;
|
double minimum_path_length = placement_->properties.minimum_path_length;
|
||||||
|
@ -109,7 +109,7 @@ void base_symbolizer_helper::initialize_geometries()
|
||||||
geo_itr_ = geometries_to_process_.begin();
|
geo_itr_ = geometries_to_process_.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void base_symbolizer_helper::initialize_points()
|
void base_symbolizer_helper::initialize_points() const
|
||||||
{
|
{
|
||||||
label_placement_enum how_placed = placement_->properties.label_placement;
|
label_placement_enum how_placed = placement_->properties.label_placement;
|
||||||
if (how_placed == LINE_PLACEMENT)
|
if (how_placed == LINE_PLACEMENT)
|
||||||
|
@ -202,7 +202,7 @@ text_symbolizer_helper::text_symbolizer_helper(
|
||||||
if (geometries_to_process_.size()) finder_.next_position();
|
if (geometries_to_process_.size()) finder_.next_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
placements_list const& text_symbolizer_helper::get()
|
placements_list const& text_symbolizer_helper::get() const
|
||||||
{
|
{
|
||||||
if (point_placement_)
|
if (point_placement_)
|
||||||
{
|
{
|
||||||
|
@ -215,7 +215,7 @@ placements_list const& text_symbolizer_helper::get()
|
||||||
return finder_.placements();
|
return finder_.placements();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool text_symbolizer_helper::next_line_placement()
|
bool text_symbolizer_helper::next_line_placement() const
|
||||||
{
|
{
|
||||||
while (!geometries_to_process_.empty())
|
while (!geometries_to_process_.empty())
|
||||||
{
|
{
|
||||||
|
@ -241,7 +241,7 @@ bool text_symbolizer_helper::next_line_placement()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool text_symbolizer_helper::next_point_placement()
|
bool text_symbolizer_helper::next_point_placement() const
|
||||||
{
|
{
|
||||||
while (!points_.empty())
|
while (!points_.empty())
|
||||||
{
|
{
|
||||||
|
@ -297,7 +297,7 @@ text_symbolizer_helper::text_symbolizer_helper(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void text_symbolizer_helper::init_marker()
|
void text_symbolizer_helper::init_marker() const
|
||||||
{
|
{
|
||||||
std::string filename = mapnik::get<std::string>(sym_, keys::file, feature_, vars_);
|
std::string filename = mapnik::get<std::string>(sym_, keys::file, feature_, vars_);
|
||||||
if (filename.empty()) return;
|
if (filename.empty()) return;
|
||||||
|
|
|
@ -59,7 +59,7 @@ text_symbolizer_properties::text_symbolizer_properties()
|
||||||
tree_() {}
|
tree_() {}
|
||||||
|
|
||||||
|
|
||||||
void text_symbolizer_properties::evaluate_text_properties(feature_impl const& feature, attributes const& attrs)
|
void text_symbolizer_properties::evaluate_text_properties(feature_impl const& feature, attributes const& attrs) //const
|
||||||
{
|
{
|
||||||
label_placement = util::apply_visitor(extract_value<label_placement_enum>(feature,attrs), expressions.label_placement);
|
label_placement = util::apply_visitor(extract_value<label_placement_enum>(feature,attrs), expressions.label_placement);
|
||||||
label_spacing = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.label_spacing);
|
label_spacing = util::apply_visitor(extract_value<value_double>(feature,attrs), expressions.label_spacing);
|
||||||
|
|
Loading…
Reference in a new issue