feat(core): Add public stringifyGeoJSON to mbgl::style::conversion (#4345)
Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <mbgl/style/conversion.hpp>
|
#include <mbgl/style/conversion.hpp>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace style {
|
namespace style {
|
||||||
@@ -12,6 +13,12 @@ namespace conversion {
|
|||||||
// Workaround until https://github.com/mapbox/mapbox-gl-native/issues/5623 is done.
|
// Workaround until https://github.com/mapbox/mapbox-gl-native/issues/5623 is done.
|
||||||
std::optional<GeoJSON> parseGeoJSON(const std::string&, Error&);
|
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 <>
|
template <>
|
||||||
struct Converter<GeoJSON> {
|
struct Converter<GeoJSON> {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include <mbgl/style/conversion/json.hpp>
|
#include <mbgl/style/conversion/json.hpp>
|
||||||
#include <mbgl/style/conversion_impl.hpp>
|
#include <mbgl/style/conversion_impl.hpp>
|
||||||
|
|
||||||
|
#include <mapbox/geojson.hpp>
|
||||||
|
|
||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace style {
|
namespace style {
|
||||||
namespace conversion {
|
namespace conversion {
|
||||||
@@ -14,6 +16,10 @@ std::optional<GeoJSON> parseGeoJSON(const std::string& value, Error& error) {
|
|||||||
return convertJSON<GeoJSON>(value, error);
|
return convertJSON<GeoJSON>(value, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string stringifyGeoJSON(const GeoJSON& geojson) {
|
||||||
|
return mapbox::geojson::stringify(geojson);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace conversion
|
} // namespace conversion
|
||||||
} // namespace style
|
} // namespace style
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
Reference in New Issue
Block a user