| 753 | | if (feature.exists(sym.get_name())) |
| 754 | | { |
| 755 | | UnicodeString text = feature[sym.get_name()].to_unicode(); |
| 756 | | boost::shared_ptr<ImageData32> const& data = sym.get_image(); |
| 757 | | |
| 758 | | if (text.length() > 0 && data) |
| 759 | | { |
| 760 | | cairo_face_ptr face = face_manager_.get_face(sym.get_face_name()); |
| 761 | | |
| 762 | | if (face) |
| 763 | | { |
| 764 | | cairo_context context(context_); |
| 765 | | |
| 766 | | context.set_font_face(face); |
| 767 | | |
| 768 | | string_info info(text); |
| 769 | | |
| 770 | | face->get_string_info(sym.get_text_size(), info); |
| 771 | | |
| 772 | | placement_finder<label_collision_detector4> finder(detector_); |
| 773 | | |
| 774 | | for (unsigned i = 0; i < feature.num_geometries(); ++i) |
| 775 | | { |
| 776 | | geometry2d const& geom = feature.get_geometry(i); |
| 777 | | |
| 778 | | if (geom.num_points() > 0) // don't bother with empty geometries |
| | 753 | UnicodeString text = feature[sym.get_name()].to_unicode(); |
| | 754 | boost::shared_ptr<ImageData32> const& data = sym.get_image(); |
| | 755 | |
| | 756 | if (text.length() > 0 && data) |
| | 757 | { |
| | 758 | cairo_face_ptr face = face_manager_.get_face(sym.get_face_name()); |
| | 759 | |
| | 760 | if (face) |
| | 761 | { |
| | 762 | cairo_context context(context_); |
| | 763 | |
| | 764 | context.set_font_face(face); |
| | 765 | |
| | 766 | string_info info(text); |
| | 767 | |
| | 768 | face->get_string_info(sym.get_text_size(), info); |
| | 769 | |
| | 770 | placement_finder<label_collision_detector4> finder(detector_); |
| | 771 | |
| | 772 | for (unsigned i = 0; i < feature.num_geometries(); ++i) |
| | 773 | { |
| | 774 | geometry2d const& geom = feature.get_geometry(i); |
| | 775 | |
| | 776 | if (geom.num_points() > 0) // don't bother with empty geometries |
| | 777 | { |
| | 778 | path_type path(t_, geom, prj_trans); |
| | 779 | placement text_placement(info, sym); |
| | 780 | |
| | 781 | text_placement.avoid_edges = sym.get_avoid_edges(); |
| | 782 | finder.find_point_placements<path_type>(text_placement, path); |
| | 783 | |
| | 784 | for (unsigned int ii = 0; ii < text_placement.placements.size(); ++ ii) |
| 780 | | path_type path(t_, geom, prj_trans); |
| 781 | | placement text_placement(info, sym); |
| 782 | | |
| 783 | | text_placement.avoid_edges = sym.get_avoid_edges(); |
| 784 | | finder.find_point_placements<path_type>(text_placement, path); |
| 785 | | |
| 786 | | for (unsigned int ii = 0; ii < text_placement.placements.size(); ++ ii) |
| 787 | | { |
| 788 | | double shield_x = text_placement.placements[ii].starting_x - data->width() / 2; |
| 789 | | double shield_y = text_placement.placements[ii].starting_y - data->height() / 2; |
| 790 | | |
| 791 | | context.add_image(shield_x, shield_y, *data); |
| 792 | | context.add_text(sym, text_placement.placements[ii], face); |
| 793 | | } |
| | 786 | double shield_x = text_placement.placements[ii].starting_x - data->width() / 2; |
| | 787 | double shield_y = text_placement.placements[ii].starting_y - data->height() / 2; |
| | 788 | |
| | 789 | context.add_image(shield_x, shield_y, *data); |
| | 790 | context.add_text(sym, text_placement.placements[ii], face); |
| 930 | | if (feature.exists(sym.get_name())) |
| 931 | | { |
| 932 | | UnicodeString text = feature[sym.get_name()].to_unicode(); |
| 933 | | |
| 934 | | if (text.length() > 0) |
| 935 | | { |
| 936 | | cairo_face_ptr face = face_manager_.get_face(sym.get_face_name()); |
| 937 | | |
| 938 | | if (face) |
| 939 | | { |
| 940 | | cairo_context context(context_); |
| 941 | | |
| 942 | | context.set_font_face(face); |
| 943 | | |
| 944 | | string_info info(text); |
| 945 | | |
| 946 | | face->get_string_info(sym.get_text_size(), info); |
| 947 | | |
| 948 | | placement_finder<label_collision_detector4> finder(detector_); |
| 949 | | |
| 950 | | for (unsigned i = 0; i < feature.num_geometries(); ++i) |
| 951 | | { |
| 952 | | geometry2d const& geom = feature.get_geometry(i); |
| 953 | | |
| 954 | | if (geom.num_points() > 0) // don't bother with empty geometries |
| | 927 | UnicodeString text = feature[sym.get_name()].to_unicode(); |
| | 928 | |
| | 929 | if (text.length() > 0) |
| | 930 | { |
| | 931 | cairo_face_ptr face = face_manager_.get_face(sym.get_face_name()); |
| | 932 | |
| | 933 | if (face) |
| | 934 | { |
| | 935 | cairo_context context(context_); |
| | 936 | |
| | 937 | context.set_font_face(face); |
| | 938 | |
| | 939 | string_info info(text); |
| | 940 | |
| | 941 | face->get_string_info(sym.get_text_size(), info); |
| | 942 | |
| | 943 | placement_finder<label_collision_detector4> finder(detector_); |
| | 944 | |
| | 945 | for (unsigned i = 0; i < feature.num_geometries(); ++i) |
| | 946 | { |
| | 947 | geometry2d const& geom = feature.get_geometry(i); |
| | 948 | |
| | 949 | if (geom.num_points() > 0) // don't bother with empty geometries |
| | 950 | { |
| | 951 | path_type path(t_, geom, prj_trans); |
| | 952 | placement text_placement(info, sym); |
| | 953 | |
| | 954 | if (sym.get_label_placement() == POINT_PLACEMENT) |
| 956 | | path_type path(t_, geom, prj_trans); |
| 957 | | placement text_placement(info, sym); |
| 958 | | |
| 959 | | if (sym.get_label_placement() == POINT_PLACEMENT) |
| 960 | | { |
| 961 | | double label_x, label_y, z = 0.0; |
| 962 | | |
| 963 | | geom.label_position(&label_x, &label_y); |
| 964 | | prj_trans.backward(label_x, label_y, z); |
| 965 | | t_.forward(&label_x, &label_y); |
| 966 | | finder.find_point_placement(text_placement, label_x, label_y); |
| 967 | | } |
| 968 | | else //LINE_PLACEMENT |
| 969 | | { |
| 970 | | finder.find_line_placements<path_type>(text_placement, path); |
| 971 | | } |
| 972 | | |
| 973 | | for (unsigned int ii = 0; ii < text_placement.placements.size(); ++ii) |
| 974 | | { |
| 975 | | context.add_text(sym, text_placement.placements[ii], face); |
| 976 | | } |
| | 956 | double label_x, label_y, z = 0.0; |
| | 957 | |
| | 958 | geom.label_position(&label_x, &label_y); |
| | 959 | prj_trans.backward(label_x, label_y, z); |
| | 960 | t_.forward(&label_x, &label_y); |
| | 961 | finder.find_point_placement(text_placement, label_x, label_y); |