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_,
00045
00046 shield_symbolizer const& sym);
00047
00048 placement(string_info & info_,
00049
00050 text_symbolizer const& sym);
00051
00052 ~placement();
00053
00054
00055
00056
00057
00058 string_info & info;
00059
00060
00061
00062 position displacement_;
00063 label_placement_e label_placement;
00064
00065 std::queue< Envelope<double> > envelopes;
00066
00067
00068 boost::ptr_vector<placement_element> placements;
00069
00070 int wrap_width;
00071 int text_ratio;
00072
00073 int label_spacing;
00074 unsigned label_position_tolerance;
00075 bool force_odd_labels;
00076
00077 double max_char_angle_delta;
00078 double minimum_distance;
00079 bool avoid_edges;
00080 bool has_dimensions;
00081 std::pair<double, double> dimensions;
00082 };
00083
00084 template <typename DetectorT>
00085 class placement_finder : boost::noncopyable
00086 {
00087 public:
00088 placement_finder(DetectorT & detector);
00089
00090
00091 void find_point_placement(placement & p, double, double);
00092
00093
00094 template <typename T>
00095 void find_point_placements(placement & p, T & path);
00096
00097
00098 template <typename T>
00099 void find_line_placements(placement & p, T & path);
00100
00101 void clear();
00102
00103 private:
00105
00107
00108
00109
00110
00111
00112
00113
00114 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);
00115
00117
00118
00119 bool test_placement(placement & p, const std::auto_ptr<placement_element> & current_placement, const int & orientation);
00120
00122
00123
00124
00125
00126 void find_line_circle_intersection(
00127 const double &cx, const double &cy, const double &radius,
00128 const double &x1, const double &y1, const double &x2, const double &y2,
00129 double &ix, double &iy);
00130
00132
00133 void update_detector(placement & p);
00134
00135 DetectorT & detector_;
00136 Envelope<double> const& dimensions_;
00137 };
00138 }
00139
00140 #endif
00141