summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-02-18 17:20:31 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-01 20:58:54 +0000
commitfcaafcc428f932e36e195e6801855344798ca33e (patch)
treea399b12baaa652acf53f19ea1f36af34737dceeb /src
parentc17e95498349db7f459cd629f2d65b9f3bfb49c6 (diff)
downloadqtlocation-mapboxgl-fcaafcc428f932e36e195e6801855344798ca33e.tar.gz
[core] Replace std::array<double, N> usage in SourceInfo
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/source/source_info.hpp6
-rw-r--r--src/mbgl/style/style_parser.cpp15
2 files changed, 14 insertions, 7 deletions
diff --git a/src/mbgl/source/source_info.hpp b/src/mbgl/source/source_info.hpp
index 9e905d2b9e..db584d9e33 100644
--- a/src/mbgl/source/source_info.hpp
+++ b/src/mbgl/source/source_info.hpp
@@ -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
diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp
index 767bee095d..797f20adeb 100644
--- a/src/mbgl/style/style_parser.cpp
+++ b/src/mbgl/style/style_parser.cpp
@@ -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;
}