Changeset 913
- Timestamp:
- 02/15/09 20:53:34 (18 months ago)
- Location:
- trunk/bindings/python
- Files:
-
- 2 modified
-
mapnik_datasource.cpp (modified) (2 diffs)
-
mapnik_layer.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/mapnik_datasource.cpp
r790 r913 32 32 #include <mapnik/feature_layer_desc.hpp> 33 33 #include <mapnik/memory_datasource.hpp> 34 35 36 using mapnik::datasource; 37 using mapnik::point_datasource; 38 39 struct ds_pickle_suite : boost::python::pickle_suite 40 { 41 static boost::python::tuple 42 getinitargs(const datasource& ds) 43 { 44 mapnik::parameters params = ds.params(); 45 return boost::python::make_tuple(params); 46 } 47 }; 34 48 35 49 namespace … … 84 98 { 85 99 using namespace boost::python; 86 using mapnik::datasource; 87 using mapnik::point_datasource; 88 100 89 101 class_<datasource,boost::shared_ptr<datasource>, 90 102 boost::noncopyable>("Datasource",no_init) 103 .def_pickle(ds_pickle_suite() 104 ) 91 105 .def("envelope",&datasource::envelope) 92 106 .def("descriptor",&datasource::get_descriptor) //todo -
trunk/bindings/python/mapnik_layer.cpp
r776 r913 23 23 24 24 25 // boost 25 26 #include <boost/python.hpp> 26 27 #include <boost/python/detail/api_placeholder.hpp> 27 28 #include <boost/python/suite/indexing/vector_indexing_suite.hpp> 29 30 // mapnik 28 31 #include <mapnik/layer.hpp> 32 #include <mapnik/datasource.hpp> 29 33 30 34 using mapnik::Layer; 31 35 using mapnik::parameters; 36 using mapnik::datasource; 37 38 39 struct layer_pickle_suite : boost::python::pickle_suite 40 { 41 static boost::python::tuple 42 getinitargs(const Layer& l) 43 { 44 return boost::python::make_tuple(l.name(),l.srs()); 45 } 46 47 static boost::python::tuple 48 getstate(const Layer& l) 49 { 50 boost::python::list s; 51 std::vector<std::string> const& style_names = l.styles(); 52 for (unsigned i = 0; i < style_names.size(); ++i) 53 { 54 s.append(style_names[i]); 55 } 56 return boost::python::make_tuple(l.abstract(),l.title(),l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource(),s); 57 } 58 59 static void 60 setstate (Layer& l, boost::python::tuple state) 61 { 62 using namespace boost::python; 63 if (len(state) != 8) 64 { 65 PyErr_SetObject(PyExc_ValueError, 66 ("expected 8-item tuple in call to __setstate__; got %s" 67 % state).ptr() 68 ); 69 throw_error_already_set(); 70 } 71 72 if (state[0]) 73 { 74 l.set_abstract(extract<std::string>(state[0])); 75 } 76 77 if (state[1]) 78 { 79 l.set_title(extract<std::string>(state[1])); 80 } 81 82 if (state[2]) 83 { 84 l.set_clear_label_cache(extract<bool>(state[2])); 85 } 86 87 if (state[3]) 88 { 89 l.setMinZoom(extract<double>(state[3])); 90 } 91 92 if (state[4]) 93 { 94 l.setMaxZoom(extract<double>(state[4])); 95 } 96 97 if (state[5]) 98 { 99 l.setQueryable(extract<bool>(state[5])); 100 } 101 102 if (state[6]) 103 { 104 boost::shared_ptr<datasource> ds = extract<boost::shared_ptr<datasource> >(state[6]); 105 l.set_datasource(ds); 106 } 107 108 boost::python::list s = extract<boost::python::list>(state[7]); 109 for (int i=0;i<len(s);++i) 110 { 111 l.add_style(extract<std::string>(s[i])); 112 } 113 } 114 }; 32 115 33 116 std::vector<std::string> & (mapnik::Layer::*_styles_)() = &mapnik::Layer::styles; … … 52 135 )) 53 136 137 .def_pickle(layer_pickle_suite() 138 ) 139 54 140 .def("envelope",&Layer::envelope, 55 141 "Return the geographic envelope/bounding box "
