From 3443c1c65e9f1753e1e656b35d08416c1fa298f2 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 00:14:38 +0200 Subject: worldmap-viewer: initial public history --- tests/test_viewer_fixtures.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_viewer_fixtures.py (limited to 'tests/test_viewer_fixtures.py') diff --git a/tests/test_viewer_fixtures.py b/tests/test_viewer_fixtures.py new file mode 100644 index 0000000..5c0b88b --- /dev/null +++ b/tests/test_viewer_fixtures.py @@ -0,0 +1,23 @@ +import json +import unittest +from pathlib import Path + +import numpy as np + +from mapgen import projections as PJ + +FIX = Path(__file__).resolve().parents[1] / "viewer" / "tests" / "fixtures" / "projections.json" +POINTS = [(0.0, 0.0), (30.0, 120.0), (-60.0, -170.0), (89.0, 45.0), (10.0, -179.0), (-45.5, 33.3)] + + +class ViewerFixtureTest(unittest.TestCase): + def test_write_projection_fixture(self): + lat = np.array([p[0] for p in POINTS]) + lon = np.array([p[1] for p in POINTS]) + x, y = PJ.equal_earth_forward(lat, lon) + data = {"ee_xmax": float(PJ.EE_XMAX), "ee_ymax": float(PJ.EE_YMAX), + "equal_earth": [{"lat": float(a), "lon": float(b), "x": float(c), "y": float(d)} + for a, b, c, d in zip(lat, lon, x, y)]} + FIX.parent.mkdir(parents=True, exist_ok=True) + FIX.write_text(json.dumps(data, indent=1)) + self.assertEqual(len(json.loads(FIX.read_text())["equal_earth"]), len(POINTS)) -- cgit