maps4fs 0.8.7__py3-none-any.whl → 0.8.9__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.
@@ -138,7 +138,8 @@ class Component:
138
138
  def get_bbox(
139
139
  self,
140
140
  coordinates: tuple[float, float] | None = None,
141
- distance: int | None = None,
141
+ height_distance: int | None = None,
142
+ width_distance: int | None = None,
142
143
  project_utm: bool = False,
143
144
  ) -> tuple[int, int, int, int]:
144
145
  """Calculates the bounding box of the map from the coordinates and the height and
@@ -148,28 +149,34 @@ class Component:
148
149
  Args:
149
150
  coordinates (tuple[float, float], optional): The latitude and longitude of the center of
150
151
  the map. Defaults to None.
151
- distance (int, optional): The distance from the center of the map to the edge of the
152
- map. Defaults to None.
152
+ height_distance (int, optional): The distance from the center of the map to the edge of
153
+ the map in the north-south direction. Defaults to None.
154
+ width_distance (int, optional): The distance from the center of the map to the edge of
155
+ the map in the east-west direction. Defaults to None.
153
156
  project_utm (bool, optional): Whether to project the bounding box to UTM.
154
157
 
155
158
  Returns:
156
159
  tuple[int, int, int, int]: The bounding box of the map.
157
160
  """
158
161
  coordinates = coordinates or self.coordinates
159
- distance = distance or int(self.map_height / 2)
162
+ height_distance = height_distance or int(self.map_height / 2)
163
+ width_distance = width_distance or int(self.map_width / 2)
160
164
 
161
165
  north, south, _, _ = ox.utils_geo.bbox_from_point(
162
- coordinates, dist=distance, project_utm=project_utm
166
+ coordinates, dist=height_distance, project_utm=project_utm
163
167
  )
164
168
  _, _, east, west = ox.utils_geo.bbox_from_point(
165
- coordinates, dist=distance, project_utm=project_utm
169
+ coordinates, dist=width_distance, project_utm=project_utm
166
170
  )
167
171
  bbox = north, south, east, west
168
172
  self.logger.debug(
169
- "Calculated bounding box for component: %s: %s, project_utm: %s",
173
+ "Calculated bounding box for component: %s: %s, project_utm: %s, "
174
+ "height_distance: %s, width_distance: %s",
170
175
  self.__class__.__name__,
171
176
  bbox,
172
177
  project_utm,
178
+ height_distance,
179
+ width_distance,
173
180
  )
174
181
  return bbox
175
182
 
@@ -67,7 +67,7 @@ class Config(Component):
67
67
  # if the map is 2048x2048 or 4096x4096, the overview will be 4096x4096
68
68
  # and the map will be in the center of the overview.
69
69
  # That's why the distance is set to the map height not as a half of it.
70
- bbox = self.get_bbox(distance=self.map_height)
70
+ bbox = self.get_bbox(height_distance=self.map_height, width_distance=self.map_width)
71
71
  south, west, north, east = bbox
72
72
  epsg3857_string = self.get_epsg3857_string(bbox=bbox)
73
73
 
maps4fs/generator/dem.py CHANGED
@@ -17,7 +17,7 @@ DEFAULT_MULTIPLIER = 1
17
17
  DEFAULT_BLUR_RADIUS = 35
18
18
 
19
19
 
20
- # pylint: disable=R0903
20
+ # pylint: disable=R0903, R0902
21
21
  class DEM(Component):
