Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mbgl/annotation/annotation_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void AnnotationManager::updateStyle(Style& style) {
layer->setSourceLayer(PointLayerID);
layer->setIconImage({"{sprite}"});
layer->setIconAllowOverlap(true);
layer->setIconIgnorePlacement(true);

layer->impl->spriteAtlas = &spriteAtlas;

Expand Down
20 changes: 13 additions & 7 deletions src/mbgl/text/collision_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ CollisionTile::CollisionTile(PlacementConfig config_) : config(std::move(config_
// bottom
CollisionBox(Point<float>(0, util::EXTENT), -infinity, 0, infinity, 0, infinity),
}}) {
tree.clear();

// Compute the transformation matrix.
const float angle_sin = std::sin(config.angle);
Expand Down Expand Up @@ -162,25 +161,32 @@ std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const mapbox:
CollisionBox queryBox(anchor, 0, 0, box.max.x - box.min.x, box.max.y - box.min.y, scale);
auto predicates = bgi::intersects(getTreeBox(anchor, queryBox));

auto fn = [&] (const Tree& tree_) {
auto fn = [&] (const Tree& tree_, bool ignorePlacement) {
for (auto it = tree_.qbegin(predicates); it != tree_.qend(); ++it) {
const CollisionBox& blocking = std::get<1>(*it);
const IndexedSubfeature& indexedFeature = std::get<2>(*it);

auto& seenFeatures = sourceLayerFeatures[indexedFeature.sourceLayerName];
if (seenFeatures.find(indexedFeature.index) == seenFeatures.end()) {
auto blockingAnchor = util::matrixMultiply(rotationMatrix, blocking.anchor);
float minPlacementScale = findPlacementScale(minScale, anchor, queryBox, blockingAnchor, blocking);
if (minPlacementScale >= scale) {
if (ignorePlacement) {
seenFeatures.insert(indexedFeature.index);
result.push_back(indexedFeature);
} else {
auto blockingAnchor = util::matrixMultiply(rotationMatrix, blocking.anchor);
float minPlacementScale = findPlacementScale(minScale, anchor, queryBox, blockingAnchor, blocking);
if (minPlacementScale >= scale) {
seenFeatures.insert(indexedFeature.index);
result.push_back(indexedFeature);
}
}
}
}
};

fn(tree);
fn(ignoredTree);
bool ignorePlacement = false;
fn(tree, ignorePlacement);
ignorePlacement = true;
fn(ignoredTree, ignorePlacement);

return result;
}
Expand Down
25 changes: 25 additions & 0 deletions test/api/annotations.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,28 @@ TEST(Annotations, QueryRenderedFeatures) {
EXPECT_TRUE(!!features2[0].id);
EXPECT_EQ(*features2[0].id, 1);
}

TEST(Annotations, QueryFractionalZoomLevels) {
AnnotationTest test;

auto viewSize = test.view.getSize();
auto box = ScreenBox { {}, { double(viewSize[0]), double(viewSize[1]) } };

test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));

std::vector<mbgl::AnnotationID> ids;
for (int longitude = 0; longitude < 10; ++longitude) {
for (int latitude = 0; latitude < 10; ++latitude) {
ids.push_back(test.map.addAnnotation(SymbolAnnotation { { double(latitude), double(longitude) }, "default_marker" }));
}
}

test.map.setLatLngZoom({ 5, 5 }, 0);
for (uint16_t zoomSteps = 0; zoomSteps <= 20; ++zoomSteps) {
test.map.setZoom(zoomSteps / 10.0);
test::render(test.map);
auto features = test.map.queryRenderedFeatures(box);
EXPECT_EQ(features.size(), ids.size());
}
}