diff --git a/bindings/python/mapnik_raster_symbolizer.cpp b/bindings/python/mapnik_raster_symbolizer.cpp index 44a1f1eb4..711d08e12 100644 --- a/bindings/python/mapnik_raster_symbolizer.cpp +++ b/bindings/python/mapnik_raster_symbolizer.cpp @@ -24,13 +24,52 @@ #include #include +using mapnik::raster_symbolizer; + +struct raster_symbolizer_pickle_suite : boost::python::pickle_suite +{ + /* + static boost::python::tuple + getinitargs(const raster_symbolizer& r) + { + return boost::python::make_tuple(); + } + */ + + static boost::python::tuple + getstate(const raster_symbolizer& r) + { + return boost::python::make_tuple(r.get_mode(),r.get_scaling(),r.get_opacity()); + } + + static void + setstate (raster_symbolizer& r, boost::python::tuple state) + { + using namespace boost::python; + if (len(state) != 3) + { + PyErr_SetObject(PyExc_ValueError, + ("expected 3-item tuple in call to __setstate__; got %s" + % state).ptr() + ); + throw_error_already_set(); + } + + r.set_mode(extract(state[0])); + r.set_scaling(extract(state[1])); + r.set_opacity(extract(state[2])); + } + +}; + void export_raster_symbolizer() { using namespace boost::python; - using mapnik::raster_symbolizer; class_("RasterSymbolizer", init<>("Default ctor")) + + .def_pickle(raster_symbolizer_pickle_suite()) .add_property("mode", make_function(&raster_symbolizer::get_mode,return_value_policy()),