22
22
  """Component for processing Digital Elevation Model data.
23
23
 
@@ -51,6 +51,7 @@ class DEM(Component):
51
51
  )
52
52
 
53
53
  self.auto_process = self.kwargs.get("auto_process", False)
54
+ self.plateau = self.kwargs.get("plateau", False)
54
55
 
55
56
  @property
56
57
  def dem_path(self) -> str:
@@ -159,6 +160,22 @@ class DEM(Component):
159
160
  resampled_data.max(),
160
161
  )
161
162
 
163
+ if self.plateau:
164
+ # Plateau is a flat area with a constant height.
165
+ # So we just add this value to each pixel of the DEM.
166
+ # And also need to ensure that there will be no values with height greater than
167
+ # it's allowed in 16-bit unsigned integer.
168
+
169
+ resampled_data += self.plateau
170
+ resampled_data = np.clip(resampled_data, 0, 65535)
171
+
172
+ self.logger.debug(
173
+ "Plateau with height %s was added to DEM data. Min: %s, max: %s.",
174
+ self.plateau,
175
+ resampled_data.min(),
176
+ resampled_data.max(),
177
+ )
178
+
162
179
  cv2.imwrite(self._dem_path, resampled_data)
163
180
  self.logger.debug("DEM data was saved to %s.", self._dem_path)
164
181
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 0.8.7
3
+ Version: 0.8.9
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
@@ -419,6 +419,8 @@ Here's the list of the advanced settings:
419
419
 
420
420
  - 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.
421
421
 
422
+ - DEM Plateau height: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, which appears to be in a "low" place. By default, it's set to 0.
423
+
422
424
  ## Resources
423
425
  In this section you'll find a list of the resources that you need to create a map for the Farming Simulator.<br>
424
426
  To create a basic map, you only need the Giants Editor. But if you want to create a background terrain - the world around the map, so it won't look like it's floating in the void - you also need Blender and the Blender Exporter Plugins. To create realistic textures for the background terrain, the QGIS is required to obtain high-resolution satellite images.<br>
@@ -2,17 +2,17 @@ maps4fs/__init__.py,sha256=da4jmND2Ths9AffnkAKgzLHNkvKFOc_l21gJisPXqWY,155
2
2
  maps4fs/logger.py,sha256=CneeHxQywjNUJXqQrUUSeiDxu95FfrfyK_Si1v0gMZ8,1477
3
3
  maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
4
4
  maps4fs/generator/background.py,sha256=YZbTSijKgNQOvpWJHqCJNHeoV5GxUjp79b8PoQwRQH0,10778
5
- maps4fs/generator/component.py,sha256=9uGWSIVQzxO_u0yZ3luQJOrpg9x61uBcAHdIr_SaNlw,7402
6
- maps4fs/generator/config.py,sha256=RIqRCPS-ki23JmiFRyt98DVocf-ZaxMsa6yFvoOcHes,3425
7
- maps4fs/generator/dem.py,sha256=FsYcaf0IQSYykKdbkHxAN5-Rc_PZZEBJfdZA2Z-b8AU,14514
5
+ maps4fs/generator/component.py,sha256=g3IBC8ul9zmcG9tHvyPJIg8hxBHFR8kB8Smw9yMW3qA,7864
6
+ maps4fs/generator/config.py,sha256=JkRexT_ZclRa_x0w6ojgG-Tsu4NoshFTUGycRFdfrVk,3463
7
+ maps4fs/generator/dem.py,sha256=p7THncPUdYWtNR2HrTXe0bCuJ8psUV8rRpYPJkzL2gA,15220
8
8
  maps4fs/generator/game.py,sha256=94HjPNOyy6XSSOnBp-uxrkBglKyC-X3ULIrrucfdlKw,6825
9
9
  maps4fs/generator/i3d.py,sha256=UuQiQRusPQ2f6PvGKxJ_UZeXsx3uG15efmy8Ysnm3F8,3597
10
10
  maps4fs/generator/map.py,sha256=BS8ylTCRlHRmbImg73wnHMpBB2ODckVyVZq5KJhCMfM,4236
11
11
  maps4fs/generator/path_steps.py,sha256=rKslIiG9mriCVL9_0i8Oet2p0DITrpBWi0pECpvuyUM,2707
12
12
  maps4fs/generator/texture.py,sha256=0gkohGmamZbmqc9VpPqt8pli_x9w9SnUh2JjYGaiI3I,18170
13
13
  maps4fs/generator/tile.py,sha256=3vmfjQiPiiUZKPuIo5tg2rOKkgcP1NRVkMGK-Vo10-A,2138
14
- maps4fs-0.8.7.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
15
- maps4fs-0.8.7.dist-info/METADATA,sha256=lnZ7LZ2hcyzBeWjvbFlKQ2tOQCcOaCR6H_xYeYZ8QP4,23799
16
- maps4fs-0.8.7.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
- maps4fs-0.8.7.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
18
- maps4fs-0.8.7.dist-info/RECORD,,
14
+ maps4fs-0.8.9.dist-info/LICENSE.md,sha256=-JY0v7p3dwXze61EbYiK7YEJ2aKrjaFZ8y2xYEOrmRY,1068
15
+ maps4fs-0.8.9.dist-info/METADATA,sha256=99ENTzW6vG2TNZDrnN4fBNQtUTYmMzfaFyn93BAZJjY,24031
16
+ maps4fs-0.8.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
+ maps4fs-0.8.9.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
18
+ maps4fs-0.8.9.dist-info/RECORD,,