keyword arguments for Layer factory

This commit is contained in:
Artem Pavlenko 2006-03-01 15:15:37 +00:00
parent d0f0f5a564
commit 06da5f14eb
3 changed files with 15 additions and 6 deletions

View file

@ -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)

View file

@ -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<len(keys);++i)
{
std::string key=extract<std::string>(keys[i]);
std::string value=extract<std::string>(d[key]);
params[key] = value;
}
return Layer(params);
}
}
@ -109,5 +114,5 @@ void export_layer()
(&Layer::styles,return_value_policy<reference_existing_object>()))
.def_pickle(layer_pickle_suite())
;
def("Layer",&create_layer);
def("_Layer",&create_layer);
}

View file

@ -29,6 +29,6 @@ void export_text_symbolizer()
using namespace boost::python;
class_<text_symbolizer>("TextSymbolizer",
init<std::string const&,Color const&>("TODO"))
init<std::string const&,unsigned,Color const&>("TODO"))
;
}