[core] Use query geometry from FeatureIndex into CollisionTile::queryRenderedSymbols
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user