maps4fs 1.8.180__py3-none-any.whl → 1.8.181__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.
@@ -245,6 +245,7 @@ class Background(MeshComponent, ImageComponent):
245
245
  decimation_agression=self.map.background_settings.decimation_agression,
246
246
  remove_center=remove_center,
247
247
  remove_size=self.map_size,
248
+ disable_tqdm=self.map.is_public,
248
249
  )
249
250
 
250
251
  mesh.export(save_path)
@@ -59,6 +59,7 @@ class MeshComponent(Component):
59
59
  decimation_agression: int,
60
60
  remove_center: bool,
61
61
  remove_size: int,
62
+ disable_tqdm: bool = False,
62
63
  ) -> trimesh.Trimesh:
63
64
  """Generates a mesh from the given numpy array.
64
65
 
@@ -72,6 +73,7 @@ class MeshComponent(Component):
72
73
  decimation_agression (int): The agression of the decimation.
73
74
  remove_center (bool): Whether to remove the center from the mesh.
74
75
  remove_size (int): The size of the center to remove.
76
+ disable_tqdm (bool): Whether to disable the tqdm progress bar.
75
77
 
76
78
  Returns:
77
79
  trimesh.Trimesh: The generated mesh.
@@ -94,7 +96,7 @@ class MeshComponent(Component):
94
96
 
95
97
  skipped = 0
96
98
 
97
- for i in tqdm(range(rows - 1), desc="Generating mesh", unit="row"):
99
+ for i in tqdm(range(rows - 1), desc="Generating mesh", unit="row", disable=disable_tqdm):
98
100
  for j in range(cols - 1):
99
101
  top_left = i * cols + j
100
102
  top_right = top_left + 1
@@ -113,7 +115,7 @@ class MeshComponent(Component):
113
115
 
114
116
  faces_np = np.array(faces)
115
117
  mesh = trimesh.Trimesh(vertices=vertices, faces=faces_np)
116
- mesh = MeshComponent.rotate_mesh(mesh)
118
+ mesh = MeshComponent.rotate_mesh(mesh, disable_tqdm=disable_tqdm)
117
119
 
118
120
  if apply_decimation:
119
121
  percent = decimation_percent / 100
@@ -123,7 +125,7 @@ class MeshComponent(Component):
123
125
 
124
126
  try:
125
127
  if not mesh.is_watertight:
126
- mesh = MeshComponent.fix_mesh(mesh)
128
+ mesh = MeshComponent.fix_mesh(mesh, disable_tqdm=disable_tqdm)
127
129
  except Exception:
128
130
  pass
129
131
 
@@ -141,11 +143,12 @@ class MeshComponent(Component):
141
143
  return mesh
142
144
 
143
145
  @staticmethod
144
- def rotate_mesh(mesh: trimesh.Trimesh) -> trimesh.Trimesh:
146
+ def rotate_mesh(mesh: trimesh.Trimesh, disable_tqdm: bool = False) -> trimesh.Trimesh:
145
147
  """Rotates the given mesh by 180 degrees around the Y-axis and Z-axis.
146
148
 
147
149
  Arguments:
148
150
  mesh (trimesh.Trimesh): The mesh to rotate.
151
+ disable_tqdm (bool): Whether to disable the tqdm progress bar.
149
152
 
150
153
  Returns:
151
154
  trimesh.Trimesh: The rotated mesh.
@@ -157,18 +160,21 @@ class MeshComponent(Component):
157
160
  trimesh.transformations.rotation_matrix(np.pi, [0, 0, 1]),
158
161
  ]
159
162
 
160
- for rotation_matrix in tqdm(rotation_matrices, desc="Rotating mesh", unit="rotation"):
163
+ for rotation_matrix in tqdm(
164
+ rotation_matrices, desc="Rotating mesh", unit="rotation", disable=disable_tqdm
165
+ ):
161
166
  mesh_copy.apply_transform(rotation_matrix)
162
167
 
163
168
  return mesh_copy
164
169
 
165
170
  @staticmethod
