diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index a46cc1ea2..e55842e26 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -66,7 +66,7 @@ void feature_add_geometries_from_wkt(Feature &feature, std::string wkt) std::string feature_to_geojson(Feature const& feature) { std::string json; - mapnik::json::geojson_generator g; + mapnik::json::feature_generator g; if (!g.generate(json,feature)) { throw std::runtime_error("Failed to generate GeoJSON"); diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index a1501e63a..06aa96207 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #if BOOST_VERSION >= 104700 @@ -163,6 +164,16 @@ std::string to_wkt2( path_type const& geom) #endif } +std::string to_geojson( path_type const& geom) +{ + std::string json; + mapnik::json::geometry_generator g; + if (!g.generate(json,geom)) + { + throw std::runtime_error("Failed to generate GeoJSON"); + } + return json; +} void export_geometry() { @@ -200,6 +211,7 @@ void export_geometry() .def("to_wkb",&to_wkb2) .def("from_wkt",from_wkt_impl) .def("from_wkb",from_wkb_impl) + .def("to_geojson",to_geojson) .staticmethod("from_wkt") .staticmethod("from_wkb") ;