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

Clip parent-tile symbols in mixed-zoom tiles #10480

Closed

Description

@ChrisLoer

Consider a tile at zoom z, partially covered by a child tile at zoom z + 1:

+-----------------+
|                 |
|                 |
|                 |
|--------+        |
|    * OAK        |
| * SF   |        |
|        |        |
+--------+--------+

In our current logic, symbols are rendered without clipping for both tiles. We rely on the CrossTileSymbolIndex to prevent duplicates from being double-drawn (in fact, we draw duplicates, but we make the duplicate copies invisible). We rely on the global CollisionIndex to prevent collisions between the child and parent tile.

However, symbols from the parent tile that are in the quadrant covered by the child tile can still "show through", as long as they don't collide with anything in the same layer. Once the parent tile is removed, they'll disappear, and maybe be replaced by something in a later layer from the child tile. This means that the quadrant covered by the child ends up showing three sets of symbols over the course of loading: parent -> mixed -> child. That "mixed" phase isn't really wrong, but it's unnecessary and can lead to extra label cross-fading (aka collision/label instability).

We could fix this if at placement time we were aware of which quadrants of a tile were covered by children, and just avoided placing symbols in those areas.

/cc @ansis @jfirebaugh @kkaefer

Activity

  1. kkaefer commented on Nov 17, 2017

    @kkaefer
    Member

    I think this is a great idea. We already have logic to calculate the covered children masks that we use for raster tiles:

    // Updates the TileMasks for all renderables. Renderables are objects that have an UnwrappedTileID
    // property indicating where they should be rendered on the screen. A TileMask describes all regions
    // within that tile that are *not* covered by other Renderables.
    // Example: Renderables in our list are 2/1/3, 3/3/6, and 4/5/13. The schematic for creating the
    // TileMask for 2/1/3 looks like this:
    //
    // ┌────────┬────────┬─────────────────┐
    // │ │ │#################│
    // │ 4/4/12 │ 4/5/12 │#################│
    // │ │ │#################│
    // ├──────3/2/6──────┤#####3/3/6#######│
    // │ │########│#################│
    // │ 4/4/13 │#4/5/13#│#################│
    // │ │########│#################│
    // ├────────┴──────2/1/3───────────────┤
    // │ │ │
    // │ │ │
    // │ │ │
    // │ 3/2/7 │ 3/3/7 │
    // │ │ │
    // │ │ │
    // │ │ │
    // └─────────────────┴─────────────────┘
    //
    // The TileMask for 2/1/3 thus consists of the tiles 4/4/12, 4/5/12, 4/4/13, 3/2/7, and 3/3/7,
    // but it does *not* include 4/5/13, and 3/3/6, since these are other Renderables.
    // A TileMask always contains TileIDs *relative* to the tile it is generated for, so 2/1/3 is
    // "subtracted" from these TileIDs. The final TileMask for 2/1/3 will thus be:
    //
    // ┌────────┬────────┬─────────────────┐
    // │ │ │#################│
    // │ 2/0/0 │ 2/1/0 │#################│
    // │ │ │#################│
    // ├────────┼────────┤#################│
    // │ │########│#################│
    // │ 2/0/1 │########│#################│
    // │ │########│#################│
    // ├────────┴────────┼─────────────────┤
    // │ │ │
    // │ │ │
    // │ │ │
    // │ 1/0/1 │ 1/1/1 │
    // │ │ │
    // │ │ │
    // │ │ │
    // └─────────────────┴─────────────────┘
    //
    // Only other Renderables that are *children* of the Renderable we are generating the mask for will
    // be considered. For example, adding a Renderable with TileID 4/8/13 won't affect the TileMask for
    // 2/1/3, since it is not a descendant of it.
    template <typename Renderable>
    void updateTileMasks(std::vector<std::reference_wrapper<Renderable>> renderables) {
    std::sort(renderables.begin(), renderables.end(),
    [](const Renderable& a, const Renderable& b) { return a.id < b.id; });
    TileMask mask;
    const auto end = renderables.end();
    for (auto it = renderables.begin(); it != end; it++) {
    auto& renderable = it->get();
    if (!renderable.used) {
    continue;
    }
    // Try to add all remaining ids as children. We sorted the tile list
    // by z earlier, so all preceding items cannot be children of the current
    // tile. We also compute the lower bound of the next wrap, because items of the next wrap
    // can never be children of the current wrap.
    auto child_it = std::next(it);
    const auto children_end = std::lower_bound(
    child_it, end,
    UnwrappedTileID{ static_cast<int16_t>(renderable.id.wrap + 1), { 0, 0, 0 } },
    [](auto& a, auto& b) { return a.get().id < b; });
    mask.clear();
    computeTileMasks<Renderable>(renderable.id.canonical, renderable.id, child_it, children_end,
    mask);
    renderable.setMask(std::move(mask));
    }
    }

  2. added
    Core
    on Nov 24, 2017
  3. added
    archived
    on Nov 3, 2018
  4. stale commented on Dec 4, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  5. reopened this on Jan 2, 2019
  6. removed
    archived
    on Jan 2, 2019
  7. added
    archived
    on Jul 1, 2019
  8. stale commented on Jul 2, 2019

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  9. reopened this on Aug 5, 2019
  10. removed
    archived
    on Aug 5, 2019
  11. added
    archived
    on Feb 1, 2020
  12. stale commented on Feb 1, 2020

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Corearchived

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions