maps4fs 1.8.247__py3-none-any.whl → 1.8.249__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,4 +22,5 @@ from maps4fs.generator.dtm.scotland import ScotlandProvider
22
22
  from maps4fs.generator.dtm.spain import SpainProvider
23
23
  from maps4fs.generator.dtm.srtm import SRTM30Provider
24
24
  from maps4fs.generator.dtm.switzerland import SwitzerlandProvider
25
+ from maps4fs.generator.dtm.thuringia import ThuringiaProvider
25
26
  from maps4fs.generator.dtm.usgs_wcs import USGSWCSProvider
@@ -404,17 +404,31 @@ class DTMProvider(ABC):
404
404
 
405
405
  Returns:
406
406
  str: Path to the unzipped file.
407
+
408
+ Raises:
409
+ FileNotFoundError: If no .img or .tif file is found in the zip file
407
410
  """
408
411
  file_path = os.path.join(output_path, file_name)
409
412
  img_file_name = file_name.replace(".zip", ".img")
413
+ tif_file_name = file_name.replace(".zip", ".tif")
410
414
  img_file_path = os.path.join(output_path, img_file_name)
411
- if not os.path.exists(img_file_path):
412
- with ZipFile(file_path, "r") as f_in:
413
- f_in.extract(img_file_name, output_path)
414
- self.logger.debug("Unzipped file %s to %s", file_name, img_file_name)
415
- else:
415
+ tif_file_path = os.path.join(output_path, tif_file_name)
416
+ if os.path.exists(img_file_path):
416
417
  self.logger.debug("File already exists: %s", img_file_name)
417
- return img_file_path
418
+ return img_file_path
419
+ if os.path.exists(tif_file_path):
420
+ self.logger.debug("File already exists: %s", tif_file_name)
421
+ return tif_file_path
422
+ with ZipFile(file_path, "r") as f_in:
423
+ if img_file_name in f_in.namelist():
424
+ f_in.extract(img_file_name, output_path)
425
+ self.logger.debug("Unzipped file %s to %s", file_name, img_file_name)
426
+ return img_file_path
427
+ if tif_file_name in f_in.namelist():
428
+ f_in.extract(tif_file_name, output_path)
429
+ self.logger.debug("Unzipped file %s to %s", file_name, tif_file_name)
430
+ return tif_file_path
431
+ raise FileNotFoundError("No .img or .tif file found in the zip file.")
418
432
 
419
433
  def reproject_geotiff(self, input_tiff: str) -> str:
420
434
  """Reproject a GeoTIFF file to a new coordinate reference system (CRS).
