Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Placement order matches viewport-y sort #14486

Merged
merged 1 commit into from
May 8, 2019

Conversation

pozdnyakov
Copy link
Contributor

Symbols are placed accordingly to their viewport Y order,
if the style symbol-z-order is set to viewport-y.

This improves rendering of symbol layers, where icons are allowed
to overlap but not text.

placements.emplace(symbolInstance.crossTileID, JointPlacement(false, false, false));
continue;
}
const bool zOrderByViewportY = bucket.layout.get<style::SymbolZOrder>() == style::SymbolZOrderType::ViewportY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!= style::SymbolZOrderType::Source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will affect the default behavior for styles that did not specify symbol-z-order 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to avoid sorting for all layers by default since this will introduce more label flickering. I think your implemented approach is good.

One alternative would be the same logic used to decide whether to sort the symbols when rendering: https://github.com/mapbox/mapbox-gl-js/blob/29a27eba5ff79720fa184ec4dc8b9dd942f759f9/src/data/bucket/symbol_bucket.js#L318-L319 - the symbols are only sorting if they are allowed to overlap. This same kind of logic could be used here but I'm not sure if that is necessary or better.

I think I like your approach better because it is simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO checking just SymbolZOrder is fine for placement: it just tells which labels to be placed first, so it is functional even if both icon and text overlapping not allowed (unlike the situation in bucket).

Symbols are placed accordingly to their viewport Y order,
if the style `symbol-z-order` is set to `viewport-y`.

This improves rendering of symbol layers, where icons are allowed
to overlap but not text.
@pozdnyakov pozdnyakov added ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold and removed ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Apr 24, 2019
Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I left one comment about an alternative option for deciding when to sort. But I think your approach is good too.

@pozdnyakov pozdnyakov merged commit ef48d53 into master May 8, 2019
@pozdnyakov pozdnyakov deleted the mikhail_sorted_y_placement branch May 8, 2019 09:21
LukasPaczos added a commit that referenced this pull request May 9, 2019
LukasPaczos added a commit that referenced this pull request May 9, 2019
@chloekraw chloekraw added the Core The cross-platform C++ core, aka mbgl label Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants