summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-02 18:01:19 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-11 12:10:32 +0300
commit623a124e01a9f3812aad3f8cda866992bb61a567 (patch)
tree713f773e6bf19fa46e3fd47111278a5d483b349c /src
parent38e78e25dfa3bc5b69a29029d4e065e72f462c37 (diff)
downloadqtlocation-mapboxgl-623a124e01a9f3812aad3f8cda866992bb61a567.tar.gz
[core] Use query geometry from FeatureIndex into CollisionTile::queryRenderedSymbols
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/feature_index.cpp2
-rw-r--r--src/mbgl/text/collision_tile.cpp15
-rw-r--r--src/mbgl/text/collision_tile.hpp3
3 files changed, 16 insertions, 4 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index cd131dde72..b37bdb5ecc 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -83,7 +83,7 @@ void FeatureIndex::query(
return;
}
- std::vector<IndexedSubfeature> symbolFeatures = collisionTile->queryRenderedSymbols(box, scale);
+ std::vector<IndexedSubfeature> symbolFeatures = collisionTile->queryRenderedSymbols(queryGeometry, scale);
std::sort(symbolFeatures.begin(), symbolFeatures.end(), topDownSymbols);
for (const auto& symbolFeature : symbolFeatures) {
addFeature(result, symbolFeature, queryGeometry, filterLayerIDs, geometryTileData, tileID, style, bearing, pixelsToTileUnits);
diff --git a/src/mbgl/text/collision_tile.cpp b/src/mbgl/text/collision_tile.cpp
index 84c3f87a76..ec92782317 100644
--- a/src/mbgl/text/collision_tile.cpp
+++ b/src/mbgl/text/collision_tile.cpp
@@ -3,6 +3,9 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/math.hpp>
+#include <mapbox/geometry/envelope.hpp>
+#include <mapbox/geometry/multi_point.hpp>
+
#include <cmath>
namespace mbgl {
@@ -152,12 +155,20 @@ Box CollisionTile::getTreeBox(const Point<float>& anchor, const CollisionBox& bo
};
}
-std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const mapbox::geometry::box<int16_t>& box, const float scale) {
+std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const GeometryCoordinates& queryGeometry, const float scale) {
std::vector<IndexedSubfeature> result;
+ if (queryGeometry.empty()) return result;
+
std::unordered_map<std::string, std::unordered_set<std::size_t>> sourceLayerFeatures;
- auto anchor = util::matrixMultiply(rotationMatrix, convertPoint<float>(box.min));
+ mapbox::geometry::multi_point<float> rotatedPoints {};
+ rotatedPoints.reserve(queryGeometry.size());
+ std::transform(queryGeometry.cbegin(), queryGeometry.cend(), std::back_inserter(rotatedPoints),
+ [&](const auto& c) { return util::matrixMultiply(rotationMatrix, convertPoint<float>(c)); });
+ const auto box = mapbox::geometry::envelope(rotatedPoints);
+
+ const auto& anchor = box.min;
CollisionBox queryBox(anchor, 0, 0, box.max.x - box.min.x, box.max.y - box.min.y, scale);
auto predicates = bgi::intersects(getTreeBox(anchor, queryBox));
diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp
index 7450fb1b86..8d660eb6e6 100644
--- a/src/mbgl/text/collision_tile.hpp
+++ b/src/mbgl/text/collision_tile.hpp
@@ -2,6 +2,7 @@
#include <mbgl/text/collision_feature.hpp>
#include <mbgl/text/placement_config.hpp>
+#include <mbgl/tile/geometry_tile_data.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
@@ -41,7 +42,7 @@ public:
float placeFeature(const CollisionFeature&, const bool allowOverlap, const bool avoidEdges);
void insertFeature(CollisionFeature&, const float minPlacementScale, const bool ignorePlacement);
- std::vector<IndexedSubfeature> queryRenderedSymbols(const mapbox::geometry::box<int16_t>&, const float scale);
+ std::vector<IndexedSubfeature> queryRenderedSymbols(const GeometryCoordinates&, const float scale);
const PlacementConfig config;