mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-01 19:27:06 +02:00
Add documentation.
This commit is contained in:
parent
0f3888430b
commit
e113ef09e4
2 changed files with 19 additions and 5 deletions
|
@ -95,4 +95,3 @@ def get_text(tags: Dict[str, Any]) -> List[str]:
|
|||
format_frequency, tags["frequency"].split(";"))))
|
||||
|
||||
return texts
|
||||
|
||||
|
|
|
@ -1,28 +1,43 @@
|
|||
"""
|
||||
Author: Sergey Vartanov (me@enzet.ru).
|
||||
"""
|
||||
from typing import List
|
||||
|
||||
from roentgen.scheme import Scheme
|
||||
from roentgen.text import Label
|
||||
|
||||
|
||||
def get_text(tags):
|
||||
def construct_labels(tags) -> List[Label]:
|
||||
"""
|
||||
Construct labels from OSM node tags.
|
||||
"""
|
||||
scheme = Scheme("scheme/default.yml")
|
||||
return scheme.construct_text(tags, True)
|
||||
|
||||
|
||||
def test_1_label() -> None:
|
||||
labels = get_text({"name": "Name"})
|
||||
"""
|
||||
Test tags that should be converted into single label.
|
||||
"""
|
||||
labels = construct_labels({"name": "Name"})
|
||||
assert len(labels) == 1
|
||||
assert labels[0].text == "Name"
|
||||
|
||||
|
||||
def test_1_label_unknown_tags() -> None:
|
||||
labels = get_text({"name": "Name", "aaa": "bbb"})
|
||||
"""
|
||||
Test tags with some unknown tags that should be converted into single label.
|
||||
"""
|
||||
labels = construct_labels({"name": "Name", "aaa": "bbb"})
|
||||
assert len(labels) == 1
|
||||
assert labels[0].text == "Name"
|
||||
|
||||
|
||||
def test_2_labels() -> None:
|
||||
labels = get_text({"name": "Name", "ref": "5"})
|
||||
"""
|
||||
Test tags that should be converted into two labels.
|
||||
"""
|
||||
labels = construct_labels({"name": "Name", "ref": "5"})
|
||||
assert len(labels) == 2
|
||||
assert labels[0].text == "Name"
|
||||
assert labels[1].text == "5"
|
||||
|
|
Loading…
Add table
Reference in a new issue