Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/mbgl/style/conversion/geojson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <mbgl/style/conversion.hpp>

#include <optional>
#include <string>

namespace mbgl {
namespace style {
Expand All @@ -12,6 +13,12 @@ namespace conversion {
// Workaround until https://github.com/mapbox/mapbox-gl-native/issues/5623 is done.
std::optional<GeoJSON> 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<GeoJSON> {
public:
Expand Down
6 changes: 6 additions & 0 deletions src/mbgl/style/conversion/geojson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion_impl.hpp>

#include <mapbox/geojson.hpp>

namespace mbgl {
namespace style {
namespace conversion {
Expand All @@ -14,6 +16,10 @@ std::optional<GeoJSON> parseGeoJSON(const std::string& value, Error& error) {
return convertJSON<GeoJSON>(value, error);
}

std::string stringifyGeoJSON(const GeoJSON& geojson) {
return mapbox::geojson::stringify(geojson);
}

} // namespace conversion
} // namespace style
} // namespace mbgl
Loading