summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2015-02-04 11:36:31 -0800
committerAnsis Brammanis <brammanis@gmail.com>2015-02-04 11:36:31 -0800
commit93b07c367577b097e3791d38690b8fc37054c5fb (patch)
tree22a488454df85437e9cacaa0e0747a92ac97b158 /src
parent465b1ac3eb45cbb946476ca73f421f02da225175 (diff)
downloadqtlocation-mapboxgl-93b07c367577b097e3791d38690b8fc37054c5fb.tar.gz
rename FadedFunction to PiecewiseConstant function
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/piecewisefunction_properties.cpp (renamed from src/mbgl/style/fadedfunction_properties.cpp)8
-rw-r--r--src/mbgl/style/piecewisefunction_properties.hpp (renamed from src/mbgl/style/fadedfunction_properties.hpp)8
-rw-r--r--src/mbgl/style/property_value.hpp6
-rw-r--r--src/mbgl/style/style_layer.cpp2
-rw-r--r--src/mbgl/style/style_parser.cpp32
-rw-r--r--src/mbgl/style/style_parser.hpp2
-rw-r--r--src/mbgl/style/style_properties.hpp2
7 files changed, 30 insertions, 30 deletions
diff --git a/src/mbgl/style/fadedfunction_properties.cpp b/src/mbgl/style/piecewisefunction_properties.cpp
index 21c3267519..e760ebdb13 100644
--- a/src/mbgl/style/fadedfunction_properties.cpp
+++ b/src/mbgl/style/piecewisefunction_properties.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/style/fadedfunction_properties.hpp>
+#include <mbgl/style/piecewisefunction_properties.hpp>
#include <mbgl/style/types.hpp>
#include <cmath>
@@ -16,7 +16,7 @@ uint32_t getBiggestStopLessThan(std::vector<std::pair<float, T>> stops, float z)
}
template <typename T>
-T FadedStopsFunction<T>::evaluate(float z, const ZoomHistory &zh) const {
+T PiecewiseConstantFunction<T>::evaluate(float z, const ZoomHistory &zh) const {
T result;
float fraction = std::fmod(z, 1.0f);
@@ -44,7 +44,7 @@ T FadedStopsFunction<T>::evaluate(float z, const ZoomHistory &zh) const {
return result;
}
-template Faded<std::string> FadedStopsFunction<Faded<std::string>>::evaluate(float z, const ZoomHistory &zoomHistory) const;
-template Faded<std::vector<float>> FadedStopsFunction<Faded<std::vector<float>>>::evaluate(float z, const ZoomHistory &zoomHistory) const;
+template Faded<std::string> PiecewiseConstantFunction<Faded<std::string>>::evaluate(float z, const ZoomHistory &zoomHistory) const;
+template Faded<std::vector<float>> PiecewiseConstantFunction<Faded<std::vector<float>>>::evaluate(float z, const ZoomHistory &zoomHistory) const;
}
diff --git a/src/mbgl/style/fadedfunction_properties.hpp b/src/mbgl/style/piecewisefunction_properties.hpp
index 7313d32759..69ddc7cc2a 100644
--- a/src/mbgl/style/fadedfunction_properties.hpp
+++ b/src/mbgl/style/piecewisefunction_properties.hpp
@@ -8,10 +8,10 @@
namespace mbgl {
template <typename T>
-struct FadedStopsFunction {
- inline FadedStopsFunction(const std::vector<std::pair<float, T>> &values_, std::chrono::duration<float> 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<std::pair<float, T>> &values_, std::chrono::duration<float> 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 49e837cf12..c7fe823025 100644
--- a/src/mbgl/style/property_value.hpp
+++ b/src/mbgl/style/property_value.hpp
@@ -3,7 +3,7 @@
#include <mbgl/util/variant.hpp>
#include <mbgl/style/function_properties.hpp>
-#include <mbgl/style/fadedfunction_properties.hpp>
+#include <mbgl/style/piecewisefunction_properties.hpp>
#include <mbgl/style/types.hpp>
#include <vector>
@@ -26,8 +26,8 @@ typedef mapbox::util::variant<
Function<bool>,
Function<float>,
Function<Color>,
- FadedStopsFunction<Faded<std::vector<float>>>,
- FadedStopsFunction<Faded<std::string>>
+ PiecewiseConstantFunction<Faded<std::vector<float>>>,
+ PiecewiseConstantFunction<Faded<std::string>>
> PropertyValue;
}
diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp
index 795c651b85..9a7066c497 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<T>(z), value);
}
- T operator()(const FadedStopsFunction<T> &value) const {
+ T operator()(const PiecewiseConstantFunction<T> &value) const {
return value.evaluate(z, zoomHistory);
}
diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp
index 1fc57e2f7e..4dd200aa29 100644
--- a/src/mbgl/style/style_parser.cpp
+++ b/src/mbgl/style/style_parser.cpp
@@ -344,10 +344,10 @@ std::tuple<bool, Function<T>> StyleParser::parseFunction(JSVal value) {
template <typename T> inline std::chrono::duration<float> defaultDurationValue() { return std::chrono::duration<float>(300.0f); }
template <typename T>
-std::tuple<bool, FadedStopsFunction<T>> StyleParser::parseFadedStopsFunction(JSVal value) {
+std::tuple<bool, PiecewiseConstantFunction<T>> StyleParser::parsePiecewiseConstantFunction(JSVal value) {
if (!value.HasMember("stops")) {
Log::Warning(Event::ParseStyle, "function must specify a function type");
- return std::tuple<bool, FadedStopsFunction<T>> { false, {} };
+ return std::tuple<bool, PiecewiseConstantFunction<T>> { false, {} };
}
std::chrono::duration<float> duration = defaultDurationValue<T>();
@@ -364,10 +364,10 @@ std::tuple<bool, FadedStopsFunction<T>> StyleParser::parseFadedStopsFunction(JSV
auto stops = parseStops<T>(value["stops"]);
if (!std::get<0>(stops)) {
- return std::tuple<bool, FadedStopsFunction<T>> { false, {} };
+ return std::tuple<bool, PiecewiseConstantFunction<T>> { false, {} };
}
- return std::tuple<bool, FadedStopsFunction<T>> { true, { std::get<1>(stops), duration } };
+ return std::tuple<bool, PiecewiseConstantFunction<T>> { true, { std::get<1>(stops), duration } };
}
template <typename T>
@@ -554,30 +554,30 @@ template<> std::tuple<bool, Function<Color>> StyleParser::parseProperty(JSVal va
}
}
-template<> std::tuple<bool, FadedStopsFunction<Faded<std::vector<float>>>> StyleParser::parseProperty(JSVal value, const char *property_name) {
+template<> std::tuple<bool, PiecewiseConstantFunction<Faded<std::vector<float>>>> StyleParser::parseProperty(JSVal value, const char *property_name) {
if (value.IsObject()) {
- return parseFadedStopsFunction<Faded<std::vector<float>>>(value);
+ return parsePiecewiseConstantFunction<Faded<std::vector<float>>>(value);
} else if (value.IsArray()) {
Faded<std::vector<float>> parsed;
std::tuple<bool, std::vector<float>> floatarray = parseFloatArray(value);
parsed.low = std::get<1>(floatarray);
- return std::tuple<bool, FadedStopsFunction<Faded<std::vector<float>>>> { std::get<0>(floatarray), parsed };
+ return std::tuple<bool, PiecewiseConstantFunction<Faded<std::vector<float>>>> { 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<bool, FadedStopsFunction<Faded<std::vector<float>>>> { false, {} };
+ return std::tuple<bool, PiecewiseConstantFunction<Faded<std::vector<float>>>> { false, {} };
}
}
-template<> std::tuple<bool, FadedStopsFunction<Faded<std::string>>> StyleParser::parseProperty(JSVal value, const char *property_name) {
+template<> std::tuple<bool, PiecewiseConstantFunction<Faded<std::string>>> StyleParser::parseProperty(JSVal value, const char *property_name) {
if (value.IsObject()) {
- return parseFadedStopsFunction<Faded<std::string>>(value);
+ return parsePiecewiseConstantFunction<Faded<std::string>>(value);
} else if (value.IsString()) {
Faded<std::string> parsed;
parsed.low = { value.GetString(), value.GetStringLength() };
- return std::tuple<bool, FadedStopsFunction<Faded<std::string>>> { true, parsed };
+ return std::tuple<bool, PiecewiseConstantFunction<Faded<std::string>>> { true, parsed };
} else {
Log::Warning(Event::ParseStyle, "value of '%s' must be string or a string function", property_name);
- return std::tuple<bool, FadedStopsFunction<Faded<std::string>>> { false, {} };
+ return std::tuple<bool, PiecewiseConstantFunction<Faded<std::string>>> { false, {} };
}
}
@@ -724,7 +724,7 @@ void StyleParser::parsePaint(JSVal value, ClassProperties &klass) {
parseOptionalProperty<Function<float>>("fill-translate", { Key::FillTranslateX, Key::FillTranslateY }, klass, value);
parseOptionalProperty<PropertyTransition>("fill-translate-transition", Key::FillTranslate, klass, value);
parseOptionalProperty<TranslateAnchorType>("fill-translate-anchor", Key::FillTranslateAnchor, klass, value);
- parseOptionalProperty<FadedStopsFunction<Faded<std::string>>>("fill-image", Key::FillImage, klass, value);
+ parseOptionalProperty<PiecewiseConstantFunction<Faded<std::string>>>("fill-image", Key::FillImage, klass, value);
parseOptionalProperty<Function<float>>("line-opacity", Key::LineOpacity, klass, value);
parseOptionalProperty<PropertyTransition>("line-opacity-transition", Key::LineOpacity, klass, value);
@@ -739,8 +739,8 @@ void StyleParser::parsePaint(JSVal value, ClassProperties &klass) {
parseOptionalProperty<PropertyTransition>("line-gap-width-transition", Key::LineGapWidth, klass, value);
parseOptionalProperty<Function<float>>("line-blur", Key::LineBlur, klass, value);
parseOptionalProperty<PropertyTransition>("line-blur-transition", Key::LineBlur, klass, value);
- parseOptionalProperty<FadedStopsFunction<Faded<std::vector<float>>>>("line-dasharray", Key::LineDashArray, klass, value);
- parseOptionalProperty<FadedStopsFunction<Faded<std::string>>>("line-image", Key::LineImage, klass, value);
+ parseOptionalProperty<PiecewiseConstantFunction<Faded<std::vector<float>>>>("line-dasharray", Key::LineDashArray, klass, value);
+ parseOptionalProperty<PiecewiseConstantFunction<Faded<std::string>>>("line-image", Key::LineImage, klass, value);
parseOptionalProperty<Function<float>>("icon-opacity", Key::IconOpacity, klass, value);
parseOptionalProperty<PropertyTransition>("icon-opacity-transition", Key::IconOpacity, klass, value);
@@ -790,7 +790,7 @@ void StyleParser::parsePaint(JSVal value, ClassProperties &klass) {
parseOptionalProperty<Function<float>>("background-opacity", Key::BackgroundOpacity, klass, value);
parseOptionalProperty<Function<Color>>("background-color", Key::BackgroundColor, klass, value);
- parseOptionalProperty<FadedStopsFunction<Faded<std::string>>>("background-image", Key::BackgroundImage, klass, value);
+ parseOptionalProperty<PiecewiseConstantFunction<Faded<std::string>>>("background-image", Key::BackgroundImage, klass, value);
}
void StyleParser::parseLayout(JSVal value, util::ptr<StyleBucket> &bucket) {
diff --git a/src/mbgl/style/style_parser.hpp b/src/mbgl/style/style_parser.hpp
index 5b55d6116e..fd26dc8648 100644
--- a/src/mbgl/style/style_parser.hpp
+++ b/src/mbgl/style/style_parser.hpp
@@ -79,7 +79,7 @@ private:
template <typename T>
std::tuple<bool, Function<T>> parseFunction(JSVal value);
template <typename T>
- std::tuple<bool, FadedStopsFunction<T>> parseFadedStopsFunction(JSVal value);
+ std::tuple<bool, PiecewiseConstantFunction<T>> parsePiecewiseConstantFunction(JSVal value);
template <typename T>
T parseFunctionArgument(JSVal value);
template <typename T>
diff --git a/src/mbgl/style/style_properties.hpp b/src/mbgl/style/style_properties.hpp
index fd55cb0bb2..f50722542d 100644
--- a/src/mbgl/style/style_properties.hpp
+++ b/src/mbgl/style/style_properties.hpp
@@ -3,7 +3,7 @@
#include <mbgl/util/variant.hpp>
#include <mbgl/style/types.hpp>
-#include <mbgl/style/fadedfunction_properties.hpp>
+#include <mbgl/style/piecewisefunction_properties.hpp>
#include <array>
#include <string>