Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering tiles with English labels when they are available #3870

Closed
EricG-Personal opened this issue Sep 4, 2019 · 13 comments
Closed

Rendering tiles with English labels when they are available #3870

EricG-Personal opened this issue Sep 4, 2019 · 13 comments

Comments

@EricG-Personal
Copy link

I have a reddit thread related to this issue at https://www.reddit.com/r/openstreetmap/comments/cytbgh/rendering_tiles_with_english_labels_when_they_are/

I setup my own mapping tile server according to the instructions found at https://switch2osm.org/manually-buildin … 18-04-lts/ (amazing job for whoever wrote them) and am using the planet data (https://planet.openstreetmap.org). However, when I render a tile in, for example, China (http://localhost/hot/7/106/53.png / https://a.tile.openstreetmap.org/7/106/53.png)), the labels are in Chinese characters.

As I understand it, the project.mml file is what controls the the labels. According to the reddit thread, it should be possible to make some modifications to the .mml so it will always output the english labels.

It would be nice if this alternative might be made available...perhaps calling the file project_en.mml.

Since it does seem fairly straightforward (if one knows what they are doing...which I do not in this case), a folder filled with .mml variants for various languages would be nice or some kind of makefile which would generate a .mml for a specific language.

I might assume that someone has already created the english language only version of project.mml...if so, it would be nice if that was made available.

@kocio-pl
Copy link
Collaborator

kocio-pl commented Sep 4, 2019

There is a separate project that allows showing different sets of languages (not only English and the name "German" is only because it is used by German fork of OSM Carto):

https://github.com/giggls/mapnik-german-l10n

@jeisenbe
Copy link
Collaborator

jeisenbe commented Sep 5, 2019

It would be nice if this alternative might be made available...perhaps calling the file project_en.mml

Displaying text labels in the local language and script is intentional. Since this map style is intended to be used all around the world, it would not be appropriate to add a special English version of this file, unless we offered support for all common languages as well.

Since it looks like your question has been answered at giggls/mapnik-german-l10n#18, where there is already a style designed to display latin script and English name lables, I hope this issue is resolved satisfactorily?

@EricG-Personal
Copy link
Author

EricG-Personal commented Sep 5, 2019

Unfortunately, no.

It is proving difficult, at best, to get mapnik-german-i10n up and running.

While I do understand the decision to display text labels in the local language, I do think it would be worthwhile supporting displaying all labels in a single language...assuming the data for the language exists - and if it does not, perhaps keep things simple and default to local.

The data is there or can be added. I do not see a reason to make it difficult to use.

@pnorman
Copy link
Collaborator

pnorman commented Sep 5, 2019

It should be easier to substitute labels in a language of choice than it currently is. I've been trying to think of ways to do so, but nothing good is coming to mind.

@EricG-Personal
Copy link
Author

Well, the general approach that giggls/mapnik-german-l10n#18 is taking seems to be a good start. If I understand what is going on there, essentially they are essentially layering over the postgres tables so the renderer continues to work as normal without any changes. This would essentially mean a few of extra steps to set the language of the tile server. Integrating that project with yours in a "nice" way may be the way to go and means less work for everyone.

@systemed
Copy link
Contributor

I've seen this request a lot over the years. Given that people treat openstreetmap-carto as a general-purpose map style that they can install on their own servers, not simply as a reference style for osm.org, it seems reasonable to enable them to display the labels in the language they (/their users) can understand.

@pnorman: I initially thought that some sort of Makefile would be a good approach, but on reflection, I wonder if building it into carto is the way to go. Essentially:

  • replace "name" in the SELECT statements with some sort of macro (say, #{name})
  • define the default for this in the .mml as simply the string "name"
  • on running carto as usual, it substitutes the #{name} string with the default value ("name")
  • but you can optionally run carto with --macro name="COALESCE(tags->'name:en', name) AS name", which substitutes that string instead

Disadvantages are that it requires changing carto (cf mapbox/carto#495), and that anyone already running osm-carto would need to update their carto install for it not to b0rk on the macro string. But it seems a clean way to do it and may have other uses.

@imagico
Copy link
Collaborator

imagico commented Sep 10, 2019

Alternative would be to use a Postgresql function. This can also be done using views. See for example:

https://github.com/giggls/openstreetmap-carto-de/blob/master/views_osmde/view-line.sql

cc @giggls

@giggls
Copy link

giggls commented Sep 10, 2019

@systemed Doing a somewhat propper localization is way more complicated than doing COALESCE. In fact COALESCE was the poor mans l10n system I have been using in German style many years ago.

See the Videos of my talks about the system that I am currently using:
https://github.com/giggls/mapnik-german-l10n/wiki

I also maintain a simple fork of osm-carto using my l10n function at:
https://github.com/giggls/openstreetmap-carto-de/tree/upstream+l10n

@systemed
Copy link
Contributor

@giggls Indeed, yes (as you know I do something reasonably similar, but transliterating in Lua rather than Postgres).

@giggls
Copy link

giggls commented Sep 10, 2019

I will probably need to point out why a fork of the style is still needed when using views.
The reason is, that in some cases I render the local name first, while in other cases I do it just the other way round. Finally while I use "-" as a separator in streetnames I use "\n" in Point and Polygon labels.

@jeisenbe
Copy link
Collaborator

jeisenbe commented Jan 9, 2020

It doen't seem like there is a technically feasible solution that will work for rendering this style as well as allowing the choice of arbitrary language for name labels. Can we close this issue as not fixable without a separate fork of this repository?

@giggls
Copy link

giggls commented Jan 9, 2020

Well this is not quite true
If you want to have only localized names for labels rather than a combination of local name and the name in your target language (which I would recommend and thus my fork). You can just replace the generic database tables by a view which replaces the name column by a function or COALESCE result and you are done. No fork needed.

@pnorman
Copy link
Collaborator

pnorman commented Jun 27, 2022

It doen't seem like there is a technically feasible solution that will work for rendering this style as well as allowing the choice of arbitrary language for name labels. Can we close this issue as not fixable without a separate fork of this repository?

Yes. Any change to language requires a change to loading the data or the data SQL, and that change has to be per-language.

I'd like it to be easier, but within the current constraints of Mapnik PostGIS datasource queries I don't see a good way to do this.

@pnorman pnorman closed this as completed Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants