mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-23 14:06:23 +02:00
Add flinger test.
This commit is contained in:
parent
a899706923
commit
867001d797
4 changed files with 49 additions and 5 deletions
|
@ -1,12 +1,15 @@
|
||||||
|
"""
|
||||||
|
Test color functions.
|
||||||
|
"""
|
||||||
from colour import Color
|
from colour import Color
|
||||||
|
|
||||||
from roentgen.color import is_bright
|
from roentgen.color import is_bright
|
||||||
|
|
||||||
__author__: str = "Sergey Vartanov"
|
__author__ = "Sergey Vartanov"
|
||||||
__email__: str = "me@enzet.ru"
|
__email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
def test_is_bright():
|
def test_is_bright() -> None:
|
||||||
"""
|
"""
|
||||||
Test detecting color brightness.
|
Test detecting color brightness.
|
||||||
"""
|
"""
|
||||||
|
|
32
test/test_flinger.py
Normal file
32
test/test_flinger.py
Normal 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
|
||||||
|
)
|
|
@ -4,6 +4,7 @@ Test icon generation for nodes.
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
|
from roentgen.icon import IconSet
|
||||||
from roentgen.grid import draw_all_icons
|
from roentgen.grid import draw_all_icons
|
||||||
from test import SCHEME, SCHEME_EXTRACTOR
|
from test import SCHEME, SCHEME_EXTRACTOR
|
||||||
|
|
||||||
|
@ -12,12 +13,17 @@ __email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
def test_icons() -> None:
|
def test_icons() -> None:
|
||||||
""" Test grid drawing. """
|
"""
|
||||||
|
Test grid drawing.
|
||||||
|
"""
|
||||||
makedirs("icon_set", exist_ok=True)
|
makedirs("icon_set", exist_ok=True)
|
||||||
draw_all_icons(SCHEME, SCHEME_EXTRACTOR, "temp.svg", "icon_set")
|
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)
|
icon, _ = SCHEME.get_icon(SCHEME_EXTRACTOR, tags)
|
||||||
return icon
|
return icon
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ Test OSM XML parsing.
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from roentgen.osm_reader import OSMNode, OSMReader, OSMRelation, OSMWay
|
from roentgen.osm_reader import OSMNode, OSMReader, OSMRelation, OSMWay
|
||||||
|
|
||||||
|
__author__ = "Sergey Vartanov"
|
||||||
|
__email__ = "me@enzet.ru"
|
||||||
|
|
||||||
|
|
||||||
def test_node() -> None:
|
def test_node() -> None:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue