[core] Handle NaN input to interpolate and step

This commit is contained in:
John Firebaugh
2018-01-10 11:48:06 -08:00
parent ecbb0baf60
commit cedda5ef4f
4 changed files with 20 additions and 12 deletions

View File

@@ -11,7 +11,7 @@
#include <memory>
#include <map>
#include <cmath>
namespace mbgl {
namespace style {
@@ -109,9 +109,15 @@ public:
EvaluationResult evaluate(const EvaluationContext& params) const override {
const EvaluationResult evaluatedInput = input->evaluate(params);
if (!evaluatedInput) { return evaluatedInput.error(); }
if (!evaluatedInput) {
return evaluatedInput.error();
}
float x = *fromExpressionValue<float>(*evaluatedInput);
if (std::isnan(x)) {
return EvaluationError { "Input is not a number." };
}
if (stops.empty()) {
return EvaluationError { "No stops in exponential curve." };
}