From 93b07c367577b097e3791d38690b8fc37054c5fb Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 4 Feb 2015 11:36:31 -0800 Subject: [PATCH] rename FadedFunction to PiecewiseConstant function --- ...s.cpp => piecewisefunction_properties.cpp} | 8 ++--- ...s.hpp => piecewisefunction_properties.hpp} | 8 ++--- src/mbgl/style/property_value.hpp | 6 ++-- src/mbgl/style/style_layer.cpp | 2 +- src/mbgl/style/style_parser.cpp | 32 +++++++++---------- src/mbgl/style/style_parser.hpp | 2 +- src/mbgl/style/style_properties.hpp | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) rename src/mbgl/style/{fadedfunction_properties.cpp => piecewisefunction_properties.cpp} (73%) rename src/mbgl/style/{fadedfunction_properties.hpp => piecewisefunction_properties.hpp} (50%) diff --git a/src/mbgl/style/fadedfunction_properties.cpp b/src/mbgl/style/piecewisefunction_properties.cpp similarity index 73% rename from src/mbgl/style/fadedfunction_properties.cpp rename to src/mbgl/style/piecewisefunction_properties.cpp index 21c326751..e760ebdb1 100644 --- a/src/mbgl/style/fadedfunction_properties.cpp +++ b/src/mbgl/style/piecewisefunction_properties.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -16,7 +16,7 @@ uint32_t getBiggestStopLessThan(std::vector> stops, float z) } template -T FadedStopsFunction::evaluate(float z, const ZoomHistory &zh) const { +T PiecewiseConstantFunction::evaluate(float z, const ZoomHistory &zh) const { T result; float fraction = std::fmod(z, 1.0f); @@ -44,7 +44,7 @@ T FadedStopsFunction::evaluate(float z, const ZoomHistory &zh) const { return result; } -template Faded FadedStopsFunction>::evaluate(float z, const ZoomHistory &zoomHistory) const; -template Faded> FadedStopsFunction>>::evaluate(float z, const ZoomHistory &zoomHistory) const; +template Faded PiecewiseConstantFunction>::evaluate(float z, const ZoomHistory &zoomHistory) const; +template Faded> PiecewiseConstantFunction>>::evaluate(float z, const ZoomHistory &zoomHistory) const; } diff --git a/src/mbgl/style/fadedfunction_properties.hpp b/src/mbgl/style/piecewisefunction_properties.hpp similarity index 50% rename from src/mbgl/style/fadedfunction_properties.hpp rename to src/mbgl/style/piecewisefunction_properties.hpp index 7313d3275..69ddc7cc2 100644 --- a/src/mbgl/style/fadedfunction_properties.hpp +++ b/src/mbgl/style/piecewisefunction_properties.hpp @@ -8,10 +8,10 @@ namespace mbgl { template -struct FadedStopsFunction { - inline FadedStopsFunction(const std::vector> &values_, std::chrono::duration duration_) : values(values_), duration(duration_) {} - inline FadedStopsFunction(T &value) : values({{ 0, value }}), duration(300) {} - inline FadedStopsFunction() : values(), duration(300) {} +struct PiecewiseConstantFunction { + inline PiecewiseConstantFunction(const std::vector> &values_, std::chrono::duration duration_) : values(values_), duration(duration_) {} + inline PiecewiseConstantFunction(T &value) : values({{ 0, value }}), duration(300) {} + inline PiecewiseConstantFunction() : values(), duration(300) {} T evaluate(float z, const ZoomHistory &zoomHistory) const; private: diff --git a/src/mbgl/style/property_value.hpp b/src/mbgl/style/property_value.hpp index 49e837cf1..c7fe82302 100644 --- a/src/mbgl/style/property_value.hpp +++ b/src/mbgl/style/property_value.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -26,8 +26,8 @@ typedef mapbox::util::variant< Function, Function, Function, - FadedStopsFunction>>, - FadedStopsFunction> + PiecewiseConstantFunction>>, + PiecewiseConstantFunction> > PropertyValue; } diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp index 795c651b8..9a7066c49 100644 --- a/src/mbgl/style/style_layer.cpp +++ b/src/mbgl/style/style_layer.cpp @@ -105,7 +105,7 @@ struct PropertyEvaluator { return mapbox::util::apply_visitor(FunctionEvaluator(z), value); } - T operator()(const FadedStopsFunction &value) const { + T operator()(const PiecewiseConstantFunction &value) const { return value.evaluate(z, zoomHistory); } diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 1fc57e2f7..4dd200aa2 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -344,10 +344,10 @@ std::tuple> StyleParser::parseFunction(JSVal value) { template inline std::chrono::duration defaultDurationValue() { return std::chrono::duration(300.0f); } template -std::tuple> StyleParser::parseFadedStopsFunction(JSVal value) { +std::tuple> StyleParser::parsePiecewiseConstantFunction(JSVal value) { if (!value.HasMember("stops")) { Log::Warning(Event::ParseStyle, "function must specify a function type"); - return std::tuple> { false, {} }; + return std::tuple> { false, {} }; } std::chrono::duration duration = defaultDurationValue(); @@ -364,10 +364,10 @@ std::tuple> StyleParser::parseFadedStopsFunction(JSV auto stops = parseStops(value["stops"]); if (!std::get<0>(stops)) { - return std::tuple> { false, {} }; + return std::tuple> { false, {} }; } - return std::tuple> { true, { std::get<1>(stops), duration } }; + return std::tuple> { true, { std::get<1>(stops), duration } }; } template @@ -554,30 +554,30 @@ template<> std::tuple> StyleParser::parseProperty(JSVal va } } -template<> std::tuple>>> StyleParser::parseProperty(JSVal value, const char *property_name) { +template<> std::tuple>>> StyleParser::parseProperty(JSVal value, const char *property_name) { if (value.IsObject()) { - return parseFadedStopsFunction>>(value); + return parsePiecewiseConstantFunction>>(value); } else if (value.IsArray()) { Faded> parsed; std::tuple> floatarray = parseFloatArray(value); parsed.low = std::get<1>(floatarray); - return std::tuple>>> { std::get<0>(floatarray), parsed }; + return std::tuple>>> { std::get<0>(floatarray), parsed }; } else { Log::Warning(Event::ParseStyle, "value of '%s' must be an array of numbers, or a number array function", property_name); - return std::tuple>>> { false, {} }; + return std::tuple>>> { false, {} }; } } -template<> std::tuple>> StyleParser::parseProperty(JSVal value, const char *property_name) { +template<> std::tuple>> StyleParser::parseProperty(JSVal value, const char *property_name) { if (value.IsObject()) { - return parseFadedStopsFunction>(value); + return parsePiecewiseConstantFunction>(value); } else if (value.IsString()) { Faded parsed; parsed.low = { value.GetString(), value.GetStringLength() }; - return std::tuple>> { true, parsed }; + return std::tuple>> { true, parsed }; } else { Log::Warning(Event::ParseStyle, "value of '%s' must be string or a string function", property_name); - return std::tuple>> { false, {} }; + return std::tuple>> { false, {} }; } } @@ -724,7 +724,7 @@ void StyleParser::parsePaint(JSVal value, ClassProperties &klass) { parseOptionalProperty>("fill-translate", { Key::FillTranslateX, Key::FillTranslateY }, klass, value); parseOptionalProperty("fill-translate-transition", Key::FillTranslate, klass, value); parseOptionalProperty("fill-translate-anchor", Key::FillTranslateAnchor, klass, value); - parseOptionalProperty>>("fill-image", Key::FillImage, klass, value); + parseOptionalProperty>>("fill-image", Key::FillImage, klass, value); parseOptionalProperty>("line-opacity", Key::LineOpacity, klass, value); parseOptionalProperty("line-opacity-transition", Key::LineOpacity, klass, value); @@ -739,8 +739,8 @@ void StyleParser::parsePaint(JSVal value, ClassProperties &klass) { parseOptionalProperty("line-gap-width-transition", Key::LineGapWidth, klass, value); parseOptionalProperty>("line-blur", Key::LineBlur, klass, value); parseOptionalProperty("line-blur-transition", Key::LineBlur, klass, value); - parseOptionalProperty>>>("line-dasharray", Key::LineDashArray, klass, value); - parseOptionalProperty>>("line-image", Key::LineImage, klass, value); + parseOptionalProperty>>>("line-dasharray", Key::LineDashArray, klass, value); + parseOptionalProperty>>("line-image", Key::LineImage, klass, value); parseOptionalProperty>("icon-opacity", Key::IconOpacity, klass, value); parseOptionalProperty("icon-opacity-transition", Key::IconOpacity, klass, value); @@ -790,7 +790,7 @@ void StyleParser::parsePaint(JSVal value, ClassProperties &klass) { parseOptionalProperty>("background-opacity", Key::BackgroundOpacity, klass, value); parseOptionalProperty>("background-color", Key::BackgroundColor, klass, value); - parseOptionalProperty>>("background-image", Key::BackgroundImage, klass, value); + parseOptionalProperty>>("background-image", Key::BackgroundImage, klass, value); } void StyleParser::parseLayout(JSVal value, util::ptr &bucket) { diff --git a/src/mbgl/style/style_parser.hpp b/src/mbgl/style/style_parser.hpp index 5b55d6116..fd26dc864 100644 --- a/src/mbgl/style/style_parser.hpp +++ b/src/mbgl/style/style_parser.hpp @@ -79,7 +79,7 @@ private: template std::tuple> parseFunction(JSVal value); template - std::tuple> parseFadedStopsFunction(JSVal value); + std::tuple> parsePiecewiseConstantFunction(JSVal value); template T parseFunctionArgument(JSVal value); template diff --git a/src/mbgl/style/style_properties.hpp b/src/mbgl/style/style_properties.hpp index fd55cb0bb..f50722542 100644 --- a/src/mbgl/style/style_properties.hpp +++ b/src/mbgl/style/style_properties.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include