Add Bavaria.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Fri, 12 Feb 2021 12:39:55 +0000 (13:39 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Fri, 12 Feb 2021 12:39:55 +0000 (13:39 +0100)
tests/test_wrdem.py
wrpylib/wrdem.py

index ebdc8bcf9337f10edbc0d44770a14f748d19f5ce..8304ea235953976f064b8edcdd0e75bf38e40c82 100644 (file)
@@ -3,7 +3,8 @@ import unittest
 import owslib.wms
 import rasterio
 
 import owslib.wms
 import rasterio
 
-from wrpylib.wrdem import get_ele_from_raster, get_ele_from_wms, MultiDem, transform_lon_lat, DemSwitzerland, DemBasemap
+from wrpylib.wrdem import get_ele_from_raster, get_ele_from_wms, MultiDem, transform_lon_lat, DemSwitzerland, \
+    DemBasemap, DemBavaria
 from wrpylib.wrvalidators import LonLat
 
 
 from wrpylib.wrvalidators import LonLat
 
 
@@ -92,6 +93,30 @@ class TestDemSwitzerland(unittest.TestCase):
         self.assertIsNone(ele)
 
 
         self.assertIsNone(ele)
 
 
+class TestDemBavaria(unittest.TestCase):
+    def setUp(self):
+        self.dem = DemBavaria()
+
+    def tearDown(self):
+        self.dem.close()
+
+    def test_get_ele_inside_valid(self):
+        ele = self.dem.get_ele(LonLat(11.5396, 47.6809))
+        self.assertAlmostEqual(ele, 863, delta=0.5)
+        # ele = self.dem.get_ele(LonLat(11.010041, 47.618947))
+        # self.assertAlmostEqual(ele, 998, delta=0.5)
+        # ele = self.dem.get_ele(LonLat(11.019577, 47.620695))
+        # self.assertAlmostEqual(ele, 833, delta=0.5)
+
+    def test_get_ele_inside_invalid(self):
+        ele = self.dem.get_ele(LonLat(9.91, 48.97))
+        self.assertIsNone(ele)
+
+    def test_get_ele_outside(self):
+        ele = self.dem.get_ele(LonLat(5.182008, 46.799233))
+        self.assertIsNone(ele)
+
+
 class TestWrDemMultiDem(unittest.TestCase):
     def setUp(self):
         self.dem = MultiDem()
 class TestWrDemMultiDem(unittest.TestCase):
     def setUp(self):
         self.dem = MultiDem()
index 9184247d412beed292c5f8cdd220ec366f7650ae..52b41d7fc54337c40883692a4e9df6d406c39875 100644 (file)
@@ -140,12 +140,16 @@ class DemBasemap(DemRasterBase):
 
 class DemSwitzerland(DemRasterBase):
     def __init__(self):
 
 class DemSwitzerland(DemRasterBase):
     def __init__(self):
-        filename = '/home/philipp/daten/GeoData/dem/schweiz_200m/data/DHM200.xyz'
-        filename = '/home/philipp/daten/GeoData/dem/schweiz_200m/data/DHM200.asc'
-        # https://www.swisstopo.admin.ch/de/swisstopo/kostenlose-geobasisdaten.html
+        filename = 'zip:///home/philipp/daten/GeoData/dem/schweiz_200m/dem_schweiz_200m.zip!data/DHM200.asc'
         super().__init__(filename, crs='EPSG:21781')
 
 
         super().__init__(filename, crs='EPSG:21781')
 
 
+class DemBavaria(DemRasterBase):
+    def __init__(self):
+        filename = 'zip:///home/philipp/daten/GeoData/dem/bayern_50m/dgm50_epsg25832.tif.zip!dgm50_epsg25832.tif'
+        super().__init__(filename)
+
+
 class DemWmsBase(DemBase):
     def __init__(self, url: str, wms_version: str, layer_name: str):
         self.url = url
 class DemWmsBase(DemBase):
     def __init__(self, url: str, wms_version: str, layer_name: str):
         self.url = url
@@ -180,7 +184,7 @@ class DemSouthTyrol(DemWmsBase):
 
 class MultiDem:
     def __init__(self):
 
 class MultiDem:
     def __init__(self):
-        self.dems = [DemBasemap(), DemSouthTyrol(), DemSwitzerland()]
+        self.dems = [DemBasemap(), DemSouthTyrol(), DemBavaria(), DemSwitzerland()]
 
     def close(self):
         for dem in self.dems:
 
     def close(self):
         for dem in self.dems: