maps4fs 0.6.8__py3-none-any.whl → 0.7.2__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.py +48 -4
- maps4fs/generator/config.py +17 -6
- maps4fs/generator/dem.py +72 -39
- maps4fs/generator/map.py +20 -22
- maps4fs/generator/texture.py +11 -11
- {maps4fs-0.6.8.dist-info → maps4fs-0.7.2.dist-info}/METADATA +31 -14
- maps4fs-0.7.2.dist-info/RECORD +14 -0
- maps4fs-0.6.8.dist-info/RECORD +0 -14
- {maps4fs-0.6.8.dist-info → maps4fs-0.7.2.dist-info}/LICENSE.md +0 -0
- {maps4fs-0.6.8.dist-info → maps4fs-0.7.2.dist-info}/WHEEL +0 -0
- {maps4fs-0.6.8.dist-info → maps4fs-0.7.2.dist-info}/top_level.txt +0 -0
maps4fs/generator/component.py
CHANGED
@@ -4,17 +4,20 @@ from __future__ import annotations
|
|
4
4
|
|
5
5
|
from typing import TYPE_CHECKING, Any
|
6
6
|
|
7
|
+
import osmnx as ox # type: ignore
|
8
|
+
|
7
9
|
if TYPE_CHECKING:
|
8
10
|
from maps4fs.generator.game import Game
|
9
11
|
|
10
12
|
|
11
|
-
# pylint: disable=R0801, R0903
|
13
|
+
# pylint: disable=R0801, R0903, R0902
|
12
14
|
class Component:
|
13
15
|
"""Base class for all map generation components.
|
14
16
|
|
15
17
|
Args:
|
16
18
|
coordinates (tuple[float, float]): The latitude and longitude of the center of the map.
|
17
|
-
|
19
|
+
map_height (int): The height of the map in pixels.
|
20
|
+
map_width (int): The width of the map in pixels.
|
18
21
|
map_directory (str): The directory where the map files are stored.
|
19
22
|
logger (Any, optional): The logger to use. Must have at least three basic methods: debug,
|
20
23
|
info, warning. If not provided, default logging will be used.
|
@@ -24,18 +27,21 @@ class Component:
|
|
24
27
|
self,
|
25
28
|
game: Game,
|
26
29
|
coordinates: tuple[float, float],
|
27
|
-
|
30
|
+
map_height: int,
|
31
|
+
map_width: int,
|
28
32
|
map_directory: str,
|
29
33
|
logger: Any = None,
|
30
34
|
**kwargs, # pylint: disable=W0613, R0913, R0917
|
31
35
|
):
|
32
36
|
self.game = game
|
33
37
|
self.coordinates = coordinates
|
34
|
-
self.
|
38
|
+
self.map_height = map_height
|
39
|
+
self.map_width = map_width
|
35
40
|
self.map_directory = map_directory
|
36
41
|
self.logger = logger
|
37
42
|
self.kwargs = kwargs
|
38
43
|
|
44
|
+
self.save_bbox()
|
39
45
|
self.preprocess()
|
40
46
|
|
41
47
|
def preprocess(self) -> None:
|
@@ -53,3 +59,41 @@ class Component:
|
|
53
59
|
NotImplementedError: If the method is not implemented in the child class.
|
54
60
|
"""
|
55
61
|
raise NotImplementedError
|
62
|
+
|
63
|
+
def previews(self) -> list[str]:
|
64
|
+
"""Returns a list of paths to the preview images. Must be implemented in the child class.
|
65
|
+
|
66
|
+
Raises:
|
67
|
+
NotImplementedError: If the method is not implemented in the child class.
|
68
|
+
"""
|
69
|
+
raise NotImplementedError
|
70
|
+
|
71
|
+
def get_bbox(self, project_utm: bool = False) -> tuple[int, int, int, int]:
|
72
|
+
"""Calculates the bounding box of the map from the coordinates and the height and
|
73
|
+
width of the map.
|
74
|
+
|
75
|
+
Args:
|
76
|
+
project_utm (bool, optional): Whether to project the bounding box to UTM.
|
77
|
+
|
78
|
+
Returns:
|
79
|
+
tuple[int, int, int, int]: The bounding box of the map.
|
80
|
+
"""
|
81
|
+
north, south, _, _ = ox.utils_geo.bbox_from_point(
|
82
|
+
self.coordinates, dist=self.map_height / 2, project_utm=project_utm
|
83
|
+
)
|
84
|
+
_, _, east, west = ox.utils_geo.bbox_from_point(
|
85
|
+
self.coordinates, dist=self.map_width / 2, project_utm=project_utm
|
86
|
+
)
|
87
|
+
bbox = north, south, east, west
|
88
|
+
self.logger.debug(
|
89
|
+
f"Calculated bounding box for component: {self.__class__.__name__}: {bbox}, "
|
90
|
+
f"project_utm: {project_utm}"
|
91
|
+
)
|
92
|
+
return bbox
|
93
|
+
|
94
|
+
def save_bbox(self) -> None:
|
95
|
+
"""Saves the bounding box of the map to the component instance from the coordinates and the
|
96
|
+
height and width of the map.
|
97
|
+
"""
|
98
|
+
self.bbox = self.get_bbox(project_utm=False)
|
99
|
+
self.logger.debug(f"Saved bounding box: {self.bbox}")
|
maps4fs/generator/config.py
CHANGED
@@ -14,7 +14,8 @@ class Config(Component):
|
|
14
14
|
|
15
15
|
Args:
|
16
16
|
coordinates (tuple[float, float]): The latitude and longitude of the center of the map.
|
17
|
-
|
17
|
+
map_height (int): The height of the map in pixels.
|
18
|
+
map_width (int): The width of the map in pixels.
|
18
19
|
map_directory (str): The directory where the map files are stored.
|
19
20
|
logger (Any, optional): The logger to use. Must have at least three basic methods: debug,
|
20
21
|
info, warning. If not provided, default logging will be used.
|
@@ -22,7 +23,7 @@ class Config(Component):
|
|
22
23
|
|
23
24
|
def preprocess(self) -> None:
|
24
25
|
self._map_xml_path = self.game.map_xml_path(self.map_directory)
|
25
|
-
self.logger.debug(
|
26
|
+
self.logger.debug("Map XML path: %s.", self._map_xml_path)
|
26
27
|
|
27
28
|
def process(self):
|
28
29
|
self._set_map_size()
|
@@ -36,9 +37,19 @@ class Config(Component):
|
|
36
37
|
self.logger.debug("Map XML file loaded from: %s.", self._map_xml_path)
|
37
38
|
root = tree.getroot()
|
38
39
|
for map_elem in root.iter("map"):
|
39
|
-
width
|
40
|
-
map_elem.set("
|
41
|
-
|
42
|
-
|
40
|
+
map_elem.set("width", str(self.map_width))
|
41
|
+
map_elem.set("height", str(self.map_height))
|
42
|
+
self.logger.debug(
|
43
|
+
"Map size set to %sx%s in Map XML file.", self.map_width, self.map_height
|
44
|
+
)
|
43
45
|
tree.write(self._map_xml_path)
|
44
46
|
self.logger.debug("Map XML file saved to: %s.", self._map_xml_path)
|
47
|
+
|
48
|
+
def previews(self) -> list[str]:
|
49
|
+
"""Returns a list of paths to the preview images (empty list).
|
50
|
+
The component does not generate any preview images so it returns an empty list.
|
51
|
+
|
52
|
+
Returns:
|
53
|
+
list[str]: An empty list.
|
54
|
+
"""
|
55
|
+
return []
|
maps4fs/generator/dem.py
CHANGED
@@ -7,13 +7,14 @@ import shutil
|
|
7
7
|
|
8
8
|
import cv2
|
9
9
|
import numpy as np
|
10
|
-
import osmnx as ox # type: ignore
|
11
10
|
import rasterio # type: ignore
|
12
11
|
import requests
|
13
12
|
|
14
13
|
from maps4fs.generator.component import Component
|
15
14
|
|
16
15
|
SRTM = "https://elevation-tiles-prod.s3.amazonaws.com/skadi/{latitude_band}/{tile_name}.hgt.gz"
|
16
|
+
DEFAULT_MULTIPLIER = 3
|
17
|
+
DEFAULT_BLUR_RADIUS = 21
|
17
18
|
|
18
19
|
|
19
20
|
# pylint: disable=R0903
|
@@ -22,16 +23,14 @@ class DEM(Component):
|
|
22
23
|
|
23
24
|
Args:
|
24
25
|
coordinates (tuple[float, float]): The latitude and longitude of the center of the map.
|
25
|
-
|
26
|
+
map_height (int): The height of the map in pixels.
|
27
|
+
map_width (int): The width of the map in pixels.
|
26
28
|
map_directory (str): The directory where the map files are stored.
|
27
29
|
logger (Any, optional): The logger to use. Must have at least three basic methods: debug,
|
28
30
|
info, warning. If not provided, default logging will be used.
|
29
31
|
"""
|
30
32
|
|
31
33
|
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
34
|
self._dem_path = self.game.dem_file_path(self.map_directory)
|
36
35
|
self.temp_dir = "temp"
|
37
36
|
self.hgt_dir = os.path.join(self.temp_dir, "hgt")
|
@@ -39,24 +38,27 @@ class DEM(Component):
|
|
39
38
|
os.makedirs(self.hgt_dir, exist_ok=True)
|
40
39
|
os.makedirs(self.gz_dir, exist_ok=True)
|
41
40
|
|
41
|
+
self.multiplier = self.kwargs.get("multiplier", DEFAULT_MULTIPLIER)
|
42
|
+
self.blur_radius = self.kwargs.get("blur_radius", DEFAULT_BLUR_RADIUS)
|
43
|
+
self.logger.debug(
|
44
|
+
"DEM multiplier is %s, blur radius is %s.", self.multiplier, self.blur_radius
|
45
|
+
)
|
46
|
+
|
42
47
|
# pylint: disable=no-member
|
43
48
|
def process(self) -> None:
|
44
49
|
"""Reads SRTM file, crops it to map size, normalizes and blurs it,
|
45
50
|
saves to map directory."""
|
46
|
-
north, south, east, west =
|
47
|
-
self.coordinates, dist=self.distance
|
48
|
-
)
|
49
|
-
self.logger.debug(
|
50
|
-
f"Processing DEM. North: {north}, south: {south}, east: {east}, west: {west}."
|
51
|
-
)
|
51
|
+
north, south, east, west = self.bbox
|
52
52
|
|
53
|
-
|
53
|
+
dem_height = self.map_height * self.game.dem_multipliyer + 1
|
54
|
+
dem_width = self.map_width * self.game.dem_multipliyer + 1
|
54
55
|
self.logger.debug(
|
55
|
-
"DEM multiplier is %s, DEM
|
56
|
+
"DEM multiplier is %s, DEM height is %s, DEM width is %s.",
|
56
57
|
self.game.dem_multipliyer,
|
57
|
-
|
58
|
+
dem_height,
|
59
|
+
dem_width,
|
58
60
|
)
|
59
|
-
dem_output_resolution = (
|
61
|
+
dem_output_resolution = (dem_width, dem_height)
|
60
62
|
self.logger.debug("DEM output resolution: %s.", dem_output_resolution)
|
61
63
|
|
62
64
|
tile_path = self._srtm_tile()
|
@@ -87,19 +89,34 @@ class DEM(Component):
|
|
87
89
|
f"Min: {data.min()}, max: {data.max()}."
|
88
90
|
)
|
89
91
|
|
90
|
-
normalized_data = self._normalize_dem(data)
|
91
|
-
|
92
92
|
resampled_data = cv2.resize(
|
93
|
-
|
93
|
+
data, dem_output_resolution, interpolation=cv2.INTER_LINEAR
|
94
|
+
).astype("uint16")
|
95
|
+
|
96
|
+
self.logger.debug(
|
97
|
+
f"Maximum value in resampled data: {resampled_data.max()}, "
|
98
|
+
f"minimum value: {resampled_data.min()}."
|
94
99
|
)
|
100
|
+
|
101
|
+
resampled_data = resampled_data * self.multiplier
|
102
|
+
self.logger.debug(
|
103
|
+
f"DEM data multiplied by {self.multiplier}. Shape: {resampled_data.shape}, "
|
104
|
+
f"dtype: {resampled_data.dtype}. "
|
105
|
+
f"Min: {resampled_data.min()}, max: {resampled_data.max()}."
|
106
|
+
)
|
107
|
+
|
95
108
|
self.logger.debug(
|
96
109
|
f"DEM data was resampled. Shape: {resampled_data.shape}, "
|
97
110
|
f"dtype: {resampled_data.dtype}. "
|
98
111
|
f"Min: {resampled_data.min()}, max: {resampled_data.max()}."
|
99
112
|
)
|
100
113
|
|
101
|
-
|
102
|
-
|
114
|
+
resampled_data = cv2.GaussianBlur(resampled_data, (self.blur_radius, self.blur_radius), 0)
|
115
|
+
self.logger.debug(
|
116
|
+
f"Gaussion blur applied to DEM data with kernel size {self.blur_radius}. "
|
117
|
+
)
|
118
|
+
|
119
|
+
cv2.imwrite(self._dem_path, resampled_data)
|
103
120
|
self.logger.debug("DEM data was saved to %s.", self._dem_path)
|
104
121
|
|
105
122
|
def _tile_info(self, lat: float, lon: float) -> tuple[str, str]:
|
@@ -182,26 +199,42 @@ class DEM(Component):
|
|
182
199
|
cv2.imwrite(self._dem_path, dem_data) # pylint: disable=no-member
|
183
200
|
self.logger.warning("DEM data filled with zeros and saved to %s.", self._dem_path)
|
184
201
|
|
185
|
-
def
|
186
|
-
"""
|
202
|
+
def grayscale_preview(self) -> str:
|
203
|
+
"""Converts DEM image to grayscale RGB image and saves it to the map directory.
|
204
|
+
Returns path to the preview image.
|
187
205
|
|
188
|
-
|
189
|
-
|
206
|
+
Returns:
|
207
|
+
str: Path to the preview image.
|
208
|
+
"""
|
209
|
+
rgb_dem_path = self._dem_path.replace(".png", "_grayscale.png")
|
210
|
+
dem_data = cv2.imread(self._dem_path, cv2.IMREAD_GRAYSCALE)
|
211
|
+
dem_data_rgb = cv2.cvtColor(dem_data, cv2.COLOR_GRAY2RGB)
|
212
|
+
cv2.imwrite(rgb_dem_path, dem_data_rgb)
|
213
|
+
return rgb_dem_path
|
214
|
+
|
215
|
+
def colored_preview(self) -> str:
|
216
|
+
"""Converts DEM image to colored RGB image and saves it to the map directory.
|
217
|
+
Returns path to the preview image.
|
190
218
|
|
191
219
|
Returns:
|
192
|
-
|
220
|
+
list[str]: List with a single path to the DEM file
|
193
221
|
"""
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
222
|
+
|
223
|
+
colored_dem_path = self._dem_path.replace(".png", "_colored.png")
|
224
|
+
dem_data = cv2.imread(self._dem_path, cv2.IMREAD_GRAYSCALE)
|
225
|
+
|
226
|
+
# Normalize the DEM data to the range [0, 255]
|
227
|
+
# dem_data_normalized = cv2.normalize(dem_data, None, 0, 255, cv2.NORM_MINMAX)
|
228
|
+
|
229
|
+
dem_data_colored = cv2.applyColorMap(dem_data, cv2.COLORMAP_JET)
|
230
|
+
|
231
|
+
cv2.imwrite(colored_dem_path, dem_data_colored)
|
232
|
+
return colored_dem_path
|
233
|
+
|
234
|
+
def previews(self) -> list[str]:
|
235
|
+
"""Get list of preview images.
|
236
|
+
|
237
|
+
Returns:
|
238
|
+
list[str]: List of preview images.
|
239
|
+
"""
|
240
|
+
return [self.grayscale_preview(), self.colored_preview()]
|
maps4fs/generator/map.py
CHANGED
@@ -6,21 +6,21 @@ from typing import Any
|
|
6
6
|
|
7
7
|
from tqdm import tqdm
|
8
8
|
|
9
|
+
from maps4fs.generator.component import Component
|
9
10
|
from maps4fs.generator.game import Game
|
10
11
|
from maps4fs.logger import Logger
|
11
12
|
|
12
13
|
|
13
|
-
# pylint: disable=R0913
|
14
|
+
# pylint: disable=R0913, R0902
|
14
15
|
class Map:
|
15
16
|
"""Class used to generate map using all components.
|
16
17
|
|
17
18
|
Args:
|
18
19
|
game (Type[Game]): Game for which the map is generated.
|
19
20
|
coordinates (tuple[float, float]): Coordinates of the center of the map.
|
20
|
-
|
21
|
+
height (int): Height of the map in pixels.
|
22
|
+
width (int): Width of the map in pixels.
|
21
23
|
map_directory (str): Path to the directory where map files will be stored.
|
22
|
-
blur_seed (int): Seed used for blur effect.
|
23
|
-
max_height (int): Maximum height of the map.
|
24
24
|
logger (Any): Logger instance
|
25
25
|
"""
|
26
26
|
|
@@ -28,15 +28,17 @@ class Map:
|
|
28
28
|
self,
|
29
29
|
game: Game,
|
30
30
|
coordinates: tuple[float, float],
|
31
|
-
|
31
|
+
height: int,
|
32
|
+
width: int,
|
32
33
|
map_directory: str,
|
33
|
-
blur_seed: int,
|
34
|
-
max_height: int,
|
35
34
|
logger: Any = None,
|
35
|
+
**kwargs,
|
36
36
|
):
|
37
37
|
self.game = game
|
38
|
+
self.components: list[Component] = []
|
38
39
|
self.coordinates = coordinates
|
39
|
-
self.
|
40
|
+
self.height = height
|
41
|
+
self.width = width
|
40
42
|
self.map_directory = map_directory
|
41
43
|
|
42
44
|
if not logger:
|
@@ -44,6 +46,8 @@ class Map:
|
|
44
46
|
self.logger = logger
|
45
47
|
self.logger.debug("Game was set to %s", game.code)
|
46
48
|
|
49
|
+
self.kwargs = kwargs
|
50
|
+
|
47
51
|
os.makedirs(self.map_directory, exist_ok=True)
|
48
52
|
self.logger.debug("Map directory created: %s", self.map_directory)
|
49
53
|
|
@@ -53,15 +57,6 @@ class Map:
|
|
53
57
|
except Exception as e:
|
54
58
|
raise RuntimeError(f"Can not unpack map template due to error: {e}") from e
|
55
59
|
|
56
|
-
# Blur seed should be positive and odd.
|
57
|
-
if blur_seed <= 0:
|
58
|
-
raise ValueError("Blur seed should be positive.")
|
59
|
-
if blur_seed % 2 == 0:
|
60
|
-
blur_seed += 1
|
61
|
-
|
62
|
-
self.blur_seed = blur_seed
|
63
|
-
self.max_height = max_height
|
64
|
-
|
65
60
|
def generate(self) -> None:
|
66
61
|
"""Launch map generation using all components."""
|
67
62
|
with tqdm(total=len(self.game.components), desc="Generating map...") as pbar:
|
@@ -69,11 +64,11 @@ class Map:
|
|
69
64
|
component = game_component(
|
70
65
|
self.game,
|
71
66
|
self.coordinates,
|
72
|
-
self.
|
67
|
+
self.height,
|
68
|
+
self.width,
|
73
69
|
self.map_directory,
|
74
70
|
self.logger,
|
75
|
-
|
76
|
-
max_height=self.max_height,
|
71
|
+
**self.kwargs,
|
77
72
|
)
|
78
73
|
try:
|
79
74
|
component.process()
|
@@ -84,7 +79,7 @@ class Map:
|
|
84
79
|
e,
|
85
80
|
)
|
86
81
|
raise e
|
87
|
-
|
82
|
+
self.components.append(component)
|
88
83
|
|
89
84
|
pbar.update(1)
|
90
85
|
|
@@ -94,7 +89,10 @@ class Map:
|
|
94
89
|
Returns:
|
95
90
|
list[str]: List of preview images.
|
96
91
|
"""
|
97
|
-
|
92
|
+
previews = []
|
93
|
+
for component in self.components:
|
94
|
+
previews.extend(component.previews())
|
95
|
+
return previews
|
98
96
|
|
99
97
|
def pack(self, archive_name: str) -> str:
|
100
98
|
"""Pack map directory to zip archive.
|
maps4fs/generator/texture.py
CHANGED
@@ -116,7 +116,6 @@ class Texture(Component):
|
|
116
116
|
self.logger.info("Loaded %s layers.", len(self.layers))
|
117
117
|
|
118
118
|
self._weights_dir = os.path.join(self.map_directory, "maps", "map", "data")
|
119
|
-
self._bbox = ox.utils_geo.bbox_from_point(self.coordinates, dist=self.distance)
|
120
119
|
self.info_save_path = os.path.join(self.map_directory, "generation_info.json")
|
121
120
|
|
122
121
|
def process(self):
|
@@ -132,9 +131,8 @@ class Texture(Component):
|
|
132
131
|
- map dimensions in meters
|
133
132
|
- map coefficients (meters per pixel)
|
134
133
|
"""
|
135
|
-
north, south, east, west =
|
136
|
-
|
137
|
-
)
|
134
|
+
north, south, east, west = self.get_bbox(project_utm=True)
|
135
|
+
|
138
136
|
# Parameters of the map in UTM format (meters).
|
139
137
|
self.minimum_x = min(west, east)
|
140
138
|
self.minimum_y = min(south, north)
|
@@ -147,8 +145,8 @@ class Texture(Component):
|
|
147
145
|
self.width = abs(east - west)
|
148
146
|
self.logger.info("Map dimensions (HxW): %s x %s.", self.height, self.width)
|
149
147
|
|
150
|
-
self.height_coef = self.height /
|
151
|
-
self.width_coef = self.width /
|
148
|
+
self.height_coef = self.height / self.map_height
|
149
|
+
self.width_coef = self.width / self.map_width
|
152
150
|
self.logger.debug("Map coefficients (HxW): %s x %s.", self.height_coef, self.width_coef)
|
153
151
|
|
154
152
|
def info_sequence(self) -> None:
|
@@ -157,7 +155,8 @@ class Texture(Component):
|
|
157
155
|
Info sequence contains following attributes:
|
158
156
|
- coordinates
|
159
157
|
- bbox
|
160
|
-
-
|
158
|
+
- map_height
|
159
|
+
- map_width
|
161
160
|
- minimum_x
|
162
161
|
- minimum_y
|
163
162
|
- maximum_x
|
@@ -170,7 +169,8 @@ class Texture(Component):
|
|
170
169
|
useful_attributes = [
|
171
170
|
"coordinates",
|
172
171
|
"bbox",
|
173
|
-
"
|
172
|
+
"map_height",
|
173
|
+
"map_width",
|
174
174
|
"minimum_x",
|
175
175
|
"minimum_y",
|
176
176
|
"maximum_x",
|
@@ -201,7 +201,7 @@ class Texture(Component):
|
|
201
201
|
texture_name (str): Name of the texture.
|
202
202
|
layer_numbers (int): Number of layers in the texture.
|
203
203
|
"""
|
204
|
-
size = self.
|
204
|
+
size = (self.map_height, self.map_width)
|
205
205
|
postfix = "_weight.png"
|
206
206
|
if layer_numbers == 0:
|
207
207
|
filepaths = [os.path.join(self._weights_dir, texture_name + postfix)]
|
@@ -212,7 +212,7 @@ class Texture(Component):
|
|
212
212
|
]
|
213
213
|
|
214
214
|
for filepath in filepaths:
|
215
|
-
img = np.zeros(
|
215
|
+
img = np.zeros(size, dtype=np.uint8)
|
216
216
|
cv2.imwrite(filepath, img) # pylint: disable=no-member
|
217
217
|
|
218
218
|
@property
|
@@ -356,7 +356,7 @@ class Texture(Component):
|
|
356
356
|
try:
|
357
357
|
with warnings.catch_warnings():
|
358
358
|
warnings.simplefilter("ignore", DeprecationWarning)
|
359
|
-
objects = ox.features_from_bbox(bbox=self.
|
359
|
+
objects = ox.features_from_bbox(bbox=self.bbox, tags=tags)
|
360
360
|
except Exception as e: # pylint: disable=W0718
|
361
361
|
self.logger.warning("Error fetching objects for tags: %s.", tags)
|
362
362
|
self.logger.warning(e)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.2
|
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>
|
@@ -28,7 +27,7 @@ Requires-Dist: tqdm
|
|
28
27
|
<a href="#How-To-Run">How-To-Run</a> •
|
29
28
|
<a href="#Features">Features</a> •
|
30
29
|
<a href="#Supported-objects">Supported objects</a> •
|
31
|
-
<a href="Settings">Settings</a> •
|
30
|
+
<a href="#Advanced Settings">Advanced Settings</a> •
|
32
31
|
<a href="#Bugs-and-feature-requests">Bugs and feature requests</a>
|
33
32
|
</p>
|
34
33
|
|
@@ -80,6 +79,20 @@ So, if you're new to map making, here's a quick overview of the process:
|
|
80
79
|
3. Open the map template in the Giants Editor.
|
81
80
|
4. Now you can start creating your map (adding roads, fields, buildings, etc.).
|
82
81
|
|
82
|
+
### Previews
|
83
|
+
|
84
|
+
The generator also creates a multiple previews of the map. Here's the list of them:
|
85
|
+
1. General preview - merging all the layers into one image with different colors.
|
86
|
+
2. Grayscale DEM preview - a grayscale image of the height map (as it is).
|
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.
|
88
|
+
|
89
|
+
<br>
|
90
|
+
*Preview of a 16 km map with a 500-meter mountain in the middle of it.*<br>
|
91
|
+
|
92
|
+
Parameters:
|
93
|
+
- coordinates: 45.15, 19.71
|
94
|
+
- size: 16 x 16 km
|
95
|
+
|
83
96
|
## How-To-Run
|
84
97
|
|
85
98
|
You'll find detailed instructions on how to run the project below. But if you prefer video tutorials, here's one for you:
|
@@ -143,10 +156,9 @@ import maps4fs as mfs
|
|
143
156
|
map = mfs.Map(
|
144
157
|
game,
|
145
158
|
(52.5200, 13.4050), # Latitude and longitude of the map center.
|
146
|
-
|
159
|
+
height=1024, # The height of the map in meters.
|
160
|
+
width=1024, # The width of the map in meters.
|
147
161
|
map_directory="path/to/your/map/directory", # The directory where the map will be saved.
|
148
|
-
blur_seed=5, # The seed for the blur algorithm. The default value is 5, which means 5 meters.
|
149
|
-
max_height=400 # The maximum height of the map.
|
150
162
|
)
|
151
163
|
```
|
152
164
|
|
@@ -157,11 +169,6 @@ map.generate()
|
|
157
169
|
|
158
170
|
The map will be saved in the `map_directory` directory.
|
159
171
|
|
160
|
-
## Settings
|
161
|
-
Advanced settings are available in the tool's UI under the **Advanced Settings** tab. Here's the list of them:
|
162
|
-
- `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.
|
163
|
-
- `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.
|
164
|
-
|
165
172
|
## Features
|
166
173
|
- Allows to enter a location by lat and lon (e.g. from Google Maps).
|
167
174
|
- Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
|
@@ -186,18 +193,28 @@ The list will be updated as the project develops.
|
|
186
193
|
The script will also generate the `generation_info.json` file in the `output` folder. It contains the following keys: <br>
|
187
194
|
`"coordinates"` - the coordinates of the map center which you entered,<br>
|
188
195
|
`"bbox"` - the bounding box of the map in lat and lon,<br>
|
189
|
-
`"
|
196
|
+
`"map_height"` - the height of the map in meters (this one is from the user input, e.g. 2048 and so on),<br>
|
197
|
+
`"map_width"` - the width of the map in meters (same as above),<br>
|
190
198
|
`"minimum_x"` - the minimum x coordinate of the map (UTM projection),<br>
|
191
199
|
`"minimum_y"` - the minimum y coordinate of the map (UTM projection),<br>
|
192
200
|
`"maximum_x"` - the maximum x coordinate of the map (UTM projection),<br>
|
193
201
|
`"maximum_y"` - the maximum y coordinate of the map (UTM projection),<br>
|
194
|
-
`"height"` - the height of the map in meters (it won't be equal to the
|
195
|
-
`"width"` - the width of the map in meters,<br>
|
202
|
+
`"height"` - the height of the map in meters (it won't be equal to the parameters above since the Earth is not flat, sorry flat-earthers),<br>
|
203
|
+
`"width"` - the width of the map in meters (same as above),<br>
|
196
204
|
`"height_coef"` - since we need a texture of exact size, the height of the map is multiplied by this coefficient,<br>
|
197
205
|
`"width_coef"` - same as above but for the width,<br>
|
198
206
|
`"tile_name"` - the name of the SRTM tile which was used to generate the height map, e.g. "N52E013"<br>
|
199
207
|
|
200
208
|
You can use this information to adjust some other sources of data to the map, e.g. textures, height maps, etc.
|
201
209
|
|
210
|
+
## Advanced Settings
|
211
|
+
You can also apply some advanced settings to the map generation process. Note that they're ADVANCED, so you don't need to use them if you're not sure what they do.<br>
|
212
|
+
|
213
|
+
Here's the list of the advanced settings:
|
214
|
+
|
215
|
+
- DEM multiplier: the height of the map is multiplied by this value. So the DEM map is just a 16-bit grayscale image, which means that the maximum avaiable value there is 65535, while the actual difference between the deepest and the highest point on Earth is about 20 km. So, by default this value is set to 3. Just note that this setting mostly does not matter, because you can always adjust it in the Giants Editor, learn more about the [heightScale](https://www.farming-simulator.org/19/terrain-heightscale.php) parameter on the [PMC Farming Simulator](https://www.farming-simulator.org/) website.
|
216
|
+
|
217
|
+
- DEM Blur radius: the radius of the Gaussian blur filter applied to the DEM map. By default, it's set to 21. This filter just makes the DEM map smoother, so the height transitions will be more natural. You can set it to 1 to disable the filter, but it will result as a Minecraft-like map.
|
218
|
+
|
202
219
|
## Bugs and feature requests
|
203
220
|
If you find a bug or have an idea for a new feature, please create an issue [here](https://github.com/iwatkot/maps4fs/issues) or contact me directly on [Telegram](https://t.me/iwatkot).<br>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
|
2
|
+
maps4fs/logger.py,sha256=CneeHxQywjNUJXqQrUUSeiDxu95FfrfyK_Si1v0gMZ8,1477
|
3
|
+
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
4
|
+
maps4fs/generator/component.py,sha256=k5SRlcXu3OHvm-5GUhHTdVgxGUAvtcftdCxFCWAYOZU,3436
|
5
|
+
maps4fs/generator/config.py,sha256=luDYXkKjgOM4-Mft4mHDPP6v-DVIUyWZAMAsCKyvaoY,2108
|
6
|
+
maps4fs/generator/dem.py,sha256=xq9F66-7otQNRAjAkM0tYNV2TTJSr10xSQlVpNtyL-0,9634
|
7
|
+
maps4fs/generator/game.py,sha256=IyXjNEC5epJmDdqjsrl4wKL85T1F23km73pUkBiuDWU,4468
|
8
|
+
maps4fs/generator/map.py,sha256=Oyu45ONmSluidaUErsU6n28pqI-XYx1eVfPT9FurCTE,3522
|
9
|
+
maps4fs/generator/texture.py,sha256=R45BFsdYHsTUW6iQVAZu9N_ifIEQMzuSheTEtpmf9nQ,15182
|
10
|
+
maps4fs-0.7.2.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
|
11
|
+
maps4fs-0.7.2.dist-info/METADATA,sha256=rv0QSEJVDk4FJi2rSo2ziKPK_bCUoctF-ftpQ37Y-4A,11698
|
12
|
+
maps4fs-0.7.2.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
13
|
+
maps4fs-0.7.2.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
14
|
+
maps4fs-0.7.2.dist-info/RECORD,,
|
maps4fs-0.6.8.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
|
2
|
-
maps4fs/logger.py,sha256=CneeHxQywjNUJXqQrUUSeiDxu95FfrfyK_Si1v0gMZ8,1477
|
3
|
-
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
4
|
-
maps4fs/generator/component.py,sha256=UmR6Gbs-uDld7897q_9hOOzqBXaIYD8svmw_a3IgC5g,1761
|
5
|
-
maps4fs/generator/config.py,sha256=3X9E6luYh0dBlYcGvE4Exzp-ShAMCFjGB_8SK3qPBtM,1760
|
6
|
-
maps4fs/generator/dem.py,sha256=_1d_TPMOGBgl2-R_CRMbKumzxCbQyb-hcpqsElhYbQ4,8546
|
7
|
-
maps4fs/generator/game.py,sha256=IyXjNEC5epJmDdqjsrl4wKL85T1F23km73pUkBiuDWU,4468
|
8
|
-
maps4fs/generator/map.py,sha256=Y7ERUB6ivxJilDAjE9UD0-vl0SKtzj6J2f8QPXM6i48,3712
|
9
|
-
maps4fs/generator/texture.py,sha256=f5dPD5q17CTg8aY6G3i33vFk9ckbpndVb1W3hbT1wL4,15318
|
10
|
-
maps4fs-0.6.8.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
|
11
|
-
maps4fs-0.6.8.dist-info/METADATA,sha256=q6HMaXkmT1mkfskzOS9EQrTILUTfAIb_D5BJF4ObMKc,10652
|
12
|
-
maps4fs-0.6.8.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
13
|
-
maps4fs-0.6.8.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
14
|
-
maps4fs-0.6.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|