[core] #7319: Add support for Filters in queryRenderedFeatures #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
map.queryRenderedFeatures()
to accept a query options struct similar to mapbox-gl-js. This change should satisfy mapbox#7319, although it does not add the 'layer' property as requested mapbox#7162.This changes the core API and requires updating the mobile SDK bindings
The new signature is
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate&, const QueryOptions& options = {});
QueryOptions
struct accepts layerIds and filter parameters, but is expandable for more query options.Usage:
Development Notes:
I chose to rework the existing
QueryParameters
struct as that internal struct mixed external and internal types and could not be reused for an external facing API such asmap.queryRenderedFeatures()
.To minimize future changes and to ease adding additional query parameters I chose to add QueryOptions and use it for all external facing parameters. QueryParameters was then flattened out and removed.
Testing:
This PR includes unit tests in core, and updated node bindings that can be used with new query tests added to the mapbox-gl-js integration test suite with this PR.
I also validated with some changes to the macosapp but stopped short of updating the bindings. The macosapp has minimal changes to compile and run but does not yet support filters in
[map visibleFeautresInRect:]
and[map visibileFeaturesAtPoint:]
.While I have played with some local changes to the macos app, I haven't done a thorough benchmark test to gauge the performance of compound filters such as All,Any.