mirror of
https://github.com/enzet/map-machine.git
synced 2025-04-29 18:27:19 +02:00
Issues #126: add test.
This commit is contained in:
parent
5a934e2f37
commit
5fc9ab0b5e
1 changed files with 46 additions and 0 deletions
46
tests/test_ways.py
Normal file
46
tests/test_ways.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from map_machine.figure import Figure
|
||||||
|
from map_machine.geometry.boundary_box import BoundaryBox
|
||||||
|
from map_machine.geometry.flinger import Flinger
|
||||||
|
from map_machine.map_configuration import MapConfiguration
|
||||||
|
from map_machine.constructor import Constructor
|
||||||
|
from map_machine.osm.osm_reader import OSMData, OSMWay, OSMNode
|
||||||
|
from tests import SCHEME, SHAPE_EXTRACTOR
|
||||||
|
|
||||||
|
|
||||||
|
def get_constructor(osm_data: OSMData) -> Constructor:
|
||||||
|
flinger: Flinger = Flinger(
|
||||||
|
BoundaryBox(-0.01, -0.01, 0.01, 0.01), 18, osm_data.equator_length
|
||||||
|
)
|
||||||
|
constructor: Constructor = Constructor(
|
||||||
|
osm_data, flinger, SCHEME, SHAPE_EXTRACTOR, MapConfiguration()
|
||||||
|
)
|
||||||
|
constructor.construct_ways()
|
||||||
|
return constructor
|
||||||
|
|
||||||
|
|
||||||
|
def test_river_and_wood() -> None:
|
||||||
|
"""
|
||||||
|
Check that river is above the wood.
|
||||||
|
|
||||||
|
See https://github.com/enzet/map-machine/issues/126
|
||||||
|
"""
|
||||||
|
nodes_1: list[OSMNode] = [
|
||||||
|
OSMNode({}, 1, np.array((-0.01, -0.01))),
|
||||||
|
OSMNode({}, 2, np.array((0.01, 0.01))),
|
||||||
|
]
|
||||||
|
nodes_2: list[OSMNode] = [
|
||||||
|
OSMNode({}, 3, np.array((-0.01, -0.01))),
|
||||||
|
OSMNode({}, 4, np.array((0.01, 0.01))),
|
||||||
|
]
|
||||||
|
|
||||||
|
osm_data: OSMData = OSMData()
|
||||||
|
osm_data.add_way(OSMWay({"natural": "wood"}, 1, nodes_1))
|
||||||
|
osm_data.add_way(OSMWay({"waterway": "river"}, 2, nodes_2))
|
||||||
|
|
||||||
|
figures: list[Figure] = get_constructor(osm_data).get_sorted_figures()
|
||||||
|
|
||||||
|
assert len(figures) == 2
|
||||||
|
assert figures[0].tags["natural"] == "wood"
|
||||||
|
assert figures[1].tags["waterway"] == "river"
|
Loading…
Add table
Reference in a new issue