00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __PLACEMENT_FINDER__
00027 #define __PLACEMENT_FINDER__
00028
00029 #include <mapnik/ctrans.hpp>
00030 #include <mapnik/label_collision_detector.hpp>
00031 #include <mapnik/text_symbolizer.hpp>
00032 #include <mapnik/shield_symbolizer.hpp>
00033 #include <mapnik/geometry.hpp>
00034 #include <mapnik/text_path.hpp>
00035
00036 #include <queue>
00037
00038 namespace mapnik
00039 {
00040 typedef text_path placement_element;
00041
00042 struct placement : boost::noncopyable
00043 {
00044 placement(string_info & info_, shield_symbolizer const& sym, bool has_dimensions_= false);
00045
00046 placement(string_info & info_, text_symbolizer const& sym);
00047
00048 ~placement();
00049
00050 string_info & info;
00051
00052 position displacement_;
00053 label_placement_e label_placement;
00054
00055 std::queue< Envelope<double> > envelopes;
00056
00057
00058 boost::ptr_vector<placement_element> placements;
00059
00060 int wrap_width;
00061 int text_ratio;
00062
00063 int label_spacing;
00064 unsigned label_position_tolerance;
00065 bool force_odd_labels;
00066
00067 double max_char_angle_delta;
00068 double minimum_distance;
00069 bool avoid_edges;
00070 bool has_dimensions;
00071 std::pair<double, double> dimensions;
00072 };
00073
00074 template <typename DetectorT>
00075 class placement_finder : boost::noncopyable
00076 {
00077 public:
00078 placement_finder(DetectorT & detector);
00079
00080
00081 void find_point_placement(placement & p, double, double);
00082
00083
00084 template <typename T>
00085 void find_point_placements(placement & p, T & path);
00086
00087
00088 template <typename T>
00089 void find_line_placements(placement & p, T & path);
00090
00091 void update_detector(placement & p);
00092
00093 void clear();
00094
00095 private:
00097
00099
00100
00101
00102
00103
00104
00105
00106 std::auto_ptr<placement_element> get_placement_offset(placement & p, const std::vector<vertex2d> & path_positions, const std::vector<double> & path_distances, int & orientation, unsigned index, double distance);
00107
00109
00110
00111 bool test_placement(placement & p, const std::auto_ptr<placement_element> & current_placement, const int & orientation);
00112
00114
00115
00116
00117
00118 void find_line_circle_intersection(
00119 const double &cx, const double &cy, const double &radius,
00120 const double &x1, const double &y1, const double &x2, const double &y2,
00121 double &ix, double &iy);
00122
00124
00125
00126
00127 DetectorT & detector_;
00128 Envelope<double> const& dimensions_;
00129 };
00130 }
00131
00132 #endif
00133