maps4fs 1.8.177__py3-none-any.whl → 1.8.178__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.
maps4fs/__init__.py CHANGED
@@ -16,6 +16,7 @@ from maps4fs.generator.dtm.spain import SpainProvider
16
16
  from maps4fs.generator.dtm.france import FranceProvider
17
17
  from maps4fs.generator.dtm.norway import NorwayProvider
18
18
  from maps4fs.generator.dtm.denmark import DenmarkProvider
19
+ from maps4fs.generator.dtm.switzerland import SwitzerlandProvider
19
20
  from maps4fs.generator.game import Game
20
21
  from maps4fs.generator.map import Map
21
22
  from maps4fs.generator.settings import (
@@ -0,0 +1,104 @@
1
+ """This module contains provider of Switzerland data."""
2
+
3
+ import json
4
+ import os
5
+
6
+ import requests
7
+
8
+ from maps4fs.generator.dtm import utils
9
+ from maps4fs.generator.dtm.dtm import DTMProvider, DTMProviderSettings
10
+
11
+
12
+ class SwitzerlandProviderSettings(DTMProviderSettings):
13
+ """Settings for the Switzerland provider."""
14
+
15
+ resolution: tuple | str = ("0.5", "2.0")
16
+
17
+
18
+ class SwitzerlandProvider(DTMProvider):
19
+ """Provider of Switzerland."""
20
+
21
+ _code = "switzerland"
22
+ _name = "Switzerland"
23
+ _region = "CH"
24
+ _icon = "🇨🇭"
25
+ _resolution = "0.5-2"
26
+ _settings = SwitzerlandProviderSettings
27
+ _author = "[kbrandwijk](https://github.com/kbrandwijk)"
28
+ _is_community = True
29
+
30
+ _extents = (47.8308275417, 45.7769477403, 10.4427014502, 6.02260949059)
31
+
32
+ _url = (
33
+ "https://ogd.swisstopo.admin.ch/services/swiseld/"
34
+ "services/assets/ch.swisstopo.swissalti3d/search"
35
+ )
36
+
37
+ def download_tiles(self):
38
+ download_urls = self.get_download_urls()
39
+ all_tif_files = self.download_tif_files(download_urls, self.shared_tiff_path)
40
+ return all_tif_files
41
+
42
+ def __init__(self, *args, **kwargs):
43
+ super().__init__(*args, **kwargs)
44
+ self.shared_tiff_path = os.path.join(self._tile_directory, "shared")
45
+ os.makedirs(self.shared_tiff_path, exist_ok=True)
46
+
47
+ def get_download_urls(self) -> list[str]:
48
+ """Get download URLs of the GeoTIFF files from the USGS API.
49
+
50
+ Returns:
51
+ list: List of download URLs.
52
+ """
53
+ urls = []
54
+ try:
55
+ bbox = self.get_bbox()
56
+ north, south, east, west = utils.transform_bbox(bbox, "EPSG:2056")
57
+
58
+ params = {
59
+ "format": "image/tiff; application=geotiff; profile=cloud-optimized",
60
+ "resolution": self.user_settings.resolution, # type: ignore
61
+ "srid": 2056,
62
+ "state": "current",
63
+ }
64
+
65
+ data = {
66
+ "geometry": json.dumps(
67
+ {
68
+ "type": "Polygon",
69
+ "crs": {"type": "name", "properties": {"name": "EPSG:2056"}},
70
+ "coordinates": [
71
+ [
72
+ [north, east],
73
+ [south, east],
74
+ [south, west],
75
+ [north, west],
76
+ [north, east],
77
+ ]
78
+ ],
79
+ }
80
+ )
81
+ }
82
+
83
+ response = requests.post( # pylint: disable=W3101
84
+ self.url, # type: ignore
85
+ params=params,
86
+ data=data,
87
+ headers={"Content-Type": "application/x-www-form-urlencoded"},
88
+ timeout=60,
89
+ )
90
+ self.logger.debug("Getting file locations...")
91
+
92
+ # Check if the request was successful (HTTP status code 200)
93
+ if response.status_code == 200:
94
+ # Parse the JSON response
95
+ json_data = response.json()
96
+ items = json_data["items"]
97
+ for item in items:
98
+ urls.append(item["ass_asset_href"])
99
+ else:
100
+ self.logger.error("Failed to get data. HTTP Status Code: %s", response.status_code)
101
+ except requests.exceptions.RequestException as e:
102
+ self.logger.error("Failed to get data. Error: %s", e)
103
+ self.logger.debug("Received %s urls", len(urls))
104
+ return urls
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.8.177
3
+ Version: 1.8.178
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
@@ -682,7 +682,7 @@ The generator supports adding the own DTM providers, please refer to the [DTM Pr
682
682
 
683
683
  ### Supported DTM providers
684
684
 
685
- ![coverage map](https://github.com/user-attachments/assets/fc78e755-13e2-4187-b846-4de5cb407dbf)
685
+ ![coverage map](https://github.com/user-attachments/assets/138fa637-ce63-4dd9-bd11-bf92fe038a74)
686
686
 
687
687
  In addition to SRTM 30m, which provides global coverage, the map above highlights all countries and/or regions where higher resolution coverage is provided by one of the DTM providers.
688
688
 
@@ -703,6 +703,8 @@ In addition to SRTM 30m, which provides global coverage, the map above highlight
703
703
  | 🇳🇴 Norway | 1 meter | [kbrandwijk](https://github.com/kbrandwijk) |
704
704
  | 🇪🇸 Spain | 5 meter | [kbrandwijk](https://github.com/kbrandwijk) |
705
705
  | 🇫🇮 Finland | 2 meter | [kbrandwijk](https://github.com/kbrandwijk) |
706
+ | 🇩🇰 Denmark | 0.4 meter | [kbrandwijk](https://github.com/kbrandwijk) |
707
+ | 🇨🇭 Switzerland | 0.5-2 meter | [kbrandwijk](https://github.com/kbrandwijk) |
706
708
 
707
709
  ## Special thanks
708
710
 
@@ -1,4 +1,4 @@
1
- maps4fs/__init__.py,sha256=Jq1Zp0vSkv-beVXfebt_0ELxlrV3ZJX4cT4oaCFda_0,1365
1
+ maps4fs/__init__.py,sha256=vbZRLqERqH-LD2l69dSyZEU4DsuVCU93UrGX5wYs3Os,1431
2
2
  maps4fs/logger.py,sha256=HQrDyj72mUjVYo25aR_-_SxVn2rfFjDCNbj-JKJdSnE,1488
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
4
  maps4fs/generator/dem.py,sha256=oLN02bWNax73HzFsseRBOV47Azl_1L7qdrzuxHh4i_c,11886
@@ -35,6 +35,7 @@ maps4fs/generator/dtm/nrw.py,sha256=1zMa10O0NdQbiTwOa7XXGrx3NhdHUqRXI4yBn_Scb2M,
35
35
  maps4fs/generator/dtm/scotland.py,sha256=Od4dDMuCM_iteewjGBbmZXJ26S0bDwrhRhXeV4HyyOA,4803
36
36
  maps4fs/generator/dtm/spain.py,sha256=HxN0MvrtRqqeTmhl47q60-1DGaMDb2wq6neMcDlDCl8,1005
37
37
  maps4fs/generator/dtm/srtm.py,sha256=ob6AUuEn3G3G9kdqTA2VhT335N65RRBJsqAfHuw0gA8,4502
38
+ maps4fs/generator/dtm/switzerland.py,sha256=GC5fbWL5kkiWksB-H4dWl4I7GSmOsUZ_ywPpfkxBTo8,3547
38
39
  maps4fs/generator/dtm/usgs.py,sha256=1XzLP5GJbe6xcqzkOrEBUtR2SPw7gm6rl1nw5YXmBP8,3253
39
40
  maps4fs/generator/dtm/utils.py,sha256=I-wUSA_J85Xbt8sZCZAVKHSIcrMj5Ng-0adtPVhVmk0,2315
40
41
  maps4fs/generator/dtm/base/wcs.py,sha256=UfkLNHqsYTr2ytjyZjWDocq2hFC_qyFCvl-_tnz6gHM,2510
@@ -43,8 +44,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
43
44
  maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
44
45
  maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
45
46
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
46
- maps4fs-1.8.177.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
47
- maps4fs-1.8.177.dist-info/METADATA,sha256=WtSUt8A9aunNM9Guy-u76Nbi1eVnlBXBl7YzKBRSmAA,44023
48
- maps4fs-1.8.177.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
49
- maps4fs-1.8.177.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
50
- maps4fs-1.8.177.dist-info/RECORD,,
47
+ maps4fs-1.8.178.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
48
+ maps4fs-1.8.178.dist-info/METADATA,sha256=JwRZ0vsWJ_S0xwewgqwW3zdShEH2-HbLQF0cWKMv5no,44229
49
+ maps4fs-1.8.178.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
50
+ maps4fs-1.8.178.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
51
+ maps4fs-1.8.178.dist-info/RECORD,,