maps4fs 2.1.8__tar.gz → 2.2.0__tar.gz
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-2.1.8 → maps4fs-2.2.0}/PKG-INFO +1 -1
- maps4fs-2.2.0/maps4fs/generator/config.py +93 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/game.py +32 -12
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/map.py +1 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/settings.py +2 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs.egg-info/PKG-INFO +1 -1
- {maps4fs-2.1.8 → maps4fs-2.2.0}/pyproject.toml +1 -1
- maps4fs-2.1.8/maps4fs/generator/config.py +0 -52
- {maps4fs-2.1.8 → maps4fs-2.2.0}/LICENSE.md +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/README.md +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/__init__.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/__init__.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/__init__.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/background.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/base/__init__.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/base/component.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/base/component_image.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/base/component_mesh.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/base/component_xml.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/config.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/dem.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/grle.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/i3d.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/layer.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/satellite.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/component/texture.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/qgis.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/generator/statistics.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs/logger.py +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs.egg-info/SOURCES.txt +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs.egg-info/dependency_links.txt +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs.egg-info/requires.txt +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/maps4fs.egg-info/top_level.txt +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/setup.cfg +0 -0
- {maps4fs-2.1.8 → maps4fs-2.2.0}/tests/test_generator.py +0 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
"""This module contains configuration files for the maps4fs generator."""
|
2
|
+
|
3
|
+
import os
|
4
|
+
import shutil
|
5
|
+
import subprocess
|
6
|
+
|
7
|
+
from osmnx import settings as ox_settings
|
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
|
+
|
42
|
+
MFS_ROOT_DIR = os.getenv("MFS_ROOT_DIRECTORY", os.path.join(os.getcwd(), "mfsrootdir"))
|
43
|
+
MFS_CACHE_DIR = os.path.join(MFS_ROOT_DIR, "cache")
|
44
|
+
MFS_DATA_DIR = os.path.join(MFS_ROOT_DIR, "data")
|
45
|
+
os.makedirs(MFS_CACHE_DIR, exist_ok=True)
|
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
|
+
)
|
53
|
+
|
54
|
+
DTM_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "dtm")
|
55
|
+
SAT_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "sat")
|
56
|
+
|
57
|
+
osmnx_cache = os.path.join(MFS_CACHE_DIR, "osmnx")
|
58
|
+
osmnx_data = os.path.join(MFS_CACHE_DIR, "odata")
|
59
|
+
os.makedirs(osmnx_cache, exist_ok=True)
|
60
|
+
os.makedirs(osmnx_data, exist_ok=True)
|
61
|
+
|
62
|
+
|
63
|
+
ox_settings.cache_folder = osmnx_cache
|
64
|
+
ox_settings.data_folder = osmnx_data
|
65
|
+
|
66
|
+
|
67
|
+
def get_package_version(package_name: str) -> str:
|
68
|
+
"""Get the package version.
|
69
|
+
|
70
|
+
Arguments:
|
71
|
+
package_name (str): The name of the package to check.
|
72
|
+
|
73
|
+
Returns:
|
74
|
+
str: The version of the package, or "unknown" if it cannot be determined.
|
75
|
+
"""
|
76
|
+
try:
|
77
|
+
result = subprocess.run(
|
78
|
+
[os.sys.executable, "-m", "pip", "show", package_name], # type: ignore
|
79
|
+
stdout=subprocess.PIPE,
|
80
|
+
stderr=subprocess.PIPE,
|
81
|
+
text=True,
|
82
|
+
check=True,
|
83
|
+
)
|
84
|
+
for line in result.stdout.splitlines():
|
85
|
+
if line.startswith("Version:"):
|
86
|
+
return line.split(":", 1)[1].strip()
|
87
|
+
return "unknown"
|
88
|
+
except Exception:
|
89
|
+
return "unknown"
|
90
|
+
|
91
|
+
|
92
|
+
PACKAGE_VERSION = get_package_version("maps4fs")
|
93
|
+
logger.info("maps4fs version: %s", PACKAGE_VERSION)
|
@@ -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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
301
|
-
|
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
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
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.
|
@@ -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,
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "maps4fs"
|
7
|
-
version = "2.
|
7
|
+
version = "2.2.0"
|
8
8
|
description = "Generate map templates for Farming Simulator from real places."
|
9
9
|
authors = [{name = "iwatkot", email = "iwatkot@gmail.com"}]
|
10
10
|
license = {text = "Apache License 2.0"}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
"""This module contains configuration files for the maps4fs generator."""
|
2
|
-
|
3
|
-
import os
|
4
|
-
import subprocess
|
5
|
-
|
6
|
-
from osmnx import settings as ox_settings
|
7
|
-
|
8
|
-
MFS_ROOT_DIR = os.getenv("MFS_ROOT_DIRECTORY", os.path.join(os.getcwd(), "mfsrootdir"))
|
9
|
-
MFS_CACHE_DIR = os.path.join(MFS_ROOT_DIR, "cache")
|
10
|
-
MFS_DATA_DIR = os.path.join(MFS_ROOT_DIR, "data")
|
11
|
-
os.makedirs(MFS_CACHE_DIR, exist_ok=True)
|
12
|
-
os.makedirs(MFS_DATA_DIR, exist_ok=True)
|
13
|
-
|
14
|
-
DTM_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "dtm")
|
15
|
-
SAT_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "sat")
|
16
|
-
|
17
|
-
osmnx_cache = os.path.join(MFS_CACHE_DIR, "osmnx")
|
18
|
-
osmnx_data = os.path.join(MFS_CACHE_DIR, "odata")
|
19
|
-
os.makedirs(osmnx_cache, exist_ok=True)
|
20
|
-
os.makedirs(osmnx_data, exist_ok=True)
|
21
|
-
|
22
|
-
|
23
|
-
ox_settings.cache_folder = osmnx_cache
|
24
|
-
ox_settings.data_folder = osmnx_data
|
25
|
-
|
26
|
-
|
27
|
-
def get_package_version(package_name: str) -> str:
|
28
|
-
"""Get the package version.
|
29
|
-
|
30
|
-
Arguments:
|
31
|
-
package_name (str): The name of the package to check.
|
32
|
-
|
33
|
-
Returns:
|
34
|
-
str: The version of the package, or "unknown" if it cannot be determined.
|
35
|
-
"""
|
36
|
-
try:
|
37
|
-
result = subprocess.run(
|
38
|
-
[os.sys.executable, "-m", "pip", "show", package_name], # type: ignore
|
39
|
-
stdout=subprocess.PIPE,
|
40
|
-
stderr=subprocess.PIPE,
|
41
|
-
text=True,
|
42
|
-
check=True,
|
43
|
-
)
|
44
|
-
for line in result.stdout.splitlines():
|
45
|
-
if line.startswith("Version:"):
|
46
|
-
return line.split(":", 1)[1].strip()
|
47
|
-
return "unknown"
|
48
|
-
except Exception:
|
49
|
-
return "unknown"
|
50
|
-
|
51
|
-
|
52
|
-
PACKAGE_VERSION = get_package_version("maps4fs")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|