[core] Replace std::array<double, N> usage in SourceInfo
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
@@ -19,8 +20,9 @@ public:
|
||||
uint16_t minZoom = 0;
|
||||
uint16_t maxZoom = 22;
|
||||
std::string attribution;
|
||||
std::array<double, 3> center = { { 0, 0, 0 } };
|
||||
std::array<double, 4> bounds = { { -util::LONGITUDE_MAX, -util::LATITUDE_MAX, util::LONGITUDE_MAX, util::LATITUDE_MAX } };
|
||||
LatLng center;
|
||||
double zoom = 0;
|
||||
LatLngBounds bounds = LatLngBounds::world();
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -77,14 +77,13 @@ void parseTileJSONMember(const JSValue& value, uint16_t& target, const char* nam
|
||||
target = uint;
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
void parseTileJSONMember(const JSValue& value, std::array<double, N>& target, const char* name) {
|
||||
void parseTileJSONMember(const JSValue& value, std::array<double, 4>& target, const char* name) {
|
||||
if (!value.HasMember(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const JSValue& property = value[name];
|
||||
if (!property.IsArray() || property.Size() != N) {
|
||||
if (!property.IsArray() || property.Size() > 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -284,8 +283,14 @@ std::unique_ptr<SourceInfo> StyleParser::parseTileJSON(const JSValue& value) {
|
||||
parseTileJSONMember(value, info->minZoom, "minzoom");
|
||||
parseTileJSONMember(value, info->maxZoom, "maxzoom");
|
||||
parseTileJSONMember(value, info->attribution, "attribution");
|
||||
parseTileJSONMember(value, info->center, "center");
|
||||
parseTileJSONMember(value, info->bounds, "bounds");
|
||||
|
||||
std::array<double, 4> array;
|
||||
parseTileJSONMember(value, array, "center");
|
||||
info->center = { array[0], array[1] };
|
||||
info->zoom = array[2];
|
||||
parseTileJSONMember(value, array, "bounds");
|
||||
info->bounds = LatLngBounds::hull({ array[0], array[1] }, { array[2], array[3] });
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user