summaryrefslogtreecommitdiff
path: root/include/mbgl/style/expression
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-28 10:00:40 -0700
commitbc771ee02e813e0f05663f108d34d3fd057dbd66 (patch)
treebdd4bc1bce209ec34419e1aa4a988dc3ecf6a405 /include/mbgl/style/expression
parenteabf209bad80634e1dd4fbe7784408ee7d332c5a (diff)
downloadqtlocation-mapboxgl-bc771ee02e813e0f05663f108d34d3fd057dbd66.tar.gz
[core] Split Interpolator into a separate file
Diffstat (limited to 'include/mbgl/style/expression')
-rw-r--r--include/mbgl/style/expression/interpolate.hpp43
-rw-r--r--include/mbgl/style/expression/interpolator.hpp50
2 files changed, 51 insertions, 42 deletions
diff --git a/include/mbgl/style/expression/interpolate.hpp b/include/mbgl/style/expression/interpolate.hpp
index cc744ac7b7..1f73fc14b4 100644
--- a/include/mbgl/style/expression/interpolate.hpp
+++ b/include/mbgl/style/expression/interpolate.hpp
@@ -3,12 +3,9 @@
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/parsing_context.hpp>
#include <mbgl/style/expression/get_covering_stops.hpp>
+#include <mbgl/style/expression/interpolator.hpp>
#include <mbgl/style/conversion.hpp>
-#include <mbgl/util/interpolate.hpp>
-#include <mbgl/util/range.hpp>
-#include <mbgl/util/unitbezier.hpp>
-
#include <memory>
#include <map>
#include <cmath>
@@ -17,48 +14,10 @@ namespace mbgl {
namespace style {
namespace expression {
-class ExponentialInterpolator {
-public:
- ExponentialInterpolator(double base_) : base(base_) {}
-
- double base;
-
- double interpolationFactor(const Range<double>& inputLevels, const double input) const {
- return util::interpolationFactor(base,
- Range<float> {
- static_cast<float>(inputLevels.min),
- static_cast<float>(inputLevels.max)
- },
- input);
- }
-
- bool operator==(const ExponentialInterpolator& rhs) const {
- return base == rhs.base;
- }
-};
-
-class CubicBezierInterpolator {
-public:
- CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_) : ub(x1_, y1_, x2_, y2_) {}
-
- double interpolationFactor(const Range<double>& inputLevels, const double input) const {
- return ub.solve(input / (inputLevels.max - inputLevels.min), 1e-6);
- }
-
- bool operator==(const CubicBezierInterpolator& rhs) const {
- return ub == rhs.ub;
- }
-
- util::UnitBezier ub;
-};
-
-
ParseResult parseInterpolate(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx);
class InterpolateBase : public Expression {
public:
- using Interpolator = variant<ExponentialInterpolator, CubicBezierInterpolator>;
-
InterpolateBase(const type::Type& type_,
Interpolator interpolator_,
std::unique_ptr<Expression> input_,
diff --git a/include/mbgl/style/expression/interpolator.hpp b/include/mbgl/style/expression/interpolator.hpp
new file mode 100644
index 0000000000..f37fb2c9cd
--- /dev/null
+++ b/include/mbgl/style/expression/interpolator.hpp
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <mbgl/util/interpolate.hpp>
+#include <mbgl/util/range.hpp>
+#include <mbgl/util/unitbezier.hpp>
+
+namespace mbgl {
+namespace style {
+namespace expression {
+
+class ExponentialInterpolator {
+public:
+ ExponentialInterpolator(double base_) : base(base_) {}
+
+ double base;
+
+ double interpolationFactor(const Range<double>& inputLevels, const double input) const {
+ return util::interpolationFactor(base,
+ Range<float> {
+ static_cast<float>(inputLevels.min),
+ static_cast<float>(inputLevels.max)
+ },
+ input);
+ }
+
+ bool operator==(const ExponentialInterpolator& rhs) const {
+ return base == rhs.base;
+ }
+};
+
+class CubicBezierInterpolator {
+public:
+ CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_) : ub(x1_, y1_, x2_, y2_) {}
+
+ double interpolationFactor(const Range<double>& inputLevels, const double input) const {
+ return ub.solve(input / (inputLevels.max - inputLevels.min), 1e-6);
+ }
+
+ bool operator==(const CubicBezierInterpolator& rhs) const {
+ return ub == rhs.ub;
+ }
+
+ util::UnitBezier ub;
+};
+
+using Interpolator = variant<ExponentialInterpolator, CubicBezierInterpolator>;
+
+} // namespace expression
+} // namespace style
+} // namespace mbgl