#pragma once #include #include #include #include #include #include #include #include namespace mbgl { namespace style { template class SourceFunction { public: using Stops = std::conditional_t< util::Interpolatable, variant< ExponentialStops, IntervalStops, CategoricalStops, IdentityStops>, variant< IntervalStops, CategoricalStops, IdentityStops>>; SourceFunction(std::string property_, Stops stops_) : property(std::move(property_)), stops(std::move(stops_)) { } T evaluate(const GeometryTileFeature& feature) const { optional v = feature.getValue(property); if (!v) { return T(); } return stops.match([&] (const auto& s) { return s.evaluate(*v); }); } friend bool operator==(const SourceFunction& lhs, const SourceFunction& rhs) { return lhs.property == rhs.property && lhs.stops == rhs.stops; } std::string property; Stops stops; }; } // namespace style } // namespace mbgl