maps4fs 0.7.0__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 +40 -4
- maps4fs/generator/config.py +8 -6
- maps4fs/generator/dem.py +37 -44
- maps4fs/generator/map.py +12 -23
- maps4fs/generator/texture.py +11 -11
- {maps4fs-0.7.0.dist-info → maps4fs-0.7.2.dist-info}/METADATA +22 -23
- maps4fs-0.7.2.dist-info/RECORD +14 -0
- maps4fs-0.7.0.dist-info/RECORD +0 -14
- {maps4fs-0.7.0.dist-info → maps4fs-0.7.2.dist-info}/LICENSE.md +0 -0
- {maps4fs-0.7.0.dist-info → maps4fs-0.7.2.dist-info}/WHEEL +0 -0
- {maps4fs-0.7.0.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:
|
@@ -61,3 +67,33 @@ class Component:
|
|
61
67
|
NotImplementedError: If the method is not implemented in the child class.
|
62
68
|
"""
|
63
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,10 +37,11 @@ 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)
|
45
47
|
|
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,30 +199,6 @@ 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 _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
202
|
def grayscale_preview(self) -> str:
|
210
203
|
"""Converts DEM image to grayscale RGB image and saves it to the map directory.
|
211
204
|
Returns path to the preview image.
|
maps4fs/generator/map.py
CHANGED
@@ -18,10 +18,9 @@ class Map:
|
|
18
18
|
Args:
|
19
19
|
game (Type[Game]): Game for which the map is generated.
|
20
20
|
coordinates (tuple[float, float]): Coordinates of the center of the map.
|
21
|
-
|
21
|
+
height (int): Height of the map in pixels.
|
22
|
+
width (int): Width of the map in pixels.
|
22
23
|
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
24
|
logger (Any): Logger instance
|
26
25
|
"""
|
27
26
|
|
@@ -29,16 +28,17 @@ class Map:
|
|
29
28
|
self,
|
30
29
|
game: Game,
|
31
30
|
coordinates: tuple[float, float],
|
32
|
-
|
31
|
+
height: int,
|
32
|
+
width: int,
|
33
33
|
map_directory: str,
|
34
|
-
blur_seed: int,
|
35
|
-
max_height: int,
|
36
34
|
logger: Any = None,
|
35
|
+
**kwargs,
|
37
36
|
):
|
38
37
|
self.game = game
|
39
38
|
self.components: list[Component] = []
|
40
39
|
self.coordinates = coordinates
|
41
|
-
self.
|
40
|
+
self.height = height
|
41
|
+
self.width = width
|
42
42
|
self.map_directory = map_directory
|
43
43
|
|
44
44
|
if not logger:
|
@@ -46,6 +46,8 @@ class Map:
|
|
46
46
|
self.logger = logger
|
47
47
|
self.logger.debug("Game was set to %s", game.code)
|
48
48
|
|
49
|
+
self.kwargs = kwargs
|
50
|
+
|
49
51
|
os.makedirs(self.map_directory, exist_ok=True)
|
50
52
|
self.logger.debug("Map directory created: %s", self.map_directory)
|
51
53
|
|
@@ -55,15 +57,6 @@ class Map:
|
|
55
57
|
except Exception as e:
|
56
58
|
raise RuntimeError(f"Can not unpack map template due to error: {e}") from e
|
57
59
|
|
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
60
|
def generate(self) -> None:
|
68
61
|
"""Launch map generation using all components."""
|
69
62
|
with tqdm(total=len(self.game.components), desc="Generating map...") as pbar:
|
@@ -71,11 +64,11 @@ class Map:
|
|
71
64
|
component = game_component(
|
72
65
|
self.game,
|
73
66
|
self.coordinates,
|
74
|
-
self.
|
67
|
+
self.height,
|
68
|
+
self.width,
|
75
69
|
self.map_directory,
|
76
70
|
self.logger,
|
77
|
-
|
78
|
-
max_height=self.max_height,
|
71
|
+
**self.kwargs,
|
79
72
|
)
|
80
73
|
try:
|
81
74
|
component.process()
|
@@ -86,7 +79,6 @@ class Map:
|
|
86
79
|
e,
|
87
80
|
)
|
88
81
|
raise e
|
89
|
-
# setattr(self, game_component.__name__.lower(), component)
|
90
82
|
self.components.append(component)
|
91
83
|
|
92
84
|
pbar.update(1)
|
@@ -97,9 +89,6 @@ class Map:
|
|
97
89
|
Returns:
|
98
90
|
list[str]: List of preview images.
|
99
91
|
"""
|
100
|
-
# texture_previews = self.texture.previews() # type: ignore # pylint: disable=no-member
|
101
|
-
# dem_previews = self.dem.previews() # type: ignore # pylint: disable=no-member
|
102
|
-
# return texture_previews + dem_previews
|
103
92
|
previews = []
|
104
93
|
for component in self.components:
|
105
94
|
previews.extend(component.previews())
|
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.7.
|
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
|
|
@@ -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
|
|
@@ -161,10 +156,9 @@ import maps4fs as mfs
|
|
161
156
|
map = mfs.Map(
|
162
157
|
game,
|
163
158
|
(52.5200, 13.4050), # Latitude and longitude of the map center.
|
164
|
-
|
159
|
+
height=1024, # The height of the map in meters.
|
160
|
+
width=1024, # The width of the map in meters.
|
165
161
|
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
162
|
)
|
169
163
|
```
|
170
164
|
|
@@ -175,11 +169,6 @@ map.generate()
|
|
175
169
|
|
176
170
|
The map will be saved in the `map_directory` directory.
|
177
171
|
|
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
172
|
## Features
|
184
173
|
- Allows to enter a location by lat and lon (e.g. from Google Maps).
|
185
174
|
- Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
|
@@ -204,18 +193,28 @@ The list will be updated as the project develops.
|
|
204
193
|
The script will also generate the `generation_info.json` file in the `output` folder. It contains the following keys: <br>
|
205
194
|
`"coordinates"` - the coordinates of the map center which you entered,<br>
|
206
195
|
`"bbox"` - the bounding box of the map in lat and lon,<br>
|
207
|
-
`"
|
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>
|
208
198
|
`"minimum_x"` - the minimum x coordinate of the map (UTM projection),<br>
|
209
199
|
`"minimum_y"` - the minimum y coordinate of the map (UTM projection),<br>
|
210
200
|
`"maximum_x"` - the maximum x coordinate of the map (UTM projection),<br>
|
211
201
|
`"maximum_y"` - the maximum y coordinate of the map (UTM projection),<br>
|
212
|
-
`"height"` - the height of the map in meters (it won't be equal to the
|
213
|
-
`"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>
|
214
204
|
`"height_coef"` - since we need a texture of exact size, the height of the map is multiplied by this coefficient,<br>
|
215
205
|
`"width_coef"` - same as above but for the width,<br>
|
216
206
|
`"tile_name"` - the name of the SRTM tile which was used to generate the height map, e.g. "N52E013"<br>
|
217
207
|
|
218
208
|
You can use this information to adjust some other sources of data to the map, e.g. textures, height maps, etc.
|
219
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
|
+
|
220
219
|
## Bugs and feature requests
|
221
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.7.0.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=Xq5yVFMqG1d1iHTtn2mn5RN-UntsutXIvV5eQYBuFLw,2046
|
5
|
-
maps4fs/generator/config.py,sha256=wlGacB69fdcvggfEDvCpx5gzPRKq_4Sh6xuX-z-kwwE,2043
|
6
|
-
maps4fs/generator/dem.py,sha256=xOKHvWIMD-7nIWGQNQi6Tan1Ovb1EPfHHVnUfUIC31k,10004
|
7
|
-
maps4fs/generator/game.py,sha256=IyXjNEC5epJmDdqjsrl4wKL85T1F23km73pUkBiuDWU,4468
|
8
|
-
maps4fs/generator/map.py,sha256=bqog38u2fltYdC1xgfeC0ehboL7Vp7V6nJq0NQOI9lA,4157
|
9
|
-
maps4fs/generator/texture.py,sha256=f5dPD5q17CTg8aY6G3i33vFk9ckbpndVb1W3hbT1wL4,15318
|
10
|
-
maps4fs-0.7.0.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
|
11
|
-
maps4fs-0.7.0.dist-info/METADATA,sha256=559aJEFn3HctVKqakqaBoTVA6xLY8WTNQsKTlFG-icE,12187
|
12
|
-
maps4fs-0.7.0.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
13
|
-
maps4fs-0.7.0.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
14
|
-
maps4fs-0.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|