[core] PlacedSymbolData contains layer id

This commit is contained in:
Mikhail Pozdnyakov
2020-04-09 12:40:15 +03:00
parent 718dd295ab
commit e6c156420d
5 changed files with 22 additions and 5 deletions

View File

@@ -36,6 +36,8 @@ struct PlacedSymbolData {
bool intersectsTileBorder;
// Viewport padding ({viewportPadding, viewportPadding} is a coordinate of the tile's top-left corner)
float viewportPadding;
// Layer id (leader of the symbol layout group)
std::string layer;
};
class Renderer {

View File

@@ -814,8 +814,8 @@ void TestRunner::run(TestMetadata& metadata) {
ss << std::endl
<< ++metadata.duplicationsCount << ". \"" << cv.to_bytes(placedSymbol.key) << "\" "
<< (isIcon ? "icon" : "text") << " ((" << box.min.x << ", " << box.min.y << "), ("
<< box.max.x << ", " << box.max.y << ")) "
<< "at " << util::toString(tileId);
<< box.max.x << ", " << box.max.y << ")) from layer: " << placedSymbol.layer << " at "
<< util::toString(tileId);
duplicationsReport += ss.str();
return;
}
@@ -824,7 +824,7 @@ void TestRunner::run(TestMetadata& metadata) {
ss << std::endl
<< ++metadata.labelCutOffFound << ". \"" << cv.to_bytes(placedSymbol.key) << "\" "
<< (isIcon ? "icon" : "text") << " ((" << box.min.x << ", " << box.min.y << "), ("
<< box.max.x << ", " << box.max.y << "))"
<< box.max.x << ", " << box.max.y << ")) from layer: " << placedSymbol.layer
<< (placed ? " is placed at " : " is not placed at ") << util::toString(tileId) << " and"
<< (it->placed ? " placed at " : " not placed at ") << util::toString(it->tileId);
cutOffLabelsReport += ss.str();

View File

@@ -608,7 +608,7 @@ void Placement::placeSymbol(const SymbolInstance& symbolInstance,
JointPlacement(
placeText || ctx.alwaysShowText, placeIcon || ctx.alwaysShowIcon, offscreen || bucket.justReloaded));
assert(pair.second);
newSymbolPlaced(symbolInstance, pair.first->second, ctx.placementType, textBoxes, iconBoxes);
newSymbolPlaced(symbolInstance, ctx, pair.first->second, ctx.placementType, textBoxes, iconBoxes);
seenCrossTileIDs.insert(symbolInstance.crossTileID);
}
@@ -1268,6 +1268,7 @@ private:
const mat4& posMatrix,
float textPixelRatio) override;
void newSymbolPlaced(const SymbolInstance&,
const PlacementContext&,
const JointPlacement&,
style::SymbolPlacementType,
const std::vector<ProjectedCollisionBox>&,
@@ -1476,6 +1477,7 @@ bool TilePlacement::canPlaceAtVariableAnchor(const CollisionBox& box,
}
void TilePlacement::newSymbolPlaced(const SymbolInstance& symbol,
const PlacementContext& ctx,
const JointPlacement& placement,
style::SymbolPlacementType placementType,
const std::vector<ProjectedCollisionBox>& textCollisionBoxes,
@@ -1502,7 +1504,8 @@ void TilePlacement::newSymbolPlaced(const SymbolInstance& symbol,
placement.text,
placement.icon,
!placement.skipFade && populateIntersections,
collisionIndex.getViewportPadding()};
collisionIndex.getViewportPadding(),
ctx.getBucket().bucketLeaderID};
placedSymbolsData.emplace_back(std::move(symbolData));
}

View File

@@ -148,6 +148,7 @@ protected:
void placeLayer(const RenderLayer&, std::set<uint32_t>&);
virtual void commit();
virtual void newSymbolPlaced(const SymbolInstance&,
const PlacementContext&,
const JointPlacement&,
style::SymbolPlacementType,
const std::vector<ProjectedCollisionBox>& /*textBoxes*/,

View File

@@ -1431,7 +1431,18 @@ TEST(Map, PlacedSymbolData) {
int placedTotal = 0;
const std::set<std::string> symbolLayers{"place-city-lg-s",
"place-neighbourhood",
"place-suburb",
"poi-scalerank2",
"poi-scalerank3",
"poi-parks-scalerank1",
"poi-parks-scalerank2",
"poi-parks-scalerank3",
"rail-label"};
for (const auto& placedSymbol : placedSymbols) {
EXPECT_NE(0u, symbolLayers.count(placedSymbol.layer));
if (placedSymbol.textPlaced && placedSymbol.textCollisionBox) {
if (isInsideTile(*placedSymbol.textCollisionBox, placedSymbol.viewportPadding, viewportSize)) {
EXPECT_FALSE(placedSymbol.intersectsTileBorder);