[core] Functions must have at least one stop
This is already enforced by the style validator in mapbox-gl-style-spec. Enforce it here too.
This commit is contained in:
@@ -25,6 +25,10 @@ struct Converter<Function<T>> {
|
||||
return Error { "function stops must be an array" };
|
||||
}
|
||||
|
||||
if (arrayLength(*stopsValue) == 0) {
|
||||
return Error { "function must have at least one stop" };
|
||||
}
|
||||
|
||||
std::vector<std::pair<float, T>> stops;
|
||||
for (std::size_t i = 0; i < arrayLength(*stopsValue); ++i) {
|
||||
const auto& stopValue = arrayMember(*stopsValue, i);
|
||||
|
||||
@@ -12,8 +12,10 @@ public:
|
||||
using Stop = std::pair<float, T>;
|
||||
using Stops = std::vector<Stop>;
|
||||
|
||||
explicit Function(Stops stops_, float base_)
|
||||
: base(base_), stops(std::move(stops_)) {}
|
||||
Function(Stops stops_, float base_)
|
||||
: base(base_), stops(std::move(stops_)) {
|
||||
assert(stops.size() > 0);
|
||||
}
|
||||
|
||||
float getBase() const { return base; }
|
||||
const std::vector<std::pair<float, T>>& getStops() const { return stops; }
|
||||
|
||||
Reference in New Issue
Block a user