@@ -0,0 +1,60 @@
1
+ """This module contains provider of Thuringia data."""
2
+
3
+ import os
4
+ from maps4fs.generator.dtm import utils
5
+ from maps4fs.generator.dtm.dtm import DTMProvider
6
+
7
+ class ThuringiaProvider(DTMProvider):
8
+ """Provider of Thuringia data.
9
+ Data is provided by the Kompetenzzentrum Geodateninfrastruktur Thüringen (© GDI-Th) and available
10
+ at https://geoportal.thueringen.de/gdi-th/download-offene-geodaten/download-hoehendaten under BY 2.0 license.
11
+ """
12
+ _code = "thuringia"
13
+ _name = "Thüringen DGM1"
14
+ _region = "DE"
15
+ _icon = "🇩🇪󠁥󠁢󠁹󠁿"
16
+ _resolution = 1
17
+ _author = "[H4rdB4se](https://github.com/H4rdB4se)"
18
+ _is_community = True
19
+ _instructions = None
20
+ _extents = [(51.5997, 50.2070, 12.69674, 9.8548)]
21
+
22
+ def __init__(self, *args, **kwargs):
23
+ super().__init__(*args, **kwargs)
24
+ self.tiff_path = os.path.join(self._tile_directory, "tiffs")
25
+ os.makedirs(self.tiff_path, exist_ok=True)
26
+
27
+ def download_tiles(self) -> list[str]:
28
+ bbox = self.get_bbox()
29
+ west, east, north, south = utils.transform_bbox(bbox, "EPSG:25832")
30
+ download_urls = self.get_download_urls(north, south, east, west)
31
+ all_tif_files = self.download_tif_files(download_urls, self.tiff_path)
32
+ return all_tif_files
33
+
34
+ @staticmethod
35
+ def get_first_n_digits(value: float, digits: int) -> int:
36
+ """Get the first n digits of a number."""
37
+ return int(str(value)[:digits])
38
+
39
+ def get_download_urls(self, north: float, south: float, east: float, west: float) -> list[str]:
40
+ """Calculate all possible tiles within the bounding box.
41
+
42
+ Args:
43
+ north (float): Northern boundary.
44
+ south (float): Southern boundary.
45
+ east (float): Eastern boundary.
46
+ west (float): Western boundary.
47
+
48
+ Returns:
49
+ list: List of tile names.
50
+ """
51
+ urls = []
52
+ lat = self.get_first_n_digits(south, 4)
53
+ while lat <= self.get_first_n_digits(north, 4):
54
+ lon = self.get_first_n_digits(west, 3)
55
+ while lon <= self.get_first_n_digits(east, 3):
56
+ tile_url = f"https://geoportal.geoportal-th.de/hoehendaten/DGM/dgm_2020-2025/dgm1_32_{lon}_{lat}_1_th_2020-2025.zip"
57
+ urls.append(tile_url)
58
+ lon += 1
59
+ lat += 1
60
+ return urls
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: maps4fs
3
- Version: 1.8.247
3
+ Version: 1.8.249
4
4
  Summary: Generate map templates for Farming Simulator from real places.
5
5
  Author-email: iwatkot <iwatkot@gmail.com>
6
6
  License: MIT License
@@ -27,6 +27,7 @@ Requires-Dist: pygmdl
27
27
  Requires-Dist: owslib
28
28
  Requires-Dist: tqdm
29
29
  Requires-Dist: scipy
30
+ Dynamic: license-file
30
31
 
31
32
  <div align="center" markdown>
32
33
  <a href="https://discord.gg/Sj5QKKyE42">
