Create test for wrdem.py.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 26 Jan 2021 21:59:07 +0000 (22:59 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 26 Jan 2021 21:59:07 +0000 (22:59 +0100)
tests/test_wrdem.py [new file with mode: 0644]

diff --git a/tests/test_wrdem.py b/tests/test_wrdem.py
new file mode 100644 (file)
index 0000000..8fbd120
--- /dev/null
@@ -0,0 +1,23 @@
+import unittest
+
+from wrpylib.wrdem import get_ele_from_raster
+from wrpylib.wrvalidators import LonLat
+
+
+class TestWrDem(unittest.TestCase):
+    def setUp(self):
+        self.filename = '/home/philipp/daten/GeoData/dem/oesterreich_10m/dhm_lamb_10m.tif'
+        # https://www.data.gv.at/katalog/dataset/dgm
+
+    def test_get_ele_from_raster_inside_valid(self):
+        value = get_ele_from_raster(self.filename, LonLat(13.682109, 47.934012))
+        ele = round(int(value))
+        self.assertEqual(ele, 557)
+
+    def test_get_ele_from_raster_inside_invalid(self):
+        value = get_ele_from_raster(self.filename, LonLat(14.67656, 48.16182))
+        self.assertIsNone(value)
+
+    def test_get_ele_from_raster_outside(self):
+        value = get_ele_from_raster(self.filename, LonLat(8.67656, 47.16182))
+        self.assertIsNone(value)