From f3249c8fdaeef8e02ad230fa87e8677746f00d3f Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 26 Jan 2012 18:32:16 -0500 Subject: [PATCH] Bind statistics in Python --- bindings/python/mapnik_datasource.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 7f9ce5d2f..99479d6e7 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -93,6 +93,24 @@ boost::python::dict describe(boost::shared_ptr const& ds) return description; } +boost::python::dict statistics(boost::shared_ptr const& ds) +{ + boost::python::dict description; + std::map stats = ds->get_statistics(); + std::map::iterator it; + + for (it = stats.begin(); it != stats.end(); it++) { + boost::python::dict field; + mapnik::parameters::const_iterator k = it->second.begin(); + for (; k != it->second.end(); ++k) { + field[k->first] = boost::get(k->second); + } + description[it->first] = field; + } + + return description; +} + boost::python::list fields(boost::shared_ptr const& ds) { boost::python::list flds; @@ -165,6 +183,7 @@ void export_datasource() .def("type",&datasource::type) .def("geometry_type",&datasource::get_geometry_type) .def("describe",&describe) + .def("statistics",&statistics) .def("envelope",&datasource::envelope) .def("features",&datasource::features) .def("bind",&datasource::bind)