Skip to content
Browse files

reflect feature's properties in Python

(see wiki for more info and usage)
  • Loading branch information...
1 parent bb035bd commit 995980433e28159a292a4def213911bbbf6bf30b @artemp artemp committed Dec 31, 2006
Showing with 15 additions and 2 deletions.
  1. +14 −1 bindings/python/mapnik_feature.cpp
  2. +1 −1 include/mapnik/feature.hpp
View
15 bindings/python/mapnik_feature.cpp
@@ -22,6 +22,7 @@
//$Id$
// boost
+#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <boost/python.hpp>
// mapnik
#include <mapnik/feature.hpp>
@@ -33,7 +34,19 @@ void export_feature()
class_<Feature,boost::shared_ptr<Feature>,
boost::noncopyable>("Feature",no_init)
.def("id",&Feature::id)
- //.def("__iter__", range<>())
.def("__str__",&Feature::to_string)
+ .add_property("properties",
+ make_function(&Feature::props,return_value_policy<reference_existing_object>()))
;
+
+ //implicitly_convertible<std::string,mapnik::value>();
+
+ class_<std::map<std::string, mapnik::value> >("Properties")
+ .def(map_indexing_suite<std::map<std::string, mapnik::value
+ > >())
+ ;
+
+ class_<mapnik::value>("Value")
+ .def("__str__",&mapnik::value::to_string)
+ ;
}
View
2 include/mapnik/feature.hpp
@@ -92,7 +92,7 @@ namespace mapnik {
raster_=raster;
}
- const properties& get_properties() const
+ std::map<std::string,value> const& props() const
{
return props_;
}

0 comments on commit 9959804

Please sign in to comment.
Something went wrong with that request. Please try again.