diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 30f2876df..516c5fc90 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace { @@ -88,6 +89,16 @@ PyObject* to_wkb( geometry_type const& geom) ((const char*)wkb->buffer(),wkb->size()); } +std::string to_wkt( geometry_type const& geom) +{ + std::string wkt; // Use Python String directly ? + bool result = mapnik::util::to_wkt(wkt,geom); + if (!result) + { + throw std::runtime_error("Generate WKT failed"); + } + return wkt; +} void export_geometry() { @@ -108,6 +119,7 @@ void export_geometry() // .def("__str__",&geometry_type::to_string) .def("type",&geometry_type::type) .def("to_wkb",&to_wkb) + .def("to_wkt",&to_wkt) // TODO add other geometry_type methods ;