maps4fs 2.1.8__py3-none-any.whl → 2.2.0__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.
@@ -1,15 +1,55 @@
1
1
  """This module contains configuration files for the maps4fs generator."""
2
2
 
3
3
  import os
4
+ import shutil
4
5
  import subprocess
5
6
 
6
7
  from osmnx import settings as ox_settings
7
8
 
9
+ from maps4fs.logger import Logger
10
+
11
+ logger = Logger()
12
+
13
+ DEFAULT_TEMPLATES_DIR = os.path.join(os.getcwd(), "data")
14
+ MFS_TEMPLATES_DIR = os.getenv("MFS_TEMPLATES_DIRECTORY")
15
+ if MFS_TEMPLATES_DIR is None:
16
+ logger.info("MFS_TEMPLATES_DIRECTORY is not set. Using default templates directory.")
17
+ MFS_TEMPLATES_DIR = DEFAULT_TEMPLATES_DIR
18
+ else:
19
+ logger.info("MFS_TEMPLATES_DIRECTORY is set to: %s", MFS_TEMPLATES_DIR)
20
+ if not os.path.isdir(MFS_TEMPLATES_DIR):
21
+ logger.info("Templates directory %s does not exist. Creating it.", MFS_TEMPLATES_DIR)
22
+ os.makedirs(MFS_TEMPLATES_DIR, exist_ok=True)
23
+
24
+ # Check if there any files (directory is empty).
25
+ if not os.listdir(MFS_TEMPLATES_DIR):
26
+ logger.info("Templates directory %s is empty. Copying default files.", MFS_TEMPLATES_DIR)
27
+ for item in os.listdir(DEFAULT_TEMPLATES_DIR):
28
+ s = os.path.join(DEFAULT_TEMPLATES_DIR, item)
29
+ d = os.path.join(MFS_TEMPLATES_DIR, item)
30
+ if os.path.isdir(s):
31
+ shutil.copytree(s, d, False, None)
32
+ else:
33
+ shutil.copy2(s, d)
34
+ logger.info("Default files copied to %s.", MFS_TEMPLATES_DIR)
35
+ else:
36
+ logger.warning(
37
+ "Templates directory %s is not empty. Will not copy default files. "
38
+ "Ensure that the directory contains the necessary template files.",
39
+ MFS_TEMPLATES_DIR,
40
+ )
41
+
8
42
  MFS_ROOT_DIR = os.getenv("MFS_ROOT_DIRECTORY", os.path.join(os.getcwd(), "mfsrootdir"))
9
43
  MFS_CACHE_DIR = os.path.join(MFS_ROOT_DIR, "cache")
10
44
  MFS_DATA_DIR = os.path.join(MFS_ROOT_DIR, "data")
11
45
  os.makedirs(MFS_CACHE_DIR, exist_ok=True)
12
46
  os.makedirs(MFS_DATA_DIR, exist_ok=True)
47
+ logger.info(
48
+ "MFS_ROOT_DIR: %s. MFS_CACHE_DIR: %s. MFS_DATA_DIR: %s.",
49
+ MFS_ROOT_DIR,
50
+ MFS_CACHE_DIR,
51
+ MFS_DATA_DIR,
52
+ )
13
53
 
14
54
  DTM_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "dtm")
15
55
  SAT_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "sat")
@@ -50,3 +90,4 @@ def get_package_version(package_name: str) -> str:
50
90
 
51
91
 
52
92
  PACKAGE_VERSION = get_package_version("maps4fs")
93
+ logger.info("maps4fs version: %s", PACKAGE_VERSION)
maps4fs/generator/game.py CHANGED
@@ -6,6 +6,7 @@ from __future__ import annotations
6
6
 
7
7
  import os
8
8
 
9
+ import maps4fs.generator.config as mfscfg
9
10
  from maps4fs.generator.component.background import Background
10
11
  from maps4fs.generator.component.config import Config
11
12
  from maps4fs.generator.component.grle import GRLE
@@ -13,8 +14,6 @@ from maps4fs.generator.component.i3d import I3d
13
14
  from maps4fs.generator.component.satellite import Satellite
14
15
  from maps4fs.generator.component.texture import Texture
15
16
 
16
- working_directory = os.getcwd()
17
-
18
17
 
19
18
  class Game:
