maps4fs 1.8.235__py3-none-any.whl → 1.8.237__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/background.py +54 -0
- maps4fs/generator/settings.py +2 -0
- {maps4fs-1.8.235.dist-info → maps4fs-1.8.237.dist-info}/METADATA +3 -1
- {maps4fs-1.8.235.dist-info → maps4fs-1.8.237.dist-info}/RECORD +7 -7
- {maps4fs-1.8.235.dist-info → maps4fs-1.8.237.dist-info}/LICENSE.md +0 -0
- {maps4fs-1.8.235.dist-info → maps4fs-1.8.237.dist-info}/WHEEL +0 -0
- {maps4fs-1.8.235.dist-info → maps4fs-1.8.237.dist-info}/top_level.txt +0 -0
@@ -10,6 +10,7 @@ from copy import deepcopy
|
|
10
10
|
|
11
11
|
import cv2
|
12
12
|
import numpy as np
|
13
|
+
from tqdm import tqdm
|
13
14
|
|
14
15
|
from maps4fs.generator.component.base.component_image import ImageComponent
|
15
16
|
from maps4fs.generator.component.base.component_mesh import MeshComponent
|
@@ -101,6 +102,56 @@ class Background(MeshComponent, ImageComponent):
|
|
101
102
|
if self.map.background_settings.generate_water:
|
102
103
|
self.generate_water_resources_obj()
|
103
104
|
|
105
|
+
def create_foundations(self, dem_image: np.ndarray) -> np.ndarray:
|
106
|
+
"""Creates foundations for buildings based on the DEM data.
|
107
|
+
|
108
|
+
Arguments:
|
109
|
+
dem_image (np.ndarray): The DEM data as a numpy array.
|
110
|
+
|
111
|
+
Returns:
|
112
|
+
np.ndarray: The DEM data with the foundations added.
|
113
|
+
"""
|
114
|
+
buildings = self.get_infolayer_data(Parameters.TEXTURES, Parameters.BUILDINGS)
|
115
|
+
if not buildings:
|
116
|
+
self.logger.warning("Buildings data not found in textures info layer.")
|
117
|
+
return dem_image
|
118
|
+
|
119
|
+
self.logger.debug("Found %s buildings in textures info layer.", len(buildings))
|
120
|
+
|
121
|
+
for building in tqdm(buildings, desc="Creating foundations", unit="building"):
|
122
|
+
try:
|
123
|
+
fitted_building = self.fit_object_into_bounds(
|
124
|
+
polygon_points=building, angle=self.rotation
|
125
|
+
)
|
126
|
+
except ValueError as e:
|
127
|
+
self.logger.debug(
|
128
|
+
"Building could not be fitted into the map bounds with error: %s",
|
129
|
+
e,
|
130
|
+
)
|
131
|
+
continue
|
132
|
+
|
133
|
+
# 1. Read the pixel values from the DEM image.
|
134
|
+
# 2. Calculate the average pixel value of the building area.
|
135
|
+
# 3. Set the pixel values in the DEM to the average pixel value.
|
136
|
+
|
137
|
+
building_np = self.polygon_points_to_np(fitted_building)
|
138
|
+
mask = np.zeros(dem_image.shape, dtype=np.uint8)
|
139
|
+
|
140
|
+
try:
|
141
|
+
cv2.fillPoly(mask, [building_np], 255) # type: ignore
|
142
|
+
except Exception as e:
|
143
|
+
self.logger.debug("Could not create mask for building with error: %s", e)
|
144
|
+
continue
|
145
|
+
|
146
|
+
mean_value = cv2.mean(dem_image, mask=mask)[0]
|
147
|
+
mean_value = np.round(mean_value).astype(dem_image.dtype)
|
148
|
+
self.logger.info("Mean value of the building area: %s", mean_value)
|
149
|
+
|
150
|
+
# Set the pixel values in the DEM to the average pixel value.
|
151
|
+
dem_image[mask == 255] = mean_value
|
152
|
+
|
153
|
+
return dem_image
|
154
|
+
|
104
155
|
def make_copy(self, dem_path: str, dem_name: str) -> None:
|
105
156
|
"""Copies DEM data to additional DEM file.
|
106
157
|
|
@@ -198,6 +249,9 @@ class Background(MeshComponent, ImageComponent):
|
|
198
249
|
self.logger.debug("Not resized DEM saved: %s", save_path)
|
199
250
|
return save_path
|
200
251
|
|
252
|
+
if self.map.dem_settings.add_foundations:
|
253
|
+
dem_data = self.create_foundations(dem_data)
|
254
|
+
|
201
255
|
output_size = self.map_size + 1
|
202
256
|
|
203
257
|
main_dem_path = self.game.dem_file_path(self.map_directory)
|
maps4fs/generator/settings.py
CHANGED
@@ -13,6 +13,7 @@ class Parameters:
|
|
13
13
|
|
14
14
|
FIELD = "field"
|
15
15
|
FIELDS = "fields"
|
16
|
+
BUILDINGS = "buildings"
|
16
17
|
TEXTURES = "textures"
|
17
18
|
FOREST = "forest"
|
18
19
|
ROADS_POLYLINES = "roads_polylines"
|
@@ -133,6 +134,7 @@ class DEMSettings(SettingsModel):
|
|
133
134
|
ceiling: int = 0
|
134
135
|
water_depth: int = 0
|
135
136
|
blur_radius: int = 3
|
137
|
+
add_foundations: bool = False
|
136
138
|
|
137
139
|
|
138
140
|
class BackgroundSettings(SettingsModel):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 1.8.
|
3
|
+
Version: 1.8.237
|
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
|
@@ -590,6 +590,8 @@ You can also apply some advanced settings to the map generation process.<br>
|
|
590
590
|
|
591
591
|
- Water depth: Water depth value (in meters) will be subtracted from the DEM image, making the water deeper. The pixel value used for this is calculated based on the heightScale value for your map.
|
592
592
|
|
593
|
+
- Add foundations: If enabled the terrain under the buildings will be flattened to the average height of the building.
|
594
|
+
|
593
595
|
### Background terrain Advanced settings
|
594
596
|
|
595
597
|
- Generate background - if enabled, the obj files for the background terrain will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
|
@@ -5,10 +5,10 @@ maps4fs/generator/dem.py,sha256=a9B3tatj7pzvvdLIyLw7BA3JoDTibFczpqiXJnx054U,1286
|
|
5
5
|
maps4fs/generator/game.py,sha256=NZaxj5z7WzMiHzAvQyr-TvVjGoHgqGldM6ZsItuYyzA,11292
|
6
6
|
maps4fs/generator/map.py,sha256=tgbpu3xxtFFWMualvaOnfnBXjDYWqAa_xIpu-OvcnbQ,12636
|
7
7
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
8
|
-
maps4fs/generator/settings.py,sha256
|
8
|
+
maps4fs/generator/settings.py,sha256=-QdpmIoMiWXPeqYX5QQ5Pplz9xHk2OnyBdzRIc7aB44,6848
|
9
9
|
maps4fs/generator/statistics.py,sha256=aynS3zbAtiwnU_YLKHPTiiaKW98_suvQUhy1SGBA6mc,2448
|
10
10
|
maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM2x7vAC7GX4,490
|
11
|
-
maps4fs/generator/component/background.py,sha256=
|
11
|
+
maps4fs/generator/component/background.py,sha256=RhUDOTfo7Ph9B2bM5tp85wTg6FKycpsf1L_pHYa2TLc,21152
|
12
12
|
maps4fs/generator/component/config.py,sha256=RitKgFDZPzjA1fi8GcEi1na75qqaueUvpcITHjBvCXc,3674
|
13
13
|
maps4fs/generator/component/grle.py,sha256=C6wpYQrJBVRb3vVbEAY5BYTRYU9BaefmoWCXoPrVn2A,19454
|
14
14
|
maps4fs/generator/component/i3d.py,sha256=yWGs5eBuBT7V4F6SbTNAmF-8fj2Zy4kcC5OKZ_XVICs,21329
|
@@ -53,8 +53,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
|
|
53
53
|
maps4fs/toolbox/background.py,sha256=RclEqxEWLbMxuEkkegQP8jybzugwQ1_R3rdfDe0s21U,2104
|
54
54
|
maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
|
55
55
|
maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
|
56
|
-
maps4fs-1.8.
|
57
|
-
maps4fs-1.8.
|
58
|
-
maps4fs-1.8.
|
59
|
-
maps4fs-1.8.
|
60
|
-
maps4fs-1.8.
|
56
|
+
maps4fs-1.8.237.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
57
|
+
maps4fs-1.8.237.dist-info/METADATA,sha256=cYwHiebwnB_vFE-JNMqZBw2xXiU4XNL5rJjWAOpldCY,46159
|
58
|
+
maps4fs-1.8.237.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
59
|
+
maps4fs-1.8.237.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
60
|
+
maps4fs-1.8.237.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|