From f24641e80247eeb457a8d4df01c2870236167dcd Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 17 Aug 2012 16:53:43 +0100 Subject: [PATCH] + add envelope() method to mapnik.Path --- bindings/python/mapnik_geometry.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 7357c4b59..85dd99dee 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -97,6 +97,25 @@ boost::shared_ptr from_geojson_impl(std::string const& json) return paths; } +mapnik::box2d envelope_impl(path_type & p) +{ + mapnik::box2d b; + bool first = true; + BOOST_FOREACH(mapnik::geometry_type const& geom, p) + { + if (first) + { + b = geom.envelope(); + first=false; + } + else + { + b.expand_to_include(geom.envelope()); + } + } + return b; +} + } inline std::string boost_version() @@ -235,6 +254,7 @@ void export_geometry() class_, boost::noncopyable>("Path") .def("__getitem__", getitem_impl,return_value_policy()) .def("__len__", &path_type::size) + .def("envelope",envelope_impl) .def("add_wkt",add_wkt_impl) .def("add_wkb",add_wkb_impl) .def("add_geojson",add_geojson_impl)