maps4fs 0.7.0__tar.gz → 0.7.1__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-0.7.0 → maps4fs-0.7.1}/PKG-INFO +6 -18
- {maps4fs-0.7.0 → maps4fs-0.7.1}/README.md +5 -16
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/dem.py +4 -33
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/map.py +0 -15
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs.egg-info/PKG-INFO +6 -18
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs.egg-info/requires.txt +0 -1
- {maps4fs-0.7.0 → maps4fs-0.7.1}/pyproject.toml +1 -2
- {maps4fs-0.7.0 → maps4fs-0.7.1}/tests/test_generator.py +1 -33
- {maps4fs-0.7.0 → maps4fs-0.7.1}/LICENSE.md +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/__init__.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/__init__.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/component.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/config.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/game.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/generator/texture.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs/logger.py +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs.egg-info/SOURCES.txt +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs.egg-info/dependency_links.txt +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/maps4fs.egg-info/top_level.txt +0 -0
- {maps4fs-0.7.0 → maps4fs-0.7.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.1
|
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
|
@@ -16,7 +16,6 @@ License-File: LICENSE.md
|
|
16
16
|
Requires-Dist: opencv-python
|
17
17
|
Requires-Dist: osmnx<2.0.0
|
18
18
|
Requires-Dist: rasterio
|
19
|
-
Requires-Dist: python_dotenv
|
20
19
|
Requires-Dist: tqdm
|
21
20
|
|
22
21
|
<div align="center" markdown>
|
@@ -87,16 +86,12 @@ The generator also creates a multiple previews of the map. Here's the list of th
|
|
87
86
|
2. Grayscale DEM preview - a grayscale image of the height map (as it is).
|
88
87
|
3. Colored DEM preview - a colored image of the height map (from blue to red). The blue color represents the lowest point, and the red color represents the highest point.
|
89
88
|
|
90
|
-
|
89
|
+
<br>
|
90
|
+
*Preview of a 16 km map with a 500-meter mountain in the middle of it.*<br>
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
2. Colored DEM preview with `max_height=200`.
|
96
|
-
3. Colored DEM preview with `max_height=50`.
|
97
|
-
|
98
|
-
As you can see there's a huge difference between images 2 and 3. The third (with lower `max_height`) will have a higher terrain contrast, and the second one will have lower differences between the terrain heights.<br>
|
99
|
-
There's no like "in real world" option, because FS system of coordinates does not work in meters or something like that when talking about DEM. So you need to experiment with the `max_height` parameter to get the desired result. To clarify: in the example above the difference on the platue is about 80 meters, so `max_height=50` made this like super mountainous terrain, and `max_height=200` made it like a plain.
|
92
|
+
Parameters:
|
93
|
+
- coordinates: 45.15, 19.71
|
94
|
+
- size: 16 x 16 km
|
100
95
|
|
101
96
|
## How-To-Run
|
102
97
|
|
@@ -163,8 +158,6 @@ map = mfs.Map(
|
|
163
158
|
(52.5200, 13.4050), # Latitude and longitude of the map center.
|
164
159
|
distance=1024, # The DISTANCE from the center to the edge of the map in meters. The map will be 2048x2048 meters.
|
165
160
|
map_directory="path/to/your/map/directory", # The directory where the map will be saved.
|
166
|
-
blur_seed=5, # The seed for the blur algorithm. The default value is 5, which means 5 meters.
|
167
|
-
max_height=400 # The maximum height of the map.
|
168
161
|
)
|
169
162
|
```
|
170
163
|
|
@@ -175,11 +168,6 @@ map.generate()
|
|
175
168
|
|
176
169
|
The map will be saved in the `map_directory` directory.
|
177
170
|
|
178
|
-
## Settings
|
179
|
-
Advanced settings are available in the tool's UI under the **Advanced Settings** tab. Here's the list of them:
|
180
|
-
- `max_height` - the maximum height of the map. The default value is 400. Select smaller values for plain-like maps and bigger values for mountainous maps. You may need to experiment with this value to get the desired result.
|
181
|
-
- `blur_seed` - the seed for the blur algorithm. The default value is 5, which means 5 meters. The bigger the value, the smoother the map will be. The smaller the value, the more detailed the map will be. Keep in mind that for some regions, where terrain is bumpy, disabling the blur algorithm may lead to a very rough map. So, I recommend leaving this value as it is.
|
182
|
-
|
183
171
|
## Features
|
184
172
|
- Allows to enter a location by lat and lon (e.g. from Google Maps).
|
185
173
|
- Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
|
@@ -66,16 +66,12 @@ The generator also creates a multiple previews of the map. Here's the list of th
|
|
66
66
|
2. Grayscale DEM preview - a grayscale image of the height map (as it is).
|
67
67
|
3. Colored DEM preview - a colored image of the height map (from blue to red). The blue color represents the lowest point, and the red color represents the highest point.
|
68
68
|
|
69
|
-
|
69
|
+
<br>
|
70
|
+
*Preview of a 16 km map with a 500-meter mountain in the middle of it.*<br>
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
2. Colored DEM preview with `max_height=200`.
|
75
|
-
3. Colored DEM preview with `max_height=50`.
|
76
|
-
|
77
|
-
As you can see there's a huge difference between images 2 and 3. The third (with lower `max_height`) will have a higher terrain contrast, and the second one will have lower differences between the terrain heights.<br>
|
78
|
-
There's no like "in real world" option, because FS system of coordinates does not work in meters or something like that when talking about DEM. So you need to experiment with the `max_height` parameter to get the desired result. To clarify: in the example above the difference on the platue is about 80 meters, so `max_height=50` made this like super mountainous terrain, and `max_height=200` made it like a plain.
|
72
|
+
Parameters:
|
73
|
+
- coordinates: 45.15, 19.71
|
74
|
+
- size: 16 x 16 km
|
79
75
|
|
80
76
|
## How-To-Run
|
81
77
|
|
@@ -142,8 +138,6 @@ map = mfs.Map(
|
|
142
138
|
(52.5200, 13.4050), # Latitude and longitude of the map center.
|
143
139
|
distance=1024, # The DISTANCE from the center to the edge of the map in meters. The map will be 2048x2048 meters.
|
144
140
|
map_directory="path/to/your/map/directory", # The directory where the map will be saved.
|
145
|
-
blur_seed=5, # The seed for the blur algorithm. The default value is 5, which means 5 meters.
|
146
|
-
max_height=400 # The maximum height of the map.
|
147
141
|
)
|
148
142
|
```
|
149
143
|
|
@@ -154,11 +148,6 @@ map.generate()
|
|
154
148
|
|
155
149
|
The map will be saved in the `map_directory` directory.
|
156
150
|
|
157
|
-
## Settings
|
158
|
-
Advanced settings are available in the tool's UI under the **Advanced Settings** tab. Here's the list of them:
|
159
|
-
- `max_height` - the maximum height of the map. The default value is 400. Select smaller values for plain-like maps and bigger values for mountainous maps. You may need to experiment with this value to get the desired result.
|
160
|
-
- `blur_seed` - the seed for the blur algorithm. The default value is 5, which means 5 meters. The bigger the value, the smoother the map will be. The smaller the value, the more detailed the map will be. Keep in mind that for some regions, where terrain is bumpy, disabling the blur algorithm may lead to a very rough map. So, I recommend leaving this value as it is.
|
161
|
-
|
162
151
|
## Features
|
163
152
|
- Allows to enter a location by lat and lon (e.g. from Google Maps).
|
164
153
|
- Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
|
@@ -29,9 +29,6 @@ class DEM(Component):
|
|
29
29
|
"""
|
30
30
|
|
31
31
|
def preprocess(self) -> None:
|
32
|
-
self._blur_seed: int = self.kwargs.get("blur_seed") or 5
|
33
|
-
self._max_height: int = self.kwargs.get("max_height") or 200
|
34
|
-
|
35
32
|
self._dem_path = self.game.dem_file_path(self.map_directory)
|
36
33
|
self.temp_dir = "temp"
|
37
34
|
self.hgt_dir = os.path.join(self.temp_dir, "hgt")
|
@@ -87,19 +84,17 @@ class DEM(Component):
|
|
87
84
|
f"Min: {data.min()}, max: {data.max()}."
|
88
85
|
)
|
89
86
|
|
90
|
-
normalized_data = self._normalize_dem(data)
|
91
|
-
|
92
87
|
resampled_data = cv2.resize(
|
93
|
-
|
94
|
-
)
|
88
|
+
data, dem_output_resolution, interpolation=cv2.INTER_LINEAR
|
89
|
+
).astype("uint16")
|
90
|
+
|
95
91
|
self.logger.debug(
|
96
92
|
f"DEM data was resampled. Shape: {resampled_data.shape}, "
|
97
93
|
f"dtype: {resampled_data.dtype}. "
|
98
94
|
f"Min: {resampled_data.min()}, max: {resampled_data.max()}."
|
99
95
|
)
|
100
96
|
|
101
|
-
|
102
|
-
cv2.imwrite(self._dem_path, blurred_data)
|
97
|
+
cv2.imwrite(self._dem_path, resampled_data)
|
103
98
|
self.logger.debug("DEM data was saved to %s.", self._dem_path)
|
104
99
|
|
105
100
|
def _tile_info(self, lat: float, lon: float) -> tuple[str, str]:
|
@@ -182,30 +177,6 @@ class DEM(Component):
|
|
182
177
|
cv2.imwrite(self._dem_path, dem_data) # pylint: disable=no-member
|
183
178
|
self.logger.warning("DEM data filled with zeros and saved to %s.", self._dem_path)
|
184
179
|
|
185
|
-
def _normalize_dem(self, data: np.ndarray) -> np.ndarray:
|
186
|
-
"""Normalize DEM data to 16-bit unsigned integer using max height from settings.
|
187
|
-
|
188
|
-
Args:
|
189
|
-
data (np.ndarray): DEM data from SRTM file after cropping.
|
190
|
-
|
191
|
-
Returns:
|
192
|
-
np.ndarray: Normalized DEM data.
|
193
|
-
"""
|
194
|
-
max_dev = data.max() - data.min()
|
195
|
-
scaling_factor = max_dev / self._max_height if max_dev < self._max_height else 1
|
196
|
-
adjusted_max_height = int(65535 * scaling_factor)
|
197
|
-
self.logger.debug(
|
198
|
-
f"Maximum deviation: {max_dev}. Scaling factor: {scaling_factor}. "
|
199
|
-
f"Adjusted max height: {adjusted_max_height}."
|
200
|
-
)
|
201
|
-
normalized_data = (
|
202
|
-
(data - data.min()) / (data.max() - data.min()) * adjusted_max_height
|
203
|
-
).astype("uint16")
|
204
|
-
self.logger.debug(
|
205
|
-
f"DEM data was normalized to {normalized_data.min()} - {normalized_data.max()}."
|
206
|
-
)
|
207
|
-
return normalized_data
|
208
|
-
|
209
180
|
def grayscale_preview(self) -> str:
|
210
181
|
"""Converts DEM image to grayscale RGB image and saves it to the map directory.
|
211
182
|
Returns path to the preview image.
|
@@ -20,8 +20,6 @@ class Map:
|
|
20
20
|
coordinates (tuple[float, float]): Coordinates of the center of the map.
|
21
21
|
distance (int): Distance from the center of the map.
|
22
22
|
map_directory (str): Path to the directory where map files will be stored.
|
23
|
-
blur_seed (int): Seed used for blur effect.
|
24
|
-
max_height (int): Maximum height of the map.
|
25
23
|
logger (Any): Logger instance
|
26
24
|
"""
|
27
25
|
|
@@ -31,8 +29,6 @@ class Map:
|
|
31
29
|
coordinates: tuple[float, float],
|
32
30
|
distance: int,
|
33
31
|
map_directory: str,
|
34
|
-
blur_seed: int,
|
35
|
-
max_height: int,
|
36
32
|
logger: Any = None,
|
37
33
|
):
|
38
34
|
self.game = game
|
@@ -55,15 +51,6 @@ class Map:
|
|
55
51
|
except Exception as e:
|
56
52
|
raise RuntimeError(f"Can not unpack map template due to error: {e}") from e
|
57
53
|
|
58
|
-
# Blur seed should be positive and odd.
|
59
|
-
if blur_seed <= 0:
|
60
|
-
raise ValueError("Blur seed should be positive.")
|
61
|
-
if blur_seed % 2 == 0:
|
62
|
-
blur_seed += 1
|
63
|
-
|
64
|
-
self.blur_seed = blur_seed
|
65
|
-
self.max_height = max_height
|
66
|
-
|
67
54
|
def generate(self) -> None:
|
68
55
|
"""Launch map generation using all components."""
|
69
56
|
with tqdm(total=len(self.game.components), desc="Generating map...") as pbar:
|
@@ -74,8 +61,6 @@ class Map:
|
|
74
61
|
self.distance,
|
75
62
|
self.map_directory,
|
76
63
|
self.logger,
|
77
|
-
blur_seed=self.blur_seed,
|
78
|
-
max_height=self.max_height,
|
79
64
|
)
|
80
65
|
try:
|
81
66
|
component.process()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.1
|
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
|
@@ -16,7 +16,6 @@ License-File: LICENSE.md
|
|
16
16
|
Requires-Dist: opencv-python
|
17
17
|
Requires-Dist: osmnx<2.0.0
|
18
18
|
Requires-Dist: rasterio
|
19
|
-
Requires-Dist: python_dotenv
|
20
19
|
Requires-Dist: tqdm
|
21
20
|
|
22
21
|
<div align="center" markdown>
|
@@ -87,16 +86,12 @@ The generator also creates a multiple previews of the map. Here's the list of th
|
|
87
86
|
2. Grayscale DEM preview - a grayscale image of the height map (as it is).
|
88
87
|
3. Colored DEM preview - a colored image of the height map (from blue to red). The blue color represents the lowest point, and the red color represents the highest point.
|
89
88
|
|
90
|
-
|
89
|
+
<br>
|
90
|
+
*Preview of a 16 km map with a 500-meter mountain in the middle of it.*<br>
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
2. Colored DEM preview with `max_height=200`.
|
96
|
-
3. Colored DEM preview with `max_height=50`.
|
97
|
-
|
98
|
-
As you can see there's a huge difference between images 2 and 3. The third (with lower `max_height`) will have a higher terrain contrast, and the second one will have lower differences between the terrain heights.<br>
|
99
|
-
There's no like "in real world" option, because FS system of coordinates does not work in meters or something like that when talking about DEM. So you need to experiment with the `max_height` parameter to get the desired result. To clarify: in the example above the difference on the platue is about 80 meters, so `max_height=50` made this like super mountainous terrain, and `max_height=200` made it like a plain.
|
92
|
+
Parameters:
|
93
|
+
- coordinates: 45.15, 19.71
|
94
|
+
- size: 16 x 16 km
|
100
95
|
|
101
96
|
## How-To-Run
|
102
97
|
|
@@ -163,8 +158,6 @@ map = mfs.Map(
|
|
163
158
|
(52.5200, 13.4050), # Latitude and longitude of the map center.
|
164
159
|
distance=1024, # The DISTANCE from the center to the edge of the map in meters. The map will be 2048x2048 meters.
|
165
160
|
map_directory="path/to/your/map/directory", # The directory where the map will be saved.
|
166
|
-
blur_seed=5, # The seed for the blur algorithm. The default value is 5, which means 5 meters.
|
167
|
-
max_height=400 # The maximum height of the map.
|
168
161
|
)
|
169
162
|
```
|
170
163
|
|
@@ -175,11 +168,6 @@ map.generate()
|
|
175
168
|
|
176
169
|
The map will be saved in the `map_directory` directory.
|
177
170
|
|
178
|
-
## Settings
|
179
|
-
Advanced settings are available in the tool's UI under the **Advanced Settings** tab. Here's the list of them:
|
180
|
-
- `max_height` - the maximum height of the map. The default value is 400. Select smaller values for plain-like maps and bigger values for mountainous maps. You may need to experiment with this value to get the desired result.
|
181
|
-
- `blur_seed` - the seed for the blur algorithm. The default value is 5, which means 5 meters. The bigger the value, the smoother the map will be. The smaller the value, the more detailed the map will be. Keep in mind that for some regions, where terrain is bumpy, disabling the blur algorithm may lead to a very rough map. So, I recommend leaving this value as it is.
|
182
|
-
|
183
171
|
## Features
|
184
172
|
- Allows to enter a location by lat and lon (e.g. from Google Maps).
|
185
173
|
- Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "maps4fs"
|
7
|
-
version = "0.7.
|
7
|
+
version = "0.7.1"
|
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 = "MIT License"}
|
@@ -20,7 +20,6 @@ dependencies = [
|
|
20
20
|
"opencv-python",
|
21
21
|
"osmnx<2.0.0",
|
22
22
|
"rasterio",
|
23
|
-
"python_dotenv",
|
24
23
|
"tqdm",
|
25
24
|
]
|
26
25
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import json
|
2
2
|
import os
|
3
3
|
import shutil
|
4
|
-
from random import choice
|
4
|
+
from random import choice
|
5
5
|
from time import time
|
6
6
|
|
7
7
|
import cv2
|
@@ -9,8 +9,6 @@ import cv2
|
|
9
9
|
from maps4fs import Map
|
10
10
|
from maps4fs.generator.game import Game
|
11
11
|
|
12
|
-
# from maps4fs.generator.texture import TEXTURES
|
13
|
-
|
14
12
|
working_directory = os.getcwd()
|
15
13
|
|
16
14
|
base_directory = os.path.join(working_directory, "tests/data")
|
@@ -40,24 +38,6 @@ def random_distance() -> int:
|
|
40
38
|
return choice(distances_cases[:2]) # Larger maps are too slow for automated tests.
|
41
39
|
|
42
40
|
|
43
|
-
def random_blur_seed() -> int:
|
44
|
-
"""Return random blur seed.
|
45
|
-
|
46
|
-
Returns:
|
47
|
-
int: Random blur seed.
|
48
|
-
"""
|
49
|
-
return randint(1, 30)
|
50
|
-
|
51
|
-
|
52
|
-
def random_max_height() -> int:
|
53
|
-
"""Return random max height.
|
54
|
-
|
55
|
-
Returns:
|
56
|
-
int: Random max height.
|
57
|
-
"""
|
58
|
-
return randint(100, 3000)
|
59
|
-
|
60
|
-
|
61
41
|
def map_directory() -> str:
|
62
42
|
"""Creates a new map directory and returns its path.
|
63
43
|
|
@@ -89,8 +69,6 @@ def test_map():
|
|
89
69
|
game = Game.from_code(game_code)
|
90
70
|
for coordinates in coordinates_cases:
|
91
71
|
distance = random_distance()
|
92
|
-
blur_seed = random_blur_seed()
|
93
|
-
max_height = random_max_height()
|
94
72
|
directory = map_directory()
|
95
73
|
|
96
74
|
map = Map(
|
@@ -98,8 +76,6 @@ def test_map():
|
|
98
76
|
coordinates=coordinates,
|
99
77
|
distance=distance,
|
100
78
|
map_directory=directory,
|
101
|
-
blur_seed=blur_seed,
|
102
|
-
max_height=max_height,
|
103
79
|
)
|
104
80
|
|
105
81
|
map.generate()
|
@@ -142,8 +118,6 @@ def test_map_preview():
|
|
142
118
|
"""Test Map preview generation."""
|
143
119
|
case = choice(coordinates_cases)
|
144
120
|
distance = random_distance()
|
145
|
-
blur_seed = random_blur_seed()
|
146
|
-
max_height = random_max_height()
|
147
121
|
|
148
122
|
game_code = choice(game_code_cases)
|
149
123
|
game = Game.from_code(game_code)
|
@@ -154,8 +128,6 @@ def test_map_preview():
|
|
154
128
|
coordinates=case,
|
155
129
|
distance=distance,
|
156
130
|
map_directory=directory,
|
157
|
-
blur_seed=blur_seed,
|
158
|
-
max_height=max_height,
|
159
131
|
)
|
160
132
|
map.generate()
|
161
133
|
previews_paths = map.previews()
|
@@ -169,8 +141,6 @@ def test_map_pack():
|
|
169
141
|
"""Test Map packing into zip archive."""
|
170
142
|
case = choice(coordinates_cases)
|
171
143
|
distance = random_distance()
|
172
|
-
blur_seed = random_blur_seed()
|
173
|
-
max_height = random_max_height()
|
174
144
|
|
175
145
|
game_code = choice(game_code_cases)
|
176
146
|
game = Game.from_code(game_code)
|
@@ -181,8 +151,6 @@ def test_map_pack():
|
|
181
151
|
coordinates=case,
|
182
152
|
distance=distance,
|
183
153
|
map_directory=directory,
|
184
|
-
blur_seed=blur_seed,
|
185
|
-
max_height=max_height,
|
186
154
|
)
|
187
155
|
map.generate()
|
188
156
|
archive_name = os.path.join(base_directory, "archive")
|
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
|