Skip to content

Commit 114bab7

Browse files
committed
Add keys() method returning boost::python::list e.g
``` >>> import mapnik >>> sym = mapnik.PolygonSymbolizer() >>> sym.keys() [] >>> sym.fill = mapnik.Color("skyblue") >>> sym.fill_opacity = 0.7 >>> sym.keys() ['fill', 'fill-opacity'] ```
1 parent f61bfeb commit 114bab7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/mapnik_symbolizer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ boost::python::object __getitem__(mapnik::symbolizer_base const& sym, std::strin
196196
return boost::python::object();
197197
}
198198

199+
boost::python::object symbolizer_keys(mapnik::symbolizer_base const& sym)
200+
{
201+
using const_iterator = symbolizer_base::cont_type::const_iterator;
202+
boost::python::list keys;
203+
for (auto const& kv : sym.properties)
204+
{
205+
std::string name = std::get<0>(mapnik::get_meta(kv.first));
206+
keys.append(name);
207+
}
208+
return keys;
209+
}
199210
/*
200211
std::string __str__(mapnik::symbolizer const& sym)
201212
{
@@ -268,6 +279,7 @@ void export_symbolizer()
268279
.def("__setattr__",&__setitem__)
269280
.def("__getitem__",&__getitem__)
270281
.def("__getattr__",&__getitem__)
282+
.def("keys", &symbolizer_keys)
271283
//.def("__str__", &__str__)
272284
.def(self == self) // __eq__
273285
;

0 commit comments

Comments
 (0)