I have a working local OSM tile renderer (courtesy the kind people at switch2osm for the instructions). I'd like it to render labels in English where available, falling back to the local name if there is no English. I don't want to show both, or a translation / transliteration.
I'm using the openstreetmap-carto style from git://github.com/gravitystorm/openstreetmap-carto.git
After making sure the rendering works, I've modified the style (based on some guidance on the OSM discussion forums), with this change:
diff --git a/project.mml b/project.mml
index 7fb3d472..2d5099a7 100644
--- a/project.mml
+++ b/project.mml
@@ -90,7 +90,7 @@ Layer:
way, name, religion, way_pixels, is_building,
COALESCE(aeroway, golf, amenity, wetland, power, landuse, leisure, man_made, "natural", shop, tourism, highway, railway) AS feature
FROM (SELECT
- way, COALESCE(name, '') AS name,
+ way, COALESCE(tags->'name:en', name) AS name,
('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway END)) AS aeroway,
('golf_' || (CASE WHEN (tags->'golf') IN ('rough', 'fairway', 'driving_range', 'water_hazard', 'green', 'bunker', 'tee') THEN tags->'golf' ELSE NULL END)) AS golf,
('amenity_' || (CASE WHEN amenity IN ('bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'taxi',
I've regenerated mapnik.xml, and checked it has a corresponding change. I've checked I have the hstore tags entries in my database.
However even after forcing regeneration of tiles and clearing browser cache, I still see the name
value rather than the name:en
value. For example, I see "Soomaaliya الصومال" rather than "Somalia".
Can anyone suggest the required changes to render the English name for this style?
Failing that, changes for a similar style would be almost as useful.
Best Answer
You would have to use the COALESCE function every time a name is requested in the sql of the project.mml.
E.g. for country_names (see https://github.com/gravitystorm/openstreetmap-carto/blob/master/project.mml#L1195-L1216 ):
There are quite a few occurrences where a name is selected, you would have to change all those where you want the English label used (if available).