166
- def fix_mesh(mesh: trimesh.Trimesh) -> trimesh.Trimesh:
171
+ def fix_mesh(mesh: trimesh.Trimesh, disable_tqdm: bool = False) -> trimesh.Trimesh:
167
172
  """Fixes the given mesh by filling holes, fixing normals, fixing winding, fixing inversion,
168
173
  fixing broken faces, and stitching.
169
174
 
170
175
  Arguments:
171
176
  mesh (trimesh.Trimesh): The mesh to fix.
177
+ disable_tqdm (bool): Whether to disable the tqdm progress bar.
172
178
 
173
179
  Returns:
174
180
  trimesh.Trimesh: The fixed mesh.
@@ -184,7 +190,7 @@ class MeshComponent(Component):
184
190
  trimesh.repair.stitch,
185
191
  ]
186
192
 
187
- for method in tqdm(fix_methods, desc="Fixing mesh", unit="method"):
193
+ for method in tqdm(fix_methods, desc="Fixing mesh", unit="method", disable=disable_tqdm):
188
194
  method(mesh_copy) # type: ignore
189
195
 
190
196
  return mesh_copy
@@ -79,7 +79,9 @@ class GRLE(ImageComponent, XMLComponent):
79
79
  self.logger.debug("GRLE schema is not obtained, skipping the processing.")
80
80
  return
81
81
 
82
- for info_layer in tqdm(grle_schema, desc="Preparing GRLE files", unit="layer"):
82
+ for info_layer in tqdm(
83
+ grle_schema, desc="Preparing GRLE files", unit="layer", disable=self.map.is_public
84
+ ):
83
85
  if isinstance(info_layer, dict):
84
86
  file_path = os.path.join(
85
87
  self.game.weights_dir_path(self.map_directory), info_layer["name"]
@@ -208,7 +210,9 @@ class GRLE(ImageComponent, XMLComponent):
208
210
 
209
211
  farmland_id = 1
210
212
 
211
- for farmland in tqdm(farmlands, desc="Adding farmlands", unit="farmland"):
213
+ for farmland in tqdm(
214
+ farmlands, desc="Adding farmlands", unit="farmland", disable=self.map.is_public
215
+ ):
212
216
  try:
213
217
  fitted_farmland = self.fit_object_into_bounds(
214
218
  polygon_points=farmland,
@@ -362,7 +366,9 @@ class GRLE(ImageComponent, XMLComponent):
362
366
  # B and G channels remain the same (zeros), while we change the R channel.
363
367
  possible_r_values = [65, 97, 129, 161, 193, 225]
364
368
 
365
- for _ in tqdm(range(count), desc="Adding islands of plants", unit="island"):
369
+ for _ in tqdm(
370
+ range(count), desc="Adding islands of plants", unit="island", disable=self.map.is_public
371
+ ):
366
372
  # Randomly choose the value for the island.
367
373
  plant_value = choice(possible_r_values)
368
374
  # Randomly choose the size of the island.
@@ -249,7 +249,7 @@ class I3d(XMLComponent):
249
249
  node_id = NODE_ID_STARTING_VALUE
250
250
  field_id = 1
251
251
 
252
- for field in tqdm(fields, desc="Adding fields", unit="field"):
252
+ for field in tqdm(fields, desc="Adding fields", unit="field", disable=self.map.is_public):
253
253
  try:
254
254
  fitted_field = self.fit_object_into_bounds(
255
255
  polygon_points=field, angle=self.rotation, border=border
@@ -82,6 +82,7 @@ class Satellite(ImageComponent):
82
82
  zoom=task.zoom,
83
83
  from_center=True,
84
84
  logger=self.logger,
85
+ show_progress=not self.map.is_public,
85
86
  )
86
87
 
87
88
  except Exception as e:
@@ -1,7 +1,7 @@
1
1
  """This module contains the base WCS provider."""
2
2
 
3
- from abc import abstractmethod
4
3
  import os
4
+ from abc import abstractmethod
5
5
 
6
6
  from owslib.wcs import WebCoverageService
7
7
  from tqdm import tqdm
@@ -68,7 +68,7 @@ class WCSProvider(DTMProvider):
68
68
  params = self.get_wcs_instance_parameters()
69
69
  wcs = WebCoverageService(**params)
70
70
 
71
- for tile in tqdm(tiles, desc="Downloading tiles", unit="tile"):
71
+ for tile in tqdm(tiles, desc="Downloading tiles", unit="tile", disable=self.map.is_public):
72
72
  file_name = "_".join(map(str, tile)) + ".tif"
73
73
  file_path = os.path.join(self.shared_tiff_path, file_name)
74
74
  if not os.path.exists(file_path):
@@ -1,7 +1,7 @@
1
1
  """This module contains the base WMS provider."""
2
2
 
3
- from abc import abstractmethod
4
3
  import os
4
+ from abc import abstractmethod
5
5
 
6
6
  from owslib.wms import WebMapService
7
7
  from tqdm import tqdm
@@ -59,7 +59,7 @@ class WMSProvider(DTMProvider):
59
59
  # auth=Authentication(verify=False),
60
60
  timeout=600,
61
61
  )
62
- for tile in tqdm(tiles, desc="Downloading tiles", unit="tile"):
62
+ for tile in tqdm(tiles, desc="Downloading tiles", unit="tile", disable=self.map.is_public):
63
63
  file_name = "_".join(map(str, tile)) + ".tif"
64
64
  file_path = os.path.join(self.shared_tiff_path, file_name)
65
65
  if not os.path.exists(file_path):
@@ -10,8 +10,8 @@ from typing import TYPE_CHECKING, Type
10
10
  from zipfile import ZipFile
11
11
 
12
12
  import numpy as np
13
- import osmnx as ox # type: ignore
14
- import rasterio # type: ignore
13
+ import osmnx as ox
14
+ import rasterio
15
15
  import requests
16
16
  from pydantic import BaseModel
17
17
  from rasterio.enums import Resampling
@@ -29,7 +29,6 @@ class DTMProviderSettings(BaseModel):
29
29
  """Base class for DTM provider settings models."""
30
30
 
31
31
 
32
- # pylint: disable=too-many-public-methods, too-many-instance-attributes
33
32
  class DTMProvider(ABC):
34
33
  """Base class for DTM providers."""
35
34
 
@@ -54,7 +53,6 @@ class DTMProvider(ABC):
54
53
 
55
54
  _base_instructions = None
56
55
 
57
- # pylint: disable=R0913, R0917
58
56
  def __init__(
59
57
  self,
60
58
  coordinates: tuple[float, float],
@@ -62,7 +60,7 @@ class DTMProvider(ABC):
62
60
  size: int,
63
61
  directory: str,
64
62
  logger: Logger,
65
- map: Map | None = None, # pylint: disable=W0622
63
+ map: Map,
66
64
  ):
67
65
  self._coordinates = coordinates
68
66
  self._user_settings = user_settings
@@ -347,6 +345,7 @@ class DTMProvider(ABC):
347
345
  unit="tile",
348
346
  initial=len(tif_files),
349
347
  total=len(urls),
348
+ disable=self.map.is_public,
350
349
  ):
351
350
  try:
352
351
  file_name = os.path.basename(url)
maps4fs/generator/map.py CHANGED
@@ -156,6 +156,8 @@ class Map:
156
156
  save_path = os.path.join(self.map_directory, "custom_background.png")
157
157
  shutil.copyfile(self.custom_background_path, save_path)
158
158
 
159
+ self.is_public = kwargs.get("is_public", False)
160
+
159
161
  try:
160
162
  shutil.unpack_archive(game.template_path, self.map_directory)
161
163
  self.logger.debug("Map template unpacked to %s", self.map_directory)
@@ -370,7 +370,9 @@ class Texture(Component):
370
370
  """Rotates textures of the layers which have tags."""
371
371
  if self.rotation:
372
372
  # Iterate over the layers which have tags and rotate them.
373
- for layer in tqdm(self.layers, desc="Rotating textures", unit="layer"):
373
+ for layer in tqdm(
374
+ self.layers, desc="Rotating textures", unit="layer", disable=self.map.is_public
375
+ ):
374
376
  if layer.tags:
375
377
  self.logger.debug("Rotating layer %s.", layer.name)
376
378
  layer_paths = layer.paths(self._weights_dir)
@@ -415,7 +417,9 @@ class Texture(Component):
415
417
  def _prepare_weights(self):
416
418
  self.logger.debug("Starting preparing weights from %s layers.", len(self.layers))
417
419
 
418
- for layer in tqdm(self.layers, desc="Preparing weights", unit="layer"):
420
+ for layer in tqdm(
421
+ self.layers, desc="Preparing weights", unit="layer", disable=self.map.is_public
422
+ ):
419
423
  self._generate_weights(layer)
420
424
  self.logger.debug("Prepared weights for %s layers.", len(self.layers))
421
425
 
@@ -491,7 +495,9 @@ class Texture(Component):
491
495
  # Key is a layer.info_layer, value is a list of polygon points as tuples (x, y).
492
496
  info_layer_data = defaultdict(list)
493
497
 
494
- for layer in tqdm(layers, desc="Drawing textures", unit="layer"):
498
+ for layer in tqdm(
499
+ layers, desc="Drawing textures", unit="layer", disable=self.map.is_public
500
+ ):
495
501
  if self.map.texture_settings.skip_drains and layer.usage == "drain":
496
502
  self.logger.debug("Skipping layer %s because of the usage.", layer.name)
497
503
  continue
@@ -567,7 +573,9 @@ class Texture(Component):
567
573
  contains any non-zero values (255), splits those non-values between different weight
568
574
  files of the corresponding layer and saves the changes to the files.
569
575
  """
