maps4fs 2.2.71__tar.gz → 2.2.72__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.
Files changed (36) hide show
  1. {maps4fs-2.2.71 → maps4fs-2.2.72}/PKG-INFO +2 -4
  2. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/dem.py +0 -6
  3. maps4fs-2.2.72/maps4fs/generator/config.py +154 -0
  4. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/map.py +2 -0
  5. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs.egg-info/PKG-INFO +2 -4
  6. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs.egg-info/requires.txt +1 -3
  7. {maps4fs-2.2.71 → maps4fs-2.2.72}/pyproject.toml +2 -4
  8. maps4fs-2.2.71/maps4fs/generator/config.py +0 -93
  9. {maps4fs-2.2.71 → maps4fs-2.2.72}/LICENSE.md +0 -0
  10. {maps4fs-2.2.71 → maps4fs-2.2.72}/README.md +0 -0
  11. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/__init__.py +0 -0
  12. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/__init__.py +0 -0
  13. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/__init__.py +0 -0
  14. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/background.py +0 -0
  15. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/base/__init__.py +0 -0
  16. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/base/component.py +0 -0
  17. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/base/component_image.py +0 -0
  18. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/base/component_mesh.py +0 -0
  19. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/base/component_xml.py +0 -0
  20. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/config.py +0 -0
  21. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/grle.py +0 -0
  22. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/i3d.py +0 -0
  23. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/layer.py +0 -0
  24. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/satellite.py +0 -0
  25. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/component/texture.py +0 -0
  26. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/game.py +0 -0
  27. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/qgis.py +0 -0
  28. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/settings.py +0 -0
  29. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/statistics.py +0 -0
  30. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/generator/utils.py +0 -0
  31. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs/logger.py +0 -0
  32. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs.egg-info/SOURCES.txt +0 -0
  33. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs.egg-info/dependency_links.txt +0 -0
  34. {maps4fs-2.2.71 → maps4fs-2.2.72}/maps4fs.egg-info/top_level.txt +0 -0
  35. {maps4fs-2.2.71 → maps4fs-2.2.72}/setup.cfg +0 -0
  36. {maps4fs-2.2.71 → maps4fs-2.2.72}/tests/test_generator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maps4fs
3
- Version: 2.2.71
3
+ Version: 2.2.72
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
@@ -18,15 +18,13 @@ Requires-Dist: osmnx>=2.0.0
18
18
  Requires-Dist: rasterio
19
19
  Requires-Dist: geopy
20
20
  Requires-Dist: trimesh
21
- Requires-Dist: imageio
22
- Requires-Dist: tifffile
23
- Requires-Dist: pympler
24
21
  Requires-Dist: pydantic
25
22
  Requires-Dist: pygmdl
26
23
  Requires-Dist: owslib
27
24
  Requires-Dist: tqdm
28
25
  Requires-Dist: scipy
29
26
  Requires-Dist: pydtmdl
27
+ Requires-Dist: manifold3d
30
28
  Dynamic: license-file
31
29
 
32
30
  ⚠️ Learn more about the 2.0 changes in the [migration guide](docs/migration.md).
@@ -7,9 +7,6 @@ import cv2
7
7
  import numpy as np
8
8
  from pydtmdl import DTMProvider
9
9
 
10
- # import rasterio # type: ignore
11
- from pympler import asizeof # type: ignore
12
-
13
10
  import maps4fs.generator.config as mfscfg
14
11
  from maps4fs.generator.component.base.component_image import ImageComponent
15
12
 
