diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2016-04-05 16:27:37 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-29 12:00:24 -0700 |
commit | 61d14089e0dd742719328fd74c693bcae6274a4b (patch) | |
tree | e47265a472fe75c635a22815ddc4a0c3fa1dbf84 /include | |
parent | 25442a77be75001665771097d8978b1191e403d9 (diff) | |
download | qtlocation-mapboxgl-61d14089e0dd742719328fd74c693bcae6274a4b.tar.gz |
[core] implement queryRenderedFeatures
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/map/map.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/util/math.hpp | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 0b1720e65b..41f34c102b 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -158,6 +158,10 @@ public: const char* before = nullptr); void removeCustomLayer(const std::string& id); + // Feature queries + std::vector<std::string> queryRenderedFeatures(const ScreenCoordinate&, const optional<std::vector<std::string>>& layerIDs = {}); + std::vector<std::string> queryRenderedFeatures(const std::array<ScreenCoordinate, 2>&, const optional<std::vector<std::string>>& layerIDs = {}); + // Memory void setSourceTileCacheSize(size_t); void onLowMemory(); diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp index 1e5073ab3b..c0fdea47fb 100644 --- a/include/mbgl/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -88,6 +88,14 @@ inline T dist(const S1& a, const S2& b) { return c; } +template <typename T, typename S1, typename S2> +inline T distSqr(const S1& a, const S2& b) { + T dx = b.x - a.x; + T dy = b.y - a.y; + T c = dx * dx + dy * dy; + return c; +} + template <typename T> inline T round(const T& a) { return T(::round(a.x), ::round(a.y)); @@ -113,6 +121,15 @@ inline S unit(const S& a) { return a * (1 / magnitude); } +template <typename T, typename S = double> +inline T rotate(const T& a, S angle) { + S cos = std::cos(angle); + S sin = std::sin(angle); + S x = cos * a.x - sin * a.y; + S y = sin * a.x + cos * a.y; + return T(x, y); +} + template <typename T> T clamp(T value, T min_, T max_) { return max(min_, min(max_, value)); |