Rename starting_{x,y} to center to reflect actual meaning.

This commit is contained in:
Hermann Kraus 2012-02-18 13:07:23 +01:00
parent db168a0db7
commit bb3ad18c95
13 changed files with 108 additions and 106 deletions

View file

@ -345,8 +345,8 @@ struct text_renderer : private boost::noncopyable
text_renderer (pixmap_type & pixmap, face_manager<freetype_engine> &font_manager_, stroker & s); text_renderer (pixmap_type & pixmap, face_manager<freetype_engine> &font_manager_, stroker & s);
box2d<double> prepare_glyphs(text_path *path); box2d<double> prepare_glyphs(text_path *path);
void render(double x0, double y0); void render(pixel_position pos);
void render_id(int feature_id,double x0, double y0, double min_radius=1.0); void render_id(int feature_id, pixel_position pos, double min_radius=1.0);
private: private:
void render_bitmap(FT_Bitmap *bitmap, unsigned rgba, int x, int y, double opacity) void render_bitmap(FT_Bitmap *bitmap, unsigned rgba, int x, int y, double opacity)

View file

@ -27,8 +27,8 @@ struct pixel_position
{ {
double x; double x;
double y; double y;
pixel_coord(double x, double y) : x(x), y(y) { } pixel_position(double x, double y) : x(x), y(y) { }
pixel_coord() : x(0), y(0) { } pixel_position() : x(0), y(0) { }
}; };
#endif // MAPNIK_PIXEL_POSITION_HPP #endif // MAPNIK_PIXEL_POSITION_HPP

View file

@ -96,8 +96,17 @@ private:
string_info &info_; string_info &info_;
text_symbolizer_properties &p; text_symbolizer_properties &p;
text_placement_info &pi; text_placement_info &pi;
/** Length of the longest line after linebreaks.
* Before find_line_breaks() this is the total length of the string.
*/
double string_width_; double string_width_;
/** Height of the string after linebreaks.
* Before find_line_breaks() this is the total length of the string.
*/
double string_height_; double string_height_;
/** Height of the tallest font in the first line not including line spacing.
* Used to determine the correct offset for the first line.
*/
double first_line_space_; double first_line_space_;
vertical_alignment_e valign_; vertical_alignment_e valign_;
horizontal_alignment_e halign_; horizontal_alignment_e halign_;

View file

@ -25,6 +25,7 @@
// mapnik // mapnik
#include <mapnik/char_info.hpp> #include <mapnik/char_info.hpp>
#include <mapnik/pixel_position.hpp>
//stl //stl
#include <vector> #include <vector>
@ -124,18 +125,23 @@ class text_path : boost::noncopyable
struct character_node struct character_node
{ {
int c; int c;
double x, y, angle; pixel_position pos;
double angle;
char_properties *format; char_properties *format;
character_node(int c_, double x_, double y_, double angle_, char_properties *format_) character_node(int c_, double x_, double y_, double angle_, char_properties *format_)
: c(c_), x(x_), y(y_), angle(angle_), format(format_) {} : c(c_), pos(x_, y_), angle(angle_), format(format_)
{
}
~character_node() {} ~character_node() {}
void vertex(int *c_, double *x_, double *y_, double *angle_, char_properties **format_) void vertex(int *c_, double *x_, double *y_, double *angle_, char_properties **format_)
{ {
*c_ = c; *c_ = c;
*x_ = x; *x_ = pos.x;
*y_ = y; *y_ = pos.y;
*angle_ = angle; *angle_ = angle;
*format_ = format; *format_ = format;
} }
@ -145,16 +151,11 @@ class text_path : boost::noncopyable
public: public:
typedef std::vector<character_node> character_nodes_t; typedef std::vector<character_node> character_nodes_t;
character_nodes_t nodes_; character_nodes_t nodes_;
double starting_x;
double starting_y;
// std::pair<unsigned,unsigned> string_dimensions; pixel_position center;
text_path() text_path()
: itr_(0), : itr_(0)
starting_x(0),
starting_y(0)
{ {
} }

View file

@ -57,10 +57,8 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
std::pair<int, int> marker_pos = helper.get_marker_position(placement->placements[ii]); std::pair<int, int> marker_pos = helper.get_marker_position(placement->placements[ii]);
render_marker(marker_pos.first, marker_pos.second, helper.get_marker(), helper.get_transform(), sym.get_opacity()); render_marker(marker_pos.first, marker_pos.second, helper.get_marker(), helper.get_transform(), sym.get_opacity());
double x = placement->placements[ii].starting_x;
double y = placement->placements[ii].starting_y;
ren.prepare_glyphs(&(placement->placements[ii])); ren.prepare_glyphs(&(placement->placements[ii]));
ren.render(x, y); ren.render(placement->placements[ii].center);
} }
} }
} }

