You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prioritize labels of larger countries over smaller ones #985
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.)
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.
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.
"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:
This is the same view in production with both centroids and place points displayed:
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 deletingplace=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.
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.
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.
Activity
CharliePlett commentedon Mar 19, 2025
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.
1ec5 commentedon Mar 19, 2025
symbol-sort-keywill 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.
Testing symbol sort key
tsinn commentedon Mar 21, 2025
"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_km2field 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:

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

1ec5 commentedon Mar 21, 2025
Thanks, in general, combining tile layers and style layers is a good step that we should take for performance reasons. But deleting
place=countrypoints might be necessary too, since standaloneplace=*points don’t havearea_km2properties. I’ve already started deletingplace=countypoints 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, settingsymbol-sort-keyis a low-risk change that we can deploy without reducing the overall number of labels.CharliePlett commentedon Mar 28, 2025
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.
1ec5 commentedon Mar 28, 2025
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.