maps4fs 0.7.0__py3-none-any.whl → 0.7.3__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.
@@ -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
- distance (int): The distance from the center to the edge of the map.
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
- distance: int,
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.distance = distance
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,35 @@ 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
+ "Calculated bounding box for component: %s: %s, project_utm: %s",
90
+ self.__class__.__name__,
91
+ bbox,
92
+ project_utm,
93
+ )
94
+ return bbox
95
+
96
+ def save_bbox(self) -> None:
97
+ """Saves the bounding box of the map to the component instance from the coordinates and the
98
+ height and width of the map.
99
+ """
100
+ self.bbox = self.get_bbox(project_utm=False)
101
+ self.logger.debug("Saved bounding box: %s", self.bbox)
@@ -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
- distance (int): The distance from the center to the edge of the map.
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(f"Map XML path: {self._map_xml_path}")
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 = height = str(self.distance * 2)
40
- map_elem.set("width", width)
41
- map_elem.set("height", height)
42
- self.logger.debug("Map size set to %sx%s in Map XML file.", width, height)
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
- distance (int): The distance from the center to the edge of the map.
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 = ox.utils_geo.bbox_from_point( # pylint: disable=W0632
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
- dem_output_size = self.distance * self.game.dem_multipliyer + 1
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 output size is %s.",
56
+ "DEM multiplier is %s, DEM height is %s, DEM width is %s.",
56
57
  self.game.dem_multipliyer,
57
- dem_output_size,
58
+ dem_height,
59
+ dem_width,
58
60
  )
59
- dem_output_resolution = (dem_output_size, dem_output_size)
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()
@@ -83,23 +85,48 @@ class DEM(Component):
83
85
  return
84
86
 
85
87
  self.logger.debug(
86
- f"DEM data was read from SRTM file. Shape: {data.shape}, dtype: {data.dtype}. "
87
- f"Min: {data.min()}, max: {data.max()}."
88
+ "DEM data was read from SRTM file. Shape: %s, dtype: %s. Min: %s, max: %s.",
89
+ data.shape,
90
+ data.dtype,
91
+ data.min(),
92
+ data.max(),
88
93
  )
89
94
 
90
- normalized_data = self._normalize_dem(data)
91
-
92
95
  resampled_data = cv2.resize(
93
- normalized_data, dem_output_resolution, interpolation=cv2.INTER_LINEAR
96
+ data, dem_output_resolution, interpolation=cv2.INTER_LINEAR
97
+ ).astype("uint16")
98
+
99
+ self.logger.debug(
100
+ "Maximum value in resampled data: %s, minimum value: %s.",
101
+ resampled_data.max(),
102
+ resampled_data.min(),
94
103
  )
104
+
105
+ resampled_data = resampled_data * self.multiplier
106
+ self.logger.debug(
107
+ "DEM data multiplied by %s. Shape: %s, dtype: %s. Min: %s, max: %s.",
108
+ self.multiplier,
109
+ resampled_data.shape,
110
+ resampled_data.dtype,
111
+ resampled_data.min(),
112
+ resampled_data.max(),
113
+ )
114
+
95
115
  self.logger.debug(
96
- f"DEM data was resampled. Shape: {resampled_data.shape}, "
97
- f"dtype: {resampled_data.dtype}. "
98
- f"Min: {resampled_data.min()}, max: {resampled_data.max()}."
116
+ "DEM data was resampled. Shape: %s, dtype: %s. Min: %s, max: %s.",
117
+ resampled_data.shape,
118
+ resampled_data.dtype,
119
+ resampled_data.min(),
120
+ resampled_data.max(),
99
121
  )
100
122
 
101
- blurred_data = cv2.GaussianBlur(resampled_data, (self._blur_seed, self._blur_seed), 0)
102
- cv2.imwrite(self._dem_path, blurred_data)
123
+ resampled_data = cv2.GaussianBlur(resampled_data, (self.blur_radius, self.blur_radius), 0)
124
+ self.logger.debug(
125
+ "Gaussion blur applied to DEM data with kernel size %s.",
126
+ self.blur_radius,
127
+ )
128
+
129
+ cv2.imwrite(self._dem_path, resampled_data)
103
130
  self.logger.debug("DEM data was saved to %s.", self._dem_path)
