From 7d01f509abab01eac86c9a06fbb71ac5ccc91d7b Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Sun, 22 Jan 2012 03:11:55 +0100 Subject: [PATCH] Add text_placement_info_list functions. --- include/mapnik/text_placements.hpp | 2 +- src/text_placements.cpp | 66 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/include/mapnik/text_placements.hpp b/include/mapnik/text_placements.hpp index c6f4aee2a..14c55367d 100644 --- a/include/mapnik/text_placements.hpp +++ b/include/mapnik/text_placements.hpp @@ -130,7 +130,7 @@ public: * Each class has to return at least one position! * If this functions returns false the placement data should be considered invalid! */ - virtual bool next_position_only()=0; + virtual bool next_position_only() { return false; } virtual ~text_placement_info() {} void init(double scale_factor_, unsigned w = 0, unsigned h = 0, bool has_dimensions_ = false); diff --git a/src/text_placements.cpp b/src/text_placements.cpp index 554dd53fb..d14bef71a 100644 --- a/src/text_placements.cpp +++ b/src/text_placements.cpp @@ -492,4 +492,70 @@ text_placements_simple::text_placements_simple(std::string positions) { set_positions(positions); } + +/***************************************************************************/ + +bool text_placement_info_list::next() +{ + if (state == 0) { + properties = parent_->properties; + } else { + if (state-1 >= parent_->list_.size()) return false; + properties = parent_->list_[state-1]; + } + state++; + return true; +} + +text_symbolizer_properties & text_placements_list::add() +{ + if (list_.size()) { + text_symbolizer_properties &last = list_.back(); + list_.push_back(last); //Preinitialize with old values + } else { + list_.push_back(properties); + } + return list_.back(); +} + +text_symbolizer_properties & text_placements_list::get(unsigned i) +{ + return list_[i]; +} + +/***************************************************************************/ + +text_placement_info_ptr text_placements_list::get_placement_info() const +{ + return text_placement_info_ptr(new text_placement_info_list(this)); +} + +text_placements_list::text_placements_list() : text_placements(), list_(0) +{ + +} + +std::set text_placements_list::get_all_expressions() +{ + std::set result, tmp; + tmp = properties.processor.get_all_expressions(); + result.insert(tmp.begin(), tmp.end()); + result.insert(properties.orientation); + + std::vector::const_iterator it; + for (it=list_.begin(); it != list_.end(); it++) + { + tmp = it->processor.get_all_expressions(); + result.insert(tmp.begin(), tmp.end()); + result.insert(it->orientation); + } + return result; +} + +unsigned text_placements_list::size() const +{ + return list_.size(); +} + + } //namespace