Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix access to mapnik::query::property_names in python - closes #1762

  • Loading branch information...
commit 7f0c745366fc149e7b836004da431cf37f3c2401 1 parent 098f9de
@springmeyer springmeyer authored
View
23 bindings/python/mapnik_query.cpp
@@ -22,11 +22,15 @@
// boost
#include <boost/python.hpp>
+#include <boost/foreach.hpp>
// mapnik
#include <mapnik/query.hpp>
#include <mapnik/box2d.hpp>
+#include <string>
+#include <set>
+
using mapnik::query;
using mapnik::box2d;
@@ -46,11 +50,30 @@ struct resolution_to_tuple
}
};
+struct names_to_list
+{
+ static PyObject* convert(std::set<std::string> const& names)
+ {
+ boost::python::list l;
+ BOOST_FOREACH( std::string const& name, names )
+ {
+ l.append(name);
+ }
+ return python::incref(l.ptr());
+ }
+
+ static PyTypeObject const* get_pytype()
+ {
+ return &PyList_Type;
+ }
+};
+
void export_query()
{
using namespace boost::python;
to_python_converter<query::resolution_type, resolution_to_tuple> ();
+ to_python_converter<std::set<std::string>, names_to_list> ();
class_<query>("Query", "a spatial query data object",
init<box2d<double>,query::resolution_type const&,double>() )
View
4 tests/python_tests/query_test.py
@@ -17,6 +17,10 @@ def test_query_init():
r = query.resolution
assert_almost_equal(r[0], 1.0, places=7)
assert_almost_equal(r[1], 1.0, places=7)
+ # https://github.com/mapnik/mapnik/issues/1762
+ eq_(query.property_names,[])
+ query.add_property_name('migurski')
+ eq_(query.property_names,['migurski'])
# Converting *from* tuples *to* resolutions is not yet supported
@raises(TypeError)
Please sign in to comment.
Something went wrong with that request. Please try again.