20
19
  """Class used to define different versions of the game for which the map is generated.
@@ -34,10 +33,10 @@ class Game:
34
33
  code: str | None = None
35
34
  dem_multipliyer: int = 2
36
35
  _additional_dem_name: str | None = None
37
- _map_template_path: str | None = None
38
- _texture_schema: str | None = None
39
- _grle_schema: str | None = None
40
- _tree_schema: str | None = None
36
+ _map_template_file: str | None = None
37
+ _texture_schema_file: str | None = None
38
+ _grle_schema_file: str | None = None
39
+ _tree_schema_file: str | None = None
41
40
  _i3d_processing: bool = True
42
41
  _plants_processing: bool = True
43
42
  _environment_processing: bool = True
@@ -50,6 +49,27 @@ class Game:
50
49
  def __init__(self, map_template_path: str | None = None):
51
50
  if map_template_path:
52
51
  self._map_template_path = map_template_path
52
+ else:
53
+ if not self._map_template_file:
54
+ raise ValueError("Map template file not set.")
55
+ self._map_template_path = os.path.join(
56
+ mfscfg.MFS_TEMPLATES_DIR, self._map_template_file # type: ignore
57
+ )
58
+
59
+ if not self._texture_schema_file:
60
+ self._texture_schema = None
61
+ else:
62
+ self._texture_schema = os.path.join(mfscfg.MFS_TEMPLATES_DIR, self._texture_schema_file) # type: ignore
63
+
64
+ if not self._grle_schema_file:
65
+ self._grle_schema = None
66
+ else:
67
+ self._grle_schema = os.path.join(mfscfg.MFS_TEMPLATES_DIR, self._grle_schema_file) # type: ignore
68
+
69
+ if not self._tree_schema_file:
70
+ self._tree_schema = None
71
+ else:
72
+ self._tree_schema = os.path.join(mfscfg.MFS_TEMPLATES_DIR, self._tree_schema_file) # type: ignore
53
73
 
54
74
  def set_components_by_names(self, component_names: list[str]) -> None:
55
75
  """Sets the components used for map generation by their names.
@@ -297,8 +317,8 @@ class FS22(Game):
297
317
  """Class used to define the game version FS22."""
298
318
 
299
319
  code = "FS22"
300
- _map_template_path = os.path.join(working_directory, "data", "fs22-map-template.zip")
301
- _texture_schema = os.path.join(working_directory, "data", "fs22-texture-schema.json")
320
+ _map_template_file = "fs22-map-template.zip"
321
+ _texture_schema_file = "fs22-texture-schema.json"
302
322
  _i3d_processing = False
303
323
  _environment_processing = False
304
324
  _fog_processing = False
@@ -342,10 +362,10 @@ class FS25(Game):
342
362
  code = "FS25"
343
363
  dem_multipliyer: int = 2
344
364
  _additional_dem_name = "unprocessedHeightMap.png"
345
- _map_template_path = os.path.join(working_directory, "data", "fs25-map-template.zip")
346
- _texture_schema = os.path.join(working_directory, "data", "fs25-texture-schema.json")
347
- _grle_schema = os.path.join(working_directory, "data", "fs25-grle-schema.json")
348
- _tree_schema = os.path.join(working_directory, "data", "fs25-tree-schema.json")
365
+ _map_template_file = "fs25-map-template.zip"
366
+ _texture_schema_file = "fs25-texture-schema.json"
367
+ _grle_schema_file = "fs25-grle-schema.json"
368
+ _tree_schema_file = "fs25-tree-schema.json"
349
369
 
350
370
  def dem_file_path(self, map_directory: str) -> str:
351
371
  """Returns the path to the DEM file.
maps4fs/generator/map.py CHANGED
@@ -96,6 +96,7 @@ class Map:
96
96
  "longitude": coordinates[1],
97
97
  "country": self.get_country_by_coordinates(),
98
98
  "size": size,
99
+ "output_size": self.output_size,
99
100
  "rotation": rotation,
100
101
  "dtm_provider": dtm_provider.name(),
101
102
  "custom_osm": bool(custom_osm),
@@ -307,6 +307,7 @@ class MainSettings(NamedTuple):
307
307
  longitude: float
308
308
  country: str
309
309
  size: int
310
+ output_size: int | None
310
311
  rotation: int
311
312
  dtm_provider: str
312
313
  custom_osm: bool
@@ -342,6 +343,7 @@ class MainSettings(NamedTuple):
342
343
  "longitude": self.longitude,
343
344
  "country": self.country,
344
345
  "size": self.size,
346
+ "output_size": self.output_size,
345
347
  "rotation": self.rotation,
346
348
  "dtm_provider": self.dtm_provider,
347
349
  "custom_osm": self.custom_osm,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maps4fs
3
- Version: 2.1.8
3
+ Version: 2.2.0
4
4
  Summary: Generate map templates for Farming Simulator from real places.
5
5
  Author-email: iwatkot <iwatkot@gmail.com>
6
6
  License: Apache License 2.0
@@ -1,11 +1,11 @@
1
1
  maps4fs/__init__.py,sha256=Fy521EmVAWnhu6OvOInc97yrtJotFzcV0YfRB2b9O4s,314
2
2
  maps4fs/logger.py,sha256=6sem0aFKQqtVjQ_yNu9iGcc-hqzLQUhfxco05K6nqow,763
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
- maps4fs/generator/config.py,sha256=hBJqCay6mzV2h32EqTCFYywvrOuMpkvOCF9IDBBtO2U,1572
5
- maps4fs/generator/game.py,sha256=Qqeh1rg0RFghhu9uhBMn_XKXYkTkg7fsjY1xO2eIZRw,13777
6
- maps4fs/generator/map.py,sha256=VOJJYQYzSkk-ed38R__SoYpi50YUYWO8kpLeZ2TB6tM,19024
4
+ maps4fs/generator/config.py,sha256=H63HqgpZG6M2wt2DnS-m44cDPiy_hd3qJubX8WZz5Ys,3185
5
+ maps4fs/generator/game.py,sha256=nf6iuYNA5NJc-ir_WOgkw-MdJVgetVHeEtxbWJYt3Vo,14462
6
+ maps4fs/generator/map.py,sha256=ATTRrsxvwao3kW1M-AGeFpyJGG3h-LuTDZjC5v1MDMY,19073
7
7
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
8
- maps4fs/generator/settings.py,sha256=8dN96L5Ueb5LxgJaKNv8-zH2Yym627o4Uj8zJYHfT8g,11312
8
+ maps4fs/generator/settings.py,sha256=NukAt1s4CS0HEWmUcBPc8OiqkWqjts3AvvkX0APZKes,11385
9
9
  maps4fs/generator/statistics.py,sha256=aynS3zbAtiwnU_YLKHPTiiaKW98_suvQUhy1SGBA6mc,2448
10
10
  maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
11
11
  maps4fs/generator/component/background.py,sha256=JANbVgcBXpaQ0HB1eeV16KkFgpU-Txj5kB5eJNEDAv0,34473
@@ -21,8 +21,8 @@ maps4fs/generator/component/base/component.py,sha256=AP7b6rmYV_HdyyHlCTo9s6fyBXy
21
21
  maps4fs/generator/component/base/component_image.py,sha256=WTGC6v1KuS5sLNCC95Z48nCspvATKKNOuhTNYzTWXr4,8315
22
22
  maps4fs/generator/component/base/component_mesh.py,sha256=3hC-qDT8Vde6SmRMqs9USAkrF-gL2dDTYW71ATpxUS4,9130
23
23
  maps4fs/generator/component/base/component_xml.py,sha256=MT-VhU2dEckLFxAgmxg6V3gnv11di_94Qq6atfpOLdc,5342
24
- maps4fs-2.1.8.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
25
- maps4fs-2.1.8.dist-info/METADATA,sha256=A1yjg3hwPS8EptLoOemoTdMW645MbvQDfAv8aKvRDII,45431
26
- maps4fs-2.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- maps4fs-2.1.8.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
28
- maps4fs-2.1.8.dist-info/RECORD,,
24
+ maps4fs-2.2.0.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
25
+ maps4fs-2.2.0.dist-info/METADATA,sha256=kqnmOq-uxIG07x5Bjypf-gkU0eiyN1AWvVtysxm6tYw,45431
26
+ maps4fs-2.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ maps4fs-2.2.0.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
28
+ maps4fs-2.2.0.dist-info/RECORD,,