diff --git a/include/mbgl/style/conversion/geojson.hpp b/include/mbgl/style/conversion/geojson.hpp index 063b5bc63820..bacc3342b688 100644 --- a/include/mbgl/style/conversion/geojson.hpp +++ b/include/mbgl/style/conversion/geojson.hpp @@ -4,6 +4,7 @@ #include #include +#include namespace mbgl { namespace style { @@ -12,6 +13,12 @@ namespace conversion { // Workaround until https://github.com/mapbox/mapbox-gl-native/issues/5623 is done. std::optional parseGeoJSON(const std::string&, Error&); +// Serialize a GeoJSON value back to a JSON string. This is the public +// counterpart to parseGeoJSON: consumers that link the core through the +// amalgam (which exports only mbgl::* symbols) cannot reach the bundled +// mapbox::geojson::stringify directly. +std::string stringifyGeoJSON(const GeoJSON&); + template <> struct Converter { public: diff --git a/src/mbgl/style/conversion/geojson.cpp b/src/mbgl/style/conversion/geojson.cpp index 0a64ca61fb17..192e1d46ad5c 100644 --- a/src/mbgl/style/conversion/geojson.cpp +++ b/src/mbgl/style/conversion/geojson.cpp @@ -2,6 +2,8 @@ #include #include +#include + namespace mbgl { namespace style { namespace conversion { @@ -14,6 +16,10 @@ std::optional parseGeoJSON(const std::string& value, Error& error) { return convertJSON(value, error); } +std::string stringifyGeoJSON(const GeoJSON& geojson) { + return mapbox::geojson::stringify(geojson); +} + } // namespace conversion } // namespace style } // namespace mbgl