OSM map l10n functions
PLpgSQL Shell C Makefile C++ Python
Clone or download
Sven Geggus
Sven Geggus * remove legacy (old style l10n) functions
* do some code refracturing:
  move street abbrev function into osml10n_gen_combined_name
Latest commit a01079c Apr 21, 2018
Permalink
Failed to load latest commit information.
debian * remove legacy (old style l10n) functions Apr 21, 2018
icutranslit Change TMPTARGET variable to DESTDIR (default in rpm) Mar 30, 2017
kanjitranscript Change TMPTARGET variable to DESTDIR (default in rpm) Mar 30, 2017
plpgsql * remove legacy (old style l10n) functions Apr 21, 2018
tests * remove legacy (old style l10n) functions Apr 21, 2018
thaitranscript Break thai transcription into its own package to make it optional for… Apr 13, 2018
.gitignore Break thai transcription into its own package to make it optional for… Apr 13, 2018
INSTALL.md * Add unit/regression test Apr 13, 2018
LICENSE.txt clarify license Jun 15, 2016
Makefile Break thai transcription into its own package to make it optional for… Apr 13, 2018
README.md * remove legacy (old style l10n) functions Apr 21, 2018
country_languages.data.in Rework osml10n_get_country_name function to do a lot of magic :) Dec 22, 2016
gen_country_languages_table.py * Add a osml10n_get_country_name function for generation of a Nov 13, 2016
gen_osml10n_extension.sh Break thai transcription into its own package to make it optional for… Apr 13, 2018
gen_osml10n_thai_extension.sh Break thai transcription into its own package to make it optional for… Apr 13, 2018
osml10n.control.in Break thai transcription into its own package to make it optional for… Apr 13, 2018
osml10n_thai_transcript.control.in Break thai transcription into its own package to make it optional for… Apr 13, 2018

README.md

OSM map l10n functions

(from german mapnik style)

All l10n functions from german mapnik style are implemented as PL/pgSQL stored procedures and are therefore usable in a renderer independent way.

For this reason they are now hosted in their own repository.

Currently the code consists of three parts:

  1. An "Any-Latin" transliterate function using libicu
  2. A japanese kanji transliterate function using libkakasi
  3. A couple of PL/pgSQL functions which can be used to generate labels for map rendering.

See INSTALL.md file from sources for manual installation instructions. If you just installed the debian package all you have to do now ist to enable our extension in your PostgreSQL database as follows:

CREATE EXTENSION osml10n;

API

The following functions are provided for use in map rendering:

osml10n_get_placename_from_tags(tags hstore, loc_in_brackets boolean, show_brackets boolean DEFAULT false, separator text DEFAULT chr(10), targetlang text DEFAULT 'de', place geometry DEFAULT NULL, name text DEFAULT NULL) : Will try its best to return a usable name pair with both a localiced name and an on site name

osml10n_get_streetname_from_tags(tags hstore, loc_in_brackets boolean, show_brackets boolean DEFAULT false, separator text DEFAULT ' - ', targetlang text DEFAULT 'de', place geometry DEFAULT NULL, name text DEFAULT NULL) : Same as get_localized_placename_from_tags, but with some common abbreviations for street names (Straße->Str.), if name ist longer than 15 characters

osml10n_get_name_without_brackets_from_tags(tags hstore, loc_in_brackets boolean, targetlang text DEFAULT 'de', place geometry DEFAULT NULL, name text DEFAULT NULL) : Produces localiced name only output (on site name will be discarded)

osml10n_get_country_name(tags hstore, separator text DEFAULT chr(10), targetlang text DEFAULT 'de') : Generate a combined country name from name:xx tags (targetlang plus official languages of the country)

A convinient way of using these functions is to hide them behind virtual colums using database views.

Examples

select osml10n_get_placename_from_tags('"name"=>"Москва́","name:de"=>"Moskau","name:en"=>"Moscow"',true) as name; --> Москва́ Moskau select osml10n_get_placename_from_tags('"name"=>"Москва́","name:de"=>"Moskau","name:en"=>"Moscow"',false) as name; --> Moskau Москва́ select osml10n_get_placename_from_tags('"name"=>"القاهرة","name:de"=>"Kairo","int_name"=>"Cairo","name:en"=>"Cairo"',false) as name; --> Kairo القاهرة select osml10n_get_placename_from_tags('name=>"Brixen Bressanone",name:de=>"Brixen",name:it=>"Bressanone"',false); --> Brixen Bressanone select osml10n_get_placename_from_tags('"name"=>"Roma","name:de"=>"Rom"',false) as name; --> Rom Roma select osml10n_get_streetname_from_tags('"name"=>"Doktor-No-Straße"',false) as name; --> Dr.-No-Str. select osml10n_get_streetname_from_tags('"name"=>"Dr. No Street","name:de"=>"Professor-Doktor-No-Straße"',false) as name; --> Prof.-Dr.-No-Str. - Dr. No St. select osml10n_get_name_without_brackets_from_tags('"name"=>"Dr. No Street","name:de"=>"Doktor-No-Straße"') as name; --> Doktor-No-Straße select osml10n_get_streetname_from_tags('"name"=>"улица Воздвиженка","name:en"=>"Vozdvizhenka Street"',true,true,' ','de') as name; --> ул. Воздвиженка (Vozdvizhenka St.) select osml10n_get_streetname_from_tags('"name"=>"улица Воздвиженка"',true,true,' ','de') as name; --> ул. Воздвиженка (ul. Vozdviženka) select osml10n_get_streetname_from_tags('"name"=>"вулиця Молока"',true,false,' - ','de') as name; --> вул. Молока - vul. Moloka select osml10n_get_placename_from_tags('"name"=>"주촌 Juchon", "name:ko"=>"주촌","name:ko_rm"=>"Juchon"',false) as name; --> 주촌 Juchon select osml10n_get_placename_from_tags('"name"=>"주촌", "name:ko"=>"주촌","name:ko_rm"=>"Juchon"',false) as name; --> Juchon J주촌 select osml10n_get_country_name('"ISO3166-1:alpha2"=>"IN","name:de"=>"Indien","name:hi"=>"भारत","name:en"=>"India"') as name; --> Indien भारत India