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