summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-04-03 02:41:09 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-05-23 11:12:23 +0200
commitd002e74e38a2a19785d8733a6130d1b8428f5eff (patch)
treee217f118b345ff704c528c963bb5212874a5b1a1
parent3ef1f5f8b45f1aa0a5f4bafd6c07a737b6160883 (diff)
downloadqtlocation-mapboxgl-d002e74e38a2a19785d8733a6130d1b8428f5eff.tar.gz
[core] fix querying circles across tile boundaries
(cherry picked from commit f7d20a5)
-rw-r--r--src/mbgl/geometry/feature_index.cpp8
-rw-r--r--src/mbgl/geometry/feature_index.hpp2
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp6
-rw-r--r--src/mbgl/tile/geometry_tile.cpp22
-rw-r--r--src/mbgl/tile/geometry_tile.hpp2
-rw-r--r--src/mbgl/tile/tile.cpp4
-rw-r--r--src/mbgl/tile/tile.hpp2
7 files changed, 30 insertions, 16 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index 145c16bf09..9f90e48b09 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -41,7 +41,7 @@ void FeatureIndex::query(
const RenderedQueryOptions& queryOptions,
const UnwrappedTileID& tileID,
const std::vector<const RenderLayer*>& layers,
- const float additionalQueryRadius) const {
+ const float additionalQueryPadding) const {
if (!tileData) {
return;
@@ -49,12 +49,12 @@ void FeatureIndex::query(
// Determine query radius
const float pixelsToTileUnits = util::EXTENT / tileSize / scale;
- const int16_t additionalRadius = std::min<int16_t>(util::EXTENT, additionalQueryRadius * pixelsToTileUnits);
+ const int16_t additionalPadding = std::min<int16_t>(util::EXTENT, additionalQueryPadding * pixelsToTileUnits);
// Query the grid index
mapbox::geometry::box<int16_t> box = mapbox::geometry::envelope(queryGeometry);
- std::vector<IndexedSubfeature> features = grid.query({ convertPoint<float>(box.min - additionalRadius),
- convertPoint<float>(box.max + additionalRadius) });
+ std::vector<IndexedSubfeature> features = grid.query({ convertPoint<float>(box.min - additionalPadding),
+ convertPoint<float>(box.max + additionalPadding) });
std::sort(features.begin(), features.end(), [](const IndexedSubfeature& a, const IndexedSubfeature& b) {
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp
index 5a15a379c4..f105260c0c 100644
--- a/src/mbgl/geometry/feature_index.hpp
+++ b/src/mbgl/geometry/feature_index.hpp
@@ -62,7 +62,7 @@ public:
const RenderedQueryOptions& options,
const UnwrappedTileID&,
const std::vector<const RenderLayer*>&,
- const float additionalQueryRadius) const;
+ const float additionalQueryPadding) const;
static optional<GeometryCoordinates> translateQueryGeometry(
const GeometryCoordinates& queryGeometry,
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index e2d4d9829f..b2d72680e7 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -264,13 +264,15 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
});
for (const RenderTile& renderTile : sortedTiles) {
+ auto queryPadding = renderTile.tile.getQueryPadding(layers);
+
GeometryCoordinate tileSpaceBoundsMin = TileCoordinate::toGeometryCoordinate(renderTile.id, box.min);
- if (tileSpaceBoundsMin.x >= util::EXTENT || tileSpaceBoundsMin.y >= util::EXTENT) {
+ if (tileSpaceBoundsMin.x - queryPadding >= util::EXTENT || tileSpaceBoundsMin.y - queryPadding >= util::EXTENT) {
continue;
}
GeometryCoordinate tileSpaceBoundsMax = TileCoordinate::toGeometryCoordinate(renderTile.id, box.max);
- if (tileSpaceBoundsMax.x < 0 || tileSpaceBoundsMax.y < 0) {
+ if (tileSpaceBoundsMax.x + queryPadding < 0 || tileSpaceBoundsMax.y + queryPadding < 0) {
continue;
}
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index b0b898e61a..56a0558248 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -200,6 +200,17 @@ Bucket* GeometryTile::getBucket(const Layer::Impl& layer) const {
return it->second.get();
}
+float GeometryTile::getQueryPadding(const std::vector<const RenderLayer*>& layers) {
+ float queryPadding = 0;
+ for (const RenderLayer* layer : layers) {
+ auto bucket = getBucket(*layer->baseImpl);
+ if (bucket) {
+ queryPadding = std::max(queryPadding, bucket->getQueryRadius(*layer));
+ }
+ }
+ return queryPadding;
+}
+
void GeometryTile::queryRenderedFeatures(
std::unordered_map<std::string, std::vector<Feature>>& result,
const GeometryCoordinates& queryGeometry,
@@ -209,14 +220,7 @@ void GeometryTile::queryRenderedFeatures(
if (!getData()) return;
- // Determine the additional radius needed factoring in property functions
- float additionalRadius = 0;
- for (const RenderLayer* layer : layers) {
- auto bucket = getBucket(*layer->baseImpl);
- if (bucket) {
- additionalRadius = std::max(additionalRadius, bucket->getQueryRadius(*layer));
- }
- }
+ const float queryPadding = getQueryPadding(layers);
latestFeatureIndex->query(result,
queryGeometry,
@@ -226,7 +230,7 @@ void GeometryTile::queryRenderedFeatures(
options,
id.toUnwrapped(),
layers,
- additionalRadius);
+ queryPadding);
}
void GeometryTile::querySourceFeatures(
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp
index a3b2eb6492..a43bf44940 100644
--- a/src/mbgl/tile/geometry_tile.hpp
+++ b/src/mbgl/tile/geometry_tile.hpp
@@ -60,6 +60,8 @@ public:
std::vector<Feature>& result,
const SourceQueryOptions&) override;
+ float getQueryPadding(const std::vector<const RenderLayer*>&) override;
+
void cancel() override;
class LayoutResult {
diff --git a/src/mbgl/tile/tile.cpp b/src/mbgl/tile/tile.cpp
index e65bc39540..56698e84c4 100644
--- a/src/mbgl/tile/tile.cpp
+++ b/src/mbgl/tile/tile.cpp
@@ -39,6 +39,10 @@ void Tile::queryRenderedFeatures(
const std::vector<const RenderLayer*>&,
const RenderedQueryOptions&) {}
+float Tile::getQueryPadding(const std::vector<const RenderLayer*>&) {
+ return 0;
+}
+
void Tile::querySourceFeatures(
std::vector<Feature>&,
const SourceQueryOptions&) {}
diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp
index a0effa29a1..5f7a076850 100644
--- a/src/mbgl/tile/tile.hpp
+++ b/src/mbgl/tile/tile.hpp
@@ -63,6 +63,8 @@ public:
std::vector<Feature>& result,
const SourceQueryOptions&);
+ virtual float getQueryPadding(const std::vector<const RenderLayer*>&);
+
void setTriedCache();
// Returns true when the tile source has received a first response, regardless of whether a load