maps4fs 0.9.8__py3-none-any.whl → 0.9.92__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/dem.py +33 -0
- maps4fs/generator/map.py +8 -4
- {maps4fs-0.9.8.dist-info → maps4fs-0.9.92.dist-info}/METADATA +2 -1
- {maps4fs-0.9.8.dist-info → maps4fs-0.9.92.dist-info}/RECORD +7 -7
- {maps4fs-0.9.8.dist-info → maps4fs-0.9.92.dist-info}/LICENSE.md +0 -0
- {maps4fs-0.9.8.dist-info → maps4fs-0.9.92.dist-info}/WHEEL +0 -0
- {maps4fs-0.9.8.dist-info → maps4fs-0.9.92.dist-info}/top_level.txt +0 -0
maps4fs/generator/dem.py
CHANGED
@@ -9,6 +9,7 @@ import cv2
|
|
9
9
|
import numpy as np
|
10
10
|
import rasterio # type: ignore
|
11
11
|
import requests
|
12
|
+
from pympler import asizeof # type: ignore
|
12
13
|
|
13
14
|
from maps4fs.generator.component import Component
|
14
15
|
|
@@ -79,6 +80,22 @@ class DEM(Component):
|
|
79
80
|
)
|
80
81
|
return dem_width, dem_height
|
81
82
|
|
83
|
+
def to_ground(self, data: np.ndarray) -> np.ndarray:
|
84
|
+
"""Receives the signed 16-bit integer array and converts it to the ground level.
|
85
|
+
If the min value is negative, it will become zero value and the rest of the values
|
86
|
+
will be shifted accordingly.
|
87
|
+
"""
|
88
|
+
# For examlem, min value was -50, it will become 0 and for all values we'll +50.
|
89
|
+
|
90
|
+
if data.min() < 0:
|
91
|
+
self.logger.debug("Array contains negative values, will be shifted to the ground.")
|
92
|
+
data = data + abs(data.min())
|
93
|
+
|
94
|
+
self.logger.debug(
|
95
|
+
"Array was shifted to the ground. Min: %s, max: %s.", data.min(), data.max()
|
96
|
+
)
|
97
|
+
return data
|
98
|
+
|
82
99
|
# pylint: disable=no-member
|
83
100
|
def process(self) -> None:
|
84
101
|
"""Reads SRTM file, crops it to map size, normalizes and blurs it,
|
@@ -119,10 +136,15 @@ class DEM(Component):
|
|
119
136
|
data.max(),
|
120
137
|
)
|
121
138
|
|
139
|
+
data = self.to_ground(data)
|
140
|
+
|
122
141
|
resampled_data = cv2.resize(
|
123
142
|
data, dem_output_resolution, interpolation=cv2.INTER_LINEAR
|
124
143
|
).astype("uint16")
|
125
144
|
|
145
|
+
size_of_resampled_data = asizeof.asizeof(resampled_data) / 1024 / 1024
|
146
|
+
self.logger.debug("Size of resampled data: %s MB.", size_of_resampled_data)
|
147
|
+
|
126
148
|
self.logger.debug(
|
127
149
|
"Maximum value in resampled data: %s, minimum value: %s.",
|
128
150
|
resampled_data.max(),
|
@@ -135,6 +157,17 @@ class DEM(Component):
|
|
135
157
|
else:
|
136
158
|
self.logger.debug("Auto processing is disabled, DEM data will not be normalized.")
|
137
159
|
resampled_data = resampled_data * self.multiplier
|
160
|
+
|
161
|
+
self.logger.debug(
|
162
|
+
"DEM data was multiplied by %s. Min: %s, max: %s.",
|
163
|
+
self.multiplier,
|
164
|
+
resampled_data.min(),
|
165
|
+
resampled_data.max(),
|
166
|
+
)
|
167
|
+
|
168
|
+
size_of_resampled_data = asizeof.asizeof(resampled_data) / 1024 / 1024
|
169
|
+
self.logger.debug("Size of resampled data: %s MB.", size_of_resampled_data)
|
170
|
+
|
138
171
|
# Clip values to 16-bit unsigned integer range.
|
139
172
|
resampled_data = np.clip(resampled_data, 0, 65535)
|
140
173
|
resampled_data = resampled_data.astype("uint16")
|
maps4fs/generator/map.py
CHANGED
@@ -116,15 +116,19 @@ class Map:
|
|
116
116
|
)
|
117
117
|
return previews
|
118
118
|
|
119
|
-
def pack(self,
|
119
|
+
def pack(self, archive_path: str, remove_source: bool = True) -> str:
|
120
120
|
"""Pack map directory to zip archive.
|
121
121
|
|
122
122
|
Args:
|
123
|
-
|
123
|
+
archive_path (str): Path to the archive.
|
124
|
+
remove_source (bool, optional): Remove source directory after packing.
|
124
125
|
|
125
126
|
Returns:
|
126
127
|
str: Path to the archive.
|
127
128
|
"""
|
128
|
-
archive_path = shutil.make_archive(
|
129
|
-
self.logger.info("Map packed to %s.zip",
|
129
|
+
archive_path = shutil.make_archive(archive_path, "zip", self.map_directory)
|
130
|
+
self.logger.info("Map packed to %s.zip", archive_path)
|
131
|
+
if remove_source:
|
132
|
+
shutil.rmtree(self.map_directory)
|
133
|
+
self.logger.info("Map directory removed: %s", self.map_directory)
|
130
134
|
return archive_path
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.92
|
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
|
@@ -21,6 +21,7 @@ Requires-Dist: geopy
|
|
21
21
|
Requires-Dist: trimesh
|
22
22
|
Requires-Dist: imageio
|
23
23
|
Requires-Dist: tifffile
|
24
|
+
Requires-Dist: pympler
|
24
25
|
|
25
26
|
<div align="center" markdown>
|
26
27
|
<a href="https://discord.gg/Sj5QKKyE42">
|
@@ -4,18 +4,18 @@ maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk
|
|
4
4
|
maps4fs/generator/background.py,sha256=AP-Z3F-4I9achvA9xsaXAAoA6IHtmPLxb1RkUsVYdbg,14036
|
5
5
|
maps4fs/generator/component.py,sha256=ZEDjChPnvqAsgnBu2f2YBOlwGOlfax4VaAYBcJerLIQ,10684
|
6
6
|
maps4fs/generator/config.py,sha256=ZO5BWDU-S3p0-ndKDSFa8Oin3YcYy0iH8B4lqEA_07Q,4275
|
7
|
-
maps4fs/generator/dem.py,sha256=
|
7
|
+
maps4fs/generator/dem.py,sha256=7UnIUnXbN3OVMSHKgrFcyzWYCMgk6vIg1-ehrNn4ek8,17042
|
8
8
|
maps4fs/generator/game.py,sha256=94HjPNOyy6XSSOnBp-uxrkBglKyC-X3ULIrrucfdlKw,6825
|
9
9
|
maps4fs/generator/i3d.py,sha256=UuQiQRusPQ2f6PvGKxJ_UZeXsx3uG15efmy8Ysnm3F8,3597
|
10
|
-
maps4fs/generator/map.py,sha256=
|
10
|
+
maps4fs/generator/map.py,sha256=_LQe54KLfS_4M462UiiNSqKyUroqnQ8inwXZIZDP9a0,4487
|
11
11
|
maps4fs/generator/path_steps.py,sha256=yeN6hmOD8O2LMozUf4HcQMIy8WJ5sHF5pGQT_s2FfOw,3147
|
12
12
|
maps4fs/generator/qgis.py,sha256=R5Iv3ovyLXkhAL5Oy41u3ZLNOSEbc1byLetzPootO7o,6091
|
13
13
|
maps4fs/generator/texture.py,sha256=CwaXZfAG4e3D3YR7yVR2MC677EHpbUWTboCS3G6jkhk,17723
|
14
14
|
maps4fs/generator/tile.py,sha256=3vmfjQiPiiUZKPuIo5tg2rOKkgcP1NRVkMGK-Vo10-A,2138
|
15
15
|
maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
16
16
|
maps4fs/toolbox/dem.py,sha256=53KVZ6IKIlK642eYFSRDAC8l2HL9IEUpQNYkkTC56uU,3510
|
17
|
-
maps4fs-0.9.
|
18
|
-
maps4fs-0.9.
|
19
|
-
maps4fs-0.9.
|
20
|
-
maps4fs-0.9.
|
21
|
-
maps4fs-0.9.
|
17
|
+
maps4fs-0.9.92.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
|
18
|
+
maps4fs-0.9.92.dist-info/METADATA,sha256=wQTqG8ZcfeJYv4IYn9vIor9WtK36JnxPFAbjzTV-Tqw,25194
|
19
|
+
maps4fs-0.9.92.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
20
|
+
maps4fs-0.9.92.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
21
|
+
maps4fs-0.9.92.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|