maps4fs 2.2.71__py3-none-any.whl → 2.2.72__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.
- maps4fs/generator/component/dem.py +0 -6
- maps4fs/generator/config.py +88 -27
- maps4fs/generator/map.py +2 -0
- {maps4fs-2.2.71.dist-info → maps4fs-2.2.72.dist-info}/METADATA +2 -4
- {maps4fs-2.2.71.dist-info → maps4fs-2.2.72.dist-info}/RECORD +8 -8
- {maps4fs-2.2.71.dist-info → maps4fs-2.2.72.dist-info}/WHEEL +0 -0
- {maps4fs-2.2.71.dist-info → maps4fs-2.2.72.dist-info}/licenses/LICENSE.md +0 -0
- {maps4fs-2.2.71.dist-info → maps4fs-2.2.72.dist-info}/top_level.txt +0 -0
@@ -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:
|
maps4fs/generator/config.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
import os
|
4
4
|
import shutil
|
5
5
|
import subprocess
|
6
|
+
import tempfile
|
6
7
|
|
7
8
|
from osmnx import settings as ox_settings
|
8
9
|
|
@@ -10,34 +11,94 @@ from maps4fs.logger import Logger
|
|
10
11
|
|
11
12
|
logger = Logger()
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
+
)
|
32
85
|
else:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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()
|
41
102
|
|
42
103
|
MFS_ROOT_DIR = os.getenv("MFS_ROOT_DIRECTORY", os.path.join(os.getcwd(), "mfsrootdir"))
|
43
104
|
MFS_CACHE_DIR = os.path.join(MFS_ROOT_DIR, "cache")
|
maps4fs/generator/map.py
CHANGED
@@ -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.
|
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).
|
@@ -1,9 +1,9 @@
|
|
1
1
|
maps4fs/__init__.py,sha256=5ixsCA5vgcIV0OrF9EJBm91Mmc_KfMiDRM-QyifMAvo,386
|
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=
|
4
|
+
maps4fs/generator/config.py,sha256=vJ5Qff3V8C6I2VVyksz8XcwtLST9gtvSqOBhqBoMZT8,5489
|
5
5
|
maps4fs/generator/game.py,sha256=nf6iuYNA5NJc-ir_WOgkw-MdJVgetVHeEtxbWJYt3Vo,14462
|
6
|
-
maps4fs/generator/map.py,sha256=
|
6
|
+
maps4fs/generator/map.py,sha256=5at6Dlk1nk2dGr46rjjuQvq4hUNpbvchIoc8ahrKNag,12723
|
7
7
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
8
8
|
maps4fs/generator/settings.py,sha256=LX1Y4_8cisiel2fMvoRuxMypJlmysEHenM4SZ5oqw5o,13052
|
9
9
|
maps4fs/generator/statistics.py,sha256=Dp1-NS-DWv0l0UdmhOoXeQs_N-Hs7svYUnmziSW5Z9I,2098
|
@@ -11,7 +11,7 @@ maps4fs/generator/utils.py,sha256=ugdQ8C22NeiZLIlldLoEKCc7ioOefz4W-8qF2eOy9qU,48
|
|
11
11
|
maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
|
12
12
|
maps4fs/generator/component/background.py,sha256=rUDTPduNCD7KKt_eoVWN4XVSVgjwGSoLNPbZOzpGx7E,34532
|
13
13
|
maps4fs/generator/component/config.py,sha256=uL76h9UwyhZKZmbxz0mBmWtEPN6qYay4epTEqqtej60,8601
|
14
|
-
maps4fs/generator/component/dem.py,sha256=
|
14
|
+
maps4fs/generator/component/dem.py,sha256=FPqcXmFQg5MPaGuy4g5kxzvY1wbhozeCf-aNMCj5eaU,11687
|
15
15
|
maps4fs/generator/component/grle.py,sha256=0PC1K829wjD4y4d9qfIbnU29ebjflIPBbwIZx8FXwc8,27242
|
16
16
|
maps4fs/generator/component/i3d.py,sha256=RvpiW9skkZ6McyahC-AeIdPuSQjpXiFs1l0xOioJAu4,26638
|
17
17
|
maps4fs/generator/component/layer.py,sha256=bdy1XGOODyPqYUM3b_wEY2H9Piz-AaHsCDecl-qRHiM,6627
|
@@ -22,8 +22,8 @@ maps4fs/generator/component/base/component.py,sha256=lf0V9CLUXMg88Nm2yI3rP5taVYY
|
|
22
22
|
maps4fs/generator/component/base/component_image.py,sha256=WTGC6v1KuS5sLNCC95Z48nCspvATKKNOuhTNYzTWXr4,8315
|
23
23
|
maps4fs/generator/component/base/component_mesh.py,sha256=3hC-qDT8Vde6SmRMqs9USAkrF-gL2dDTYW71ATpxUS4,9130
|
24
24
|
maps4fs/generator/component/base/component_xml.py,sha256=MT-VhU2dEckLFxAgmxg6V3gnv11di_94Qq6atfpOLdc,5342
|
25
|
-
maps4fs-2.2.
|
26
|
-
maps4fs-2.2.
|
27
|
-
maps4fs-2.2.
|
28
|
-
maps4fs-2.2.
|
29
|
-
maps4fs-2.2.
|
25
|
+
maps4fs-2.2.72.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
26
|
+
maps4fs-2.2.72.dist-info/METADATA,sha256=Rps1HNin3PYU98Oo_olUxMx2STbIlWCmODd6kwaToxs,46271
|
27
|
+
maps4fs-2.2.72.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
28
|
+
maps4fs-2.2.72.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
29
|
+
maps4fs-2.2.72.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|