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 <queue>
00030
00031 #include <mapnik/ctrans.hpp>
00032 #include <mapnik/label_collision_detector.hpp>
00033 #include <mapnik/text_symbolizer.hpp>
00034 #include <mapnik/geometry.hpp>
00035 #include <mapnik/text_path.hpp>
00036
00037 namespace mapnik
00038 {
00039
00040 struct placement_element
00041 {
00042 double starting_x;
00043 double starting_y;
00044
00045 text_path path;
00046 };
00047
00048 struct placement
00049 {
00050 typedef coord_transform2<CoordTransform,geometry_type> path_type;
00051
00052
00053 placement(string_info *info_,
00054 CoordTransform *ctrans_,
00055 const proj_transform *proj_trans_,
00056 geometry_ptr geom_,
00057 std::pair<double, double> dimensions_);
00058
00059
00060 placement(string_info *info_,
00061 CoordTransform *ctrans_,
00062 const proj_transform *proj_trans_,
00063 geometry_ptr geom_,
00064 position const& displacement,
00065 label_placement_e placement_);
00066
00067 ~placement();
00068
00069 unsigned path_size() const;
00070 string_info *info;
00071
00072 CoordTransform *ctrans;
00073 const proj_transform *proj_trans;
00074
00075 geometry_ptr geom;
00076 position displacement_;
00077 label_placement_e label_placement;
00078 std::pair<double, double> dimensions;
00079
00080 bool has_dimensions;
00081
00082 path_type shape_path;
00083 std::queue< Envelope<double> > envelopes;
00084
00085
00086 std::vector<placement_element> placements;
00087
00088
00089 placement_element current_placement;
00090
00091
00092 std::pair<double, double> get_position_at_distance(double target_distance);
00093 double get_total_distance();
00094 void clear_envelopes();
00095
00096 double total_distance_;
00097
00098 int wrap_width;
00099 int text_ratio;
00100
00101 int label_spacing;
00102 unsigned label_position_tolerance;
00103 bool force_odd_labels;
00104
00105 double max_char_angle_delta;
00106
00107 bool avoid_edges;
00108 };
00109
00110
00111
00112 class placement_finder : boost::noncopyable
00113 {
00114 public:
00115
00116 placement_finder(Envelope<double> e, unsigned buffer);
00117 bool find_placements(placement *p);
00118 void clear();
00119
00120 protected:
00121 bool find_placement_follow(placement *p);
00122 bool find_placement_horizontal(placement *p);
00123 bool build_path_follow(placement *p, double target_distance);
00124 bool build_path_horizontal(placement *p, double target_distance);
00125 void update_detector(placement *p);
00126 Envelope<double> dimensions_;
00127 label_collision_detector3 detector_;
00128 };
00129 }
00130
00131 #endif
00132