From 798b0731e53e426219081c293d62d71d07789822 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 13 Dec 2009 23:29:02 +0000 Subject: [PATCH] apply small patch from David Eastcott which fixes a problem with the insertion of character envelope fragments (as a result of overlap rejection) into the detector which in turn causes rejection of other text placement that should have been rendered. --- src/placement_finder.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index d7f564fb2..af33b2be4 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -92,7 +92,7 @@ namespace mapnik dimensions(), text_size(sym.get_text_size()) {} - + placement::~placement() {} template @@ -353,6 +353,8 @@ namespace mapnik x = (string_width / 2.0) - line_width; // save each character rendering position and build envelope as go thru loop + std::queue< Envelope > c_envelopes; + for (unsigned i = 0; i < p.info.num_characters(); i++) { character_info ci; @@ -397,20 +399,26 @@ namespace mapnik current_placement->starting_y - y - max_character_height); } - if (!dimensions_.intersects(e) || - (!p.allow_overlap && !detector_.has_point_placement(e,p.minimum_distance))) - { + // if there is an overlap with existing envelopes, then exit - no placement + if (!dimensions_.intersects(e) || (!p.allow_overlap && !detector_.has_point_placement(e,p.minimum_distance))) return; - } - if (p.avoid_edges && !dimensions_.contains(e)) return; + if (p.avoid_edges && !dimensions_.contains(e)) + return; - p.envelopes.push(e); + c_envelopes.push(e); // add character's envelope to temp storage } x += cwidth; // move position to next character } + + // since there was no early exit, add the character envelopes to the placements' envelopes + while( !c_envelopes.empty() ) + { + p.envelopes.push( c_envelopes.front() ); + c_envelopes.pop(); + } + p.placements.push_back(current_placement.release()); - //update_detector(p); }