summaryrefslogtreecommitdiff
path: root/platform/glfw
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-06-27 16:57:23 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-06-29 15:38:11 -0700
commit542a4b4501794653b55fd1ffc60cb01348d8fc88 (patch)
tree9e451d4117427044d4155396992faf0495a544f7 /platform/glfw
parent16a3f318a13448a46a4f59b0e8df6a7f0b73bc17 (diff)
downloadqtlocation-mapboxgl-542a4b4501794653b55fd1ffc60cb01348d8fc88.tar.gz
[core] Replace use of *Stops with expressions DSL
Diffstat (limited to 'platform/glfw')
-rw-r--r--platform/glfw/glfw_view.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp
index fcb470e114..a08dc7c768 100644
--- a/platform/glfw/glfw_view.cpp
+++ b/platform/glfw/glfw_view.cpp
@@ -7,8 +7,7 @@
#include <mbgl/style/image.hpp>
#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
-#include <mbgl/style/expression/compound_expression.hpp>
-#include <mbgl/style/expression/literal.hpp>
+#include <mbgl/style/expression/dsl.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/platform.hpp>
#include <mbgl/util/string.hpp>
@@ -622,8 +621,8 @@ void GLFWView::onDidFinishLoadingStyle() {
void GLFWView::toggle3DExtrusions(bool visible) {
using namespace mbgl::style;
- using namespace mbgl::style::expression;
-
+ using namespace mbgl::style::expression::dsl;
+
show3DExtrusions = visible;
// Satellite-only style does not contain building extrusions data.
@@ -632,34 +631,22 @@ void GLFWView::toggle3DExtrusions(bool visible) {
}
if (auto layer = map->getStyle().getLayer("3d-buildings")) {
- layer->setVisibility(mbgl::style::VisibilityType(!show3DExtrusions));
+ layer->setVisibility(VisibilityType(!show3DExtrusions));
return;
}
- auto extrusionLayer = std::make_unique<mbgl::style::FillExtrusionLayer>("3d-buildings", "composite");
+ auto extrusionLayer = std::make_unique<FillExtrusionLayer>("3d-buildings", "composite");
extrusionLayer->setSourceLayer("building");
extrusionLayer->setMinZoom(15.0f);
-
- ParsingContext parsingContext;
- extrusionLayer->setFilter(Filter(createCompoundExpression("filter-==", createLiteral("extrude"), createLiteral("true"), parsingContext)));
-
- auto colorFn = mbgl::style::SourceFunction<mbgl::Color> { "height",
- mbgl::style::ExponentialStops<mbgl::Color> {
- std::map<float, mbgl::Color> {
- { 0.f, *mbgl::Color::parse("#160e23") },
- { 50.f, *mbgl::Color::parse("#00615f") },
- { 100.f, *mbgl::Color::parse("#55e9ff") }
- }
- }
- };
- extrusionLayer->setFillExtrusionColor({ colorFn });
- extrusionLayer->setFillExtrusionOpacity({ 0.6f });
-
- auto heightSourceFn = mbgl::style::SourceFunction<float> { "height", mbgl::style::IdentityStops<float>() };
- extrusionLayer->setFillExtrusionHeight({ heightSourceFn });
-
- auto baseSourceFn = mbgl::style::SourceFunction<float> { "min_height", mbgl::style::IdentityStops<float>() };
- extrusionLayer->setFillExtrusionBase({ baseSourceFn });
+ extrusionLayer->setFilter(Filter(eq(get("extrude"), literal("true"))));
+ extrusionLayer->setFillExtrusionColor(SourceFunction<mbgl::Color>(
+ interpolate(linear(), get("height"),
+ 0.f, toColor("#160e23"),
+ 50.f, toColor("#00615f"),
+ 100.f, toColor("#55e9ff"))));
+ extrusionLayer->setFillExtrusionOpacity(0.6f);
+ extrusionLayer->setFillExtrusionHeight(SourceFunction<float>(get("height")));
+ extrusionLayer->setFillExtrusionBase(SourceFunction<float>(get("min_height")));
map->getStyle().addLayer(std::move(extrusionLayer));
}