diff --git a/bindings/python/mapnik_symbolizer.cpp b/bindings/python/mapnik_symbolizer.cpp index aeb2d8ea1..a2d43c24b 100644 --- a/bindings/python/mapnik_symbolizer.cpp +++ b/bindings/python/mapnik_symbolizer.cpp @@ -72,13 +72,32 @@ using mapnik::parse_path; namespace { using namespace boost::python; - void __setitem__(mapnik::symbolizer_base & sym, std::string const& name, mapnik::symbolizer_base::value_type const& val) { - //std::cerr << "__setitem__ " << typeid(val).name() << std::endl; put(sym, mapnik::get_key(name), val); } +std::shared_ptr numeric_wrapper(const object& arg) +{ + std::shared_ptr result; + if (PyBool_Check(arg.ptr())) + { + mapnik::value_bool val = extract(arg); + result.reset(new mapnik::symbolizer_base::value_type(val)); + } + else if (PyFloat_Check(arg.ptr())) + { + mapnik::value_double val = extract(arg); + result.reset(new mapnik::symbolizer_base::value_type(val)); + } + else + { + mapnik::value_integer val = extract(arg); + result.reset(new mapnik::symbolizer_base::value_type(val)); + } + return result; +} + struct extract_python_object : public boost::static_visitor { typedef boost::python::object result_type; @@ -208,13 +227,14 @@ void export_symbolizer() { using namespace boost::python; - implicitly_convertible(); + //implicitly_convertible(); + implicitly_convertible(); + implicitly_convertible(); implicitly_convertible(); implicitly_convertible(); implicitly_convertible(); - implicitly_convertible(); - implicitly_convertible(); - implicitly_convertible(); + implicitly_convertible(); + enum_("keys") .value("gamma", mapnik::keys::gamma) @@ -246,6 +266,10 @@ void export_symbolizer() return_value_policy()) ; + class_("NumericWrapper") + .def("__init__", make_constructor(numeric_wrapper)) + ; + class_("SymbolizerBase",no_init) .def("__setitem__",&__setitem__) .def("__setattr__",&__setitem__)