diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-10-30 11:07:56 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@gmail.com> | 2017-10-31 10:25:57 -0700 |
commit | 5fc7d4abc6c6080a2dc0d0fcd65fb86f92ca84da (patch) | |
tree | cd6994023c5b06f078e85a9aabf3ef123bfb04ab | |
parent | e82e817df80f6832a61b4ca7526558d4826268d4 (diff) | |
download | qtlocation-mapboxgl-5fc7d4abc6c6080a2dc0d0fcd65fb86f92ca84da.tar.gz |
Store sourceID in IndexedSubfeature so that queryRenderedSymbols can filter to appropriate source.
TODO: should sourceID have a stronger type than std::string?
-rw-r--r-- | src/mbgl/geometry/feature_index.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/geometry/feature_index.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/text/collision_index.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/collision_index.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.hpp | 2 |
9 files changed, 27 insertions, 14 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index 77335bce36..ec6a3b5c2c 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -28,7 +28,7 @@ void FeatureIndex::insert(const GeometryCollection& geometries, for (const auto& ring : geometries) { // TODO: Templatize grid units so feature index can stick with integers? auto envelope = mapbox::geometry::envelope(ring); - grid.insert(IndexedSubfeature { index, sourceLayerName, bucketName, sortIndex++, 0, 0, 0, 0, 0 }, // TODO: FeatureIndex doesn't need to care about tileIDs, make this cleaner + grid.insert(IndexedSubfeature { index, "", sourceLayerName, bucketName, sortIndex++, 0, 0, 0, 0, 0 }, // TODO: FeatureIndex doesn't need to care about tileIDs or source IDS, make this cleaner {convertPoint<float>(envelope.min), convertPoint<float>(envelope.max)}); } } @@ -50,6 +50,7 @@ void FeatureIndex::query( const RenderedQueryOptions& queryOptions, const GeometryTileData& geometryTileData, const CanonicalTileID& tileID, + const std::string& sourceID, const std::vector<const RenderLayer*>& layers, const CollisionIndex& collisionIndex, const float additionalQueryRadius) const { @@ -81,7 +82,7 @@ void FeatureIndex::query( addFeature(result, indexedFeature, queryGeometry, queryOptions, geometryTileData, tileID, layers, bearing, pixelsToTileUnits); } - std::vector<IndexedSubfeature> symbolFeatures = collisionIndex.queryRenderedSymbols(queryGeometry, UnwrappedTileID(0, tileID)); // TODO: hook up + std::vector<IndexedSubfeature> symbolFeatures = collisionIndex.queryRenderedSymbols(queryGeometry, UnwrappedTileID(0, tileID), sourceID); // TODO: hook up std::sort(symbolFeatures.begin(), symbolFeatures.end(), topDownSymbols); for (const auto& symbolFeature : symbolFeatures) { addFeature(result, symbolFeature, queryGeometry, queryOptions, geometryTileData, tileID, layers, bearing, pixelsToTileUnits); diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp index 38b84071ac..7d1759a4be 100644 --- a/src/mbgl/geometry/feature_index.hpp +++ b/src/mbgl/geometry/feature_index.hpp @@ -21,6 +21,7 @@ class IndexedSubfeature { public: IndexedSubfeature() = delete; std::size_t index; + std::string sourceID; std::string sourceLayerName; std::string bucketName; size_t sortIndex; @@ -46,6 +47,7 @@ public: const RenderedQueryOptions& options, const GeometryTileData&, const CanonicalTileID&, + const std::string&, const std::vector<const RenderLayer*>&, const CollisionIndex&, const float additionalQueryRadius) const; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index c18b800c21..58c06aa923 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -179,7 +179,7 @@ bool SymbolLayout::hasSymbolInstances() const { void SymbolLayout::prepare(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions, const ImageMap& imageMap, const ImagePositions& imagePositions, - const OverscaledTileID& tileID) { + const OverscaledTileID& tileID, const std::string& sourceID) { const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map && layout.get<SymbolPlacement>() == SymbolPlacementType::Line; @@ -248,7 +248,7 @@ void SymbolLayout::prepare(const GlyphMap& glyphMap, const GlyphPositions& glyph // if either shapedText or icon position is present, add the feature if (shapedTextOrientations.first || shapedIcon) { - addFeature(std::distance(features.begin(), it), feature, shapedTextOrientations, shapedIcon, glyphPositionMap, tileID); + addFeature(std::distance(features.begin(), it), feature, shapedTextOrientations, shapedIcon, glyphPositionMap, tileID, sourceID); } feature.geometry.clear(); @@ -262,7 +262,8 @@ void SymbolLayout::addFeature(const std::size_t index, const std::pair<Shaping, Shaping>& shapedTextOrientations, optional<PositionedIcon> shapedIcon, const GlyphPositionMap& glyphPositionMap, - const OverscaledTileID& tileID) { + const OverscaledTileID& tileID, + const std::string& sourceID) { const float minScale = 0.5f; const float glyphSize = 24.0f; @@ -293,7 +294,7 @@ void SymbolLayout::addFeature(const std::size_t index, ? SymbolPlacementType::Point : layout.get<SymbolPlacement>(); const float textRepeatDistance = symbolSpacing / 2; - IndexedSubfeature indexedFeature = { feature.index, sourceLayer->getName(), bucketName, + IndexedSubfeature indexedFeature = { feature.index, sourceID, sourceLayer->getName(), bucketName, symbolInstances.size(), tileID.canonical.z, tileID.canonical.x, tileID.canonical.y, tileID.overscaledZ, tileID.wrap }; auto addSymbolInstance = [&] (const GeometryCoordinates& line, Anchor& anchor) { diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 4d63b2487d..dc4f0bfb3d 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -34,7 +34,8 @@ public: GlyphDependencies&); void prepare(const GlyphMap&, const GlyphPositions&, - const ImageMap&, const ImagePositions&, const OverscaledTileID&); + const ImageMap&, const ImagePositions&, + const OverscaledTileID&, const std::string&); std::unique_ptr<SymbolBucket> place(const bool showCollisionBoxes); @@ -52,7 +53,8 @@ private: const std::pair<Shaping, Shaping>& shapedTextOrientations, optional<PositionedIcon> shapedIcon, const GlyphPositionMap&, - const OverscaledTileID&); + const OverscaledTileID&, + const std::string&); bool anchorIsTooClose(const std::u16string& text, const float repeatDistance, const Anchor&); std::map<std::u16string, std::vector<Anchor>> compareText; diff --git a/src/mbgl/text/collision_index.cpp b/src/mbgl/text/collision_index.cpp index b80ba215fe..1d1d1d9a10 100644 --- a/src/mbgl/text/collision_index.cpp +++ b/src/mbgl/text/collision_index.cpp @@ -235,7 +235,7 @@ void CollisionIndex::insertFeature(CollisionFeature& feature, bool ignorePlaceme } } -std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const GeometryCoordinates& queryGeometry, const UnwrappedTileID& tileID) 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; @@ -271,9 +271,9 @@ std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const Geomet std::vector<QueryResult> features = collisionGrid.query({{minX, minY}, {maxX, maxY}}); for (auto& queryResult : features) { - auto& feature = queryResult.first; + auto& feature = queryResult.first; UnwrappedTileID featureTileID(feature.z, feature.x, feature.y); // TODO: Think about overscaling/wrapping - if (featureTileID == tileID) { + if (feature.sourceID == sourceID && featureTileID == tileID) { thisTileFeatures.push_back(queryResult); } } @@ -282,7 +282,7 @@ std::vector<IndexedSubfeature> CollisionIndex::queryRenderedSymbols(const Geomet for (auto& queryResult : ignoredFeatures) { auto& feature = queryResult.first; UnwrappedTileID featureTileID(feature.z, feature.x, feature.y); // TODO: Think about overscaling/wrapping - if (featureTileID == tileID) { + if (feature.sourceID == sourceID && featureTileID == tileID) { thisTileFeatures.push_back(queryResult); } } diff --git a/src/mbgl/text/collision_index.hpp b/src/mbgl/text/collision_index.hpp index 0d19d6f9cd..3a6ad031af 100644 --- a/src/mbgl/text/collision_index.hpp +++ b/src/mbgl/text/collision_index.hpp @@ -31,7 +31,7 @@ public: void insertFeature(CollisionFeature& feature, bool ignorePlacement); - std::vector<IndexedSubfeature> queryRenderedSymbols(const GeometryCoordinates&, const UnwrappedTileID& tileID) 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 ff5177aa0d..6371cbdc0b 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -51,6 +51,7 @@ GeometryTile::GeometryTile(const OverscaledTileID& id_, worker(parameters.workerScheduler, ActorRef<GeometryTile>(*this, mailbox), id_, + sourceID, obsolete, parameters.mode, parameters.pixelRatio, @@ -238,6 +239,7 @@ void GeometryTile::queryRenderedFeatures( options, *data, id.canonical, + sourceID, layers, collisionIndex, // TODO: hook up to global CollisionIndex additionalRadius); diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index 9b9ca5ff1b..969b137c1f 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -23,6 +23,7 @@ using namespace style; GeometryTileWorker::GeometryTileWorker(ActorRef<GeometryTileWorker> self_, ActorRef<GeometryTile> parent_, OverscaledTileID id_, + const std::string& sourceID_, const std::atomic<bool>& obsolete_, const MapMode mode_, const float pixelRatio_, @@ -30,6 +31,7 @@ GeometryTileWorker::GeometryTileWorker(ActorRef<GeometryTileWorker> self_, : self(std::move(self_)), parent(std::move(parent_)), id(std::move(id_)), + sourceID(sourceID_), obsolete(obsolete_), mode(mode_), pixelRatio(pixelRatio_), @@ -393,7 +395,8 @@ void GeometryTileWorker::attemptPlacement() { } symbolLayout->prepare(glyphMap, glyphAtlas.positions, - imageMap, imageAtlas.positions, id); + imageMap, imageAtlas.positions, + id, sourceID); } symbolLayoutsNeedPreparation = false; diff --git a/src/mbgl/tile/geometry_tile_worker.hpp b/src/mbgl/tile/geometry_tile_worker.hpp index 289e7c69af..cc86248cec 100644 --- a/src/mbgl/tile/geometry_tile_worker.hpp +++ b/src/mbgl/tile/geometry_tile_worker.hpp @@ -27,6 +27,7 @@ public: GeometryTileWorker(ActorRef<GeometryTileWorker> self, ActorRef<GeometryTile> parent, OverscaledTileID, + const std::string&, const std::atomic<bool>&, const MapMode, const float pixelRatio, @@ -57,6 +58,7 @@ private: ActorRef<GeometryTile> parent; const OverscaledTileID id; + const std::string sourceID; const std::atomic<bool>& obsolete; const MapMode mode; const float pixelRatio; |