summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-07-17 14:54:22 -0700
committerKonstantin Käfer <mail@kkaefer.com>2014-07-17 14:54:22 -0700
commitc01143a73185431d2faa2f2ac0ccc03920cab296 (patch)
tree8717c7a926701a5288c888bb0675ace4cd9ff791
parentafe069df2b4a4b3ef72328fc960389ea9cfb121b (diff)
downloadqtlocation-mapboxgl-c01143a73185431d2faa2f2ac0ccc03920cab296.tar.gz
parse min-zoom/max-zoom values
refs mapbox/mapbox-gl-style-spec#65
-rw-r--r--include/mbgl/style/style_bucket.hpp2
-rw-r--r--src/style/style_parser.cpp19
2 files changed, 21 insertions, 0 deletions
diff --git a/include/mbgl/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp
index 62f072d9cd..6508abca20 100644
--- a/include/mbgl/style/style_bucket.hpp
+++ b/include/mbgl/style/style_bucket.hpp
@@ -79,6 +79,8 @@ public:
std::string source_layer;
FilterExpression filter;
StyleBucketRender render = std::false_type();
+ float min_zoom = -std::numeric_limits<float>::infinity();
+ float max_zoom = std::numeric_limits<float>::infinity();
};
diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp
index 3c79ee3c92..c037e51726 100644
--- a/src/style/style_parser.cpp
+++ b/src/style/style_parser.cpp
@@ -2,6 +2,7 @@
#include <mbgl/style/style_layer_group.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/std.hpp>
+#include <mbgl/platform/log.hpp>
#include <csscolorparser/csscolorparser.hpp>
namespace mbgl {
@@ -714,6 +715,24 @@ void StyleParser::parseBucket(JSVal value, std::shared_ptr<StyleLayer> &layer) {
JSVal value_render = replaceConstant(value["render"]);
parseRender(value_render, layer);
}
+
+ if (value.HasMember("min-zoom")) {
+ JSVal min_zoom = value["min-zoom"];
+ if (min_zoom.IsNumber()) {
+ layer->bucket->min_zoom = min_zoom.GetDouble();
+ } else {
+ Log::Warning(Event::ParseStyle, "min-zoom of layer %s must be numeric", layer->id.c_str());
+ }
+ }
+
+ if (value.HasMember("max-zoom")) {
+ JSVal max_zoom = value["max-zoom"];
+ if (max_zoom.IsNumber()) {
+ layer->bucket->min_zoom = max_zoom.GetDouble();
+ } else {
+ Log::Warning(Event::ParseStyle, "max-zoom of layer %s must be numeric", layer->id.c_str());
+ }
+ }
}
FilterExpression StyleParser::parseFilter(JSVal value) {