#pragma once #include "../value.hpp" #include #include #include #include #include #include #include #include namespace mbgl { namespace style { namespace conversion { template <> Result convertGeoJSON(const mbgl::android::Value& value) { //Value should be a string wrapped in an object mbgl::android::Value jsonValue = value.get("data"); if(value.isNull()) { return Error { "no json data found" }; } std::string jsonString = value.get("data").toString(); rapidjson::GenericDocument, rapidjson::CrtAllocator> d; d.Parse(jsonString.c_str()); if (d.HasParseError()) { std::stringstream message; message << d.GetErrorOffset() << " - " << rapidjson::GetParseError_En(d.GetParseError()); return Error { message.str() }; } conversion::Result geoJSON = conversion::convertGeoJSON(d); if (!geoJSON) { return Error { geoJSON.error().message }; } return geoJSON; } template <> struct Converter { Result operator()(const mbgl::android::Value& value) const { return convertGeoJSON(value); } }; } // namespace conversion } // namespace style } // namespace mbgl