+reflect new text symbolizer options added in r1254 - closes #391
This commit is contained in:
parent
41af03be53
commit
e897b832a4
4 changed files with 133 additions and 86 deletions
|
@ -71,11 +71,20 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
boost::python::list disp = get_displacement_list(t);
|
boost::python::list disp = get_displacement_list(t);
|
||||||
boost::python::list anchor = get_anchor_list(t);
|
boost::python::list anchor = get_anchor_list(t);
|
||||||
|
|
||||||
|
// so we do not exceed max args accepted by make_tuple,
|
||||||
|
// lets put the increasing list of parameters in a list
|
||||||
|
boost::python::list extras;
|
||||||
|
extras.append(t.get_wrap_char());
|
||||||
|
extras.append(t.get_line_spacing());
|
||||||
|
extras.append(t.get_character_spacing());
|
||||||
|
extras.append(t.get_text_convert());
|
||||||
|
|
||||||
return boost::python::make_tuple(disp,t.get_fontset().get_name(),t.get_label_placement(),
|
return boost::python::make_tuple(disp,t.get_fontset().get_name(),t.get_label_placement(),
|
||||||
t.get_vertical_alignment(),t.get_halo_radius(),t.get_halo_fill(),t.get_text_ratio(),
|
t.get_vertical_alignment(),t.get_halo_radius(),t.get_halo_fill(),t.get_text_ratio(),
|
||||||
t.get_wrap_width(),t.get_label_spacing(),t.get_minimum_distance(),t.get_allow_overlap(),
|
t.get_wrap_width(),t.get_label_spacing(),t.get_minimum_distance(),t.get_allow_overlap(),
|
||||||
anchor,t.get_force_odd_labels(),t.get_max_char_angle_delta());
|
anchor,t.get_force_odd_labels(),t.get_max_char_angle_delta(),extras
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -83,10 +92,10 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
|
||||||
if (len(state) != 14)
|
if (len(state) != 15)
|
||||||
{
|
{
|
||||||
PyErr_SetObject(PyExc_ValueError,
|
PyErr_SetObject(PyExc_ValueError,
|
||||||
("expected 14-item tuple in call to __setstate__; got %s"
|
("expected 15-item tuple in call to __setstate__; got %s"
|
||||||
% state).ptr()
|
% state).ptr()
|
||||||
);
|
);
|
||||||
throw_error_already_set();
|
throw_error_already_set();
|
||||||
|
@ -129,6 +138,13 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
|
||||||
t.set_force_odd_labels(extract<bool>(state[12]));
|
t.set_force_odd_labels(extract<bool>(state[12]));
|
||||||
|
|
||||||
t.set_max_char_angle_delta(extract<double>(state[13]));
|
t.set_max_char_angle_delta(extract<double>(state[13]));
|
||||||
|
|
||||||
|
list extras = extract<list>(state[14]);
|
||||||
|
t.set_wrap_char_from_string(extract<std::string>(extras[0]));
|
||||||
|
t.set_line_spacing(extract<unsigned>(extras[1]));
|
||||||
|
t.set_character_spacing(extract<unsigned>(extras[2]));
|
||||||
|
t.set_text_convert(extract<text_convert_e>(extras[3]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -136,89 +152,102 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
|
||||||
|
|
||||||
void export_text_symbolizer()
|
void export_text_symbolizer()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
|
||||||
enumeration_<label_placement_e>("label_placement")
|
|
||||||
.value("LINE_PLACEMENT",LINE_PLACEMENT)
|
|
||||||
.value("POINT_PLACEMENT",POINT_PLACEMENT)
|
|
||||||
;
|
|
||||||
enumeration_<vertical_alignment_e>("vertical_alignment")
|
|
||||||
.value("TOP",TOP)
|
|
||||||
.value("MIDDLE",MIDDLE)
|
|
||||||
.value("BOTTOM",BOTTOM)
|
|
||||||
;
|
|
||||||
|
|
||||||
class_<text_symbolizer>("TextSymbolizer",
|
|
||||||
init<std::string const&,std::string const&, unsigned,color const&>())
|
|
||||||
.def_pickle(text_symbolizer_pickle_suite())
|
|
||||||
.add_property("halo_fill",make_function(
|
|
||||||
&text_symbolizer::get_halo_fill,
|
|
||||||
return_value_policy<copy_const_reference>()),
|
|
||||||
&text_symbolizer::set_halo_fill)
|
|
||||||
.add_property("halo_radius",
|
|
||||||
&text_symbolizer::get_halo_radius,
|
|
||||||
&text_symbolizer::set_halo_radius)
|
|
||||||
.add_property("wrap_width",
|
|
||||||
&text_symbolizer::get_wrap_width,
|
|
||||||
&text_symbolizer::set_wrap_width)
|
|
||||||
.add_property("text_ratio",
|
|
||||||
&text_symbolizer::get_text_ratio,
|
|
||||||
&text_symbolizer::set_text_ratio)
|
|
||||||
.add_property("label_spacing",
|
|
||||||
&text_symbolizer::get_label_spacing,
|
|
||||||
&text_symbolizer::set_label_spacing)
|
|
||||||
.add_property("label_position_tolerance",
|
|
||||||
&text_symbolizer::get_label_position_tolerance,
|
|
||||||
&text_symbolizer::set_label_position_tolerance)
|
|
||||||
.add_property("force_odd_labels",
|
|
||||||
&text_symbolizer::get_force_odd_labels,
|
|
||||||
&text_symbolizer::set_force_odd_labels)
|
|
||||||
|
|
||||||
.add_property("fontset",
|
enumeration_<label_placement_e>("label_placement")
|
||||||
make_function(&text_symbolizer::get_fontset,return_value_policy<copy_const_reference>()),
|
.value("LINE_PLACEMENT",LINE_PLACEMENT)
|
||||||
&text_symbolizer::set_fontset)
|
.value("POINT_PLACEMENT",POINT_PLACEMENT)
|
||||||
|
;
|
||||||
|
enumeration_<vertical_alignment_e>("vertical_alignment")
|
||||||
|
.value("TOP",TOP)
|
||||||
|
.value("MIDDLE",MIDDLE)
|
||||||
|
.value("BOTTOM",BOTTOM)
|
||||||
|
;
|
||||||
|
|
||||||
|
enumeration_<text_convert_e>("text_convert")
|
||||||
|
.value("NONE",NONE)
|
||||||
|
.value("TOUPPER",TOUPPER)
|
||||||
|
.value("TOLOWER",TOLOWER)
|
||||||
|
;
|
||||||
|
|
||||||
.add_property("fill",
|
class_<text_symbolizer>("TextSymbolizer",init<std::string const&,std::string const&, unsigned,color const&>())
|
||||||
make_function(&text_symbolizer::get_fill,return_value_policy<copy_const_reference>()),
|
.def_pickle(text_symbolizer_pickle_suite())
|
||||||
&text_symbolizer::set_fill)
|
.def("anchor",&text_symbolizer::set_anchor)
|
||||||
.add_property("name",
|
.def("displacement",&text_symbolizer::set_displacement)
|
||||||
make_function(&text_symbolizer::get_name,return_value_policy<copy_const_reference>()),
|
.def("get_anchor",get_anchor_list)
|
||||||
&text_symbolizer::set_name)
|
.def("get_displacement",get_displacement_list)
|
||||||
|
.add_property("allow_overlap",
|
||||||
.add_property("text_size",
|
&text_symbolizer::get_allow_overlap,
|
||||||
&text_symbolizer::get_text_size,
|
&text_symbolizer::set_allow_overlap,
|
||||||
&text_symbolizer::set_text_size)
|
"Set/get the allow_overlap property of the label")
|
||||||
|
.add_property("avoid_edges",
|
||||||
.add_property("face_name",
|
&text_symbolizer::get_avoid_edges,
|
||||||
make_function(&text_symbolizer::get_face_name,return_value_policy<copy_const_reference>()),
|
&text_symbolizer::set_avoid_edges,
|
||||||
&text_symbolizer::set_face_name)
|
"Set/get the avoid_edge property of the label")
|
||||||
|
.add_property("character_spacing",
|
||||||
.add_property("max_char_angle_delta",
|
&text_symbolizer::get_character_spacing,
|
||||||
&text_symbolizer::get_max_char_angle_delta,
|
&text_symbolizer::set_character_spacing,
|
||||||
&text_symbolizer::set_max_char_angle_delta)
|
"Set/get the character_spacing property of the label")
|
||||||
.add_property("avoid_edges",
|
.add_property("face_name",
|
||||||
&text_symbolizer::get_avoid_edges,
|
make_function(&text_symbolizer::get_face_name,return_value_policy<copy_const_reference>()),
|
||||||
&text_symbolizer::set_avoid_edges)
|
&text_symbolizer::set_face_name,
|
||||||
.add_property("minimum_distance",
|
"Set/get the face_name property of the label")
|
||||||
&text_symbolizer::get_minimum_distance,
|
.add_property("fill",
|
||||||
&text_symbolizer::set_minimum_distance)
|
make_function(&text_symbolizer::get_fill,return_value_policy<copy_const_reference>()),
|
||||||
.def("displacement",&text_symbolizer::set_displacement)
|
&text_symbolizer::set_fill)
|
||||||
.def("anchor",&text_symbolizer::set_anchor)
|
.add_property("fontset",
|
||||||
.def("get_displacement",get_displacement_list)
|
make_function(&text_symbolizer::get_fontset,return_value_policy<copy_const_reference>()),
|
||||||
.def("get_anchor",get_anchor_list)
|
&text_symbolizer::set_fontset)
|
||||||
.add_property("label_placement",
|
.add_property("force_odd_labels",
|
||||||
&text_symbolizer::get_label_placement,
|
&text_symbolizer::get_force_odd_labels,
|
||||||
&text_symbolizer::set_label_placement,
|
&text_symbolizer::set_force_odd_labels)
|
||||||
"Set/get the placement of the label")
|
.add_property("halo_fill",
|
||||||
|
make_function(&text_symbolizer::get_halo_fill,return_value_policy<copy_const_reference>()),
|
||||||
.add_property("vertical_alignment",
|
&text_symbolizer::set_halo_fill)
|
||||||
&text_symbolizer::get_vertical_alignment,
|
.add_property("halo_radius",
|
||||||
&text_symbolizer::set_vertical_alignment,
|
&text_symbolizer::get_halo_radius,
|
||||||
"Set/get the vertical alignment of the label")
|
&text_symbolizer::set_halo_radius)
|
||||||
|
.add_property("label_placement",
|
||||||
.add_property("allow_overlap",
|
&text_symbolizer::get_label_placement,
|
||||||
&text_symbolizer::get_allow_overlap,
|
&text_symbolizer::set_label_placement,
|
||||||
&text_symbolizer::set_allow_overlap,
|
"Set/get the placement of the label")
|
||||||
"Set/get the allow_overlap property of the label")
|
.add_property("label_position_tolerance",
|
||||||
;
|
&text_symbolizer::get_label_position_tolerance,
|
||||||
|
&text_symbolizer::set_label_position_tolerance)
|
||||||
|
.add_property("label_spacing",
|
||||||
|
&text_symbolizer::get_label_spacing,
|
||||||
|
&text_symbolizer::set_label_spacing)
|
||||||
|
.add_property("line_spacing",
|
||||||
|
&text_symbolizer::get_line_spacing,
|
||||||
|
&text_symbolizer::set_line_spacing)
|
||||||
|
.add_property("max_char_angle_delta",
|
||||||
|
&text_symbolizer::get_max_char_angle_delta,
|
||||||
|
&text_symbolizer::set_max_char_angle_delta)
|
||||||
|
.add_property("minimum_distance",
|
||||||
|
&text_symbolizer::get_minimum_distance,
|
||||||
|
&text_symbolizer::set_minimum_distance)
|
||||||
|
.add_property("name",
|
||||||
|
make_function(&text_symbolizer::get_name,return_value_policy<copy_const_reference>()),
|
||||||
|
&text_symbolizer::set_name)
|
||||||
|
.add_property("text_convert",
|
||||||
|
&text_symbolizer::get_text_convert,
|
||||||
|
&text_symbolizer::set_text_convert,
|
||||||
|
"Set/get the text conversion method")
|
||||||
|
.add_property("text_ratio",
|
||||||
|
&text_symbolizer::get_text_ratio,
|
||||||
|
&text_symbolizer::set_text_ratio)
|
||||||
|
.add_property("text_size",
|
||||||
|
&text_symbolizer::get_text_size,
|
||||||
|
&text_symbolizer::set_text_size)
|
||||||
|
.add_property("vertical_alignment",
|
||||||
|
&text_symbolizer::get_vertical_alignment,
|
||||||
|
&text_symbolizer::set_vertical_alignment,
|
||||||
|
"Set/get the vertical alignment of the label")
|
||||||
|
.add_property("wrap_width",
|
||||||
|
&text_symbolizer::get_wrap_width,
|
||||||
|
&text_symbolizer::set_wrap_width)
|
||||||
|
.add_property("wrap_character",
|
||||||
|
make_function(&text_symbolizer::get_wrap_char_string,return_value_policy<copy_const_reference>()),
|
||||||
|
&text_symbolizer::set_wrap_char_from_string)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,9 @@ namespace mapnik
|
||||||
unsigned get_wrap_width() const; // width to wrap text at, or trigger ratio
|
unsigned get_wrap_width() const; // width to wrap text at, or trigger ratio
|
||||||
void set_wrap_width(unsigned ratio);
|
void set_wrap_width(unsigned ratio);
|
||||||
unsigned char get_wrap_char() const; // character used to wrap lines
|
unsigned char get_wrap_char() const; // character used to wrap lines
|
||||||
|
std::string const& get_wrap_char_string() const; // character used to wrap lines as std::string
|
||||||
void set_wrap_char(unsigned char character);
|
void set_wrap_char(unsigned char character);
|
||||||
|
void set_wrap_char_from_string(std::string character);
|
||||||
text_convert_e get_text_convert() const; // text conversion on strings before display
|
text_convert_e get_text_convert() const; // text conversion on strings before display
|
||||||
void set_text_convert(text_convert_e convert);
|
void set_text_convert(text_convert_e convert);
|
||||||
unsigned get_line_spacing() const; // spacing between lines of text
|
unsigned get_line_spacing() const; // spacing between lines of text
|
||||||
|
|
|
@ -223,11 +223,21 @@ namespace mapnik
|
||||||
return wrap_char_;
|
return wrap_char_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const& text_symbolizer::get_wrap_char_string() const
|
||||||
|
{
|
||||||
|
return std::string(1, wrap_char_);
|
||||||
|
}
|
||||||
|
|
||||||
void text_symbolizer::set_wrap_char(unsigned char character)
|
void text_symbolizer::set_wrap_char(unsigned char character)
|
||||||
{
|
{
|
||||||
wrap_char_ = character;
|
wrap_char_ = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void text_symbolizer::set_wrap_char_from_string(std::string character)
|
||||||
|
{
|
||||||
|
wrap_char_ = (character)[0];
|
||||||
|
}
|
||||||
|
|
||||||
text_convert_e text_symbolizer::get_text_convert() const
|
text_convert_e text_symbolizer::get_text_convert() const
|
||||||
{
|
{
|
||||||
return text_convert_;
|
return text_convert_;
|
||||||
|
|
|
@ -203,6 +203,12 @@ def test_textsymbolizer_pickle():
|
||||||
eq_(ts.vertical_alignment, ts2.vertical_alignment)
|
eq_(ts.vertical_alignment, ts2.vertical_alignment)
|
||||||
eq_(ts.label_spacing, ts2.label_spacing)
|
eq_(ts.label_spacing, ts2.label_spacing)
|
||||||
eq_(ts.label_position_tolerance, ts2.label_position_tolerance)
|
eq_(ts.label_position_tolerance, ts2.label_position_tolerance)
|
||||||
|
|
||||||
|
eq_(ts.wrap_character, ts2.wrap_character)
|
||||||
|
eq_(ts.text_convert, ts2.text_convert)
|
||||||
|
eq_(ts.line_spacing, ts2.line_spacing)
|
||||||
|
eq_(ts.character_spacing, ts2.character_spacing)
|
||||||
|
|
||||||
eq_(ts.fontset, ts2.fontset)
|
eq_(ts.fontset, ts2.fontset)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue