maps4fs 1.3.4__py3-none-any.whl → 1.3.7__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.
@@ -476,7 +476,7 @@ class Background(Component):
476
476
  rotation=self.rotation,
477
477
  map_directory=self.map_directory,
478
478
  logger=self.logger,
479
- custom_schema=background_layers, # type: ignore
479
+ texture_custom_schema=background_layers, # type: ignore
480
480
  )
481
481
 
482
482
  self.background_texture.preprocess()
maps4fs/generator/i3d.py CHANGED
@@ -54,7 +54,8 @@ class I3d(Component):
54
54
  """Updates the map I3D file with the default settings."""
55
55
  self._update_i3d_file()
56
56
  self._add_fields()
57
- self._add_forests()
57
+ if self.game.code == "FS25":
58
+ self._add_forests()
58
59
 
59
60
  def _get_tree(self) -> ET.ElementTree | None:
60
61
  """Returns the ElementTree instance of the map I3D file."""
@@ -327,24 +328,28 @@ class I3d(Component):
327
328
  # pylint: disable=R0911
328
329
  def _add_forests(self) -> None:
329
330
  """Adds forests to the map I3D file."""
330
- try:
331
- tree_schema_path = self.game.tree_schema
332
- except ValueError:
333
- self.logger.warning("Tree schema path not set for the Game %s.", self.game.code)
334
- return
335
-
336
- if not os.path.isfile(tree_schema_path):
337
- self.logger.warning("Tree schema file was not found: %s.", tree_schema_path)
338
- return
339
-
340
- try:
341
- with open(tree_schema_path, "r", encoding="utf-8") as tree_schema_file:
342
- tree_schema: list[dict[str, str | int]] = json.load(tree_schema_file)
343
- except json.JSONDecodeError as e:
344
- self.logger.warning(
345
- "Could not load tree schema from %s with error: %s", tree_schema_path, e
346
- )
347
- return
331
+ custom_schema = self.kwargs.get("tree_custom_schema")
332
+ if custom_schema:
333
+ tree_schema = custom_schema
334
+ else:
335
+ try:
336
+ tree_schema_path = self.game.tree_schema
337
+ except ValueError:
338
+ self.logger.warning("Tree schema path not set for the Game %s.", self.game.code)
339
+ return
340
+
341
+ if not os.path.isfile(tree_schema_path):
342
+ self.logger.warning("Tree schema file was not found: %s.", tree_schema_path)
343
+ return
344
+
345
+ try:
346
+ with open(tree_schema_path, "r", encoding="utf-8") as tree_schema_file:
347
+ tree_schema = json.load(tree_schema_file) # type: ignore
348
+ except json.JSONDecodeError as e:
349
+ self.logger.warning(
350
+ "Could not load tree schema from %s with error: %s", tree_schema_path, e
351
+ )
352
+ return
348
353
 
349
354
  texture_component: Texture | None = self.map.get_component("Texture") # type: ignore
350
355
  if not texture_component:
@@ -399,7 +404,7 @@ class I3d(Component):
399
404
  (xcs, ycs), self.map.i3d_settings.forest_density
400
405
  )
401
406
 
402
- random_tree = choice(tree_schema)
407
+ random_tree = choice(tree_schema) # type: ignore
403
408
  tree_name = random_tree["name"]
404
409
  tree_id = random_tree["reference_id"]
405
410
 
maps4fs/generator/map.py CHANGED
@@ -71,13 +71,15 @@ class TextureSettings(NamedTuple):
71
71
  Attributes:
72
72
  dissolve (bool): dissolve the texture into several images.
73
73
  fields_padding (int): padding around the fields.
74
+ skip_drains (bool): skip drains generation.
74
75
  """
75
76
 
76
77
  dissolve: bool = True
77
78
  fields_padding: int = 0
79
+ skip_drains: bool = False
78
80
 
79
81
 
80
- # pylint: disable=R0913, R0902
82
+ # pylint: disable=R0913, R0902, R0914
81
83
  class Map:
82
84
  """Class used to generate map using all components.
83
85
 
@@ -97,11 +99,13 @@ class Map:
97
99
  rotation: int,
98
100
  map_directory: str,
99
101
  logger: Any = None,
102
+ custom_osm: str | None = None,
100
103
  dem_settings: DEMSettings = DEMSettings(),
101
104
  background_settings: BackgroundSettings = BackgroundSettings(),
102
105
  grle_settings: GRLESettings = GRLESettings(),
103
106
  i3d_settings: I3DSettings = I3DSettings(),
104
107
  texture_settings: TextureSettings = TextureSettings(),
108
+ **kwargs,
105
109
  ):
106
110
  if not logger:
107
111
  logger = Logger(to_stdout=True, to_file=False)
@@ -123,6 +127,9 @@ class Map:
123
127
 
124
128
  self.logger.info("Game was set to %s", game.code)
125
129
 
130
+ self.custom_osm = custom_osm
131
+ self.logger.info("Custom OSM file: %s", custom_osm)
132
+
126
133
  self.dem_settings = dem_settings
127
134
  self.logger.info("DEM settings: %s", dem_settings)
128
135
  self.background_settings = background_settings
@@ -137,6 +144,9 @@ class Map:
137
144
  os.makedirs(self.map_directory, exist_ok=True)
138
145
  self.logger.debug("Map directory created: %s", self.map_directory)
139
146
 
147
+ self.texture_custom_schema = kwargs.get("texture_custom_schema", None)
148
+ self.tree_custom_schema = kwargs.get("tree_custom_schema", None)
149
+
140
150
  try:
141
151
  shutil.unpack_archive(game.template_path, self.map_directory)
142
152
  self.logger.debug("Map template unpacked to %s", self.map_directory)
@@ -167,6 +177,8 @@ class Map:
167
177
  self.rotation,
168
178
  self.map_directory,
169
179
  self.logger,
180
+ texture_custom_schema=self.texture_custom_schema,
181
+ tree_custom_schema=self.tree_custom_schema,
170
182
  )
171
183
  self.components.append(component)
172
184
 
@@ -178,7 +178,7 @@ class Texture(Component):
178
178
 
179
179
  def preprocess(self) -> None:
180
180
  """Preprocesses the data before the generation."""
181
- custom_schema = self.kwargs.get("custom_schema")
181
+ custom_schema = self.kwargs.get("texture_custom_schema")
182
182
  if custom_schema:
183
183
  layers_schema = custom_schema # type: ignore
184
184
  self.logger.info("Custom schema loaded with %s layers.", len(layers_schema))
@@ -388,6 +388,9 @@ class Texture(Component):
388
388
  info_layer_data = defaultdict(list)
389
389
 
390
390
  for layer in layers:
391
+ if self.map.texture_settings.skip_drains and layer.usage == "drain":
392
+ self.logger.debug("Skipping layer %s because of the usage.", layer.name)
393
+ continue
391
394
  if not layer.tags:
392
395
  self.logger.debug("Layer %s has no tags, there's nothing to draw.", layer.name)
393
396
  continue
@@ -632,7 +635,10 @@ class Texture(Component):
632
635
  """
633
636
  is_fieds = info_layer == "fields"
634
637
  try:
635
- objects = ox.features_from_bbox(bbox=self.new_bbox, tags=tags)
638
+ if self.map.custom_osm is not None:
639
+ objects = ox.features_from_xml(self.map.custom_osm, tags=tags)
640
+ else:
641
+ objects = ox.features_from_bbox(bbox=self.new_bbox, tags=tags)
636
642
  except Exception: # pylint: disable=W0718
637
643
  self.logger.debug("Error fetching objects for tags: %s.", tags)
638
644
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 1.3.4
3
+ Version: 1.3.7
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
@@ -72,6 +72,7 @@ Requires-Dist: pympler
72
72
  🌲 Automatically generates forests 🆕<br>
73
73
  🌊 Automatically generates water planes 🆕<br>
74
74
  🌍 Based on real-world data from OpenStreetMap<br>
75
+ 🗺️ Supports [custom OSM maps](/docs/custom_osm.md)<br>
75
76
  🏞️ Generates height map using SRTM dataset<br>
76
77
  📦 Provides a ready-to-use map template for the Giants Editor<br>
77
78
  🚜 Supports Farming Simulator 22 and 25<br>
@@ -483,6 +484,8 @@ You can also apply some advanced settings to the map generation process. Note th
483
484
 
484
485
  - Texture dissolving - if enabled, the values from one layer will be splitted between different layers of texture, making it look more natural. By default, it's set to True. Can be turned of for faster processing.
485
486
 
487
+ - Skip drains - if enabled, the tool will not generate the drains and ditches on the map. By default, it's set to False. Use this if you don't need the drains on the map.
488
+
486
489
  ### Farmlands Advanced settings
487
490
 
488
491
  - Farmlands margin - this value (in meters) will be applied to each farmland, making it bigger. You can use the value to adjust how much the farmland should be bigger than the actual field. By default, it's set to 3.
@@ -526,3 +529,4 @@ But also, I want to thank the people who helped me with the project in some way,
526
529
  - [BFernaesds](https://github.com/BFernaesds) - for the manual tests of the app.
527
530
  - [gamerdesigns](https://github.com/gamerdesigns) - for the manual tests of the app.
528
531
  - [Tox3](https://github.com/Tox3) - for the manual tests of the app.
532
+ - [Lucandia](https://github.com/Lucandia) - for the awesome StreamLit [widget to preview STL files](https://github.com/Lucandia/streamlit_stl).
@@ -1,21 +1,21 @@
1
1
  maps4fs/__init__.py,sha256=MlM_vkLH_22xoBwhoRD52JDECCmeAJ8gBQr7RMQZmis,261
2
2
  maps4fs/logger.py,sha256=B-NEYpMjPAAqlV4VpfTi6nbBFnEABVtQOaYe6nMpidg,1489
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/background.py,sha256=rywtqApQ0ijIaID59ThoXsWBsQfQBa-ch6Xw6zTuBCw,22298
4
+ maps4fs/generator/background.py,sha256=KFoO6GKaNrJDUoMrDyeroZG63Cv9aGkMgHaa0QYEpiU,22306
5
5
  maps4fs/generator/component.py,sha256=XN-3Zx0bujugpuRk3YB-pYNwUHREdyt_cLxPd7pr57g,17967
6
6
  maps4fs/generator/config.py,sha256=0QmK052B8bxyHVhg3jzCORLfOBMMmqVfhhbqXKf6OMk,4383
7
7
  maps4fs/generator/dem.py,sha256=MZf3ZjawJ977TxqB1q9nNpvPZUNwfmm2EaJDtVU-eCU,15939
8
8
  maps4fs/generator/game.py,sha256=ZQeYzPzPB3CG41avdhNCyTZpHEeedqNBuAbNevTZuXg,7931
9
9
  maps4fs/generator/grle.py,sha256=xKIpyhYsZol-IXcBULbX7wWZ1n83BWTZqaf8FLodchE,17499
10
- maps4fs/generator/i3d.py,sha256=z8l_dxF8cd8OQT-mcI3lha_9o_lX-moxVFBOXg7aZt4,18232
11
- maps4fs/generator/map.py,sha256=Oa8nU_5y3LpGvPW0hqkVjUxKd-U7o2eOFm0SfncDnMo,8397
10
+ maps4fs/generator/i3d.py,sha256=bW7FLAISFKCPUmad7ANz1loWI07oEZlEQOEL_tv0YmQ,18483
11
+ maps4fs/generator/map.py,sha256=VEcsh-nvJ8kF1NevBwNS0tW5oiLP8gIF61ttz6XrOHc,8920
12
12
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
13
- maps4fs/generator/texture.py,sha256=2WoP54i0ppZdbnmD2Q-GllDPTxcz6zhczC1xoTHIS_A,27542
13
+ maps4fs/generator/texture.py,sha256=PCQA2OVjTKrrMbheZ36pRAkGT8everovgvfMRwVWTFs,27894
14
14
  maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
15
15
  maps4fs/toolbox/background.py,sha256=9BXWNqs_n3HgqDiPztWylgYk_QM4YgBpe6_ZNQAWtSc,2154
16
16
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
17
- maps4fs-1.3.4.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
18
- maps4fs-1.3.4.dist-info/METADATA,sha256=gso9NEiGJ4tRl1KYeG0nJ8Uxww3kUGTARbxP_45zzI0,30910
19
- maps4fs-1.3.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
- maps4fs-1.3.4.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
21
- maps4fs-1.3.4.dist-info/RECORD,,
17
+ maps4fs-1.3.7.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
18
+ maps4fs-1.3.7.dist-info/METADATA,sha256=3yZGkkoXbOYdGYj9nANHuxY0uhT_8TNVSywkz_WhoS0,31286
19
+ maps4fs-1.3.7.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
+ maps4fs-1.3.7.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
21
+ maps4fs-1.3.7.dist-info/RECORD,,