#include namespace mbgl { namespace style { namespace expression { Range getCoveringStops(const std::map>& stops, const double lower, const double upper) { assert(!stops.empty()); auto minIt = stops.lower_bound(lower); auto maxIt = stops.lower_bound(upper); // lower_bound yields first element >= lowerZoom, but we want the *last* // element <= lowerZoom, so if we found a stop > lowerZoom, back up by one. if (minIt != stops.begin() && minIt != stops.end() && minIt->first > lower) { minIt--; } return Range { static_cast(minIt == stops.end() ? stops.rbegin()->first : minIt->first), static_cast(maxIt == stops.end() ? stops.rbegin()->first : maxIt->first) }; } } // namespace expression } // namespace style } // namespace mbgl