570
- for layer in tqdm(self.layers, desc="Dissolving textures", unit="layer"):
576
+ for layer in tqdm(
577
+ self.layers, desc="Dissolving textures", unit="layer", disable=self.map.is_public
578
+ ):
571
579
  if not layer.tags:
572
580
  self.logger.debug("Layer %s has no tags, there's nothing to dissolve.", layer.name)
573
581
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.8.180
3
+ Version: 1.8.181
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
@@ -3,26 +3,26 @@ 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
5
5
  maps4fs/generator/game.py,sha256=FFAyckuTW6Ix5aRACXOj2eiA72xd3OMCcOARrMhS164,11025
6
- maps4fs/generator/map.py,sha256=N3lSIEmGQXSrOYXochHEib5djmxL5szFM2crT31Nwog,11312
6
+ maps4fs/generator/map.py,sha256=ONeScf0MnYRhlW33ykQBJcXd_GbMqP7p1QQlhODD5hE,11369
7
7
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
8
8
  maps4fs/generator/settings.py,sha256=cFlN-gK8QcySqyPtcGm-2fLnxQnlmC3Y9kQufJxwI3Y,6270
9
- maps4fs/generator/texture.py,sha256=_IfqIuxH4934VJXKtdABHa6ToPWk3T0xknvlu-rZ5Uc,36570
9
+ maps4fs/generator/texture.py,sha256=-xIpt71y349Hb0svnFln3e6Bu2GjI5jjNdmooP5TrOI,36778
10
10
  maps4fs/generator/component/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
11
- maps4fs/generator/component/background.py,sha256=cBBp-ULrJzuNG9wfE_MaxzAn_mR24neqtL7WjxXEb3I,18749
11
+ maps4fs/generator/component/background.py,sha256=1JPFZFgRFXGWE5u957gemudC4VzlRazzVBgv9diPzP8,18794
12
12
  maps4fs/generator/component/config.py,sha256=RitKgFDZPzjA1fi8GcEi1na75qqaueUvpcITHjBvCXc,3674
13
- maps4fs/generator/component/grle.py,sha256=aKMjVJNuKHJJ2gsXaH00bz10kWaIbbZXU_JbP-ZAGw4,18990
14
- maps4fs/generator/component/i3d.py,sha256=z2ZkflA5E8FrHcGleXSVKZRWvkqclz_Yh_qxJI86enE,19685
15
- maps4fs/generator/component/satellite.py,sha256=oZBHjP_QY0ik1-Vk7JqMS__zIG8ffw2voeozB7-HUQc,4946
13
+ maps4fs/generator/component/grle.py,sha256=fT0LRR9cHi0oIPGY7zxsnrAvxnnsZs-lxQxhBhm43z8,19140
14
+ maps4fs/generator/component/i3d.py,sha256=kJ3Th1mSdBC9j8cyWBwIyYm0fKzYJtocI0jYWkVX3AU,19713
15
+ maps4fs/generator/component/satellite.py,sha256=xzxqHp-G-jRgyI38-XdaMPdGWiC3PdhVJAjBnZL9wL8,5004
16
16
  maps4fs/generator/component/base/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
17
17
  maps4fs/generator/component/base/component.py,sha256=apGuQ7TcwqL0neJZiciNLGO22wZwYyqoDZM7aI1RHw8,21273
18
18
  maps4fs/generator/component/base/component_image.py,sha256=fFgY6k2CbLIg3HS7KeiHi9iFQPJXCAxmBueYh2ExlFU,3918
