Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

CollisionTile::queryRenderedSymbols should receive the query geometry #6627

Merged

Conversation

brunoabinader
Copy link
Member

As per @ansis comments in #6055:

The entire query geometry should be passed to CollisionTile#queryRenderedSymbols. It should
rotate each point of the query using rotationMatrix and then take the bbox of that. The fix for
this should be tested in mapbox-gl-test-suite and should be ported to -gl-js.

@brunoabinader brunoabinader added bug Core The cross-platform C++ core, aka mbgl labels Oct 7, 2016
@mention-bot
Copy link

@brunoabinader, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @ansis and @kkaefer to be potential reviewers.

std::unordered_map<std::string, std::unordered_set<std::size_t>> sourceLayerFeatures;

auto anchor = util::matrixMultiply(rotationMatrix, convertPoint<float>(box.min));
mapbox::geometry::box<float> box {
Copy link
Contributor

@jfirebaugh jfirebaugh Oct 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be more clearly expressed as a rotating transform (using a for loop, std::transform, or a geometry.hpp specific version) followed by mapbox::geometry::envelope.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intuit was to avoid traversing through the geometries twice - first for transforming each point, and then later for obtaining the bounding box. However, I acknowledge the need for readability in complex code like this, so doing as suggested.

@@ -153,12 +155,27 @@ Box CollisionTile::getTreeBox(const Point<float>& anchor, const CollisionBox& bo
};
}

std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const mapbox::geometry::box<int16_t>& box, const float scale) {
std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const GeometryCollection& queryGeometry, const float scale) {
Copy link
Contributor

@jfirebaugh jfirebaugh Oct 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify the parameter here, and various other places, to const GeometryCoordinates& queryGeometry. There's no need to support multipolygon query geometries: d7a816d.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I perceived this too, though didn't wanted to change behavior - good to know 👍

@brunoabinader brunoabinader force-pushed the 6627-collisiontile-queryrenderedsymbols-query-geometry branch 2 times, most recently from cc1192a to 5f524bc Compare October 9, 2016 13:34
@brunoabinader
Copy link
Member Author

Addressed @jfirebaugh review comments.

Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good; CI failures need investigation of course.

@brunoabinader brunoabinader force-pushed the 6627-collisiontile-queryrenderedsymbols-query-geometry branch 2 times, most recently from 83d8653 to c956030 Compare October 11, 2016 08:32
@brunoabinader
Copy link
Member Author

Unit test rendering check failure in Annotations.VisibleFeatures looks like a GL driver issue:
screen shot 2016-10-11 at 12 01 04 pm

Thus, I'm skipping rendering checks on Annotations.VisibleFeatures for now.

This provides a means of testing cases where an updated geometry tile
would return wrong results for `queryRenderedFeatures`.
This gives the ability to pan and/or rotate the map in a posterior step
after initial render for testing purposes.
@brunoabinader brunoabinader force-pushed the 6627-collisiontile-queryrenderedsymbols-query-geometry branch from c956030 to 7dbc302 Compare October 11, 2016 09:12
@brunoabinader
Copy link
Member Author

Render test failures were caused by rebasing the newly-added query tests symbol/panned-after-insert and symbol/rotated-after-insert against mapbox-gl-test-suite master upstream, which contains tests not yet passable on GL native. I've added those tests on top @jfirebaugh's native-fixes branch there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants