summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-02-23 14:48:56 +0200
committerKonstantin Käfer <mail@kkaefer.com>2017-03-28 13:53:19 +0200
commit9b39013ce4c6f98590b80ced425e0a3bcdb3f77f (patch)
tree6afaab5e122b013f45f5e8763822ccf8ebd7c4e5 /platform
parent321d820a87b37ecd4656b8c5adf585f2f00e09e2 (diff)
downloadqtlocation-mapboxgl-9b39013ce4c6f98590b80ced425e0a3bcdb3f77f.tar.gz
[core] Internalize rapidjson.hpp
Diffstat (limited to 'platform')
-rw-r--r--platform/android/src/style/conversion/geojson.hpp24
-rw-r--r--platform/qt/src/qt_geojson.hpp27
2 files changed, 3 insertions, 48 deletions
diff --git a/platform/android/src/style/conversion/geojson.hpp b/platform/android/src/style/conversion/geojson.hpp
index 6ac6abcd7c..db474e8542 100644
--- a/platform/android/src/style/conversion/geojson.hpp
+++ b/platform/android/src/style/conversion/geojson.hpp
@@ -5,45 +5,23 @@
#include <mapbox/geojson.hpp>
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/geojson.hpp>
-#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/logging.hpp>
#include <jni/jni.hpp>
-#include <sstream>
-#include <string>
-
namespace mbgl {
namespace style {
namespace conversion {
template <>
optional<GeoJSON> convertGeoJSON(const mbgl::android::Value& value, Error& error) {
-
// Value should be a string wrapped in an object
mbgl::android::Value jsonValue = value.get("data");
if(value.isNull()) {
error = { "no json data found" };
return {};
}
- std::string jsonString = value.get("data").toString();
-
- rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
- d.Parse(jsonString.c_str());
-
- if (d.HasParseError()) {
- std::stringstream message;
- message << d.GetErrorOffset() << " - " << rapidjson::GetParseError_En(d.GetParseError());
- error = { message.str() };
- return {};
- }
-
- optional<GeoJSON> geoJSON = conversion::convertGeoJSON<JSValue>(d, error);
- if (!geoJSON) {
- error = { error.message };
- return {};
- }
- return geoJSON;
+ return convertGeoJSON(value.get("data").toString(), error);
}
template <>
diff --git a/platform/qt/src/qt_geojson.hpp b/platform/qt/src/qt_geojson.hpp
index 7c50c663dd..7d12660aec 100644
--- a/platform/qt/src/qt_geojson.hpp
+++ b/platform/qt/src/qt_geojson.hpp
@@ -2,7 +2,6 @@
#include <mapbox/geojson.hpp>
#include <mbgl/style/conversion/geojson.hpp>
-#include <mbgl/util/rapidjson.hpp>
#include <QMapbox>
@@ -10,7 +9,6 @@
#include <QDebug>
#include <QVariant>
-#include <sstream>
#include <string>
namespace QMapbox {
@@ -197,29 +195,8 @@ optional<GeoJSON> convertGeoJSON(const QVariant& value, Error& error) {
return {};
}
- auto data = value.toByteArray();
-
- rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
- if (data.endsWith(char(0))) {
- d.Parse<0>(value.toByteArray().data());
- } else {
- d.Parse<0>(value.toByteArray().constData());
- }
-
- if (d.HasParseError()) {
- std::stringstream message;
- message << d.GetErrorOffset() << " - " << rapidjson::GetParseError_En(d.GetParseError());
- error = { message.str() };
- return {};
- }
-
- optional<GeoJSON> geoJSON = convertGeoJSON<JSValue>(d, error);
- if (!geoJSON) {
- error = { error.message };
- return {};
- }
-
- return geoJSON;
+ QByteArray data = value.toByteArray();
+ return convertGeoJSON(std::string(data.constData(), data.size()), error);
}
} // namespace conversion