From 5f4e33b1a3d14cdbebbfe724e51bdcba11f44437 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Wed, 25 Mar 2020 17:03:52 +0200 Subject: [core] Introduce API to collect placed symbols data The following methods are added to the `Renderer` class: - `collectPlacedSymbolData()` enables or disables collecting of the placed symbols data - `getPlacedSymbolsData()` if collecting of the placed symbols data is enabled, returns the reference to the `PlacedSymbolData` vector holding the collected data. --- include/mbgl/renderer/renderer.hpp | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp index 79782839ee..c7514054e4 100644 --- a/include/mbgl/renderer/renderer.hpp +++ b/include/mbgl/renderer/renderer.hpp @@ -21,6 +21,21 @@ namespace gfx { class RendererBackend; } // namespace gfx +struct PlacedSymbolData { + // Contents of the label + std::u16string key; + // If symbol contains text, text collision box in viewport coordinates + optional> textCollisionBox; + // If symbol contains icon, icon collision box in viewport coordinates + optional> iconCollisionBox; + // Symbol text was placed + bool textPlaced; + // Symbol icon was placed + bool iconPlaced; + // Symbol text or icon collision box intersects tile borders + bool intersectsTileBorder; +}; + class Renderer { public: Renderer(gfx::RendererBackend&, float pixelRatio_, const optional& localFontFamily = {}); @@ -54,12 +69,32 @@ public: void getFeatureState(FeatureState& state, const std::string& sourceID, const optional& sourceLayerID, const std::string& featureID) const; - void removeFeatureState(const std::string& sourceID, const optional& sourceLayerID, - const optional& featureID, const optional& stateKey); + void removeFeatureState(const std::string& sourceID, + const optional& sourceLayerID, + const optional& featureID, + const optional& stateKey); // Debug void dumpDebugLogs(); + /** + * @brief In Tile map mode, enables or disables collecting of the placed symbols data, + * which can be obtained with `getPlacedSymbolsData()`. + * + * The placed symbols data collecting is disabled by default. + */ + void collectPlacedSymbolData(bool enable); + + /** + * @brief If collecting of the placed symbols data is enabled, returns the reference + * to the `PlacedSymbolData` vector holding the collected data. + * + * Note: the returned vector gets re-populated at every `render()` call. + * + * @return collected placed symbols data + */ + const std::vector& getPlacedSymbolsData() const; + // Memory void reduceMemoryUse(); void clearData(); -- cgit v1.2.1