View file

@ -46,10 +46,8 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
while ((placement = helper.get_placement())) { while ((placement = helper.get_placement())) {
for (unsigned int ii = 0; ii < placement->placements.size(); ++ii) for (unsigned int ii = 0; ii < placement->placements.size(); ++ii)
{ {
double x = placement->placements[ii].starting_x;
double y = placement->placements[ii].starting_y;
ren.prepare_glyphs(&(placement->placements[ii])); ren.prepare_glyphs(&(placement->placements[ii]));
ren.render(x, y); ren.render(placement->placements[ii].center);
} }
} }
} }

View file

@ -575,8 +575,8 @@ public:
cairo_face_manager & manager, cairo_face_manager & manager,
face_manager<freetype_engine> &font_manager) face_manager<freetype_engine> &font_manager)
{ {
double sx = path.starting_x; double sx = path.center.x;
double sy = path.starting_y; double sy = path.center.y;
path.rewind(); path.rewind();

View file

@ -379,25 +379,25 @@ box2d<double> text_renderer<T>::prepare_glyphs(text_path *path)
} }
template <typename T> template <typename T>
void text_renderer<T>::render(double x0, double y0) void text_renderer<T>::render(pixel_position pos)
{ {
FT_Error error; FT_Error error;
FT_Vector start; FT_Vector start;
unsigned height = pixmap_.height(); unsigned height = pixmap_.height();
start.x = static_cast<FT_Pos>(x0 * (1 << 6)); start.x = static_cast<FT_Pos>(pos.x * (1 << 6));
start.y = static_cast<FT_Pos>((height - y0) * (1 << 6)); start.y = static_cast<FT_Pos>((height - pos.y) * (1 << 6));
// now render transformed glyphs // now render transformed glyphs
typename glyphs_t::iterator pos; typename glyphs_t::iterator itr;
for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) for (itr = glyphs_.begin(); itr != glyphs_.end(); ++itr)
{ {
double halo_radius = pos->properties->halo_radius; double halo_radius = itr->properties->halo_radius;
//make sure we've got reasonable values. //make sure we've got reasonable values.
if (halo_radius <= 0.0 || halo_radius > 1024.0) continue; if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
stroker_.init(halo_radius); stroker_.init(halo_radius);
FT_Glyph g; FT_Glyph g;
error = FT_Glyph_Copy(pos->image, &g); error = FT_Glyph_Copy(itr->image, &g);
if (!error) if (!error)
{ {
FT_Glyph_Transform(g,0,&start); FT_Glyph_Transform(g,0,&start);
@ -407,49 +407,49 @@ void text_renderer<T>::render(double x0, double y0)
{ {
FT_BitmapGlyph bit = (FT_BitmapGlyph)g; FT_BitmapGlyph bit = (FT_BitmapGlyph)g;
render_bitmap(&bit->bitmap, pos->properties->halo_fill.rgba(), render_bitmap(&bit->bitmap, itr->properties->halo_fill.rgba(),
bit->left, bit->left,
height - bit->top, pos->properties->text_opacity); height - bit->top, itr->properties->text_opacity);
} }
} }
FT_Done_Glyph(g); FT_Done_Glyph(g);
} }
//render actual text //render actual text
for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) for (itr = glyphs_.begin(); itr != glyphs_.end(); ++itr)
{ {
FT_Glyph_Transform(pos->image,0,&start); FT_Glyph_Transform(itr->image,0,&start);
error = FT_Glyph_To_Bitmap( &(pos->image),FT_RENDER_MODE_NORMAL,0,1); error = FT_Glyph_To_Bitmap( &(itr->image),FT_RENDER_MODE_NORMAL,0,1);
if ( ! error ) if ( ! error )
{ {
FT_BitmapGlyph bit = (FT_BitmapGlyph)pos->image; FT_BitmapGlyph bit = (FT_BitmapGlyph)itr->image;
render_bitmap(&bit->bitmap, pos->properties->fill.rgba(), render_bitmap(&bit->bitmap, itr->properties->fill.rgba(),
bit->left, bit->left,
height - bit->top, pos->properties->text_opacity); height - bit->top, itr->properties->text_opacity);
} }
} }
} }
template <typename T> template <typename T>
void text_renderer<T>::render_id(int feature_id,double x0, double y0, double min_radius) void text_renderer<T>::render_id(int feature_id, pixel_position pos, double min_radius)
{ {
FT_Error error; FT_Error error;
FT_Vector start; FT_Vector start;
unsigned height = pixmap_.height(); unsigned height = pixmap_.height();
start.x = static_cast<FT_Pos>(x0 * (1 << 6)); start.x = static_cast<FT_Pos>(pos.x * (1 << 6));
start.y = static_cast<FT_Pos>((height - y0) * (1 << 6)); start.y = static_cast<FT_Pos>((height - pos.y) * (1 << 6));
// now render transformed glyphs // now render transformed glyphs
typename glyphs_t::iterator pos; typename glyphs_t::iterator itr;
for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) for (itr = glyphs_.begin(); itr != glyphs_.end(); ++itr)
{ {
stroker_.init(std::max(pos->properties->halo_radius, min_radius)); stroker_.init(std::max(itr->properties->halo_radius, min_radius));
FT_Glyph g; FT_Glyph g;
error = FT_Glyph_Copy(pos->image, &g); error = FT_Glyph_Copy(itr->image, &g);
if (!error) if (!error)
{ {
FT_Glyph_Transform(g,0,&start); FT_Glyph_Transform(g,0,&start);
@ -473,11 +473,11 @@ void text_renderer<T>::render_id(int feature_id,double x0, double y0, double min
boost::mutex freetype_engine::mutex_; boost::mutex freetype_engine::mutex_;
#endif #endif
std::map<std::string,std::pair<int,std::string> > freetype_engine::name2file_; std::map<std::string,std::pair<int,std::string> > freetype_engine::name2file_;
template void text_renderer<image_32>::render(double, double); template void text_renderer<image_32>::render(pixel_position);
template text_renderer<image_32>::text_renderer(image_32&, face_manager<freetype_engine>&, stroker&); template text_renderer<image_32>::text_renderer(image_32&, face_manager<freetype_engine>&, stroker&);
template box2d<double>text_renderer<image_32>::prepare_glyphs(text_path*); template box2d<double>text_renderer<image_32>::prepare_glyphs(text_path*);
template void text_renderer<grid>::render_id(int, double, double, double); template void text_renderer<grid>::render_id(int, pixel_position, double);
template text_renderer<grid>::text_renderer(grid&, face_manager<freetype_engine>&, stroker&); template text_renderer<grid>::text_renderer(grid&, face_manager<freetype_engine>&, stroker&);
template box2d<double>text_renderer<grid>::prepare_glyphs(text_path*); template box2d<double>text_renderer<grid>::prepare_glyphs(text_path*);
} }

View file

@ -66,10 +66,8 @@ void grid_renderer<T>::process(shield_symbolizer const& sym,
helper.get_marker(), helper.get_transform(), helper.get_marker(), helper.get_transform(),
sym.get_opacity()); sym.get_opacity());
double x = floor(placement->placements[ii].starting_x);
double y = floor(placement->placements[ii].starting_y);
ren.prepare_glyphs(&(placement->placements[ii])); ren.prepare_glyphs(&(placement->placements[ii]));
ren.render_id(feature->id(), x, y, 2); ren.render_id(feature->id(),placement->placements[ii].center, 2);
} }
} }
if (placement_found) if (placement_found)

