Update tests.

This commit is contained in:
Hermann Kraus 2012-02-21 09:52:14 +01:00
parent 8568c62e8e
commit d203d56d34
4 changed files with 34 additions and 30 deletions

View File

@ -188,6 +188,9 @@ void export_shield_symbolizer()
.add_property("minimum_distance",
&shield_symbolizer::get_minimum_distance,
&shield_symbolizer::set_minimum_distance)
.add_property("minimum_padding",
&shield_symbolizer::get_minimum_padding,
&shield_symbolizer::set_minimum_padding)
.add_property("name",&shield_symbolizer::get_name,
&shield_symbolizer::set_name)
.add_property("opacity",

View File

@ -357,16 +357,16 @@ void export_text_placement()
;
class_<text_symbolizer_properties>
class_with_converter<text_symbolizer_properties>
("TextSymbolizerProperties")
.def_readwrite_convert("label_placement", &text_symbolizer_properties::label_placement)
.def_readwrite_convert("horizontal_alignment", &text_symbolizer_properties::halign)
.def_readwrite_convert("justify_alignment", &text_symbolizer_properties::jalign)
.def_readwrite_convert("vertical_alignment", &text_symbolizer_properties::valign)
.def_readwrite("orientation", &text_symbolizer_properties::orientation)
.add_property("displacement",
&get_displacement,
&set_displacement)
.def_readwrite("label_placement", &text_symbolizer_properties::label_placement)
.def_readwrite("horizontal_alignment", &text_symbolizer_properties::halign)
.def_readwrite("justify_alignment", &text_symbolizer_properties::jalign)
.def_readwrite("vertical_alignment", &text_symbolizer_properties::valign)
.def_readwrite("label_spacing", &text_symbolizer_properties::label_spacing)
.def_readwrite("label_position_tolerance", &text_symbolizer_properties::label_position_tolerance)
.def_readwrite("avoid_edges", &text_symbolizer_properties::avoid_edges)
@ -483,22 +483,22 @@ void export_text_placement()
register_ptr_to_python<boost::shared_ptr<formatting::text_node> >();
class_with_optional<FormatNodeWrap,
class_with_converter<FormatNodeWrap,
boost::shared_ptr<FormatNodeWrap>,
bases<formatting::node>,
boost::noncopyable>
("FormattingFormat")
.def_readwrite_optional("text_size", &formatting::format_node::text_size)
.def_readwrite_optional("face_name", &formatting::format_node::face_name)
.def_readwrite_optional("character_spacing", &formatting::format_node::character_spacing)
.def_readwrite_optional("line_spacing", &formatting::format_node::line_spacing)
.def_readwrite_optional("text_opacity", &formatting::format_node::text_opacity)
.def_readwrite_optional("wrap_char", &formatting::format_node::wrap_char)
.def_readwrite_optional("wrap_before", &formatting::format_node::wrap_before)
.def_readwrite_optional("text_transform", &formatting::format_node::text_transform)
.def_readwrite_optional("fill", &formatting::format_node::fill)
.def_readwrite_optional("halo_fill", &formatting::format_node::halo_fill)
.def_readwrite_optional("halo_radius", &formatting::format_node::halo_radius)
.def_readwrite_convert("text_size", &formatting::format_node::text_size)
.def_readwrite_convert("face_name", &formatting::format_node::face_name)
.def_readwrite_convert("character_spacing", &formatting::format_node::character_spacing)
.def_readwrite_convert("line_spacing", &formatting::format_node::line_spacing)
.def_readwrite_convert("text_opacity", &formatting::format_node::text_opacity)
.def_readwrite_convert("wrap_char", &formatting::format_node::wrap_char)
.def_readwrite_convert("wrap_before", &formatting::format_node::wrap_before)
.def_readwrite_convert("text_transform", &formatting::format_node::text_transform)
.def_readwrite_convert("fill", &formatting::format_node::fill)
.def_readwrite_convert("halo_fill", &formatting::format_node::halo_fill)
.def_readwrite_convert("halo_radius", &formatting::format_node::halo_radius)
.def("apply", &formatting::format_node::apply, &FormatNodeWrap::default_apply)
.add_property("child",
&formatting::format_node::get_child,

View File

@ -104,31 +104,31 @@ struct python_optional : public boost::noncopyable
See http://osdir.com/ml/python.c++/2003-11/msg00158.html
*/
template <typename T, typename X1, typename X2, typename X3>
class class_with_optional : public boost::python::class_<T, X1, X2, X3>
template <typename T, typename X1 = boost::python::detail::not_specified, typename X2 = boost::python::detail::not_specified, typename X3 = boost::python::detail::not_specified>
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
{
public:
typedef class_with_optional<T,X1,X2,X3> self;
typedef class_with_converter<T,X1,X2,X3> self;
// Construct with the class name, with or without docstring, and default __init__() function
class_with_optional(char const* name, char const* doc = 0) : boost::python::class_<T, X1, X2, X3>(name, doc) { }
class_with_converter(char const* name, char const* doc = 0) : boost::python::class_<T, X1, X2, X3>(name, doc) { }
// Construct with class name, no docstring, and an uncallable __init__ function
class_with_optional(char const* name, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, y) { }
class_with_converter(char const* name, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, y) { }
// Construct with class name, docstring, and an uncallable __init__ function
class_with_optional(char const* name, char const* doc, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, doc, y) { }
class_with_converter(char const* name, char const* doc, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, doc, y) { }
// Construct with class name and init<> function
template <class DerivedT> class_with_optional(char const* name, boost::python::init_base<DerivedT> const& i)
template <class DerivedT> class_with_converter(char const* name, boost::python::init_base<DerivedT> const& i)
: boost::python::class_<T, X1, X2, X3>(name, i) { }
// Construct with class name, docstring and init<> function
template <class DerivedT>
inline class_with_optional(char const* name, char const* doc, boost::python::init_base<DerivedT> const& i)
inline class_with_converter(char const* name, char const* doc, boost::python::init_base<DerivedT> const& i)
: boost::python::class_<T, X1, X2, X3>(name, doc, i) { }
template <class D>
self& def_readwrite_optional(char const* name, D const& d, char const* doc=0)
self& def_readwrite_convert(char const* name, D const& d, char const* doc=0)
{
this->add_property(name,
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),

View File

@ -198,10 +198,11 @@ def test_textsymbolizer_init():
ts = mapnik.TextSymbolizer(mapnik.Expression('[Field_Name]'), 'Font Name', 8, mapnik.Color('black'))
# eq_(str(ts.name), str(mapnik2.Expression('[Field_Name]'))) name field is no longer supported
eq_(ts.face_name, 'Font Name')
eq_(ts.text_size, 8)
eq_(ts.fill, mapnik.Color('black'))
eq_(ts.label_placement, mapnik.label_placement.POINT_PLACEMENT)
eq_(ts.format.face_name, 'Font Name')
eq_(ts.format.text_size, 8)
eq_(ts.format.fill, mapnik.Color('black'))
eq_(ts.properties.label_placement, mapnik.label_placement.POINT_PLACEMENT)
eq_(ts.properties.horizontal_alignment, mapnik.horizontal_alignment.AUTO)
# Map initialization
def test_layer_init():