No Florida State Label in OSM Data
I have imported the planet.osm and using osm-bright with imposm as my base style. However, I have just now noticed there is no label for the state of Florida. Does anyone know why or what would be the best solution for dealing with this?
I noticed that it's not even on their map: http://www.openstreetmap.org/
It is on all of the mapbox sample maps, however. For example the map on this page looks great: http://mapbox.com/tour/design/
Is this map using separate shapefiles for the labels?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by AJ on 20 Sep, 2012 06:06 PM
Hi Jane,
Labeling things properly from OSM data can be rather complex as the label information can be stored in different ways. Some states, cities, etc have the label information stored in the shape of the boundaries - this is the case with Florida. Some parts of the OSM community are moving toward this method of labeling things for various reasons, for one thing because it is useful to know the size of an object you are labeling. Unfortunately this means there is some inconsistency to deal with on the rendering side (and as you noted even OSM.org hasn't caught up to this mapping strategy yet).
One option is to use a 3rd party data source for state labels. You could use Natural Earth (from the MapBox geodata library) for this. This is how we currently do it on MapBox Streets. Another option is to get your label information from both points and polygons -- you could post-process your administrative boundaries table to add points to your labels table with ST_PointOnSurface (though there will likely be some de-duplication to do).
3 Posted by Jane Delarson on 21 Sep, 2012 02:55 PM
Thanks for the quick reply. That makes sense. Is the style for the MapBox streets publicly available via Carto?
4 Posted by Jane Delarson on 21 Sep, 2012 11:46 PM
I guess what I'm interested in specifically is how the markers (the dots) next to the states were accomplished. It seems to be auto aligning the label to either the left or the right which is much more elegant than just statically doing text-dy/dx.
Support Staff 5 Posted by AJ on 24 Sep, 2012 04:36 PM
Hi Jane,
The dots and the left/right aligned labels are created using the CartoCSS properties
text-placement-typeandtext-placements. The text style for the city labels looks like this:This means the renderer will try to position a label East of the point first, and if there is no room at that position try Northeast, then Southeast, and so on until it finds a position that fits or decides there is no room for the label anywhere.
With this style alone you'd get a majority of labels with East-positioned labels. In order to get a more even distribution, we create an alternative style that prefers West-positioning (
text-placements: "W,NW,SW,E,NE,SE";). We choose which side each label gets by calculating the direction of the nearest city (via a PostGIS function that looks like this). A more simple approach that would still improve the distribution would be to just randomly assign an East or West preference for each label, just as by generating a random number, or looking at whether its ID is odd or even.6 Posted by Jane Delarson on 24 Sep, 2012 05:41 PM
That worked beautifully. Thanks a lot!
AJ closed this discussion on 24 Sep, 2012 07:34 PM.