From def1c709cefacbf2b599bcddc45558482b4595fc Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 24 May 2009 06:02:33 +0000 Subject: [PATCH] +add pickle support to projection class - see #345 --- bindings/python/mapnik_projection.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bindings/python/mapnik_projection.cpp b/bindings/python/mapnik_projection.cpp index 067a625ba..eed5ec6e1 100644 --- a/bindings/python/mapnik_projection.cpp +++ b/bindings/python/mapnik_projection.cpp @@ -25,6 +25,18 @@ #include #include +using mapnik::projection; + +struct projection_pickle_suite : boost::python::pickle_suite +{ + static boost::python::tuple + getinitargs(const projection& p) + { + using namespace boost::python; + return boost::python::make_tuple(p.params()); + } +}; + namespace { mapnik::coord2d forward_pt(mapnik::coord2d const& pt, mapnik::projection const& prj) @@ -73,9 +85,9 @@ namespace { void export_projection () { using namespace boost::python; - using mapnik::projection; - + class_("Projection", init >()) + .def_pickle(projection_pickle_suite()) .def ("params", make_function(&projection::params, return_value_policy())) .add_property ("geographic",&projection::is_geographic)