[core] only index features within tile boundaries

Previously we relied on tile buffers for querying features who's
rendered representations cross tile boundaries. Now we query multiple
tiles making it unnecessary to index features that are completely
outside a tile's boundaries.
This commit is contained in:
Ansis Brammanis
2018-03-30 16:28:05 -04:00
committed by Ansis Brammanis
parent f86fe44dbd
commit 0ca53ea5a8
3 changed files with 11 additions and 5 deletions

View File

@@ -28,8 +28,13 @@ void FeatureIndex::insert(const GeometryCollection& geometries,
const std::string& bucketName) {
for (const auto& ring : geometries) {
auto envelope = mapbox::geometry::envelope(ring);
grid.insert(IndexedSubfeature(index, sourceLayerName, bucketName, sortIndex++),
{convertPoint<float>(envelope.min), convertPoint<float>(envelope.max)});
if (envelope.min.x < util::EXTENT &&
envelope.min.y < util::EXTENT &&
envelope.max.x >= 0 &&
envelope.max.y >= 0) {
grid.insert(IndexedSubfeature(index, sourceLayerName, bucketName, sortIndex++),
{convertPoint<float>(envelope.min), convertPoint<float>(envelope.max)});
}
}
}
@@ -106,7 +111,8 @@ std::unordered_map<std::string, std::vector<Feature>> FeatureIndex::lookupSymbol
});
for (const auto& symbolFeature : sortedFeatures) {
addFeature(result, symbolFeature, queryOptions, tileID.canonical, layers, GeometryCoordinates(), {}, 0, {});
mat4 unusedMatrix;
addFeature(result, symbolFeature, queryOptions, tileID.canonical, layers, GeometryCoordinates(), {}, 0, unusedMatrix);
}
return result;
}

View File

@@ -131,7 +131,7 @@ bool RenderCircleLayer::queryIntersectsFeature(
auto stroke = evaluated.evaluate<style::CircleStrokeWidth>(zoom, feature);
auto size = radius + stroke;
// For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile
// For pitch-alignment: map, compare feature geometry to query geometry in the plane of the tile
// Otherwise, compare geometry in the plane of the viewport
// A circle with fixed scaling relative to the viewport gets larger in tile space as it moves into the distance
// A circle with fixed scaling relative to the map gets smaller in viewport space as it moves into the distance

View File

@@ -205,7 +205,7 @@ float GeometryTile::getQueryPadding(const std::vector<const RenderLayer*>& layer
float queryPadding = 0;
for (const RenderLayer* layer : layers) {
auto bucket = getBucket(*layer->baseImpl);
if (bucket) {
if (bucket && bucket->hasData()) {
queryPadding = std::max(queryPadding, bucket->getQueryRadius(*layer));
}
}