pass text_placement_info by ref to placement_finder + formatting
This commit is contained in:
parent
8c6015ec60
commit
6cd7026aac
3 changed files with 24 additions and 24 deletions
|
@ -48,7 +48,7 @@ public:
|
||||||
attributes const& attr,
|
attributes const& attr,
|
||||||
DetectorType & detector,
|
DetectorType & detector,
|
||||||
box2d<double> const& extent,
|
box2d<double> const& extent,
|
||||||
text_placement_info_ptr & placement_info,
|
text_placement_info & placement_info,
|
||||||
face_manager_freetype & font_manager,
|
face_manager_freetype & font_manager,
|
||||||
double scale_factor);
|
double scale_factor);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ private:
|
||||||
attributes const& attr_;
|
attributes const& attr_;
|
||||||
DetectorType & detector_;
|
DetectorType & detector_;
|
||||||
box2d<double> const& extent_;
|
box2d<double> const& extent_;
|
||||||
text_placement_info_ptr & info_;
|
text_placement_info & info_;
|
||||||
layout_container layouts_;
|
layout_container layouts_;
|
||||||
bool valid_;
|
bool valid_;
|
||||||
|
|
||||||
|
|
|
@ -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_ptr & placement_info,
|
text_placement_info & placement_info,
|
||||||
face_manager_freetype & font_manager,
|
face_manager_freetype & font_manager,
|
||||||
double scale_factor)
|
double scale_factor)
|
||||||
: feature_(feature),
|
: feature_(feature),
|
||||||
|
@ -69,15 +69,15 @@ bool placement_finder::next_position()
|
||||||
MAPNIK_LOG_WARN(placement_finder) << "next_position() called while last call already returned false!\n";
|
MAPNIK_LOG_WARN(placement_finder) << "next_position() called while last call already returned false!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!info_->next())
|
if (!info_.next())
|
||||||
{
|
{
|
||||||
valid_ = false;
|
valid_ = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_layout_ptr layout = std::make_shared<text_layout>(font_manager_, scale_factor_, info_->properties.layout_defaults);
|
text_layout_ptr layout = std::make_shared<text_layout>(font_manager_, scale_factor_, info_.properties.layout_defaults);
|
||||||
layout->init_orientation(feature_, attr_);
|
layout->init_orientation(feature_, attr_);
|
||||||
info_->properties.process(*layout, feature_, attr_);
|
info_.properties.process(*layout, feature_, attr_);
|
||||||
|
|
||||||
layouts_.clear();
|
layouts_.clear();
|
||||||
layouts_.add(layout);
|
layouts_.add(layout);
|
||||||
|
@ -197,7 +197,7 @@ bool placement_finder::find_line_placements(T & path, bool points)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((pp.length() < info_->properties.minimum_path_length * scale_factor_)
|
if ((pp.length() < info_.properties.minimum_path_length * scale_factor_)
|
||||||
||
|
||
|
||||||
(pp.length() <= 0.001) /* Clipping removed whole geometry */
|
(pp.length() <= 0.001) /* Clipping removed whole geometry */
|
||||||
||
|
||
|
||||||
|
@ -209,7 +209,7 @@ bool placement_finder::find_line_placements(T & path, bool points)
|
||||||
|
|
||||||
double spacing = get_spacing(pp.length(), points ? 0. : layouts_.width());
|
double spacing = get_spacing(pp.length(), points ? 0. : layouts_.width());
|
||||||
|
|
||||||
horizontal_alignment_e halign = info_->properties.layout_defaults.halign;
|
horizontal_alignment_e halign = info_.properties.layout_defaults.halign;
|
||||||
if (halign == H_LEFT)
|
if (halign == H_LEFT)
|
||||||
{
|
{
|
||||||
// Don't move
|
// Don't move
|
||||||
|
@ -225,14 +225,14 @@ bool placement_finder::find_line_placements(T & path, bool points)
|
||||||
path_move_dx(pp);
|
path_move_dx(pp);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
tolerance_iterator tolerance_offset(info_->properties.label_position_tolerance * scale_factor_, spacing); //TODO: Handle halign
|
tolerance_iterator tolerance_offset(info_.properties.label_position_tolerance * scale_factor_, spacing); //TODO: Handle halign
|
||||||
while (tolerance_offset.next())
|
while (tolerance_offset.next())
|
||||||
{
|
{
|
||||||
vertex_cache::scoped_state state(pp);
|
vertex_cache::scoped_state state(pp);
|
||||||
if (pp.move(tolerance_offset.get())
|
if (pp.move(tolerance_offset.get())
|
||||||
&& (
|
&& (
|
||||||
(points && find_point_placement(pp.current_position()))
|
(points && find_point_placement(pp.current_position()))
|
||||||
|| (!points && single_line_placement(pp, info_->properties.upright))))
|
|| (!points && single_line_placement(pp, info_.properties.upright))))
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
|
@ -296,8 +296,8 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
|
||||||
// Only calculate new angle at the start of each cluster!
|
// Only calculate new angle at the start of each cluster!
|
||||||
angle = normalize_angle(off_pp.angle(sign * layout.cluster_width(current_cluster)));
|
angle = normalize_angle(off_pp.angle(sign * layout.cluster_width(current_cluster)));
|
||||||
rot.init(angle);
|
rot.init(angle);
|
||||||
if ((info_->properties.max_char_angle_delta > 0) && (last_cluster_angle != 999) &&
|
if ((info_.properties.max_char_angle_delta > 0) && (last_cluster_angle != 999) &&
|
||||||
std::fabs(normalize_angle(angle-last_cluster_angle)) > info_->properties.max_char_angle_delta)
|
std::fabs(normalize_angle(angle-last_cluster_angle)) > info_.properties.max_char_angle_delta)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
|
||||||
|
|
||||||
void placement_finder::path_move_dx(vertex_cache &pp)
|
void placement_finder::path_move_dx(vertex_cache &pp)
|
||||||
{
|
{
|
||||||
double dx = info_->properties.layout_defaults.displacement.x * scale_factor_;
|
double dx = info_.properties.layout_defaults.displacement.x * scale_factor_;
|
||||||
if (dx != 0.0)
|
if (dx != 0.0)
|
||||||
{
|
{
|
||||||
vertex_cache::state state = pp.save_state();
|
vertex_cache::state state = pp.save_state();
|
||||||
|
@ -376,13 +376,13 @@ double placement_finder::normalize_angle(double angle)
|
||||||
double placement_finder::get_spacing(double path_length, double layout_width) const
|
double placement_finder::get_spacing(double path_length, double layout_width) const
|
||||||
{
|
{
|
||||||
int num_labels = 1;
|
int num_labels = 1;
|
||||||
if (info_->properties.label_spacing > 0)
|
if (info_.properties.label_spacing > 0)
|
||||||
{
|
{
|
||||||
num_labels = static_cast<int>(floor(
|
num_labels = static_cast<int>(floor(
|
||||||
path_length / (info_->properties.label_spacing * scale_factor_ + layout_width)));
|
path_length / (info_.properties.label_spacing * scale_factor_ + layout_width)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info_->properties.force_odd_labels && num_labels % 2 == 0)
|
if (info_.properties.force_odd_labels && num_labels % 2 == 0)
|
||||||
{
|
{
|
||||||
--num_labels;
|
--num_labels;
|
||||||
}
|
}
|
||||||
|
@ -397,13 +397,13 @@ bool placement_finder::collision(const box2d<double> &box) const
|
||||||
{
|
{
|
||||||
if (!detector_.extent().intersects(box)
|
if (!detector_.extent().intersects(box)
|
||||||
||
|
||
|
||||||
(info_->properties.avoid_edges && !extent_.contains(box))
|
(info_.properties.avoid_edges && !extent_.contains(box))
|
||||||
||
|
||
|
||||||
(info_->properties.minimum_padding > 0 &&
|
(info_.properties.minimum_padding > 0 &&
|
||||||
!extent_.contains(box + (scale_factor_ * info_->properties.minimum_padding)))
|
!extent_.contains(box + (scale_factor_ * info_.properties.minimum_padding)))
|
||||||
||
|
||
|
||||||
(!info_->properties.allow_overlap &&
|
(!info_.properties.allow_overlap &&
|
||||||
!detector_.has_point_placement(box, info_->properties.minimum_distance * scale_factor_))
|
!detector_.has_point_placement(box, info_.properties.minimum_distance * scale_factor_))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -182,7 +182,7 @@ text_symbolizer_helper::text_symbolizer_helper(
|
||||||
CoordTransform const& t, FaceManagerT & font_manager,
|
CoordTransform const& t, FaceManagerT & font_manager,
|
||||||
DetectorT &detector, const box2d<double> &query_extent)
|
DetectorT &detector, const box2d<double> &query_extent)
|
||||||
: base_symbolizer_helper(sym, feature, vars, prj_trans, width, height, scale_factor, t, query_extent),
|
: base_symbolizer_helper(sym, feature, vars, prj_trans, width, height, scale_factor, t, query_extent),
|
||||||
finder_(feature, vars, detector, dims_, placement_, font_manager, scale_factor),
|
finder_(feature, vars, detector, dims_, *placement_, font_manager, scale_factor),
|
||||||
points_on_line_(false)
|
points_on_line_(false)
|
||||||
{
|
{
|
||||||
if (geometries_to_process_.size()) finder_.next_position();
|
if (geometries_to_process_.size()) finder_.next_position();
|
||||||
|
@ -279,7 +279,7 @@ text_symbolizer_helper::text_symbolizer_helper(
|
||||||
CoordTransform const& t, FaceManagerT & font_manager,
|
CoordTransform const& t, FaceManagerT & font_manager,
|
||||||
DetectorT &detector, const box2d<double> &query_extent)
|
DetectorT &detector, const box2d<double> &query_extent)
|
||||||
: base_symbolizer_helper(sym, feature, vars, prj_trans, width, height, scale_factor, t, query_extent),
|
: base_symbolizer_helper(sym, feature, vars, prj_trans, width, height, scale_factor, t, query_extent),
|
||||||
finder_(feature, vars, detector, dims_, placement_, font_manager, scale_factor),
|
finder_(feature, vars, detector, dims_, *placement_, font_manager, scale_factor),
|
||||||
points_on_line_(true)
|
points_on_line_(true)
|
||||||
{
|
{
|
||||||
if (geometries_to_process_.size())
|
if (geometries_to_process_.size())
|
||||||
|
|
Loading…
Reference in a new issue