summaryrefslogtreecommitdiff
path: root/src/mbgl/style/sources/geojson_source_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/sources/geojson_source_impl.cpp')
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp35
1 files changed, 2 insertions, 33 deletions
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp
index 08ed95ea3f..1a686ff9bc 100644
--- a/src/mbgl/style/sources/geojson_source_impl.cpp
+++ b/src/mbgl/style/sources/geojson_source_impl.cpp
@@ -1,37 +1,18 @@
#include <mbgl/style/sources/geojson_source_impl.hpp>
+#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/geojson.hpp>
#include <mbgl/style/source_observer.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/renderer/sources/render_geojson_source.hpp>
-#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/constants.cpp>
#include <mbgl/util/logging.hpp>
-#include <mapbox/geojson.hpp>
-#include <mapbox/geojson/rapidjson.hpp>
#include <mapbox/geojsonvt.hpp>
-#include <mapbox/geojsonvt/convert.hpp>
#include <supercluster.hpp>
-#include <rapidjson/error/en.h>
-
-#include <sstream>
-
namespace mbgl {
namespace style {
-namespace conversion {
-
-template <>
-optional<GeoJSON> convertGeoJSON(const JSValue& value, Error& error) {
- try {
- return mapbox::geojson::convert(value);
- } catch (const std::exception& ex) {
- error = { ex.what() };
- return {};
- }
-}
-} // namespace conversion
class GeoJSONVTData : public GeoJSONData {
public:
@@ -129,20 +110,8 @@ void GeoJSONSource::Impl::loadDescription(FileSource& fileSource) {
observer->onSourceError(
base, std::make_exception_ptr(std::runtime_error("unexpectedly empty GeoJSON")));
} else {
- rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
- d.Parse<0>(res.data->c_str());
-
- if (d.HasParseError()) {
- std::stringstream message;
- message << d.GetErrorOffset() << " - "
- << rapidjson::GetParseError_En(d.GetParseError());
- observer->onSourceError(base,
- std::make_exception_ptr(std::runtime_error(message.str())));
- return;
- }
-
conversion::Error error;
- optional<GeoJSON> geoJSON = conversion::convertGeoJSON<JSValue>(d, error);
+ optional<GeoJSON> geoJSON = conversion::convertJSON<GeoJSON>(*res.data, error);
if (!geoJSON) {
Log::Error(Event::ParseStyle, "Failed to parse GeoJSON data: %s",
error.message.c_str());