diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-07-30 15:22:28 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2018-08-20 10:50:05 -0700 |
commit | b0fcca5879f1e8ffb0dfd43510e656cd84ca742a (patch) | |
tree | 0ac0502e22fe552c42f60823308e5f67d1063729 /src/mbgl/layout | |
parent | bded6c65d59b6da9e7cd6d4787e5f707a62a8285 (diff) | |
download | qtlocation-mapboxgl-b0fcca5879f1e8ffb0dfd43510e656cd84ca742a.tar.gz |
[core, node] Re-implement "avoid edges" behavior for MapMode::Tile
- Fixes issue #12461.
- Only implement "avoid edges" in MapMode::Tile since it's no longer relevant in Static or Continuous mode.
- New: Force "avoid edges" to "true" for line labels, since in tile mode they'll always clip poorly at tile boundaries.
- Remove unused "withinPlus0/inside" logic.
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 41469f293d..ab718351ab 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -258,11 +258,6 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, const float textMaxBoxScale = tilePixelRatio * textMaxSize / glyphSize; const float iconBoxScale = tilePixelRatio * layoutIconSize; const float symbolSpacing = tilePixelRatio * layout.get<SymbolSpacing>(); - // CJL: I'm not sure why SymbolPlacementType::Line -> avoidEdges = false. It seems redundant since - // getAnchors will already avoid generating anchors outside the tile bounds. - // However, SymbolPlacementType::LineCenter allows anchors outside tile boundaries, so its behavior - // here should match SymbolPlacement::Point - const bool avoidEdges = layout.get<SymbolAvoidEdges>() && layout.get<SymbolPlacement>() != SymbolPlacementType::Line; const float textPadding = layout.get<TextPadding>() * tilePixelRatio; const float iconPadding = layout.get<IconPadding>() * tilePixelRatio; const float textMaxAngle = layout.get<TextMaxAngle>() * util::DEG2RAD; @@ -274,25 +269,14 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, IndexedSubfeature indexedFeature(feature.index, sourceLayer->getName(), bucketLeaderID, symbolInstances.size()); auto addSymbolInstance = [&] (const GeometryCoordinates& line, Anchor& anchor) { - // https://github.com/mapbox/vector-tile-spec/tree/master/2.1#41-layers - // +-------------------+ Symbols with anchors located on tile edges - // |(0,0) || are duplicated on neighbor tiles. - // | || - // | || In continuous mode, to avoid overdraw we - // | || skip symbols located on the extent edges. - // | Tile || In still mode, we include the features in - // | || the buffers for both tiles and clip them - // | || at draw time. - // | || - // +-------------------| In this scenario, the inner bounding box - // +-------------------+ is called 'withinPlus0', and the outer - // (extent,extent) is called 'inside'. - const bool withinPlus0 = anchor.point.x >= 0 && anchor.point.x < util::EXTENT && anchor.point.y >= 0 && anchor.point.y < util::EXTENT; - const bool inside = withinPlus0 || anchor.point.x == util::EXTENT || anchor.point.y == util::EXTENT; - - if (avoidEdges && !inside) return; - - if (mode == MapMode::Tile || withinPlus0) { + const bool anchorInsideTile = anchor.point.x >= 0 && anchor.point.x < util::EXTENT && anchor.point.y >= 0 && anchor.point.y < util::EXTENT; + + if (mode == MapMode::Tile || anchorInsideTile) { + // For static/continuous rendering, only add symbols anchored within this tile: + // neighboring symbols will be added as part of the neighboring tiles. + // In tiled rendering mode, add all symbols in the buffers so that we can: + // (1) render symbols that overlap into this tile + // (2) approximate collision detection effects from neighboring symbols symbolInstances.emplace_back(anchor, line, shapedTextOrientations, shapedIcon, layout.evaluate(zoom, feature), layoutTextSize, textBoxScale, textPadding, textPlacement, textOffset, |