104
131
 
105
132
  def _tile_info(self, lat: float, lon: float) -> tuple[str, str]:
@@ -162,7 +189,8 @@ class DEM(Component):
162
189
  decompressed_file_path = os.path.join(self.hgt_dir, f"{tile_name}.hgt")
163
190
  if os.path.isfile(decompressed_file_path):
164
191
  self.logger.info(
165
- f"Decompressed tile already exists: {decompressed_file_path}, skipping download."
192
+ "Decompressed tile already exists: %s, skipping download.",
193
+ decompressed_file_path,
166
194
  )
167
195
  return decompressed_file_path
168
196
 
@@ -182,30 +210,6 @@ class DEM(Component):
182
210
  cv2.imwrite(self._dem_path, dem_data) # pylint: disable=no-member
183
211
  self.logger.warning("DEM data filled with zeros and saved to %s.", self._dem_path)
184
212
 
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
213
  def grayscale_preview(self) -> str:
210
214
  """Converts DEM image to grayscale RGB image and saves it to the map directory.
211
215
  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
- distance (int): Distance from the center of the map.
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
- distance: int,
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.distance = distance
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.distance,
67
+ self.height,
68
+ self.width,
75
69
  self.map_directory,
76
70
  self.logger,
77
- blur_seed=self.blur_seed,
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())
@@ -16,6 +16,8 @@ from shapely.geometry.base import BaseGeometry # type: ignore
16
16
 
17
17
  from maps4fs.generator.component import Component
18
18
 
19
+ PREVIEW_MAXIMUM_SIZE = 2048
20
+
19
21
 
20
22
  # pylint: disable=R0902
21
23
  class Texture(Component):
@@ -116,7 +118,6 @@ class Texture(Component):
116
118
  self.logger.info("Loaded %s layers.", len(self.layers))
117
119
 
118
120
  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
121
  self.info_save_path = os.path.join(self.map_directory, "generation_info.json")
121
122
 
122
123
  def process(self):
@@ -132,9 +133,8 @@ class Texture(Component):
132
133
  - map dimensions in meters
133
134
  - map coefficients (meters per pixel)
134
135
  """
135
- north, south, east, west = ox.utils_geo.bbox_from_point( # pylint: disable=W0632
136
- self.coordinates, dist=self.distance, project_utm=True
137
- )
136
+ north, south, east, west = self.get_bbox(project_utm=True)
137
+
138
138
  # Parameters of the map in UTM format (meters).
139
139
  self.minimum_x = min(west, east)
140
140
  self.minimum_y = min(south, north)
@@ -147,8 +147,8 @@ class Texture(Component):
147
147
  self.width = abs(east - west)
148
148
  self.logger.info("Map dimensions (HxW): %s x %s.", self.height, self.width)
149
149
 
150
- self.height_coef = self.height / (self.distance * 2)
151
- self.width_coef = self.width / (self.distance * 2)
150
+ self.height_coef = self.height / self.map_height
151
+ self.width_coef = self.width / self.map_width
152
152
  self.logger.debug("Map coefficients (HxW): %s x %s.", self.height_coef, self.width_coef)
153
153
 
154
154
  def info_sequence(self) -> None:
@@ -157,7 +157,8 @@ class Texture(Component):
157
157
  Info sequence contains following attributes:
158
158
  - coordinates
159
159
  - bbox
160
- - distance
160
+ - map_height
161
+ - map_width
161
162
  - minimum_x
162
163
  - minimum_y
163
164
  - maximum_x