@@ -730,6 +731,7 @@ In addition to SRTM 30m, which provides global coverage, the map above highlight
730
731
  | 🇩🇪 Mecklenburg-Vorpommern, Germany | 1-25 meter | [kbrandwijk](https://github.com/kbrandwijk) |
731
732
  | 🇩🇪 Baden-Württemberg, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
732
733
  | 🇩🇪 Sachsen-Anhalt, Germany | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
734
+ | 🇩🇪 Thüringen, Germany | 1 meter | [H4rdB4se](https://github.com/H4rdB4se) |
733
735
  | 🇨🇦 Canada | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
734
736
  | 🇧🇪 Flanders, Belgium | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
735
737
  | 🇫🇷 France | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
@@ -20,14 +20,14 @@ maps4fs/generator/component/base/component.py,sha256=CIR4Fjn9YfLU4y7nB_jOaz7PjGF
20
20
  maps4fs/generator/component/base/component_image.py,sha256=2QnJ9xm0D54v4whg7bc1s-kwRVjZHhOo1OR5jHr1Qp0,4786
21
21
  maps4fs/generator/component/base/component_mesh.py,sha256=BsxS5NlUK2hLhksgCwSoMK-00GNAwK2fYGpgb3R4n1w,9396
22
22
  maps4fs/generator/component/base/component_xml.py,sha256=6OO1dKoceO1ACk7-k1oGtnkfNud8ZN3u3ZNjdNMpTqw,3967
23
- maps4fs/generator/dtm/__init__.py,sha256=VIWcZiMZ0UtnJl7rQL-PVHDivXbZVwrBWumjhTTnnKY,1454
23
+ maps4fs/generator/dtm/__init__.py,sha256=CzK8ZdLU5Iv7DrwK5hIQ41zVsLRFgZO-IuRxf-NCVqg,1516
24
24
  maps4fs/generator/dtm/arctic.py,sha256=LSivLLjtd6TJUaPYvgSYQ4KalMTaY58zFvwivSh45uM,2587
25
25
  maps4fs/generator/dtm/baden.py,sha256=PQTMEPm9hrO3nKbv_DXA9oNYnGK_0ei41Q_DhtethX0,1041
26
26
  maps4fs/generator/dtm/bavaria.py,sha256=nH2wTxiIdQgKotauTqD-zztwFgfZzIdym2sjmSqfujM,4295
27
27
  maps4fs/generator/dtm/canada.py,sha256=XJ_za2LDV9PEV7hmjPnzdwPbpr6ezAR73-HDVaTuKPk,1290
28
28
  maps4fs/generator/dtm/czech.py,sha256=sT0gwbtEnizVNcZeL7kyDdwmKvB3w8m6UgJR7ZTk1to,1058
29
29
  maps4fs/generator/dtm/denmark.py,sha256=JFuBRrCJTMXe_vdO3gRCwsnZ3nZOp_Y6671Kq8aXRGM,1591
30
- maps4fs/generator/dtm/dtm.py,sha256=d5ZSBw1Nz6iCAek4O5ioLIijNRaxGvHNlNlEpkqqUIE,17464
30
+ maps4fs/generator/dtm/dtm.py,sha256=BkjVDig46dA7BHeViouCfcM-J4e40PjaVlD5xD_35GM,18211
31
31
  maps4fs/generator/dtm/england.py,sha256=3URUm7uLH_RYXcQdDW3Vt09GWKAE8RAy1ZFJB94kXOA,1124
32
32
  maps4fs/generator/dtm/finland.py,sha256=VpXpvCgzbyKA6VGSa7ikSzE4B-cLfR1_2zOHvS8delc,1870
33
33
  maps4fs/generator/dtm/flanders.py,sha256=LltmowbS84_DaBHAS9XYoJPMunX6sWGy6zaVACHj5Ro,1039
@@ -45,6 +45,7 @@ maps4fs/generator/dtm/scotland.py,sha256=kUGPNjn3mQPOU9sgK3k-uwumPG2wrRFLaDMyPMh
45
45
  maps4fs/generator/dtm/spain.py,sha256=A5QScsrd_bkVlf2n9ZfXBL9z_YoXpLsm_5FWs-5nd_o,1021
46
46
  maps4fs/generator/dtm/srtm.py,sha256=INn3Kpfmo2nLPCDko1sFk9_ZinWW3e8I9S-TX0fMHoY,4327
47
47
  maps4fs/generator/dtm/switzerland.py,sha256=Jn3qYVEps_K6cH-9rMfB_zoXMxhzWQKPnlKkSE-TehE,3549
48
+ maps4fs/generator/dtm/thuringia.py,sha256=iiIGdEZPIQJ-8tcaTeqYTvNHFmM_hFwzos4J8SW55kA,2353
48
49
  maps4fs/generator/dtm/usgs_wcs.py,sha256=X8VxdhyH0-EciGE_X-KgrAM6sVLTGssYIhtebOj8MPI,1021
49
50
  maps4fs/generator/dtm/utils.py,sha256=I-wUSA_J85Xbt8sZCZAVKHSIcrMj5Ng-0adtPVhVmk0,2315
50
51
  maps4fs/generator/dtm/base/wcs.py,sha256=lQAp_gVz9_XUmtyobJkskiefQpuJH4o1Vwb3CSQ0lQA,2510
@@ -53,8 +54,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
53
54
  maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
54
55
  maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
55
56
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
56
- maps4fs-1.8.247.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
57
- maps4fs-1.8.247.dist-info/METADATA,sha256=zH2xHd_cCbDtGc2Am8LIduDJCOJ3l3wElz7k4ixLu78,47093
58
- maps4fs-1.8.247.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
59
- maps4fs-1.8.247.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
60
- maps4fs-1.8.247.dist-info/RECORD,,
57
+ maps4fs-1.8.249.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
58
+ maps4fs-1.8.249.dist-info/METADATA,sha256=wbfG5XMKvfnVvRGq4vFWWV6VzEdw2-Fh1znbM3RIo7s,47222
59
+ maps4fs-1.8.249.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
60
+ maps4fs-1.8.249.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
61
+ maps4fs-1.8.249.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5