[core] change RapidJSON usage to use CrtAllocator and bump GeoJSON VT

This commit is contained in:
Konstantin Käfer
2015-12-14 16:07:15 -08:00
parent 9b8f5d3be1
commit 95cef66e22
36 changed files with 165 additions and 168 deletions

View File

@@ -77,7 +77,7 @@ void Source::load() {
return;
}
rapidjson::Document d;
rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
d.Parse<0>(res.data->c_str());
if (d.HasParseError()) {

View File

@@ -11,12 +11,12 @@ namespace mbgl {
namespace {
void parse(const rapidjson::Value& value, std::vector<std::string>& target, const char* name) {
void parse(const JSValue& value, std::vector<std::string>& target, const char* name) {
if (!value.HasMember(name)) {
return;
}
const rapidjson::Value& property = value[name];
const JSValue& property = value[name];
if (!property.IsArray()) {
return;
}
@@ -32,12 +32,12 @@ void parse(const rapidjson::Value& value, std::vector<std::string>& target, cons
}
}
void parse(const rapidjson::Value& value, std::string& target, const char* name) {
void parse(const JSValue& value, std::string& target, const char* name) {
if (!value.HasMember(name)) {
return;
}
const rapidjson::Value& property = value[name];
const JSValue& property = value[name];
if (!property.IsString()) {
return;
}
@@ -45,12 +45,12 @@ void parse(const rapidjson::Value& value, std::string& target, const char* name)
target = { property.GetString(), property.GetStringLength() };
}
void parse(const rapidjson::Value& value, uint16_t& target, const char* name) {
void parse(const JSValue& value, uint16_t& target, const char* name) {
if (!value.HasMember(name)) {
return;
}
const rapidjson::Value& property = value[name];
const JSValue& property = value[name];
if (!property.IsUint()) {
return;
}
@@ -64,12 +64,12 @@ void parse(const rapidjson::Value& value, uint16_t& target, const char* name) {
}
template <size_t N>
void parse(const rapidjson::Value& value, std::array<float, N>& target, const char* name) {
void parse(const JSValue& value, std::array<float, N>& target, const char* name) {
if (!value.HasMember(name)) {
return;
}
const rapidjson::Value& property = value[name];
const JSValue& property = value[name];
if (!property.IsArray() || property.Size() != N) {
return;
}
@@ -90,7 +90,7 @@ void parse(const rapidjson::Value& value, std::array<float, N>& target, const ch
// Destructor in implementation file because header only contains forward declarations.
SourceInfo::~SourceInfo() = default;
void SourceInfo::parseTileJSONProperties(const rapidjson::Value& value) {
void SourceInfo::parseTileJSONProperties(const JSValue& value) {
parse(value, tiles, "tiles");
parse(value, min_zoom, "minzoom");
parse(value, max_zoom, "maxzoom");
@@ -99,7 +99,7 @@ void SourceInfo::parseTileJSONProperties(const rapidjson::Value& value) {
parse(value, bounds, "bounds");
}
void SourceInfo::parseGeoJSON(const rapidjson::Value& value) {
void SourceInfo::parseGeoJSON(const JSValue& value) {
using namespace mapbox::geojsonvt;
try {

View File

@@ -6,9 +6,9 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/rapidjson.hpp>
#include <mapbox/variant.hpp>
#include <rapidjson/document.h>
#include <array>
#include <vector>
@@ -38,8 +38,8 @@ public:
std::string source_id = "";
std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> geojsonvt;
void parseTileJSONProperties(const rapidjson::Value&);
void parseGeoJSON(const rapidjson::Value&);
void parseTileJSONProperties(const JSValue&);
void parseGeoJSON(const JSValue&);
std::string tileURL(const TileID& id, float pixelRatio) const;
};