@@ -170,7 +171,8 @@ class Texture(Component):
170
171
  useful_attributes = [
171
172
  "coordinates",
172
173
  "bbox",
173
- "distance",
174
+ "map_height",
175
+ "map_width",
174
176
  "minimum_x",
175
177
  "minimum_y",
176
178
  "maximum_x",
@@ -201,7 +203,7 @@ class Texture(Component):
201
203
  texture_name (str): Name of the texture.
202
204
  layer_numbers (int): Number of layers in the texture.
203
205
  """
204
- size = self.distance * 2
206
+ size = (self.map_height, self.map_width)
205
207
  postfix = "_weight.png"
206
208
  if layer_numbers == 0:
207
209
  filepaths = [os.path.join(self._weights_dir, texture_name + postfix)]
@@ -212,7 +214,7 @@ class Texture(Component):
212
214
  ]
213
215
 
214
216
  for filepath in filepaths:
215
- img = np.zeros((size, size), dtype=np.uint8)
217
+ img = np.zeros(size, dtype=np.uint8)
216
218
  cv2.imwrite(filepath, img) # pylint: disable=no-member
217
219
 
218
220
  @property
@@ -356,7 +358,7 @@ class Texture(Component):
356
358
  try:
357
359
  with warnings.catch_warnings():
358
360
  warnings.simplefilter("ignore", DeprecationWarning)
359
- objects = ox.features_from_bbox(bbox=self._bbox, tags=tags)
361
+ objects = ox.features_from_bbox(bbox=self.bbox, tags=tags)
360
362
  except Exception as e: # pylint: disable=W0718
361
363
  self.logger.warning("Error fetching objects for tags: %s.", tags)
362
364
  self.logger.warning(e)
@@ -387,7 +389,20 @@ class Texture(Component):
387
389
  Returns:
388
390
  str: Path to the preview.
389
391
  """
390
- preview_size = (2048, 2048)
392
+ scaling_factor = min(
393
+ PREVIEW_MAXIMUM_SIZE / self.map_width, PREVIEW_MAXIMUM_SIZE / self.map_height
394
+ )
395
+
396
+ preview_size = (
397
+ int(self.map_width * scaling_factor),
398
+ int(self.map_height * scaling_factor),
399
+ )
400
+ self.logger.debug(
401
+ "Scaling factor: %s. Preview size: %s.",
402
+ scaling_factor,
403
+ preview_size,
404
+ )
405
+
391
406
  images = [
392
407
  cv2.resize(
393
408
  cv2.imread(layer.path(self._weights_dir), cv2.IMREAD_UNCHANGED), preview_size
@@ -402,7 +417,9 @@ class Texture(Component):
402
417
  color_images.append(color_img)
403
418
  merged = np.sum(color_images, axis=0, dtype=np.uint8)
404
419
  self.logger.debug(
405
- f"Merged layers into one image. Shape: {merged.shape}, dtype: {merged.dtype}."
420
+ "Merged layers into one image. Shape: %s, dtype: %s.",
421
+ merged.shape,
422
+ merged.dtype,
406
423
  )
407
424
  preview_path = os.path.join(self.map_directory, "preview_osm.png")
408
425
  cv2.imwrite(preview_path, merged) # pylint: disable=no-member
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 0.7.0
3
+ Version: 0.7.3
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>
@@ -26,9 +25,8 @@ Requires-Dist: tqdm
26
25
  <a href="#Quick-Start">Quick Start</a> •
27
26
  <a href="#Overview">Overview</a> •
28
27
  <a href="#How-To-Run">How-To-Run</a> •
29
- <a href="#Features">Features</a> •
30
28
  <a href="#Supported-objects">Supported objects</a> •
31
- <a href="Settings">Settings</a> •
29
+ <a href="#For-advanced-users">For advanced users</a> •
32
30
  <a href="#Bugs-and-feature-requests">Bugs and feature requests</a>
33
31
  </p>
34
32
 
@@ -45,10 +43,13 @@ Requires-Dist: tqdm
45
43
 
46
44
  </div>
47
45
 
48
- ### Supported Games
46
+ 🗺️ Supports 2x2, 4x4, 8x8, 16x16 and any custom size maps<br>
47
+ 🌍 Based on real-world data from OpenStreetMap<br>
48
+ 🏞️ Generates height using SRTM dataset<br>
49
+ 📦 Provides a ready-to-use map template for the Giants Editor<br>
50
+ 🚜 Supports Farming Simulator 22 and 25*<br>
49
51
 
50
- Farming Simulator 22<br>
51
- 🔃 Farming Simulator 25 (changes in the library are ready, waiting for the Giants to release the Giants Editor v10)<br>
52
+ \* changes in the library are ready, waiting for the Giants to release the Giants Editor v10. Meanwhile the option to generate a map for FS25 is disabled.
52
53
 
53
54
  ## Quick Start
54
55
  There are several ways to use the tool. You obviously need the **first one**, but you can choose any of the others depending on your needs.<br>
@@ -87,16 +88,12 @@ The generator also creates a multiple previews of the map. Here's the list of th
87
88
  2. Grayscale DEM preview - a grayscale image of the height map (as it is).
88
89
  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
90
 
90
- So the colored DEM preview can be very handy when you're trying to find the best value for the `max_height` parameter. Learn more about it in the [Settings](#settings) section.
91
+ ![16 km map](https://github.com/user-attachments/assets/82543bcc-1289-479e-bd13-85a8890f0485)<br>
92
+ *Preview of a 16 km map with a 500-meter mountain in the middle of it.*<br>
91
93
 
92
- ![Previews](https://github.com/user-attachments/assets/69609169-834b-4269-ac6a-9a5c56b629dc)<br>
93
- In the second row of the image you can see the following images:<br>
94
- 1. DEM preview with `max_height=200`.
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.
94
+ Parameters:
95
+ - coordinates: 45.15, 19.71
96
+ - size: 16 x 16 km
100
97
 
101
98
  ## How-To-Run
102
99
 
@@ -105,7 +102,6 @@ You'll find detailed instructions on how to run the project below. But if you pr
105
102
  <i>Video tutorial: How to generate a Farming Simulator 22 map from real-world data.</i>
106
103
 
107
104
  ### Option 1: StreamLit
108
- **🗺️ Supported map sizes:** 2x2, 4x4, 8x8, 16x16 km.<br>
109
105
  🟢 Recommended for all users, you don't need to install anything.<br>
110
106
  Using the [StreamLit](https://maps4fs.streamlit.app) version of the tool is the easiest way to generate a map template. Just open the link and follow the instructions.
111
107
  Note: due to CPU and RAM limitations of the hosting, the generation may take some time. If you need faster processing, use the [Docker version](#option-2-docker-version).<br>
@@ -113,7 +109,6 @@ Note: due to CPU and RAM limitations of the hosting, the generation may take som
113
109
  Using it is easy and doesn't require any guides. Enjoy!
114
110
 
115
111
  ### Option 2: Docker version
116
- **🗺️ Supported map sizes:** 2x2, 4x4, 8x8, 16x16 km.<br>
117
112
  🟠 Recommended for users who want faster processing, very simple installation.<br>
118
113
  You can launch the project with minimalistic UI in your browser using Docker. Follow these steps:
119
114
 
@@ -126,10 +121,9 @@ docker run -d -p 8501:8501 iwatkot/maps4fs
126
121
  4. Fill in the required fields and click on the `Generate` button.
127
122
  5. When the map is generated click on the `Download` button to get the map.
128
123
 
129
- ![WebUI](https://github.com/user-attachments/assets/e3b48c9d-7b87-4ce7-8ad7-98332a558a88)
124
+ ![WebUI](https://github.com/user-attachments/assets/581e1206-2abd-4b3c-ad31-80554ad92d99)
130
125
 
131
126
  ### Option 3: Python package
132
- **🗺️ Supported map sizes:** 2x2, 4x4, 8x8, 16x16 km (and ANY other you may add).<br>
133
127
  🔴 Recommended for developers.<br>
134
128
  You can use the Python package to generate maps. Follow these steps:
135
129
 
@@ -161,10 +155,9 @@ import maps4fs as mfs
161
155
  map = mfs.Map(
162
156
  game,
163
157
  (52.5200, 13.4050), # Latitude and longitude of the map center.
164
- distance=1024, # The DISTANCE from the center to the edge of the map in meters. The map will be 2048x2048 meters.
158
+ height=1024, # The height of the map in meters.
159
+ width=1024, # The width of the map in 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,17 +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
- ## Features
184
- - Allows to enter a location by lat and lon (e.g. from Google Maps).
185
- - Allows to select a size of the map (2x2, 4x4, 8x8 km, 16x16 km).
186
- - Generates a map template (check the list of supported objects in [this section](#supported-objects)).
187
- - Generates a height map.
188
-
189
171
  ## Supported objects
190
172
  The project is based on the [OpenStreetMap](https://www.openstreetmap.org/) data. So, refer to [this page](https://wiki.openstreetmap.org/wiki/Map_Features) to understand the list below.
191
173
  - "building": True
@@ -204,18 +186,34 @@ The list will be updated as the project develops.
204
186
  The script will also generate the `generation_info.json` file in the `output` folder. It contains the following keys: <br>
205
187
  `"coordinates"` - the coordinates of the map center which you entered,<br>
206
188
  `"bbox"` - the bounding box of the map in lat and lon,<br>
207
- `"distance"` - the size of the map in meters,<br>
189
+ `"map_height"` - the height of the map in meters (this one is from the user input, e.g. 2048 and so on),<br>
190
+ `"map_width"` - the width of the map in meters (same as above),<br>
208
191
  `"minimum_x"` - the minimum x coordinate of the map (UTM projection),<br>
209
192
  `"minimum_y"` - the minimum y coordinate of the map (UTM projection),<br>
210
193
  `"maximum_x"` - the maximum x coordinate of the map (UTM projection),<br>
211
194
  `"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 distance since the Earth is not flat, sorry flat-earthers),<br>
213
- `"width"` - the width of the map in meters,<br>
195
+ `"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>
196
+ `"width"` - the width of the map in meters (same as above),<br>
214
197
  `"height_coef"` - since we need a texture of exact size, the height of the map is multiplied by this coefficient,<br>
215
198
  `"width_coef"` - same as above but for the width,<br>
216
199
  `"tile_name"` - the name of the SRTM tile which was used to generate the height map, e.g. "N52E013"<br>
217
200
 
218
201
  You can use this information to adjust some other sources of data to the map, e.g. textures, height maps, etc.
219
202
 
203
+ ## For advanced users
204
+ The tool supports the custom size of the map. To use this feature select `Custom` in the `Map size` dropdown and enter the desired size. The tool will generate a map with the size you entered.<br>
205
+
206
+ ⛔️ Do not use this feature, if you don't know what you're doing. In most cases the Giants Editor will just crash on opening the file, because you need to enter a specific values for the map size.<br><br>
207
+
208
+ ![Advanced settings and custom size](https://github.com/user-attachments/assets/327b6065-09ed-41d0-86a8-7d904025707c)
209
+
210
+ 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>
211
+
212
+ Here's the list of the advanced settings:
213
+
214
+ - 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.
215
+
216
+ - 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.
217
+
220
218
  ## Bugs and feature requests
221
219
  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=BU_HNNyKXuEBohQJRTlXmNdSNrjolwX-ZzqqSSuzTrE,3463
5
+ maps4fs/generator/config.py,sha256=luDYXkKjgOM4-Mft4mHDPP6v-DVIUyWZAMAsCKyvaoY,2108
6
+ maps4fs/generator/dem.py,sha256=EJBXHZ0_G9nXZ-b1PmR9mjIdXjbKlYEUv-4IDGJPmdc,9779
7
+ maps4fs/generator/game.py,sha256=IyXjNEC5epJmDdqjsrl4wKL85T1F23km73pUkBiuDWU,4468
8
+ maps4fs/generator/map.py,sha256=Oyu45ONmSluidaUErsU6n28pqI-XYx1eVfPT9FurCTE,3522
9
+ maps4fs/generator/texture.py,sha256=W2tMkCxyD7qesSuutPJ3N5InDza2Dzi5_yzewSl9e-E,15615
10
+ maps4fs-0.7.3.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
11
+ maps4fs-0.7.3.dist-info/METADATA,sha256=LimQqtHMDbvCq_hUNZg8ZmxHSIk-g8G6DRJ7Etu8F7E,11961
12
+ maps4fs-0.7.3.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
13
+ maps4fs-0.7.3.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
14
+ maps4fs-0.7.3.dist-info/RECORD,,
@@ -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,,