summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression/get_covering_stops.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-10 19:18:39 -0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-12 13:41:08 -0200
commit1adc585c61e1e42f28c7944816010446091fa161 (patch)
treeafbab98a080dcea67851e5bfb43f78d7776be423 /src/mbgl/style/expression/get_covering_stops.cpp
parenta2120304a881507ed60c3199925946c1df06b44c (diff)
downloadqtlocation-mapboxgl-1adc585c61e1e42f28c7944816010446091fa161.tar.gz
Bump Mapbox GL Native
mapbox-gl-native @ 92608f58858d77c17a65ae9b29758e74bb2da7d2
Diffstat (limited to 'src/mbgl/style/expression/get_covering_stops.cpp')
-rw-r--r--src/mbgl/style/expression/get_covering_stops.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/get_covering_stops.cpp b/src/mbgl/style/expression/get_covering_stops.cpp
new file mode 100644
index 0000000000..c9f87d93ac
--- /dev/null
+++ b/src/mbgl/style/expression/get_covering_stops.cpp
@@ -0,0 +1,26 @@
+#include <mbgl/style/expression/get_covering_stops.hpp>
+
+namespace mbgl {
+namespace style {
+namespace expression {
+
+Range<float> getCoveringStops(const std::map<double, std::unique_ptr<Expression>>& 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<float> {
+ static_cast<float>(minIt == stops.end() ? stops.rbegin()->first : minIt->first),
+ static_cast<float>(maxIt == stops.end() ? stops.rbegin()->first : maxIt->first)
+ };
+}
+
+} // namespace expression
+} // namespace style
+} // namespace mbgl