[Tagging] Names localization

2010-04-25 Thread Alexander Sidorov
Hello!

Is there any way to implement the following localization strategy:
1. display russian (russian is just for example) name if it exists
2. display english name if russian name doesn't exists
3. display local name otherwise

The problem for me is to determine which language is used for some region by
default. I have found this
discussionbut
without solution.

Regards,
Alexander
___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-25 Thread John Smith
On 25 April 2010 19:25, Alexander Sidorov  wrote:
> The problem for me is to determine which language is used for some region by
> default. I have found this discussion but without solution.

The solution is a cleverly written SQL statement in the mapnik config
file, you need to add 2 extra columns to postgres table, name:ru and
name:en and then in the SQL query you check if name:ru exists and then
use it, otherwise check for name:en and use it otherwise use whatever
is in the name column.

However I haven't actually gotten round to trying to write a suitable
query to do that but I've thought about doing something similar.

___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-25 Thread Pieren
On Sun, Apr 25, 2010 at 11:25 AM, Alexander Sidorov wrote:

> Hello!
>
> Is there any way to implement the following localization strategy:
> 1. display russian (russian is just for example) name if it exists
> 2. display english name if russian name doesn't exists
> 3. display local name otherwise
>
> The problem for me is to determine which language is used for some region
> by default. I have found this 
> discussionbut
>  without solution.
>
> Regards,
> Alexander
>
>
The proposed feature is clearly not a solution since it is suggesting to add
the same tag "language=xxx" in ALL named elements within the region. I think
the right approach would be to set this default language in the polygon
identifying the region, most probably in the administrative boundary
relation. Then you could build up a query to apply this default value in
your local gis db. (or deprecate the tag name and force the locale suffix).

Pieren
___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-25 Thread Claudius Henrichs

Am 25.04.2010 11:25, Alexander Sidorov:

Hello!

Is there any way to implement the following localization strategy:
1. display russian (russian is just for example) name if it exists
2. display english name if russian name doesn't exists
3. display local name otherwise

The problem for me is to determine which language is used for some 
region by default. I have found this discussion 
 
but without solution.

There's currently no way to determine what language the "name"-tag is in.

Your question doesn't seem to be a tagging one though, because as I 
understand you want to have different rendered outputs, correct?
Like John Smith explained this has to be done with some clever JOIN SQL 
statements.


Some further readings here [1] and an example of a rendering of the 
world map in different languages here [2].


Claudius

[1] http://wiki.openstreetmap.org/wiki/Multilingual_names
[2] http://wiki.openstreetmap.org/wiki/Map_Internationalization
___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-26 Thread Emilie Laffray
On 25 April 2010 11:36, Claudius Henrichs  wrote:

>  Am 25.04.2010 11:25, Alexander Sidorov:
>
> Hello!
>
> Is there any way to implement the following localization strategy:
> 1. display russian (russian is just for example) name if it exists
> 2. display english name if russian name doesn't exists
> 3. display local name otherwise
>
> The problem for me is to determine which language is used for some region
> by default. I have found this 
> discussionbut
>  without solution.
>
> There's currently no way to determine what language the "name"-tag is in.
>
> Your question doesn't seem to be a tagging one though, because as I
> understand you want to have different rendered outputs, correct?
> Like John Smith explained this has to be done with some clever JOIN SQL
> statements.
>
> Some further readings here [1] and an example of a rendering of the world
> map in different languages here [2].
>
> Claudius
>


Part of the problem will be solved with the hstore patch I suspect. But
else, John is pretty much right, the SQL can be interesting to write. I
think a basic SQL statement would start like this. This is not real SQL code
since I don't have the name of the table in mind. Also I am keeping in mind
more of a simple osmosis schema for a just a russian extraction of name.
This is not meant to be used to extract all countries in the world. If I was
do that I would then use a slightly different approach:

SELECT ( CASE
 WHEN nt1.v IS NOT NULL THEN nt1.v
 WHEN nt2.v IS NOT NULL THEN nt2.v
 ELSE nt.v
   END
  ) AS russianName
FROM   node_tags AS nt
LEFT OUTER JOIN
node_tags AS nt1
   ON nt1.id = nt.id AND k = 'name:ru'
LEFT OUTER JOIN
node_tags AS nt2
   ON nt2.id = nt.id AND k = 'name:en'
WHERE nt.k = 'name'

Here we go, we have a simple query to do as you asked. However, do keep mind
that if the place is in Russia I wouldn't expect name:ru to actually exists
since name should be containing the local name anyway. Of course, they are
probably better way to do that. Among others things, creating a partial
index on k = 'name:ru' and k = 'name:en' would speed up the query quite
dramatically.
The other approach would be to retrieve all name elements with a condition
nt.k LIKE 'name%' and then perform a subquery on this afterwards. Similarly,
creating a view with that information would prove quite useful. It is just
down to imagination.

Emilie Laffray
___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-26 Thread John Smith
If you update default.style for osm2pgsql to include:

node,way   name text linear
node,way   name:en  text linear
node,way   name:ru  text linear

Then you need to do a complete re-import, then you need to update all
the queries in your mapnik style sheet where name is referenced from:

(select way,name from planet_osm_polygon where
boundary='national_park') as boundary

to:

(select way,(CASE WHEN 'name:ru' IS NOT NULL THEN 'name:ru' WHEN
'name:en' IS NOT NULL THEN 'name:en' ELSE name END) AS name from
planet_osm_polygon where boundary='national_park') as boundary

___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-26 Thread John Smith
Sorry I don't use pgsql much, I used ' instead of ", should be:

(CASE WHEN "name:ru" IS NOT NULL THEN "name:ru" WHEN "name:en" IS NOT
NULL THEN "name:en" ELSE name END) AS name

___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-26 Thread Emilie Laffray
On 26 April 2010 15:12, John Smith  wrote:

> Sorry I don't use pgsql much, I used ' instead of ", should be:
>
> (CASE WHEN "name:ru" IS NOT NULL THEN "name:ru" WHEN "name:en" IS NOT
> NULL THEN "name:en" ELSE name END) AS name
>
>
>
It is fine ;) Your query uses a simpler schema that the one I am using. The
case statement is an absolute classic for selecting things without doing an
proper code :)

Emilie Laffray
___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-26 Thread Pieren
On Mon, Apr 26, 2010 at 4:18 PM, Emilie Laffray wrote:

>
>
> On 26 April 2010 15:12, John Smith  wrote:
>
>> Sorry I don't use pgsql much, I used ' instead of ", should be:
>>
>> (CASE WHEN "name:ru" IS NOT NULL THEN "name:ru" WHEN "name:en" IS NOT
>> NULL THEN "name:en" ELSE name END) AS name
>>
>>
>>
> It is fine ;) Your query uses a simpler schema that the one I am using. The
> case statement is an absolute classic for selecting things without doing an
> proper code :)
>
> Emilie Laffray
>
>
This is not solving the original question : your query works outside Russia
and other coutries where russian is not the default language. This is the
discusion on the wiki page.

Pieren
___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging


Re: [Tagging] Names localization

2010-04-26 Thread John Smith
On 27 April 2010 02:20, Pieren  wrote:
> This is not solving the original question : your query works outside Russia
> and other coutries where russian is not the default language. This is the
> discusion on the wiki page.

If they are only interested in Russian names appearing in Russia, I
would have assumed that the name=* tag would be in Russian, perhaps
the original question to the list was worded in a way that confused
us.

___
Tagging mailing list
Tagging@openstreetmap.org
http://lists.openstreetmap.org/listinfo/tagging