@@ -297,9 +294,6 @@ class DEM(ImageComponent):
297
294
  """
298
295
  resampled_data = cv2.resize(data, self.output_resolution, interpolation=cv2.INTER_LINEAR)
299
296
 
300
- size_of_resampled_data = asizeof.asizeof(resampled_data) / 1024 / 1024
301
- self.logger.debug("Size of resampled data: %s MB.", size_of_resampled_data)
302
-
303
297
  return resampled_data
304
298
 
305
299
  def rotate_dem(self) -> None:
@@ -0,0 +1,154 @@
1
+ """This module contains configuration files for the maps4fs generator."""
2
+
3
+ import os
4
+ import shutil
5
+ import subprocess
6
+ import tempfile
7
+
8
+ from osmnx import settings as ox_settings
9
+
10
+ from maps4fs.logger import Logger
11
+
12
+ logger = Logger()
13
+
14
+ MFS_TEMPLATES_DIR = os.path.join(os.getcwd(), "data")
15
+
16
+
17
+ def ensure_templates():
18
+ """Ensure templates directory exists and is populated with data.
19
+
20
+ If MFS_TEMPLATES_DIR is empty or doesn't exist, clone the maps4fsdata
21
+ repository and run the preparation script to populate it.
22
+ """
23
+
24
+ # Check if templates directory exists and has content
25
+ if os.path.exists(MFS_TEMPLATES_DIR) and os.listdir(MFS_TEMPLATES_DIR):
26
+ logger.info("Templates directory already exists and contains data: %s", MFS_TEMPLATES_DIR)
27
+ return
28
+
29
+ logger.info("Templates directory is empty or missing, preparing data...")
30
+
31
+ # Create templates directory if it doesn't exist
32
+ os.makedirs(MFS_TEMPLATES_DIR, exist_ok=True)
33
+
34
+ try:
35
+ with tempfile.TemporaryDirectory() as temp_dir:
36
+ clone_dir = os.path.join(temp_dir, "maps4fsdata")
37
+
38
+ logger.info("Cloning maps4fsdata repository to temporary directory...")
39
+ # Clone the repository with depth 1 (shallow clone)
40
+ subprocess.run(
41
+ [
42
+ "git",
43
+ "clone",
44
+ "--depth",
45
+ "1",
46
+ "https://github.com/iwatkot/maps4fsdata.git",
47
+ clone_dir,
48
+ ],
49
+ check=True,
50
+ capture_output=True,
51
+ text=True,
52
+ )
53
+
54
+ # Make the preparation script executable
55
+ prep_script = os.path.join(clone_dir, "prepare_data.sh")
56
+ if os.path.exists(prep_script):
57
+ os.chmod(prep_script, 0o755)
58
+
59
+ logger.info("Running data preparation script...")
60
+ # Run the preparation script from the cloned directory
61
+ subprocess.run(
62
+ ["./prepare_data.sh"], cwd=clone_dir, check=True, capture_output=True, text=True
63
+ )
64
+
65
+ # Copy the generated data directory to templates directory
66
+ data_src = os.path.join(clone_dir, "data")
67
+ if os.path.exists(data_src):
68
+ logger.info(
69
+ "Copying prepared data to templates directory: %s", MFS_TEMPLATES_DIR
70
+ )
71
+ # Copy all files from data directory to MFS_TEMPLATES_DIR
72
+ for item in os.listdir(data_src):
73
+ src_path = os.path.join(data_src, item)
74
+ dst_path = os.path.join(MFS_TEMPLATES_DIR, item)
75
+ if os.path.isdir(src_path):
76
+ shutil.copytree(src_path, dst_path, dirs_exist_ok=True)
77
+ else:
78
+ shutil.copy2(src_path, dst_path)
79
+ logger.info("Templates data prepared successfully")
80
+ else:
81
+ logger.error("Data directory not found after running preparation script")
82
+ raise FileNotFoundError(
83
+ "Data preparation script did not create expected data directory"
84
+ )
85
+ else:
86
+ logger.error("Preparation script not found: %s", prep_script)
87
+ raise FileNotFoundError("prepare_data.sh not found in cloned repository")
88
+
89
+ except subprocess.CalledProcessError as e:
90
+ logger.error("Failed to prepare templates data: %s", str(e))
91
+ if e.stdout:
92
+ logger.error("Script stdout: %s", e.stdout)
93
+ if e.stderr:
94
+ logger.error("Script stderr: %s", e.stderr)
95
+ raise
96
+ except Exception as e:
97
+ logger.error("Error preparing templates: %s", str(e))
98
+ raise
99
+
100
+
101
+ ensure_templates()
102
+
103
+ MFS_ROOT_DIR = os.getenv("MFS_ROOT_DIRECTORY", os.path.join(os.getcwd(), "mfsrootdir"))
104
+ MFS_CACHE_DIR = os.path.join(MFS_ROOT_DIR, "cache")
105
+ MFS_DATA_DIR = os.path.join(MFS_ROOT_DIR, "data")
106
+ os.makedirs(MFS_CACHE_DIR, exist_ok=True)
107
+ os.makedirs(MFS_DATA_DIR, exist_ok=True)
108
+ logger.info(
109
+ "MFS_ROOT_DIR: %s. MFS_CACHE_DIR: %s. MFS_DATA_DIR: %s.",
110
+ MFS_ROOT_DIR,
111
+ MFS_CACHE_DIR,
112
+ MFS_DATA_DIR,
113
+ )
114
+
115
+ DTM_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "dtm")
116
+ SAT_CACHE_DIR = os.path.join(MFS_CACHE_DIR, "sat")
117
+
118
+ osmnx_cache = os.path.join(MFS_CACHE_DIR, "osmnx")
119
+ osmnx_data = os.path.join(MFS_CACHE_DIR, "odata")
120
+ os.makedirs(osmnx_cache, exist_ok=True)
121
+ os.makedirs(osmnx_data, exist_ok=True)
122
+
123
+
124
+ ox_settings.cache_folder = osmnx_cache
125
+ ox_settings.data_folder = osmnx_data
126
+
127
+
128
+ def get_package_version(package_name: str) -> str:
129
+ """Get the package version.
130
+
131
+ Arguments:
132
+ package_name (str): The name of the package to check.
133
+
134
+ Returns:
135
+ str: The version of the package, or "unknown" if it cannot be determined.
136
+ """
137
+ try:
138
+ result = subprocess.run(
139
+ [os.sys.executable, "-m", "pip", "show", package_name], # type: ignore
140
+ stdout=subprocess.PIPE,
141
+ stderr=subprocess.PIPE,
142
+ text=True,
143
+ check=True,
144
+ )
145
+ for line in result.stdout.splitlines():
146
+ if line.startswith("Version:"):
147
+ return line.split(":", 1)[1].strip()
148
+ return "unknown"
149
+ except Exception:
150
+ return "unknown"
151
+
152
+
153
+ PACKAGE_VERSION = get_package_version("maps4fs")
154
+ logger.info("maps4fs version: %s", PACKAGE_VERSION)
@@ -67,6 +67,8 @@ class Map:
67
67
 
68
68
  # region custom OSM properties
69
69
  self.custom_osm = custom_osm
70
+ if custom_osm and not os.path.isfile(custom_osm):
71
+ raise FileNotFoundError(f"Custom OSM file {custom_osm} does not exist.")
70
72
  mfsutils.check_and_fix_osm(self.custom_osm, save_directory=self.map_directory)
71
73
  # endregion
72
74
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maps4fs
3
- Version: 2.2.71
3
+ Version: 2.2.72
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
@@ -18,15 +18,13 @@ Requires-Dist: osmnx>=2.0.0
18
18
  Requires-Dist: rasterio
19
19
  Requires-Dist: geopy
20
20
  Requires-Dist: trimesh
21
- Requires-Dist: imageio
22
- Requires-Dist: tifffile
23
- Requires-Dist: pympler
24
21
  Requires-Dist: pydantic
25
22
  Requires-Dist: pygmdl
26
23
  Requires-Dist: owslib
27
24
  Requires-Dist: tqdm
28
25
  Requires-Dist: scipy
29
26
  Requires-Dist: pydtmdl
27
+ Requires-Dist: manifold3d
30
28
  Dynamic: license-file
31
29
 
32
30
  ⚠️ Learn more about the 2.0 changes in the [migration guide](docs/migration.md).
@@ -3,12 +3,10 @@ osmnx>=2.0.0
3
3
  rasterio
4
4
  geopy
5
5
  trimesh
6
- imageio
7
- tifffile
8
- pympler
9
6
  pydantic
10
7
  pygmdl
11
8
  owslib
12
9
  tqdm
13
10
  scipy
14
11
  pydtmdl
12
+ manifold3d
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maps4fs"
7
- version = "2.2.71"
7
+ version = "2.2.72"
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"}
@@ -22,15 +22,13 @@ dependencies = [
22
22
  "rasterio",
23
23
  "geopy",
24
24
  "trimesh",
25
- "imageio",
26
- "tifffile",
27
- "pympler",
28
25
  "pydantic",
29
26
  "pygmdl",
30
27
  "owslib",
31
28
  "tqdm",
32
29
  "scipy",
33
30
  "pydtmdl",
31
+ "manifold3d",
34
32
  ]
35
33
 
36
34
  [project.urls]
@@ -1,93 +0,0 @@
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)
File without changes
File without changes
File without changes
File without changes
File without changes