+copy/pickle support for Coord objects - see #345

This commit is contained in:
Dane Springmeyer 2009-05-20 00:08:18 +00:00
parent 7d9ac2a094
commit 9a2894dc3c

View file

@ -24,11 +24,23 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include <mapnik/coord.hpp> #include <mapnik/coord.hpp>
using mapnik::coord;
struct coord_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const coord<double,2>& c)
{
using namespace boost::python;
return boost::python::make_tuple(c.x,c.y);
}
};
void export_coord() void export_coord()
{ {
using namespace boost::python; using namespace boost::python;
using mapnik::coord;
class_<coord<double,2> >("Coord",init<double,double>()) class_<coord<double,2> >("Coord",init<double,double>())
.def_pickle(coord_pickle_suite())
.def_readwrite("x", &coord<double,2>::x) .def_readwrite("x", &coord<double,2>::x)
.def_readwrite("y", &coord<double,2>::y) .def_readwrite("y", &coord<double,2>::y)
.def(self == self) // __eq__ .def(self == self) // __eq__