https://github.com/phyks/osml10n
Localization functions for Openstreetmap based maps
https://github.com/phyks/osml10n
Last synced: 2 months ago
JSON representation
Localization functions for Openstreetmap based maps
- Host: GitHub
- URL: https://github.com/phyks/osml10n
- Owner: Phyks
- License: lgpl-3.0
- Created: 2018-12-18T14:01:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-18T14:17:46.000Z (over 6 years ago)
- Last Synced: 2025-01-22T12:23:00.382Z (4 months ago)
- Language: Python
- Size: 33.6 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Openstreetmap map localisation (OSM l10n) functions
## (used in German mapnik style)This is a python reimplementation of the localisation functions used in
german mapnik style. They are well suited for any target language using the
latin alphabet but meight be also usable for others.This code has originally been developed as PL/pgSQL stored procedures but is
now also available as a python module.Fortunately the original API is still supported using PL/Python.
However as there is now a native python interface as well it is now possible to
integrate the localisation into the osm data processing e.g. using pyosmium
(https://github.com/osmcode/pyosmium).The Version Number starts with 3.0, thus Versions 1.x and 2.x will refer to
the PL/pgSQL versions.A new feature of this code complared to the older versions is the usage of
the PyThaiNLP (https://github.com/PyThaiNLP/pythainlp) library for
transcription of the thai language as ICU (http://site.icu-project.org/) did
not provide the expected results in this case.### API
Useful functions for map rendering are:
* get_placename
* get_streetname
* get_latinname
* get_country_nameA more low-level function is the get_relevant_tags function which will
return an array of two strings containing a localized and an on-site name.However, I would not recommend to use it, as there is some heuristic
in the name combination code called from the other functions which will try
to do its best to make a nice non-redundant label for your map.For backward compatibility the corresponding PostgreSQl functions are:
* osml10n_get_placename_from_tags
* osml10n_get_streetname_from_tags
* osml10n_get_name_without_brackets_from_tags
* osml10n_get_country_name**Python examples:**
```
get_streetname({'name': 'улица Воздвиженка'},True,False,' - ','de')
--> ул. Воздвиженка - ul. Vozdviženkaosml10n.get_placename({'name': 'القاهرة', 'name:de': 'Kairo', 'int_name': 'Cairo', 'name:en': 'Cairo'},False,False,'\n','de')
--> Kairo
القاهرةosml10n.get_latinname(get_latinname({'name': 'القاهرة', 'name:de': 'Kairo', 'int_name': 'Cairo', 'name:en': 'Cairo'},'en'))
--> Cairoget_country_name({'ISO3166-1:alpha2': 'IN','name:de': 'Indien','name:hi': 'भारत','name:en': 'India'})
--> Indien
भारत
India
```Have a look at [test-l10n.py](test-l10n.py) for more examples.
**PostgreSQL examples:**
```SQL
select osml10n_get_streetname_from_tags('"name"=>"улица Воздвиженка"',true,false,' - ','de') as name;
--> ул. Воздвиженка - ul. Vozdviženkaselect osml10n_get_placename_from_tags('"name"=>"القاهرة","name:de"=>"Kairo","int_name"=>"Cairo","name:en"=>"Cairo"',false) as name;
--> Kairo
القاهرةselect osml10n_get_name_without_brackets_from_tags('"name"=>"القاهرة","name:de"=>"Kairo","int_name"=>"Cairo","name:en"=>"Cairo"','en') as name;
--> Cairoselect osml10n_get_country_name('"ISO3166-1:alpha2"=>"IN","name:de"=>"Indien","name:hi"=>"भारत","name:en"=>"India"') as name;
--> Indien
भारत
India
```