diff options
| author | godosa <godosa@godosa.eu> | 2026-10-07 00:14:38 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-07 00:14:38 +0200 |
| commit | 3443c1c65e9f1753e1e656b35d08416c1fa298f2 (patch) | |
| tree | 4e43236f460145a4d75d1b4616dcb7aa6ef08f51 /tests/test_viewer_fixtures.py | |
| download | worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.tar.gz worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.zip | |
worldmap-viewer: initial public history
Diffstat (limited to 'tests/test_viewer_fixtures.py')
| -rw-r--r-- | tests/test_viewer_fixtures.py | 23 |
1 files changed, 23 insertions, 0 deletions
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)) |
