diff --git a/bindings/python/mapnik_proj_transform.cpp b/bindings/python/mapnik_proj_transform.cpp index b1bdb87bf..3e06130e7 100644 --- a/bindings/python/mapnik_proj_transform.cpp +++ b/bindings/python/mapnik_proj_transform.cpp @@ -25,6 +25,19 @@ #include // boost #include + +using mapnik::proj_transform; +using mapnik::projection; + +struct proj_transform_pickle_suite : boost::python::pickle_suite +{ + static boost::python::tuple + getinitargs(const proj_transform& p) + { + using namespace boost::python; + return boost::python::make_tuple(p.source(),p.dest()); + } +}; namespace { @@ -73,10 +86,10 @@ namespace { void export_proj_transform () { - using namespace boost::python; - using mapnik::proj_transform; - using mapnik::projection; + using namespace boost::python; + class_("ProjTransform", init< projection const&, projection const& >()) + .def_pickle(proj_transform_pickle_suite()) .def("forward", forward_transform_c) .def("backward",backward_transform_c) .def("forward", forward_transform_env) diff --git a/bindings/python/mapnik_view_transform.cpp b/bindings/python/mapnik_view_transform.cpp index e2ae13e44..ed636d706 100644 --- a/bindings/python/mapnik_view_transform.cpp +++ b/bindings/python/mapnik_view_transform.cpp @@ -27,6 +27,18 @@ // mapnik #include +using mapnik::CoordTransform; + +struct view_transform_pickle_suite : boost::python::pickle_suite +{ + static boost::python::tuple + getinitargs(const CoordTransform& c) + { + using namespace boost::python; + return boost::python::make_tuple(c.width(),c.height(),c.extent()); + } +}; + namespace { mapnik::coord2d forward_point(mapnik::CoordTransform const& t, mapnik::coord2d const& in) @@ -58,11 +70,11 @@ void export_view_transform() { using namespace boost::python; using mapnik::Envelope; - using mapnik::CoordTransform; using mapnik::coord2d; class_("ViewTransform",init const& > ( "Create a ViewTransform with a width and height as integers and extent")) + .def_pickle(view_transform_pickle_suite()) .def("forward", forward_point) .def("backward",backward_point) .def("forward", forward_envelope) diff --git a/include/mapnik/ctrans.hpp b/include/mapnik/ctrans.hpp index 1dd1ba44d..486012ae4 100644 --- a/include/mapnik/ctrans.hpp +++ b/include/mapnik/ctrans.hpp @@ -124,8 +124,8 @@ namespace mapnik { class CoordTransform { private: - int width; - int height; + int width_; + int height_; double sx_; double sy_; Envelope extent_; @@ -134,12 +134,22 @@ namespace mapnik { public: CoordTransform(int width,int height,const Envelope& extent, double offset_x = 0, double offset_y = 0) - :width(width),height(height),extent_(extent),offset_x_(offset_x),offset_y_(offset_y) + :width_(width),height_(height),extent_(extent),offset_x_(offset_x),offset_y_(offset_y) { - sx_ = ((double)width)/extent_.width(); - sy_ = ((double)height)/extent_.height(); + sx_ = ((double)width_)/extent_.width(); + sy_ = ((double)height_)/extent_.height(); } - + + inline int width() const + { + return width_; + } + + inline int height() const + { + return height_; + } + inline double scale_x() const { return sx_; diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index 329553db5..923a26c5f 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -40,6 +40,8 @@ namespace mapnik { bool forward (double& x, double& y , double& z) const; bool backward (double& x, double& y , double& z) const; + mapnik::projection const& source() const; + mapnik::projection const& dest() const; private: projection const& source_; diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index f08f9f9c6..26c32b0e7 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -99,5 +99,15 @@ namespace mapnik { } return true; - } + } + + mapnik::projection const& proj_transform::source() const + { + return source_; + } + mapnik::projection const& proj_transform::dest() const + { + return dest_; + } + }