osm-americana / openstreetmap-americana

A quintessentially American map style
https://americanamap.org
Creative Commons Zero v1.0 Universal
183 stars 59 forks source link

State label is completely inside a different state #533

Open michaelblyons opened 2 years ago

michaelblyons commented 2 years ago

To be fair, Maryland is really skinny.

Screenshot_20220803-201841

1ec5 commented 2 years ago

At first I thought this was the same thing as #87, but actually the point feature lies within the state. You can even see the label slide back south of the state line in an animated transition when zooming in from z6 to z7.

Americana TileServer GL

The issue seems to be that the state label’s text-radial-offset is too large, or that text-variable-anchor is even allowing a top anchor in the first place. Since we aren’t showing the • dot icon at the anchor point, text-variable-anchor should probably just be center and nothing else.

1ec5 commented 2 years ago

text-variable-anchor might be in there to give the renderer some flexibility in where to place the label. That’s tricky because it doesn’t have any context about the nearby state line. If there’s no text-variable-anchor, then the Baltimore label collides out the Maryland label, preventing it from showing at any zoom level. It should be the Baltimore logo that gets collided out by the Maryland label.

It’d be quite tempting to move the state label layer to between the city and country label layers. But that prevents the Washington, D.C., and New York City labels from appearing at z4, where other cities are starting to show up.

https://github.com/ZeLonewolf/openstreetmap-americana/blob/098324276bb96d300d90b84d5be0a3a8089e402b/src/americana.js#L248-L252

Before After

It might be nice to place most city labels beneath state labels but a smaller number of major city labels (capital cities?) above state labels. symbol-sort-key would only be able to have that kind of effect if we were to consolidate the place label layers into a single layer.

michaelblyons commented 2 years ago

Good investigation.

a smaller number of major city labels (capital cities?) above state labels.

I think we'd never see the state labels if their capitals take precedence. Washington D.C. makes sense to prioritize, but Annapolis, Dover, Hartford, and Providence might not only interrupt their own state's label but also neighboring states'.

zekefarwell commented 2 years ago

I remember working on the state label placement last year and having a lot of trouble getting it to look reasonable because the MapTiler tiles we were using at the time had the label nodes placed very far off center much of the time (as documented in #87). So I fiddled around a bunch with the text-radial-offset and text-variable-anchor values to try and get labels to show up in more reasonable spots in most cases (and to avoid conflicts with city labels). However, now that we've switched to vanilla OpenMapTiles the label node placement seems much better and the offset/anchor properties should definitely be changed because the current values were put in place to deal with shortcomings of that other tileset.

1ec5 commented 2 years ago

407 would avoid some of the conflicts between state and capital city labels by allowing us to shorten the state labels considerably.

Thinking a bit blue-sky, it would be awesome if the lakelines in the vector tiles could be generalized for administrative boundaries. Maryland’s label could be based on a line feature arcing around D.C., and we’d show it instead of the abbreviation because the line is long enough. However, that would be more beneficial to states like California that have ample room than for space-constrained states in the northeast.

Another possibility would be for us to manually place the low-zoom northeastern state labels somewhere else, potentially off the Atlantic coast, with leader lines pointing to the state. This could be implemented as a GeoJSON source but definitely couldn’t be powered automatically by OSM data, so I’m not sure if folks would find it desirable for this project.