+add pickle support for pattern symbolizers - see #345

This commit is contained in:
Dane Springmeyer 2009-05-24 05:45:07 +00:00
parent ff36980723
commit bd1407b7c5
2 changed files with 28 additions and 2 deletions

View file

@ -22,10 +22,22 @@
//$Id$
#include <boost/python.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/line_pattern_symbolizer.hpp>
using mapnik::line_pattern_symbolizer;
struct line_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const line_pattern_symbolizer& l)
{
boost::shared_ptr<mapnik::ImageData32> img = l.get_image();
const std::string & filename = l.get_filename();
return boost::python::make_tuple(filename,mapnik::guess_type(filename),img->width(),img->height());
}
};
void export_line_pattern_symbolizer()
{
using namespace boost::python;
@ -33,5 +45,6 @@ void export_line_pattern_symbolizer()
class_<line_pattern_symbolizer>("LinePatternSymbolizer",
init<std::string const&,
std::string const&,unsigned,unsigned>("TODO"))
.def_pickle(line_pattern_symbolizer_pickle_suite())
;
}

View file

@ -22,16 +22,29 @@
//$Id$
#include <boost/python.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/polygon_pattern_symbolizer.hpp>
using mapnik::polygon_pattern_symbolizer;
struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const polygon_pattern_symbolizer& p)
{
boost::shared_ptr<mapnik::ImageData32> img = p.get_image();
const std::string & filename = p.get_filename();
return boost::python::make_tuple(filename,mapnik::guess_type(filename),img->width(),img->height());
}
};
void export_polygon_pattern_symbolizer()
{
using namespace boost::python;
using mapnik::polygon_pattern_symbolizer;
class_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer",
init<std::string const&,
std::string const&,
unsigned,unsigned>("TODO"))
;
.def_pickle(polygon_pattern_symbolizer_pickle_suite()) ;
}