diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-06-17 15:04:10 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-07-09 11:43:46 +0300 |
commit | 57402314e1be3180ce6f67d8ba29c17aceba6b60 (patch) | |
tree | efe5a01b6a2ced775726c0407528230166365a71 /src/mbgl/geometry/feature_index.cpp | |
parent | d6c1c838eb0c612aa971740fc58cc2a2e1086f77 (diff) | |
download | qtlocation-mapboxgl-57402314e1be3180ce6f67d8ba29c17aceba6b60.tar.gz |
[core] Improve performance for query rendered features
- query rendered symbols only from layers that support it
- remove unnecessary iterations over vectors
Diffstat (limited to 'src/mbgl/geometry/feature_index.cpp')
-rw-r--r-- | src/mbgl/geometry/feature_index.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index f61f89b8e7..3675e8bc6e 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -47,7 +47,7 @@ void FeatureIndex::query( const double scale, const RenderedQueryOptions& queryOptions, const UnwrappedTileID& tileID, - const std::vector<const RenderLayer*>& layers, + const std::unordered_map<std::string, const RenderLayer*>& layers, const float additionalQueryPadding) const { if (!tileData) { @@ -81,7 +81,7 @@ void FeatureIndex::query( std::unordered_map<std::string, std::vector<Feature>> FeatureIndex::lookupSymbolFeatures(const std::vector<IndexedSubfeature>& symbolFeatures, const RenderedQueryOptions& queryOptions, - const std::vector<const RenderLayer*>& layers, + const std::unordered_map<std::string, const RenderLayer*>& layers, const OverscaledTileID& tileID, const std::shared_ptr<std::vector<size_t>>& featureSortOrder) const { std::unordered_map<std::string, std::vector<Feature>> result; @@ -123,31 +123,24 @@ void FeatureIndex::addFeature( const IndexedSubfeature& indexedFeature, const RenderedQueryOptions& options, const CanonicalTileID& tileID, - const std::vector<const RenderLayer*>& layers, + const std::unordered_map<std::string, const RenderLayer*>& layers, const GeometryCoordinates& queryGeometry, const TransformState& transformState, const float pixelsToTileUnits, const mat4& posMatrix) const { - auto getRenderLayer = [&] (const std::string& layerID) -> const RenderLayer* { - for (const auto& layer : layers) { - if (layer->getID() == layerID) { - return layer; - } - } - return nullptr; - }; - // Lazily calculated. std::unique_ptr<GeometryTileLayer> sourceLayer; std::unique_ptr<GeometryTileFeature> geometryTileFeature; for (const std::string& layerID : bucketLayerIDs.at(indexedFeature.bucketLeaderID)) { - const RenderLayer* renderLayer = getRenderLayer(layerID); - if (!renderLayer) { + const auto it = layers.find(layerID); + if (it == layers.end()) { continue; } + const RenderLayer* renderLayer = it->second; + if (!geometryTileFeature) { sourceLayer = tileData->getLayer(indexedFeature.sourceLayerName); assert(sourceLayer); |