[core] Thread Style parameter through queryRenderedFeatures

This commit is contained in:
John Firebaugh
2017-05-29 14:43:35 -07:00
parent 41d2496c07
commit 32589c271c
19 changed files with 47 additions and 13 deletions

View File

@@ -59,9 +59,10 @@ void RenderAnnotationSource::reloadTiles() {
std::unordered_map<std::string, std::vector<Feature>>
RenderAnnotationSource::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const RenderedQueryOptions& options) const {
return tilePyramid.queryRenderedFeatures(geometry, transformState, options);
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const {
return tilePyramid.queryRenderedFeatures(geometry, transformState, style, options);
}
std::vector<Feature> RenderAnnotationSource::querySourceFeatures(const SourceQueryOptions&) const {

View File

@@ -37,6 +37,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const final;
std::vector<Feature>

View File

@@ -23,6 +23,10 @@ class Tile;
class RenderSourceObserver;
class TileParameters;
namespace style {
class Style;
} // namespace style
namespace algorithm {
class ClipIDGenerator;
} // namespace algorithm
@@ -75,6 +79,7 @@ public:
virtual std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const = 0;
virtual std::vector<Feature>

View File

@@ -74,9 +74,10 @@ void RenderGeoJSONSource::reloadTiles() {
std::unordered_map<std::string, std::vector<Feature>>
RenderGeoJSONSource::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const RenderedQueryOptions& options) const {
return tilePyramid.queryRenderedFeatures(geometry, transformState, options);
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const {
return tilePyramid.queryRenderedFeatures(geometry, transformState, style, options);
}
std::vector<Feature> RenderGeoJSONSource::querySourceFeatures(const SourceQueryOptions& options) const {

View File

@@ -41,6 +41,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const final;
std::vector<Feature>

View File

@@ -54,8 +54,11 @@ void RenderImageSource::finishRender(Painter& painter) {
}
}
std::unordered_map<std::string, std::vector<Feature>> RenderImageSource::queryRenderedFeatures(
const ScreenLineString&, const TransformState&, const RenderedQueryOptions&) const {
std::unordered_map<std::string, std::vector<Feature>>
RenderImageSource::queryRenderedFeatures(const ScreenLineString&,
const TransformState&,
const style::Style&,
const RenderedQueryOptions&) const {
return {};
}

View File

@@ -45,6 +45,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const final;
std::vector<Feature> querySourceFeatures(const SourceQueryOptions&) const final;

View File

@@ -67,6 +67,7 @@ void RenderRasterSource::reloadTiles() {
std::unordered_map<std::string, std::vector<Feature>>
RenderRasterSource::queryRenderedFeatures(const ScreenLineString&,
const TransformState&,
const style::Style&,
const RenderedQueryOptions&) const {
return {};
}

View File

@@ -37,6 +37,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const final;
std::vector<Feature>

View File

@@ -71,8 +71,9 @@ void RenderVectorSource::reloadTiles() {
std::unordered_map<std::string, std::vector<Feature>>
RenderVectorSource::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const {
return tilePyramid.queryRenderedFeatures(geometry, transformState, options);
return tilePyramid.queryRenderedFeatures(geometry, transformState, style, options);
}
std::vector<Feature> RenderVectorSource::querySourceFeatures(const SourceQueryOptions& options) const {

View File

@@ -37,6 +37,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const final;
std::vector<Feature>

View File

@@ -180,6 +180,7 @@ void TilePyramid::reloadTiles() {
std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const {
std::unordered_map<std::string, std::vector<Feature>> result;
if (renderTiles.empty() || geometry.empty()) {
@@ -226,6 +227,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
renderTile.tile.queryRenderedFeatures(result,
tileSpaceQueryGeometry,
transformState,
style,
options);
}

View File

@@ -24,6 +24,10 @@ class RenderedQueryOptions;
class SourceQueryOptions;
class TileParameters;
namespace style {
class Style;
} // namespace style
class TilePyramid {
public:
TilePyramid();
@@ -59,6 +63,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const style::Style& style,
const RenderedQueryOptions& options) const;
std::vector<Feature> querySourceFeatures(const SourceQueryOptions&) const;

View File

@@ -697,13 +697,13 @@ std::vector<Feature> Style::queryRenderedFeatures(const ScreenLineString& geomet
}
for (const auto& sourceID : sourceIDs) {
if (RenderSource* renderSource = getRenderSource(sourceID)) {
auto sourceResults = renderSource->queryRenderedFeatures(geometry, transformState, options);
auto sourceResults = renderSource->queryRenderedFeatures(geometry, transformState, *this, options);
std::move(sourceResults.begin(), sourceResults.end(), std::inserter(resultsByLayer, resultsByLayer.begin()));
}
}
} else {
for (const auto& entry : renderSources) {
auto sourceResults = entry.second->queryRenderedFeatures(geometry, transformState, options);
auto sourceResults = entry.second->queryRenderedFeatures(geometry, transformState, *this, options);
std::move(sourceResults.begin(), sourceResults.end(), std::inserter(resultsByLayer, resultsByLayer.begin()));
}
}

View File

@@ -181,6 +181,7 @@ void GeometryTile::queryRenderedFeatures(
std::unordered_map<std::string, std::vector<Feature>>& result,
const GeometryCoordinates& queryGeometry,
const TransformState& transformState,
const style::Style& style_,
const RenderedQueryOptions& options) {
if (!featureIndex || !data) return;
@@ -193,7 +194,7 @@ void GeometryTile::queryRenderedFeatures(
options,
*data,
id.canonical,
style,
style_,
collisionTile.get(),
*this);
}

View File

@@ -55,6 +55,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>& result,
const GeometryCoordinates& queryGeometry,
const TransformState&,
const style::Style&,
const RenderedQueryOptions& options) override;
void querySourceFeatures(
@@ -92,6 +93,8 @@ private:
void invokePlacement();
const std::string sourceID;
// TODO: remove
style::Style& style;
// Used to signal the worker that it should abandon parsing this tile as soon as possible.

View File

@@ -33,6 +33,7 @@ void Tile::queryRenderedFeatures(
std::unordered_map<std::string, std::vector<Feature>>&,
const GeometryCoordinates&,
const TransformState&,
const style::Style&,
const RenderedQueryOptions&) {}
void Tile::querySourceFeatures(

View File

@@ -25,6 +25,10 @@ class PlacementConfig;
class RenderedQueryOptions;
class SourceQueryOptions;
namespace style {
class Style;
} // namespace style
class Tile : private util::noncopyable {
public:
Tile(OverscaledTileID);
@@ -53,6 +57,7 @@ public:
std::unordered_map<std::string, std::vector<Feature>>& result,
const GeometryCoordinates& queryGeometry,
const TransformState&,
const style::Style&,
const RenderedQueryOptions& options);
virtual void querySourceFeatures(

View File

@@ -81,7 +81,7 @@ TEST(AnnotationTile, Issue8289) {
TransformState transformState;
RenderedQueryOptions options;
tile.queryRenderedFeatures(result, queryGeometry, transformState, options);
tile.queryRenderedFeatures(result, queryGeometry, transformState, test.style, options);
EXPECT_TRUE(result.empty());
}