From 5e2e6a76ad4992eeb165b74cbf4468644fa717e7 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 13 Dec 2009 23:30:36 +0000 Subject: [PATCH] apply fixes from David Eastcott originally applied to 0.7 branch --- include/mapnik/wall_clock_timer.hpp | 2 ++ plugins/input/ogr/ogr_datasource.cpp | 2 +- src/placement_finder.cpp | 24 ++++++++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/mapnik/wall_clock_timer.hpp b/include/mapnik/wall_clock_timer.hpp index 0fd3aa610..8ba9ec5f0 100644 --- a/include/mapnik/wall_clock_timer.hpp +++ b/include/mapnik/wall_clock_timer.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_WALL_CLOCK_TIMER_INCLUDED #define MAPNIK_WALL_CLOCK_TIMER_INCLUDED +#include + namespace mapnik { // This is a class with a similar signature to boost::timer, but which measures diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 869b50cae..a7cc5efe7 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -119,7 +119,7 @@ ogr_datasource::ogr_datasource(parameters const& params) extent_.init (envelope.MinX, envelope.MinY, envelope.MaxX, envelope.MaxY); // scan for index file - unsigned breakpoint = dataset_name_.find_last_of ("."); + size_t breakpoint = dataset_name_.find_last_of ("."); if (breakpoint == std::string::npos) breakpoint = dataset_name_.length(); index_name_ = dataset_name_.substr(0, breakpoint) + ".index"; std::ifstream index_file (index_name_.c_str(), std::ios::in | std::ios::binary); 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); }