[core] Replace FeatureIndex::collisionTile with a method parameter
This reduces state and simplifies the test added in the prior commit.
This commit is contained in:
@@ -59,7 +59,8 @@ void FeatureIndex::query(
|
||||
const optional<std::vector<std::string>>& filterLayerIDs,
|
||||
const GeometryTileData& geometryTileData,
|
||||
const CanonicalTileID& tileID,
|
||||
const style::Style& style) const {
|
||||
const style::Style& style,
|
||||
const CollisionTile* collisionTile) const {
|
||||
|
||||
mapbox::geometry::box<int16_t> box = mapbox::geometry::envelope(queryGeometry);
|
||||
|
||||
@@ -154,8 +155,4 @@ void FeatureIndex::addBucketLayerName(const std::string& bucketName, const std::
|
||||
bucketLayerIDs[bucketName].push_back(layerID);
|
||||
}
|
||||
|
||||
void FeatureIndex::setCollisionTile(std::unique_ptr<CollisionTile> collisionTile_) {
|
||||
collisionTile = std::move(collisionTile_);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
const optional<std::vector<std::string>>& layerIDs,
|
||||
const GeometryTileData&,
|
||||
const CanonicalTileID&,
|
||||
const style::Style&) const;
|
||||
const style::Style&,
|
||||
const CollisionTile*) const;
|
||||
|
||||
static optional<GeometryCoordinates> translateQueryGeometry(
|
||||
const GeometryCoordinates& queryGeometry,
|
||||
@@ -53,8 +54,6 @@ public:
|
||||
|
||||
void addBucketLayerName(const std::string& bucketName, const std::string& layerName);
|
||||
|
||||
void setCollisionTile(std::unique_ptr<CollisionTile>);
|
||||
|
||||
private:
|
||||
void addFeature(
|
||||
std::unordered_map<std::string, std::vector<Feature>>& result,
|
||||
@@ -67,7 +66,6 @@ private:
|
||||
const float bearing,
|
||||
const float pixelsToTileUnits) const;
|
||||
|
||||
std::unique_ptr<CollisionTile> collisionTile;
|
||||
GridIndex<IndexedSubfeature> grid;
|
||||
unsigned int sortIndex = 0;
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ Box CollisionTile::getTreeBox(const Point<float>& anchor, const CollisionBox& bo
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const GeometryCoordinates& queryGeometry, float scale) {
|
||||
std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const GeometryCoordinates& queryGeometry, float scale) const {
|
||||
std::vector<IndexedSubfeature> result;
|
||||
if (queryGeometry.empty() || (tree.empty() && ignoredTree.empty())) {
|
||||
return result;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
float placeFeature(const CollisionFeature&, bool allowOverlap, bool avoidEdges);
|
||||
void insertFeature(CollisionFeature&, float minPlacementScale, bool ignorePlacement);
|
||||
|
||||
std::vector<IndexedSubfeature> queryRenderedSymbols(const GeometryCoordinates&, float scale);
|
||||
std::vector<IndexedSubfeature> queryRenderedSymbols(const GeometryCoordinates&, float scale) const;
|
||||
|
||||
const PlacementConfig config;
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void GeometryTile::onPlacement(PlacementResult result) {
|
||||
availableData = DataAvailability::All;
|
||||
}
|
||||
symbolBuckets = std::move(result.symbolBuckets);
|
||||
featureIndex->setCollisionTile(std::move(result.collisionTile));
|
||||
collisionTile = std::move(result.collisionTile);
|
||||
observer->onTileChanged(*this);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,8 @@ void GeometryTile::queryRenderedFeatures(
|
||||
layerIDs,
|
||||
*data,
|
||||
id.canonical,
|
||||
style);
|
||||
style,
|
||||
collisionTile.get());
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -81,9 +81,11 @@ private:
|
||||
optional<PlacementConfig> requestedConfig;
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Bucket>> nonSymbolBuckets;
|
||||
std::unordered_map<std::string, std::shared_ptr<Bucket>> symbolBuckets;
|
||||
std::unique_ptr<FeatureIndex> featureIndex;
|
||||
std::unique_ptr<const GeometryTileData> data;
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Bucket>> symbolBuckets;
|
||||
std::unique_ptr<CollisionTile> collisionTile;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -62,14 +62,6 @@ TEST(VectorTile, Issue7615) {
|
||||
auto symbolBucket = std::make_shared<SymbolBucket>(
|
||||
MapMode::Continuous, style::SymbolLayoutProperties::Evaluated(), false, false);
|
||||
|
||||
// First onLayout is required so that a non-null FeatureIndex is available.
|
||||
tile.onLayout(GeometryTile::LayoutResult {
|
||||
{},
|
||||
std::make_unique<FeatureIndex>(),
|
||||
nullptr,
|
||||
0
|
||||
});
|
||||
|
||||
// Simulate placement of a symbol layer.
|
||||
tile.onPlacement(GeometryTile::PlacementResult {
|
||||
{{
|
||||
@@ -80,7 +72,7 @@ TEST(VectorTile, Issue7615) {
|
||||
0
|
||||
});
|
||||
|
||||
// Second onLayout should not cause the existing symbol bucket to be discarded.
|
||||
// Subsequent onLayout should not cause the existing symbol bucket to be discarded.
|
||||
tile.onLayout(GeometryTile::LayoutResult {
|
||||
{},
|
||||
nullptr,
|
||||
|
||||
Reference in New Issue
Block a user