Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Fix for stepwise functions #6328

Merged
merged 1 commit into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/mbgl/util/interpolate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ struct Interpolator<Color> {

struct Uninterpolated {
template <class T>
T operator()(const T&, const T& b, const double) const {
return b;
T operator()(const T& a, const T&, const double) const {
return a;
}
};

Expand Down
11 changes: 11 additions & 0 deletions test/style/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ using namespace mbgl::style;
float evaluate(PropertyValue<float> value, float zoom) {
return PropertyValue<float>::visit(value, PropertyEvaluator<float>(CalculationParameters(zoom), 0));
}
std::string evaluate(PropertyValue<std::string> value, float zoom) {
return PropertyValue<std::string>::visit(value, PropertyEvaluator<std::string>(CalculationParameters(zoom), ""));
}

TEST(Function, Constant) {
EXPECT_EQ(2.0f, evaluate(2, 0));
Expand Down Expand Up @@ -61,4 +64,12 @@ TEST(Function, Stops) {
EXPECT_EQ(4, evaluate(slope_4, 2));
EXPECT_EQ(4.75, evaluate(slope_4, 2.75));
EXPECT_EQ(10, evaluate(slope_4, 8));

// discrete values
Function<std::string> discrete_0({{ 3, "string0"}, {6, "string1"}, {9, "string2"}}, 1);
EXPECT_EQ("string0", evaluate(discrete_0, 2));
EXPECT_EQ("string0", evaluate(discrete_0, 4));
EXPECT_EQ("string1", evaluate(discrete_0, 7));
EXPECT_EQ("string2", evaluate(discrete_0, 9));
EXPECT_EQ("string2", evaluate(discrete_0, 10));
}