From 514485502db8ecacf2b11abad4599d7af09b0cf8 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Wed, 4 Jul 2018 23:12:58 +0300 Subject: Rename `HeatmapColorPropertyValue` to `ColorRampPropertyValue` Based on patch from @lbud (Lauren Budorick). Give `HeatmapColorPropertyValue` a more generic name, since the same value type will be used for both `heatmap-color` and `line-gradient` properties. --- src/mbgl/style/conversion/make_property_setters.hpp | 2 +- src/mbgl/style/conversion/property_setter.hpp | 2 +- src/mbgl/style/layers/heatmap_layer.cpp | 10 +++++----- src/mbgl/style/layers/heatmap_layer_properties.hpp | 2 ++ src/mbgl/style/layers/layer.cpp.ejs | 2 +- src/mbgl/style/layers/layer_properties.hpp.ejs | 5 ++++- src/mbgl/style/paint_property.hpp | 14 +++++++------- 7 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/mbgl') diff --git a/src/mbgl/style/conversion/make_property_setters.hpp b/src/mbgl/style/conversion/make_property_setters.hpp index 40461fc1e7..96aa1b6414 100644 --- a/src/mbgl/style/conversion/make_property_setters.hpp +++ b/src/mbgl/style/conversion/make_property_setters.hpp @@ -174,7 +174,7 @@ inline auto makePaintPropertySetters() { result["heatmap-weight-transition"] = &setTransition; result["heatmap-intensity"] = &setProperty, &HeatmapLayer::setHeatmapIntensity>; result["heatmap-intensity-transition"] = &setTransition; - result["heatmap-color"] = &setProperty; + result["heatmap-color"] = &setProperty; result["heatmap-color-transition"] = &setTransition; result["heatmap-opacity"] = &setProperty, &HeatmapLayer::setHeatmapOpacity>; result["heatmap-opacity-transition"] = &setTransition; diff --git a/src/mbgl/style/conversion/property_setter.hpp b/src/mbgl/style/conversion/property_setter.hpp index e3716a18dc..e13338f628 100644 --- a/src/mbgl/style/conversion/property_setter.hpp +++ b/src/mbgl/style/conversion/property_setter.hpp @@ -2,10 +2,10 @@ #include #include +#include #include #include #include -#include #include #include diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index 3f7881ddd3..c2a1545a00 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -5,8 +5,8 @@ #include // for constructing default heatmap-color ramp expression from style JSON #include +#include #include -#include namespace mbgl { namespace style { @@ -181,17 +181,17 @@ TransitionOptions HeatmapLayer::getHeatmapIntensityTransition() const { return impl().paint.template get().options; } -HeatmapColorPropertyValue HeatmapLayer::getDefaultHeatmapColor() { +ColorRampPropertyValue HeatmapLayer::getDefaultHeatmapColor() { conversion::Error error; std::string rawValue = R"JSON(["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"])JSON"; - return *conversion::convertJSON(rawValue, error); + return *conversion::convertJSON(rawValue, error); } -HeatmapColorPropertyValue HeatmapLayer::getHeatmapColor() const { +ColorRampPropertyValue HeatmapLayer::getHeatmapColor() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapColor(HeatmapColorPropertyValue value) { +void HeatmapLayer::setHeatmapColor(ColorRampPropertyValue value) { if (value == getHeatmapColor()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layers/heatmap_layer_properties.hpp b/src/mbgl/style/layers/heatmap_layer_properties.hpp index f7afa5fbeb..fe7257a78a 100644 --- a/src/mbgl/style/layers/heatmap_layer_properties.hpp +++ b/src/mbgl/style/layers/heatmap_layer_properties.hpp @@ -24,6 +24,8 @@ struct HeatmapIntensity : PaintProperty { static float defaultValue() { return 1; } }; +using HeatmapColor = ColorRampProperty; + struct HeatmapOpacity : PaintProperty { static float defaultValue() { return 1; } }; diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index 6d748311bf..a9b6d9d02d 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -11,8 +11,8 @@ <% if (type === 'heatmap') { -%> // for constructing default heatmap-color ramp expression from style JSON #include +#include #include -#include <% } -%> namespace mbgl { diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs index 1bceb84960..5b774933a6 100644 --- a/src/mbgl/style/layers/layer_properties.hpp.ejs +++ b/src/mbgl/style/layers/layer_properties.hpp.ejs @@ -25,10 +25,13 @@ struct <%- camelize(property.name) %> : <%- layoutPropertyType(property, type) % <% } -%> <% for (const property of paintProperties) { -%> -<% if (property.name === 'heatmap-color') continue; -%> +<% if (property['property-type'] === 'color-ramp') { -%> +using <%- camelize(property.name) %> = ColorRampProperty; +<% } else { -%> struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %> { static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; } }; +<% } -%> <% } -%> <% if (layoutProperties.length) { -%> diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index 195eb645a9..d51a6760c5 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -1,8 +1,8 @@ #pragma once +#include #include #include -#include #include #include #include @@ -50,19 +50,19 @@ public: }; /* - * Special-case paint property traits for heatmap-color, needed because - * heatmap-color values do not fit into the + * Special-case paint property traits for heatmap-color and line-gradient, + * needed because these values do not fit into the * Undefined | Value | {Camera,Source,Composite}Function taxonomy that applies * to all other paint properties. * - * These traits are provided here--despite the fact that heatmap-color + * These traits are provided here--despite the fact that color ramps * is not used like other paint properties--to allow the parameter-pack-based * batch evaluation of paint properties to compile properly. */ -class HeatmapColor { +class ColorRampProperty { public: - using TransitionableType = Transitionable; - using UnevaluatedType = Transitioning; + using TransitionableType = Transitionable; + using UnevaluatedType = Transitioning; using EvaluatorType = PropertyEvaluator; using PossiblyEvaluatedType = Color; using Type = Color; -- cgit v1.2.1