diff --git a/bindings/python/mapnik/__init__.py b/bindings/python/mapnik/__init__.py index 1b10836aa..61ac36f63 100644 --- a/bindings/python/mapnik/__init__.py +++ b/bindings/python/mapnik/__init__.py @@ -49,6 +49,10 @@ class _Envelope(Envelope,_injector): return 'Envelope(%s,%s,%s,%s)' % \ (self.minx,self.miny,self.maxx,self.maxy) +def Layer (**keywords): + return _Layer(keywords) + + #register datasources from mapnik import DatasourceCache DatasourceCache.instance().register_datasources('%s' % inputpluginspath) diff --git a/bindings/python/mapnik_layer.cpp b/bindings/python/mapnik_layer.cpp index b0d0e97bd..bd82c22f7 100644 --- a/bindings/python/mapnik_layer.cpp +++ b/bindings/python/mapnik_layer.cpp @@ -81,13 +81,18 @@ struct layer_pickle_suite : boost::python::pickle_suite namespace { + //user-friendly wrapper that uses Python dictionary using namespace boost::python; - Layer create_layer(const char* name, const char* type, const char* file) + _Layer create_layer(const dict& d) { parameters params; - params["name"] = name; - params["type"] = type; - params["file"] = file; + boost::python::list keys=d.keys(); + for (int i=0;i(keys[i]); + std::string value=extract(d[key]); + params[key] = value; + } return Layer(params); } } @@ -109,5 +114,5 @@ void export_layer() (&Layer::styles,return_value_policy())) .def_pickle(layer_pickle_suite()) ; - def("Layer",&create_layer); + def("_Layer",&create_layer); } diff --git a/bindings/python/mapnik_text_symbolizer.cpp b/bindings/python/mapnik_text_symbolizer.cpp index dfa72e04b..2989ab0cb 100644 --- a/bindings/python/mapnik_text_symbolizer.cpp +++ b/bindings/python/mapnik_text_symbolizer.cpp @@ -29,6 +29,6 @@ void export_text_symbolizer() using namespace boost::python; class_("TextSymbolizer", - init("TODO")) + init("TODO")) ; }