mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add ability to convert landmap to/from miz.
This PR adds utility functions that import/export landmap files to .miz polygons. In addition to the unit test, this PR has been tested by writing the Caucuses & Syria landmaps to a .miz file, loading the generated .miz file back in and checking that the loaded landmap object is identical to the original files.
This commit is contained in:
32
tests/theater/test_landmap.py
Normal file
32
tests/theater/test_landmap.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from shapely.geometry import MultiPolygon, Polygon
|
||||
|
||||
from dcs.terrain.caucasus.caucasus import Caucasus
|
||||
from game.theater import landmap
|
||||
|
||||
|
||||
def test_miz() -> None:
|
||||
"""
|
||||
Test miz generation and loading
|
||||
"""
|
||||
test_map = landmap.Landmap(
|
||||
inclusion_zones=MultiPolygon([Polygon([(0, 0), (0, 1), (1, 0)])]),
|
||||
exclusion_zones=MultiPolygon([Polygon([(1, 1), (0, 1), (1, 0)])]),
|
||||
sea_zones=MultiPolygon([Polygon([(0, 0), (0, 2), (1, 0)])]),
|
||||
)
|
||||
test_filename = "test.miz"
|
||||
landmap.to_miz(test_map, Caucasus(), test_filename)
|
||||
assert os.path.isfile("test.miz")
|
||||
loaded_map = landmap.from_miz("test.miz")
|
||||
assert test_map.inclusion_zones.equals_exact(
|
||||
loaded_map.inclusion_zones, tolerance=1e-6
|
||||
)
|
||||
assert test_map.sea_zones.equals_exact(loaded_map.sea_zones, tolerance=1e-6)
|
||||
assert test_map.exclusion_zones.equals_exact(
|
||||
loaded_map.exclusion_zones, tolerance=1e-6
|
||||
)
|
||||
|
||||
if os.path.isfile(test_filename):
|
||||
os.remove(test_filename)
|
||||
Reference in New Issue
Block a user