View file

@ -47,10 +47,8 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
placement_found = true; placement_found = true;
for (unsigned int ii = 0; ii < placement->placements.size(); ++ii) for (unsigned int ii = 0; ii < placement->placements.size(); ++ii)
{ {
double x = placement->placements[ii].starting_x;
double y = placement->placements[ii].starting_y;
ren.prepare_glyphs(&(placement->placements[ii])); ren.prepare_glyphs(&(placement->placements[ii]));
ren.render_id(feature->id(),x,y,2); ren.render_id(feature->id(), placement->placements[ii].center,2);
} }
} }
if (placement_found) pixmap_.add_feature(feature); if (placement_found) pixmap_.add_feature(feature);

View file

@ -202,8 +202,8 @@ void metawriter_json_stream::add_text(text_placement_info const& p,
char_properties *format; char_properties *format;
current_placement.rewind(); current_placement.rewind();
for (int i = 0; i < current_placement.num_nodes(); ++i) { for (int i = 0; i < current_placement.num_nodes(); ++i) {
int cx = current_placement.starting_x; int cx = current_placement.center.x;
int cy = current_placement.starting_y; int cy = current_placement.center.y;
current_placement.vertex(&c, &x, &y, &angle, &format); current_placement.vertex(&c, &x, &y, &angle, &format);
if (cx+x >= 0 && cx+x < width_ && cy-y >= 0 && cy-y < height_) inside = true; if (cx+x >= 0 && cx+x < width_ && cy-y >= 0 && cy-y < height_) inside = true;
if (angle > 0.001 || angle < -0.001) straight = false; if (angle > 0.001 || angle < -0.001) straight = false;
@ -225,10 +225,10 @@ void metawriter_json_stream::add_text(text_placement_info const& p,
maxy = std::max(maxy, y+ci.ymax); maxy = std::max(maxy, y+ci.ymax);
miny = std::min(miny, y+ci.ymin); miny = std::min(miny, y+ci.ymin);
} }
add_box(box2d<double>(current_placement.starting_x+minx, add_box(box2d<double>(current_placement.center.x+minx,
current_placement.starting_y-miny, current_placement.center.y-miny,
current_placement.starting_x+maxx, current_placement.center.x+maxx,
current_placement.starting_y-maxy), feature, t, properties); current_placement.center.y-maxy), feature, t, properties);
continue; continue;
} }
@ -247,8 +247,8 @@ void metawriter_json_stream::add_text(text_placement_info const& p,
double x0, y0, x1, y1, x2, y2, x3, y3; double x0, y0, x1, y1, x2, y2, x3, y3;
double sina = sin(angle); double sina = sin(angle);
double cosa = cos(angle); double cosa = cos(angle);
x0 = current_placement.starting_x + x - sina*ci.ymin; x0 = current_placement.center.x + x - sina*ci.ymin;
y0 = current_placement.starting_y - y - cosa*ci.ymin; y0 = current_placement.center.y - y - cosa*ci.ymin;
x1 = x0 + ci.width * cosa; x1 = x0 + ci.width * cosa;
y1 = y0 - ci.width * sina; y1 = y0 - ci.width * sina;
x2 = x0 + (ci.width * cosa - ci.height() * sina); x2 = x0 + (ci.width * cosa - ci.height() * sina);

View file

@ -234,7 +234,7 @@ void placement_finder<DetectorT>::find_line_breaks()
double line_height = 0.0; //Height of tallest char in line double line_height = 0.0; //Height of tallest char in line
double word_width = 0.0; //Current unfinished word width double word_width = 0.0; //Current unfinished word width
double word_height = 0.0; double word_height = 0.0;
//line_width, word_width does include char width + spacing, but not the spacing after the last char //line_width and word_width include char width + spacing, but not the spacing after the last char
for (unsigned int ii = 0; ii < info_.num_characters(); ii++) for (unsigned int ii = 0; ii < info_.num_characters(); ii++)
{ {
@ -317,26 +317,32 @@ template <typename DetectorT>
void placement_finder<DetectorT>::adjust_position(text_path *current_placement, double label_x, double label_y) void placement_finder<DetectorT>::adjust_position(text_path *current_placement, double label_x, double label_y)
{ {
// if needed, adjust for desired vertical alignment // if needed, adjust for desired vertical alignment
current_placement->starting_y = label_y; // no adjustment, default is MIDDLE current_placement->center.y = label_y; // no adjustment, default is MIDDLE
if (valign_ == V_TOP) if (valign_ == V_TOP)
current_placement->starting_y -= 0.5 * string_height_; // move center up by 1/2 the total height {
else if (valign_ == V_BOTTOM) { current_placement->center.y -= 0.5 * string_height_; // move center up by 1/2 the total height
current_placement->starting_y += 0.5 * string_height_; // move center down by the 1/2 the total height } else if (valign_ == V_BOTTOM)
current_placement->starting_y -= first_line_space_; {
} else if (valign_ == V_MIDDLE) { current_placement->center.y += 0.5 * string_height_; // move center down by the 1/2 the total height
current_placement->starting_y -= first_line_space_/2.0; current_placement->center.y -= first_line_space_;
} else if (valign_ == V_MIDDLE)
{
current_placement->center.y -= first_line_space_/2.0;
} }
// set horizontal position to middle of text // set horizontal position to middle of text
current_placement->starting_x = label_x; // no adjustment, default is MIDDLE current_placement->center.x = label_x; // no adjustment, default is MIDDLE
if (halign_ == H_LEFT) if (halign_ == H_LEFT)
current_placement->starting_x -= 0.5 * string_width_; // move center left by 1/2 the string width {
else if (halign_ == H_RIGHT) current_placement->center.x -= 0.5 * string_width_; // move center left by 1/2 the string width
current_placement->starting_x += 0.5 * string_width_; // move center right by 1/2 the string width } else if (halign_ == H_RIGHT)
{
current_placement->center.x += 0.5 * string_width_; // move center right by 1/2 the string width
}
// adjust text envelope position by user's x-y displacement (dx, dy) // adjust text envelope position by user's x-y displacement (dx, dy)
current_placement->starting_x += pi.get_scale_factor() * p.displacement.first; current_placement->center.x += pi.get_scale_factor() * p.displacement.first;
current_placement->starting_y += pi.get_scale_factor() * p.displacement.second; current_placement->center.y += pi.get_scale_factor() * p.displacement.second;
} }
@ -416,19 +422,19 @@ void placement_finder<DetectorT>::find_point_placement(double label_x, double la
/*x axis: left to right, y axis: top to bottom (negative values higher)*/ /*x axis: left to right, y axis: top to bottom (negative values higher)*/
if (pi.has_dimensions) if (pi.has_dimensions)
{ {
e.init(current_placement->starting_x - (pi.dimensions.first/2.0), // Top Left e.init(current_placement->center.x - (pi.dimensions.first/2.0), // Top Left
current_placement->starting_y - (pi.dimensions.second/2.0), current_placement->center.y - (pi.dimensions.second/2.0),
current_placement->starting_x + (pi.dimensions.first/2.0), // Bottom Right current_placement->center.x + (pi.dimensions.first/2.0), // Bottom Right
current_placement->starting_y + (pi.dimensions.second/2.0)); current_placement->center.y + (pi.dimensions.second/2.0));
} }
else else
{ {
e.init(current_placement->starting_x + dx, // Bottom Left e.init(current_placement->center.x + dx, // Bottom Left
current_placement->starting_y - dy - ci.ymin, /*ymin usually <0 */ current_placement->center.y - dy - ci.ymin, /*ymin usually <0 */
current_placement->starting_x + dx + ci.width, // Top Right current_placement->center.x + dx + ci.width, // Top Right
current_placement->starting_y - dy - ci.ymax); current_placement->center.y - dy - ci.ymax);
} }
// if there is an overlap with existing envelopes, then exit - no placement // if there is an overlap with existing envelopes, then exit - no placement
@ -465,10 +471,10 @@ void placement_finder<DetectorT>::find_point_placement(double label_x, double la
{ {
BOOST_FOREACH(box2d<double> box, pi.additional_boxes) BOOST_FOREACH(box2d<double> box, pi.additional_boxes)
{ {
box2d<double> pt(box.minx() + current_placement->starting_x, box2d<double> pt(box.minx() + current_placement->center.x,
box.miny() + current_placement->starting_y, box.miny() + current_placement->center.y,
box.maxx() + current_placement->starting_x, box.maxx() + current_placement->center.x,
box.maxy() + current_placement->starting_y); box.maxy() + current_placement->center.y);
// abort the whole placement if the additional envelopes can't be placed. // abort the whole placement if the additional envelopes can't be placed.
if (!detector_.has_point_placement(pt, p.minimum_distance)) return; if (!detector_.has_point_placement(pt, p.minimum_distance)) return;
@ -618,8 +624,8 @@ void placement_finder<DetectorT>::find_line_placements(PathT & shape_path)
//Offset all the characters by this angle //Offset all the characters by this angle
for (unsigned i = 0; i < current_placement->nodes_.size(); i++) for (unsigned i = 0; i < current_placement->nodes_.size(); i++)
{ {
current_placement->nodes_[i].x += pi.get_scale_factor() * displacement*cos(anglesum+M_PI/2); current_placement->nodes_[i].pos.x += pi.get_scale_factor() * displacement*cos(anglesum+M_PI/2);
current_placement->nodes_[i].y += pi.get_scale_factor() * displacement*sin(anglesum+M_PI/2); current_placement->nodes_[i].pos.y += pi.get_scale_factor() * displacement*sin(anglesum+M_PI/2);
} }
} }
@ -699,8 +705,8 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(const
return std::auto_ptr<text_path>(NULL); return std::auto_ptr<text_path>(NULL);
} }
current_placement->starting_x = old_x + dx*distance/segment_length; current_placement->center.x = old_x + dx*distance/segment_length;
current_placement->starting_y = old_y + dy*distance/segment_length; current_placement->center.y = old_y + dy*distance/segment_length;
double angle = atan2(-dy, dx); double angle = atan2(-dy, dx);
bool orientation_forced = (orientation != 0); //Wether the orientation was set by the caller bool orientation_forced = (orientation != 0); //Wether the orientation was set by the caller
@ -808,8 +814,8 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(const
render_y -= cwidth*sina + (char_height-2)*cosa; render_y -= cwidth*sina + (char_height-2)*cosa;
render_angle += M_PI; render_angle += M_PI;
} }
current_placement->add_node(c,render_x - current_placement->starting_x, current_placement->add_node(c,render_x - current_placement->center.x,
-render_y + current_placement->starting_y, -render_y + current_placement->center.y,
render_angle, ci.format); render_angle, ci.format);
//Normalise to 0 <= angle < 2PI //Normalise to 0 <= angle < 2PI
@ -856,8 +862,8 @@ bool placement_finder<DetectorT>::test_placement(const std::auto_ptr<text_path>
double x, y, angle; double x, y, angle;
char_properties *properties; char_properties *properties;
current_placement->vertex(&c, &x, &y, &angle, &properties); current_placement->vertex(&c, &x, &y, &angle, &properties);
x = current_placement->starting_x + x; x = current_placement->center.x + x;
y = current_placement->starting_y - y; y = current_placement->center.y - y;
double sina = fast_sin(angle); double sina = fast_sin(angle);
double cosa = fast_cos(angle); double cosa = fast_cos(angle);
@ -1011,5 +1017,4 @@ typedef label_collision_detector4 DetectorType;
template class placement_finder<DetectorType>; template class placement_finder<DetectorType>;
template void placement_finder<DetectorType>::find_point_placements<PathType>(PathType &); template void placement_finder<DetectorType>::find_point_placements<PathType>(PathType &);
template void placement_finder<DetectorType>::find_line_placements<PathType>(PathType &); template void placement_finder<DetectorType>::find_line_placements<PathType>(PathType &);
} // namespace } // namespace

View file

@ -231,7 +231,7 @@ text_placement_info_ptr shield_symbolizer_helper<FaceManagerT, DetectorT>::get_p
point_itr_ = points_.begin(); point_itr_ = points_.begin();
continue; //Reexecute size check continue; //Reexecute size check
} }
position const& pos = placement_->properties.displacement; position const& text_disp = placement_->properties.displacement;
double label_x = point_itr_->first + shield_pos.first; double label_x = point_itr_->first + shield_pos.first;
double label_y = point_itr_->second + shield_pos.second; double label_y = point_itr_->second + shield_pos.second;
@ -247,14 +247,12 @@ text_placement_info_ptr shield_symbolizer_helper<FaceManagerT, DetectorT>::get_p
} }
//Found a label placement but not necessarily also a marker placement //Found a label placement but not necessarily also a marker placement
// check to see if image overlaps anything too, there is only ever 1 placement found for points and verticies // check to see if image overlaps anything too, there is only ever 1 placement found for points and verticies
double x = floor(placement_->placements[0].starting_x);
double y = floor(placement_->placements[0].starting_y);
if (!sym_.get_unlock_image()) if (!sym_.get_unlock_image())
{ {
// center image at text center position // center image at text center position
// remove displacement from image label // remove displacement from image label
double lx = x - pos.first; double lx = placement_->placements[0].center.x - text_disp.first;
double ly = y - pos.second; double ly = placement_->placements[0].center.y - text_disp.second;
marker_x_ = lx - 0.5 * marker_w_; marker_x_ = lx - 0.5 * marker_w_;
marker_y_ = ly - 0.5 * marker_h_; marker_y_ = ly - 0.5 * marker_h_;
marker_ext_.re_center(lx, ly); marker_ext_.re_center(lx, ly);
@ -340,11 +338,8 @@ std::pair<int, int> shield_symbolizer_helper<FaceManagerT, DetectorT>::get_marke
{ {
position const& pos = placement_->properties.displacement; position const& pos = placement_->properties.displacement;
if (placement_->properties.label_placement == LINE_PLACEMENT) { if (placement_->properties.label_placement == LINE_PLACEMENT) {
double x = floor(p.starting_x); double lx = p.center.x - pos.first;
double y = floor(p.starting_y); double ly = p.center.y - pos.second;
double lx = x - pos.first;
double ly = y - pos.second;
int px = lx - 0.5*marker_w_; int px = lx - 0.5*marker_w_;
int py = ly - 0.5*marker_h_; int py = ly - 0.5*marker_h_;
marker_ext_.re_center(lx, ly); marker_ext_.re_center(lx, ly);