mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-07 14:16:39 +02:00
Add address module.
This commit is contained in:
parent
6d938a1248
commit
9b10f29d39
1 changed files with 33 additions and 0 deletions
33
roentgen/address.py
Normal file
33
roentgen/address.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""
|
||||
OSM address tag processing.
|
||||
|
||||
Author: Sergey Vartanov (me@enzet.ru).
|
||||
"""
|
||||
from typing import List, Any, Dict
|
||||
|
||||
|
||||
def get_address(tags: Dict[str, Any], draw_captions_mode: str):
|
||||
|
||||
address: List[str] = []
|
||||
|
||||
if draw_captions_mode != "main":
|
||||
if "addr:postcode" in tags:
|
||||
address.append(tags["addr:postcode"])
|
||||
tags.pop("addr:postcode", None)
|
||||
if "addr:country" in tags:
|
||||
address.append(tags["addr:country"])
|
||||
tags.pop("addr:country", None)
|
||||
if "addr:city" in tags:
|
||||
address.append(tags["addr:city"])
|
||||
tags.pop("addr:city", None)
|
||||
if "addr:street" in tags:
|
||||
street = tags["addr:street"]
|
||||
if street.startswith("улица "):
|
||||
street = "ул. " + street[len("улица "):]
|
||||
address.append(street)
|
||||
tags.pop("addr:street", None)
|
||||
|
||||
if "addr:housenumber" in tags:
|
||||
address.append(tags["addr:housenumber"])
|
||||
tags.pop("addr:housenumber", None)
|
||||
|
Loading…
Add table
Reference in a new issue