diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index f97e5d23b..1d4fb374a 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -199,6 +199,11 @@ struct symbolizer_attributes : public boost::static_visitor<> { boost::apply_visitor(f_attr,*width_expr); } + path_expression_ptr const& filename_expr = sym.get_filename(); + if (filename_expr) + { + path_processor_type::collect_attributes(*filename_expr,names_); + } collect_transform(sym.get_image_transform()); collect_transform(sym.get_transform()); } diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index 1c5f67c10..0af9e1479 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -33,11 +33,9 @@ #include #include - // agg #include "agg_conv_clip_polyline.h" - // stl #include @@ -65,21 +63,21 @@ public: DetectorT & detector, box2d const& extent); - /** Try place a single label at the given point. */ + // Try place a single label at the given point. */ void find_point_placement(double pos_x, double pos_y, double angle=0.0); - /** Iterate over the given path, placing point labels with respect to label_spacing. */ + // Iterate over the given path, placing point labels with respect to label_spacing. */ template void find_point_placements(T & path); - /** Iterate over the given path, placing line-following labels with respect to label_spacing. */ + // Iterate over the given path, placing line-following labels with respect to label_spacing. */ template void find_line_placements(T & path); - /** Add placements to detector. */ + // Add placements to detector. */ void update_detector(); - /** Remove old placements. */ + // Remove old placements. */ void clear_placements(); inline placements_type const& get_results() { return placements_; } @@ -134,17 +132,14 @@ private: string_info const& info_; text_symbolizer_properties const& p; text_placement_info const& pi; - /** Length of the longest line after linebreaks. - * Before find_line_breaks() this is the total length of the string. - */ + // Length of the longest line after linebreaks. + // Before find_line_breaks() this is the total length of the string. double string_width_; - /** Height of the string after linebreaks. - * Before find_line_breaks() this is the total length of the string. - */ + // Height of the string after linebreaks. + // Before find_line_breaks() this is the total length of the string. 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. - */ + // 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_; vertical_alignment_e valign_; horizontal_alignment_e halign_; @@ -152,18 +147,17 @@ private: std::vector line_breaks_; std::vector > line_sizes_; std::queue< box2d > envelopes_; - /** Used to return all placements found. */ + // Used to return all placements found. */ placements_type placements_; - /** Bounding box of all texts placed. */ + // Bounding box of all texts placed. */ box2d extents_; - /** Collect a bounding box of all texts placed. */ + // Collect a bounding box of all texts placed. */ bool collect_extents_; - /** Additional boxes to take into account when finding placement. - * Used for finding line placements where multiple placements are returned. - * Boxes are relative to starting point of current placement. - * Only used for point placements! - */ + // Additional boxes to take into account when finding placement. + // Used for finding line placements where multiple placements are returned. + // Boxes are relative to starting point of current placement. + // Only used for point placements! std::vector > additional_boxes_; }; } diff --git a/include/mapnik/processed_text.hpp b/include/mapnik/processed_text.hpp index 581742520..5219a6785 100644 --- a/include/mapnik/processed_text.hpp +++ b/include/mapnik/processed_text.hpp @@ -40,11 +40,10 @@ template class face_manager; class MAPNIK_DECL processed_text : mapnik::noncopyable { public: - class processed_expression + struct processed_expression { - public: - processed_expression(char_properties const& properties, UnicodeString const& text) : - p(properties), str(text) {} + processed_expression(char_properties const& properties, UnicodeString const& text) + : p(properties), str(text) {} char_properties p; UnicodeString str; }; @@ -57,7 +56,7 @@ public: typedef std::list expression_list; expression_list::const_iterator begin() const; expression_list::const_iterator end() const; - string_info &get_string_info(); + string_info const& get_string_info(); private: expression_list expr_list_; face_manager &font_manager_; diff --git a/include/mapnik/symbolizer_helpers.hpp b/include/mapnik/symbolizer_helpers.hpp index 4da83c360..479b02db9 100644 --- a/include/mapnik/symbolizer_helpers.hpp +++ b/include/mapnik/symbolizer_helpers.hpp @@ -30,7 +30,7 @@ #include //boost -#include +#include // agg #include "agg_trans_affine.h" @@ -65,34 +65,14 @@ public: CoordTransform const& t, FaceManagerT &font_manager, DetectorT &detector, - box2d const& query_extent) - : sym_(sym), - feature_(feature), - prj_trans_(prj_trans), - t_(t), - font_manager_(font_manager), - detector_(detector), - dims_(0, 0, width, height), - query_extent_(query_extent), - text_(font_manager, scale_factor), - angle_(0.0), - placement_valid_(false), - points_on_line_(false), - finder_() - { - initialize_geometries(); - if (!geometries_to_process_.size()) return; - placement_ = sym_.get_placement_options()->get_placement_info(scale_factor); - next_placement(); - initialize_points(); - } + box2d const& query_extent); - /** Return next placement. - * If no more placements are found returns null pointer. - */ + ~text_symbolizer_helper(); + // Return next placement. + // If no more placements are found returns null pointer. bool next(); - /** Get current placement. next() has to be called before! */ + // Get current placement. next() has to be called before! placements_type const& placements() const; protected: bool next_point_placement(); @@ -113,28 +93,26 @@ protected: box2d const& query_extent_; //Processing processed_text text_; - /* Using list instead of vector, because we delete random elements and need iterators to stay valid. */ - /** Remaining geometries to be processed. */ + // Using list instead of vector, because we delete random elements and need iterators to stay valid. + // Remaining geometries to be processed. std::list geometries_to_process_; - /** Geometry currently being processed. */ + // Geometry currently being processed. std::list::iterator geo_itr_; - /** Remaining points to be processed. */ + // Remaining points to be processed. std::list points_; - /** Point currently being processed. */ + // Point currently being processed. std::list::iterator point_itr_; - /** Text rotation. */ + // Text rotation. double angle_; - /** Text + formatting. */ - string_info *info_; - /** Did last call to next_placement return true? */ + // Did last call to next_placement return true? bool placement_valid_; - /** Use point placement. Otherwise line placement is used. */ + // Use point placement. Otherwise line placement is used. bool point_placement_; - /** Place text at points on a line instead of following the line (used for ShieldSymbolizer) .*/ + // Place text at points on a line instead of following the line (used for ShieldSymbolizer). bool points_on_line_; text_placement_info_ptr placement_; - boost::shared_ptr > finder_; + boost::scoped_ptr > finder_; }; template @@ -193,7 +171,6 @@ protected: using text_symbolizer_helper::geometries_to_process_; using text_symbolizer_helper::placement_; using text_symbolizer_helper::next_placement; - using text_symbolizer_helper::info_; using text_symbolizer_helper::geo_itr_; using text_symbolizer_helper::point_itr_; using text_symbolizer_helper::points_; diff --git a/src/processed_text.cpp b/src/processed_text.cpp index 83db904c1..4d2064d7e 100644 --- a/src/processed_text.cpp +++ b/src/processed_text.cpp @@ -55,7 +55,7 @@ void processed_text::clear() } -string_info &processed_text::get_string_info() +string_info const& processed_text::get_string_info() { info_.clear(); //if this function is called twice invalid results are returned, so clear string_info first expression_list::iterator itr = expr_list_.begin(); diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 65c020c56..4d89b039c 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -39,6 +39,42 @@ namespace mapnik { +template +text_symbolizer_helper::text_symbolizer_helper(text_symbolizer const& sym, + feature_impl const& feature, + proj_transform const& prj_trans, + unsigned width, + unsigned height, + double scale_factor, + CoordTransform const& t, + FaceManagerT &font_manager, + DetectorT &detector, + box2d const& query_extent) + : sym_(sym), + feature_(feature), + prj_trans_(prj_trans), + t_(t), + font_manager_(font_manager), + detector_(detector), + dims_(0, 0, width, height), + query_extent_(query_extent), + text_(font_manager, scale_factor), + angle_(0.0), + placement_valid_(false), + points_on_line_(false), + finder_(0) + { + initialize_geometries(); + if (!geometries_to_process_.size()) return; + placement_ = sym_.get_placement_options()->get_placement_info(scale_factor); + next_placement(); + initialize_points(); + } + +template +text_symbolizer_helper::~text_symbolizer_helper() +{} + template bool text_symbolizer_helper::next() { @@ -283,7 +319,6 @@ bool text_symbolizer_helper::next_placement() return false; } placement_->properties.process(text_, feature_); - info_ = &(text_.get_string_info()); if (placement_->properties.orientation) { // https://github.com/mapnik/mapnik/issues/1352 @@ -295,10 +330,9 @@ bool text_symbolizer_helper::next_placement() angle_ = 0.0; } - - finder_ = boost::shared_ptr >(new placement_finder(feature_, *placement_, *info_, detector_, dims_)); -// boost::make_shared >(feature_, *placement_, *info_, detector_, dims_); - + finder_.reset(new placement_finder(feature_, *placement_, + text_.get_string_info(), + detector_, dims_)); placement_valid_ = true; return true; } @@ -470,4 +504,5 @@ agg::trans_affine const& shield_symbolizer_helper::get_ template class text_symbolizer_helper, label_collision_detector4>; template class shield_symbolizer_helper, label_collision_detector4>; +template class mapnik::placement_finder; } //namespace