Skip to content

Prioritize labels of larger countries over smaller ones #985

Description

@1ec5

As of #801, each feature in the land_ohm_centroids layer has an area_km2 property set to the original geometry’s area in square kilometers. By setting the associated symbol layers’ symbol-sort-key properties to the value of area_km2, we should be able to make symbol collision more intuitive. For example, at zoom level 2 (raster z3), we should probably prioritize the labels for United Kingdom, Germany, and Italy over those of Ireland, Vatican City, and Belgium, respectively, based on the sizes of these countries. (At higher zoom levels or in situations where there’s more room, we’d still show labels of smaller countries.)

A map of present-day Europe labeling Ireland but not the United Kingdom, Vatican City but not Italy, and Belgium but not Germany.

Activity

  1. added theissue type on Mar 17, 2025
  2. CharliePlett commented on Mar 19, 2025

    @CharliePlett

    The size of large Soviet administrative regions are hard to visualize on the map. Currently they're mapped as admin_level=4. Even on the globe projection when you zoom in far enough to see the label, the republic has almost covered the entire screen.

    Image

  3. 1ec5 commented on Mar 19, 2025

    @1ec5
    MemberAuthor

    symbol-sort-key will only kick in if there are two labels so close together on screen that the renderer has to choose one or the other.

    In a case where the labels are so sparse that they should come in at an earlier zoom level, we’d probably need to adjust the filter instead, and probably the font size or weight at the same time to avoid confusion. Let’s track that in a separate ticket.

  4. added a commit that references this issue on Mar 21, 2025
  5. tsinn commented on Mar 21, 2025

    @tsinn

    "symbol-sort-key": ["get", "area_km2"], seems to be working well.
    The bigger issue that needs to get tackled elsewhere, as mentioned in Slack, is the fact that we are currently using two separate layers for country labels. We are using both place points and country boundary centroids. The centroids are the layer that have the area_km2 field included, but they are quite sparse! The majority of country labels come from place points, which does not have an area field for determining label sorting.

    Here's a staging view of 2024 using only country boundary centroids as labels with symbol sorting set by area:
    Image

    This is the same view in production with both centroids and place points displayed:
    Image

  6. 1ec5 commented on Mar 21, 2025

    @1ec5
    MemberAuthor

    Thanks, in general, combining tile layers and style layers is a good step that we should take for performance reasons. But deleting place=country points might be necessary too, since standalone place=* points don’t have area_km2 properties. I’ve already started deleting place=county points in California. What’s stopping us from doing it more broadly is that the boundaries’ name=* tags need to stop including date range suffixes, but mappers are still adding those suffixes because OpenHistoricalMap/ohm-website#277 hasn’t landed yet. In the meantime, setting symbol-sort-key is a low-risk change that we can deploy without reducing the overall number of labels.

  7. CharliePlett commented on Mar 28, 2025

    @CharliePlett

    Image

    Image

    I don't know if this is the issue to post this in, but here you can see Mexico City is the capital and when I zoom out a bit the other cities drown out the capital. I think capital cities should maybe get precedence with label selection.

  8. 1ec5 commented on Mar 28, 2025

    @1ec5
    MemberAuthor

    Let’s move that to another issue. It could be a similar solution, but involving a different field than area_km2. There’s a whole long tail of things we can sort more intelligently – even in the tiles before they get to the stylesheet.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions