maps4fs 1.8.197__py3-none-any.whl → 1.8.199__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.
@@ -84,6 +84,7 @@ class Background(MeshComponent, ImageComponent):
84
84
 
85
85
  if not self.map.custom_background_path:
86
86
  self.dem.process()
87
+ self.validate_np_for_mesh(self.dem.dem_path, self.map_size)
87
88
 
88
89
  shutil.copyfile(self.dem.dem_path, self.not_substracted_path)
89
90
  self.save_map_dem(self.dem.dem_path, save_path=self.not_resized_path)
@@ -1,5 +1,7 @@
1
1
  """Base class for all components that primarily used to work with meshes."""
2
2
 
3
+ import os
4
+
3
5
  import cv2
4
6
  import numpy as np
5
7
  import trimesh
@@ -17,24 +19,31 @@ class MeshComponent(Component):
17
19
  """Checks if the given image is a valid for mesh generation.
18
20
 
19
21
  Arguments:
20
- image_path (str): The path to the custom background image.
22
+ image_path (str): The path to the background image.
21
23
  map_size (int): The size of the map.
22
24
 
23
25
  Raises:
24
- ValueError: If the custom background image does not meet the requirements.
26
+ FileNotFoundError: If the background image is not found.
27
+ ValueError: If the background image does not meet the requirements.
25
28
  """
29
+ if not os.path.isfile(image_path):
30
+ raise FileNotFoundError(f"Can't find the background DEM image at {image_path}.")
31
+
26
32
  image = cv2.imread(image_path, cv2.IMREAD_UNCHANGED)
33
+ if image is None:
34
+ raise ValueError(f"Can't read the background DEM image at {image_path}.")
35
+
27
36
  if image.shape[0] != image.shape[1]:
28
- raise ValueError("The custom background image must be a square.")
37
+ raise ValueError("The background image must be a square.")
29
38
 
30
39
  if image.shape[0] != map_size + Parameters.BACKGROUND_DISTANCE * 2:
31
- raise ValueError("The custom background image must have the size of the map + 4096.")
40
+ raise ValueError("The background image must have the size of the map + 4096.")
32
41
 
33
42
  if len(image.shape) != 2:
34
- raise ValueError("The custom background image must be a grayscale image.")
43
+ raise ValueError("The background image must be a grayscale image.")
35
44
 
36
45
  if image.dtype != np.uint16:
37
- raise ValueError("The custom background image must be a 16-bit grayscale image.")
46
+ raise ValueError("The background image must be a 16-bit grayscale image.")
38
47
 
39
48
  @staticmethod
40
49
  def mesh_to_stl(mesh: trimesh.Trimesh, save_path: str) -> None:
@@ -249,10 +249,16 @@ class DTMProvider(ABC):
249
249
  return None
250
250
 
251
251
  @classmethod
252
- def get_valid_provider_descriptions(cls, lat_lon: tuple[float, float]) -> dict[str, str]:
252
+ def get_valid_provider_descriptions(
253
+ cls, lat_lon: tuple[float, float], default_code: str = "srtm30"
254
+ ) -> dict[str, str]:
253
255
  """Get descriptions of all providers, where keys are provider codes and
254
256
  values are provider descriptions.
255
257
 
258
+ Arguments:
259
+ lat_lon (tuple): Latitude and longitude of the center point.
260
+ default_code (str): Default provider code.
261
+
256
262
  Returns:
257
263
  dict: Provider descriptions.
258
264
  """
@@ -262,6 +268,10 @@ class DTMProvider(ABC):
262
268
  code = provider.code()
263
269
  if code is not None:
264
270
  providers[code] = provider.description()
271
+
272
+ # Sort the dictionary, to make sure that the default provider is the first one.
273
+ providers = dict(sorted(providers.items(), key=lambda item: item[0] != default_code))
274
+
265
275
  return providers
266
276
 
267
277
  @classmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.8.197
3
+ Version: 1.8.199
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
@@ -7,7 +7,7 @@ maps4fs/generator/map.py,sha256=FA9ZLpVMS2RLRDgWZdOo-kLzqMUBza3EZ_89-Gfw_s4,1119
7
7
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
8
8
  maps4fs/generator/settings.py,sha256=ZHwLn1ObdOuhyUTzQTYvyDs7YZ0SbVLgTSpoeUtqi0c,6708
9
9
  maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
10
- maps4fs/generator/component/background.py,sha256=47hQskCT-RfubhJKd9vHDqZOj2lwkYROY1ob5v79b54,18767
10
+ maps4fs/generator/component/background.py,sha256=JDprgCieWZXNL0IuVCdl363tjxAX6KEjfxehGXEkADg,18839
11
11
  maps4fs/generator/component/config.py,sha256=RitKgFDZPzjA1fi8GcEi1na75qqaueUvpcITHjBvCXc,3674
12
12
  maps4fs/generator/component/grle.py,sha256=nDA6vjjfWFL0Hkz6aso1aLIwuksbxzZw9syNax1bD04,19134
13
13
  maps4fs/generator/component/i3d.py,sha256=kJ3Th1mSdBC9j8cyWBwIyYm0fKzYJtocI0jYWkVX3AU,19713
@@ -17,7 +17,7 @@ maps4fs/generator/component/texture.py,sha256=VqxUmK7HHw-G_C_qS1rb5mSpkzGwI0dAnW
17
17
  maps4fs/generator/component/base/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
18
18
  maps4fs/generator/component/base/component.py,sha256=apGuQ7TcwqL0neJZiciNLGO22wZwYyqoDZM7aI1RHw8,21273
19
19
  maps4fs/generator/component/base/component_image.py,sha256=2QnJ9xm0D54v4whg7bc1s-kwRVjZHhOo1OR5jHr1Qp0,4786
20
- maps4fs/generator/component/base/component_mesh.py,sha256=43JY8X0ugIWAJq5y11vTJM9UfbL7SSugj8LkdPmni10,8871
20
+ maps4fs/generator/component/base/component_mesh.py,sha256=zx6TElBBMxo-D5AxqAYemtvkl2k4hHThf0OH7LgNRMY,9159
21
21
  maps4fs/generator/component/base/component_xml.py,sha256=6OO1dKoceO1ACk7-k1oGtnkfNud8ZN3u3ZNjdNMpTqw,3967
22
22
  maps4fs/generator/dtm/__init__.py,sha256=hzKESJm2QhIQnPKxTYCFohpvRWOmLfXZfEnrMbntp1s,1392
23
23
  maps4fs/generator/dtm/arctic.py,sha256=LSivLLjtd6TJUaPYvgSYQ4KalMTaY58zFvwivSh45uM,2587
@@ -26,7 +26,7 @@ maps4fs/generator/dtm/bavaria.py,sha256=nH2wTxiIdQgKotauTqD-zztwFgfZzIdym2sjmSqf
26
26
  maps4fs/generator/dtm/canada.py,sha256=XJ_za2LDV9PEV7hmjPnzdwPbpr6ezAR73-HDVaTuKPk,1290
27
27
  maps4fs/generator/dtm/czech.py,sha256=sT0gwbtEnizVNcZeL7kyDdwmKvB3w8m6UgJR7ZTk1to,1058
28
28
  maps4fs/generator/dtm/denmark.py,sha256=JFuBRrCJTMXe_vdO3gRCwsnZ3nZOp_Y6671Kq8aXRGM,1591
29
- maps4fs/generator/dtm/dtm.py,sha256=QGsA-JysmOXFdZa7RsaXwmB4aGK0gys0DZUG6AIBT30,17476
29
+ maps4fs/generator/dtm/dtm.py,sha256=FOOI9_vl0KoF3EfLaLm2mvFWeOrjH2_d61VNM2NIjEg,17852
30
30
  maps4fs/generator/dtm/england.py,sha256=3URUm7uLH_RYXcQdDW3Vt09GWKAE8RAy1ZFJB94kXOA,1124
31
31
  maps4fs/generator/dtm/finland.py,sha256=VpXpvCgzbyKA6VGSa7ikSzE4B-cLfR1_2zOHvS8delc,1870
32
32
  maps4fs/generator/dtm/flanders.py,sha256=LltmowbS84_DaBHAS9XYoJPMunX6sWGy6zaVACHj5Ro,1039
@@ -51,8 +51,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
51
51
  maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
52
52
  maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
53
53
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
54
- maps4fs-1.8.197.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
55
- maps4fs-1.8.197.dist-info/METADATA,sha256=fswQduWDANskTQxoORkgeZrJdZku9uPBSP7sB8uTDB8,44904
56
- maps4fs-1.8.197.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
57
- maps4fs-1.8.197.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
58
- maps4fs-1.8.197.dist-info/RECORD,,
54
+ maps4fs-1.8.199.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
55
+ maps4fs-1.8.199.dist-info/METADATA,sha256=C6odRfeNlXWxxVObXCeR4W0aJ_DNHjnhsOySqQJ7M2E,44904
56
+ maps4fs-1.8.199.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
57
+ maps4fs-1.8.199.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
58
+ maps4fs-1.8.199.dist-info/RECORD,,