19
- maps4fs/generator/component/base/component_mesh.py,sha256=jtsEQZkqiCkycYpueq1M1eqgxdShL_bHaJT6Upu8PLI,8412
19
+ maps4fs/generator/component/base/component_mesh.py,sha256=43JY8X0ugIWAJq5y11vTJM9UfbL7SSugj8LkdPmni10,8871
20
20
  maps4fs/generator/component/base/component_xml.py,sha256=6OO1dKoceO1ACk7-k1oGtnkfNud8ZN3u3ZNjdNMpTqw,3967
21
21
  maps4fs/generator/dtm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  maps4fs/generator/dtm/bavaria.py,sha256=7njrEvSCYAC8ZVyvS-_84iXHhWA0oHKrEqSzxdnZuGs,4293
23
23
  maps4fs/generator/dtm/canada.py,sha256=lYONwm6aNX5cjVggR3AiZZF9dlCDAWg0M8RMaObog8s,1288
24
24
  maps4fs/generator/dtm/denmark.py,sha256=GMB9PPxXth6V1v3XuURVWVabJf4xlr158bKfeIIisek,1476
25
- maps4fs/generator/dtm/dtm.py,sha256=vZh3Z5grfQy0gvo-xAgXwkWExk1kW1pGVw2nk54hN-8,16983
25
+ maps4fs/generator/dtm/dtm.py,sha256=eTegemDvvbDekxPJA8SJFgtTAwVLi5jfDXa3FxJHsyE,16845
26
26
  maps4fs/generator/dtm/england.py,sha256=YyCYwnNUJuBeeMNUozfKIj_yNjHpGeuH1Mz0NiAJL-U,1122
27
27
  maps4fs/generator/dtm/finland.py,sha256=Chi3-3sanLIYpipjtPpTu9tqnL3DYcnygSDCPm1s24c,1753
28
28
  maps4fs/generator/dtm/flanders.py,sha256=81pKkrM40SeOe1LSlcsTNXSmUNpofC4D454DG6WFSyA,1037
@@ -38,14 +38,14 @@ maps4fs/generator/dtm/srtm.py,sha256=ob6AUuEn3G3G9kdqTA2VhT335N65RRBJsqAfHuw0gA8
38
38
  maps4fs/generator/dtm/switzerland.py,sha256=GC5fbWL5kkiWksB-H4dWl4I7GSmOsUZ_ywPpfkxBTo8,3547
39
39
  maps4fs/generator/dtm/usgs.py,sha256=1XzLP5GJbe6xcqzkOrEBUtR2SPw7gm6rl1nw5YXmBP8,3253
40
40
  maps4fs/generator/dtm/utils.py,sha256=I-wUSA_J85Xbt8sZCZAVKHSIcrMj5Ng-0adtPVhVmk0,2315
41
- maps4fs/generator/dtm/base/wcs.py,sha256=UfkLNHqsYTr2ytjyZjWDocq2hFC_qyFCvl-_tnz6gHM,2510
42
- maps4fs/generator/dtm/base/wms.py,sha256=hiupNvNjwDZs3oUE41R9OhDtsMgqQI0rfVBYKB4N7GE,2264
41
+ maps4fs/generator/dtm/base/wcs.py,sha256=PRG3IIwj2RWZh2y3d3taCxEsulDcwSYmsaaseNcjW3M,2538
42
+ maps4fs/generator/dtm/base/wms.py,sha256=14ssC11SeitP9PYJwXx6669w4JZ5Z4KSobV9pWtYVQE,2292
43
43
  maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
44
44
  maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
45
45
  maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
46
46
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
47
- maps4fs-1.8.180.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
48
- maps4fs-1.8.180.dist-info/METADATA,sha256=pGroCVCggi-YpaaLtC0j3GE5UBAeWsoTiEukhYuOjzM,44229
49
- maps4fs-1.8.180.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
50
- maps4fs-1.8.180.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
51
- maps4fs-1.8.180.dist-info/RECORD,,
47
+ maps4fs-1.8.181.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
48
+ maps4fs-1.8.181.dist-info/METADATA,sha256=lSXjtMsf3nY098isYPXV9XwTLWmSOQw0ce8z-shIePo,44229
49
+ maps4fs-1.8.181.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
50
+ maps4fs-1.8.181.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
51
+ maps4fs-1.8.181.dist-info/RECORD,,