Add flinger test.

This commit is contained in:
Sergey Vartanov 2021-05-29 15:36:03 +03:00
parent a899706923
commit 867001d797
4 changed files with 49 additions and 5 deletions

View file

@ -1,12 +1,15 @@
"""
Test color functions.
"""
from colour import Color
from roentgen.color import is_bright
__author__: str = "Sergey Vartanov"
__email__: str = "me@enzet.ru"
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
def test_is_bright():
def test_is_bright() -> None:
"""
Test detecting color brightness.
"""

32
test/test_flinger.py Normal file
View file

@ -0,0 +1,32 @@
"""
Test coordinates computation.
"""
import numpy as np
from roentgen.flinger import (
pseudo_mercator,
osm_zoom_level_to_pixels_per_meter,
)
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
def test_pseudo_mercator() -> None:
"""
Test pseudo-Mercator projection.
"""
assert np.allclose(pseudo_mercator(np.array((0, 0))), np.array((0, 0)))
assert np.allclose(pseudo_mercator(np.array((0, 10))), np.array((10, 0)))
assert np.allclose(
pseudo_mercator(np.array((10, 0))), np.array((0, 10.05115966))
)
def test_osm_zoom_level_to_pixels_per_meter() -> None:
"""
Test scale computation.
"""
assert np.allclose(
osm_zoom_level_to_pixels_per_meter(18), 1.6759517949045808
)

View file

@ -4,6 +4,7 @@ Test icon generation for nodes.
from os import makedirs
from typing import Dict
from roentgen.icon import IconSet
from roentgen.grid import draw_all_icons
from test import SCHEME, SCHEME_EXTRACTOR
@ -12,12 +13,17 @@ __email__ = "me@enzet.ru"
def test_icons() -> None:
""" Test grid drawing. """
"""
Test grid drawing.
"""
makedirs("icon_set", exist_ok=True)
draw_all_icons(SCHEME, SCHEME_EXTRACTOR, "temp.svg", "icon_set")
def get_icon(tags: Dict[str, str]):
def get_icon(tags: Dict[str, str]) -> IconSet:
"""
Construct icon from tags.
"""
icon, _ = SCHEME.get_icon(SCHEME_EXTRACTOR, tags)
return icon

View file

@ -4,6 +4,9 @@ Test OSM XML parsing.
import numpy as np
from roentgen.osm_reader import OSMNode, OSMReader, OSMRelation, OSMWay
__author__ = "Sergey Vartanov"
__email__ = "me@enzet.ru"
def test_node() -> None:
"""