summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-06-17 15:04:10 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-07-09 11:43:46 +0300
commit57402314e1be3180ce6f67d8ba29c17aceba6b60 (patch)
treeefe5a01b6a2ced775726c0407528230166365a71 /src/mbgl/geometry
parentd6c1c838eb0c612aa971740fc58cc2a2e1086f77 (diff)
downloadqtlocation-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')
-rw-r--r--src/mbgl/geometry/feature_index.cpp21
-rw-r--r--src/mbgl/geometry/feature_index.hpp6
2 files changed, 10 insertions, 17 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);
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp
index cd041a7fdb..1a212761fa 100644
--- a/src/mbgl/geometry/feature_index.hpp
+++ b/src/mbgl/geometry/feature_index.hpp
@@ -67,7 +67,7 @@ public:
const double scale,
const RenderedQueryOptions& options,
const UnwrappedTileID&,
- const std::vector<const RenderLayer*>&,
+ const std::unordered_map<std::string, const RenderLayer*>&,
const float additionalQueryPadding) const;
static optional<GeometryCoordinates> translateQueryGeometry(
@@ -82,7 +82,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>> lookupSymbolFeatures(
const std::vector<IndexedSubfeature>& symbolFeatures,
const RenderedQueryOptions& options,
- 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;
@@ -92,7 +92,7 @@ private:
const IndexedSubfeature&,
const RenderedQueryOptions& options,
const CanonicalTileID&,
- const std::vector<const RenderLayer*>&,
+ const std::unordered_map<std::string, const RenderLayer*>&,
const GeometryCoordinates& queryGeometry,
const TransformState& transformState,
const float pixelsToTileUnits,