summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r--src/mbgl/geometry/feature_index.cpp17
-rw-r--r--src/mbgl/geometry/feature_index.hpp7
2 files changed, 14 insertions, 10 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index 6fb0d5e446..c67786274a 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -17,8 +17,9 @@
namespace mbgl {
-FeatureIndex::FeatureIndex()
- : grid(util::EXTENT, util::EXTENT, util::EXTENT / 16) { // 16x16 grid -> 32px cell
+FeatureIndex::FeatureIndex(std::unique_ptr<const GeometryTileData> tileData_)
+ : grid(util::EXTENT, util::EXTENT, util::EXTENT / 16) // 16x16 grid -> 32px cell
+ , tileData(std::move(tileData_)) {
}
void FeatureIndex::insert(const GeometryCollection& geometries,
@@ -47,12 +48,15 @@ void FeatureIndex::query(
const double tileSize,
const double scale,
const RenderedQueryOptions& queryOptions,
- const GeometryTileData& geometryTileData,
const UnwrappedTileID& tileID,
const std::string& sourceID,
const std::vector<const RenderLayer*>& layers,
const CollisionIndex& collisionIndex,
const float additionalQueryRadius) const {
+
+ if (!tileData) {
+ return;
+ }
// Determine query radius
const float pixelsToTileUnits = util::EXTENT / tileSize / scale;
@@ -72,13 +76,13 @@ void FeatureIndex::query(
if (indexedFeature.sortIndex == previousSortIndex) continue;
previousSortIndex = indexedFeature.sortIndex;
- addFeature(result, indexedFeature, queryGeometry, queryOptions, geometryTileData, tileID.canonical, layers, bearing, pixelsToTileUnits);
+ addFeature(result, indexedFeature, queryGeometry, queryOptions, tileID.canonical, layers, bearing, pixelsToTileUnits);
}
std::vector<IndexedSubfeature> symbolFeatures = collisionIndex.queryRenderedSymbols(queryGeometry, tileID, sourceID);
std::sort(symbolFeatures.begin(), symbolFeatures.end(), topDownSymbols);
for (const auto& symbolFeature : symbolFeatures) {
- addFeature(result, symbolFeature, queryGeometry, queryOptions, geometryTileData, tileID.canonical, layers, bearing, pixelsToTileUnits);
+ addFeature(result, symbolFeature, queryGeometry, queryOptions, tileID.canonical, layers, bearing, pixelsToTileUnits);
}
}
@@ -87,7 +91,6 @@ void FeatureIndex::addFeature(
const IndexedSubfeature& indexedFeature,
const GeometryCoordinates& queryGeometry,
const RenderedQueryOptions& options,
- const GeometryTileData& geometryTileData,
const CanonicalTileID& tileID,
const std::vector<const RenderLayer*>& layers,
const float bearing,
@@ -113,7 +116,7 @@ void FeatureIndex::addFeature(
}
if (!geometryTileFeature) {
- sourceLayer = geometryTileData.getLayer(indexedFeature.sourceLayerName);
+ sourceLayer = tileData->getLayer(indexedFeature.sourceLayerName);
assert(sourceLayer);
geometryTileFeature = sourceLayer->getFeature(indexedFeature.index);
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp
index e95bb94da6..9e0c172342 100644
--- a/src/mbgl/geometry/feature_index.hpp
+++ b/src/mbgl/geometry/feature_index.hpp
@@ -50,8 +50,10 @@ public:
class FeatureIndex {
public:
- FeatureIndex();
+ FeatureIndex(std::unique_ptr<const GeometryTileData> tileData_);
+ const GeometryTileData* getData() { return tileData.get(); }
+
void insert(const GeometryCollection&, std::size_t index, const std::string& sourceLayerName, const std::string& bucketName);
void query(
@@ -61,7 +63,6 @@ public:
const double tileSize,
const double scale,
const RenderedQueryOptions& options,
- const GeometryTileData&,
const UnwrappedTileID&,
const std::string&,
const std::vector<const RenderLayer*>&,
@@ -83,7 +84,6 @@ private:
const IndexedSubfeature&,
const GeometryCoordinates& queryGeometry,
const RenderedQueryOptions& options,
- const GeometryTileData&,
const CanonicalTileID&,
const std::vector<const RenderLayer*>&,
const float bearing,
@@ -93,5 +93,6 @@ private:
unsigned int sortIndex = 0;
std::unordered_map<std::string, std::vector<std::string>> bucketLayerIDs;
+ std::unique_ptr<const GeometryTileData> tileData;
};
} // namespace mbgl