summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-11-07 15:57:39 -0800
committerChris Loer <chris.loer@gmail.com>2017-11-07 15:57:39 -0800
commitb2b5c3e8e193893009eb042771a74811ac458e5a (patch)
treecb8394ce2f6f686947e4dba9f325fd09a468ce0e
parent75a70cf0b80b98b3d8faf41a44b1907cc3bc6e45 (diff)
downloadqtlocation-mapboxgl-b2b5c3e8e193893009eb042771a74811ac458e5a.tar.gz
Use UnwrappedTileID instead of CanonicalTileID as input to queryRenderedSymbols.
This is necessary for handling the case where the feature is not projected onto the screen for the tile with wrap 0, but is onscreen for a tile with a different wrap.
-rw-r--r--src/mbgl/geometry/feature_index.cpp6
-rw-r--r--src/mbgl/geometry/feature_index.hpp2
-rw-r--r--src/mbgl/text/collision_index.cpp10
-rw-r--r--src/mbgl/text/collision_index.hpp2
-rw-r--r--src/mbgl/tile/geometry_tile.cpp2
5 files changed, 12 insertions, 10 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index c2ffe0412e..e610e5ba5f 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -48,7 +48,7 @@ void FeatureIndex::query(
const double scale,
const RenderedQueryOptions& queryOptions,
const GeometryTileData& geometryTileData,
- const CanonicalTileID& tileID,
+ const UnwrappedTileID& tileID,
const std::string& sourceID,
const std::vector<const RenderLayer*>& layers,
const CollisionIndex& collisionIndex,
@@ -72,13 +72,13 @@ void FeatureIndex::query(
if (indexedFeature.sortIndex == previousSortIndex) continue;
previousSortIndex = indexedFeature.sortIndex;
- addFeature(result, indexedFeature, queryGeometry, queryOptions, geometryTileData, tileID, layers, bearing, pixelsToTileUnits);
+ addFeature(result, indexedFeature, queryGeometry, queryOptions, geometryTileData, tileID.canonical, layers, bearing, pixelsToTileUnits);
}
std::vector<IndexedSubfeature> symbolFeatures = collisionIndex.queryRenderedSymbols(queryGeometry, tileID, sourceID);
std::sort(symbolFeatures.begin(), symbolFeatures.end(), topDownSymbols);
for (const auto& symbolFeature : symbolFeatures) {
- addFeature(result, symbolFeature, queryGeometry, queryOptions, geometryTileData, tileID, layers, bearing, pixelsToTileUnits);
+ addFeature(result, symbolFeature, queryGeometry, queryOptions, geometryTileData, tileID.canonical, layers, bearing, pixelsToTileUnits);
}
}
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp
index 5cf7b14d8c..0e8b0cb85e 100644
--- a/src/mbgl/geometry/feature_index.hpp
+++ b/src/mbgl/geometry/feature_index.hpp
@@ -68,7 +68,7 @@ public:
const double scale,
const RenderedQueryOptions& options,
const GeometryTileData&,
- const CanonicalTileID&,
+ const UnwrappedTileID&,
const std::string&,
const std::vector<const RenderLayer*>&,
const CollisionIndex&,
diff --git a/src/mbgl/text/collision_index.cpp b/src/mbgl/text/collision_index.cpp
index 234a0bb4ed..05a0450465 100644
--- a/src/mbgl/text/collision_index.cpp
+++ b/src/mbgl/text/collision_index.cpp
@@ -227,7 +227,7 @@ void CollisionIndex::insertFeature(CollisionFeature& feature, bool ignorePlaceme
}
}
-std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const GeometryCoordinates& queryGeometry, const CanonicalTileID& tileID, const std::string& sourceID) const {
+std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const GeometryCoordinates& queryGeometry, const UnwrappedTileID& tileID, const std::string& sourceID) const {
std::vector<IndexedSubfeature> result;
if (queryGeometry.empty() || (collisionGrid.empty() && ignoredGrid.empty())) {
return result;
@@ -236,7 +236,7 @@ std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const Geomet
mat4 posMatrix;
mat4 projMatrix;
transformState.getProjMatrix(projMatrix);
- transformState.matrixFor(posMatrix, UnwrappedTileID(0, tileID)); // TODO: This probably isn't right, I think it's working right now because both the wrapped and unwrapped version are getting queried, but I haven't thought through why it should work.
+ transformState.matrixFor(posMatrix, tileID);
matrix::multiply(posMatrix, projMatrix, posMatrix);
// Two versions of the query here just because util::polygonIntersectsPolygon requires
@@ -260,7 +260,9 @@ std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const Geomet
for (auto& queryResult : features) {
auto& feature = queryResult.first;
CanonicalTileID featureTileID(feature.z, feature.x, feature.y);
- if (feature.sourceID == sourceID && featureTileID == tileID) {
+ if (feature.sourceID == sourceID && featureTileID == tileID.canonical) {
+ // We only have to filter on the canonical ID because even if the feature is showing multiple times
+ // we treat it as one feature.
thisTileFeatures.push_back(queryResult);
}
}
@@ -269,7 +271,7 @@ std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const Geomet
for (auto& queryResult : ignoredFeatures) {
auto& feature = queryResult.first;
CanonicalTileID featureTileID(feature.z, feature.x, feature.y);
- if (feature.sourceID == sourceID && featureTileID == tileID) {
+ if (feature.sourceID == sourceID && featureTileID == tileID.canonical) {
thisTileFeatures.push_back(queryResult);
}
}
diff --git a/src/mbgl/text/collision_index.hpp b/src/mbgl/text/collision_index.hpp
index 2e9201e4c4..6f78d8aeda 100644
--- a/src/mbgl/text/collision_index.hpp
+++ b/src/mbgl/text/collision_index.hpp
@@ -30,7 +30,7 @@ public:
void insertFeature(CollisionFeature& feature, bool ignorePlacement);
- std::vector<IndexedSubfeature> queryRenderedSymbols(const GeometryCoordinates&, const CanonicalTileID& tileID, const std::string& sourceID) const;
+ std::vector<IndexedSubfeature> queryRenderedSymbols(const GeometryCoordinates&, const UnwrappedTileID& tileID, const std::string& sourceID) const;
private:
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 9c83864a87..576c23b682 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -239,7 +239,7 @@ void GeometryTile::queryRenderedFeatures(
std::pow(2, transformState.getZoom() - id.overscaledZ),
options,
*data,
- id.canonical,
+ id.toUnwrapped(),
sourceID,
layers,
collisionIndex,