maps4fs 2.9.2__py3-none-any.whl → 2.9.37__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.
@@ -81,6 +81,9 @@ class Background(MeshComponent, ImageComponent):
81
81
  self.not_resized_with_foundations_path: str = os.path.join(
82
82
  self.background_directory, "not_resized_with_foundations.png"
83
83
  )
84
+ self.not_resized_with_flattened_roads_path: str = os.path.join(
85
+ self.background_directory, "not_resized_with_flattened_roads.png"
86
+ )
84
87
 
85
88
  self.flatten_water_to: int | None = None
86
89
 
@@ -823,6 +826,10 @@ class Background(MeshComponent, ImageComponent):
823
826
 
824
827
  if self.map.background_settings.flatten_water:
825
828
  try:
829
+ # Check if there are any water pixels (255) in the water resources image.
830
+ if not np.any(water_resources_image == 255):
831
+ self.logger.warning("No water pixels found in water resources image.")
832
+ return
826
833
  mask = water_resources_image == 255
827
834
  flatten_to = int(np.mean(dem_image[mask]) - subtract_by) # type: ignore
828
835
  self.flatten_water_to = flatten_to # type: ignore
@@ -862,13 +869,14 @@ class Background(MeshComponent, ImageComponent):
862
869
  """
863
870
  self.logger.debug("Starting line-based water generation...")
864
871
  water_polygons = self.get_infolayer_data(Parameters.BACKGROUND, Parameters.WATER)
865
- self.logger.debug(
866
- "Found %s water polygons in background info layer.", len(water_polygons) # type: ignore
867
- )
868
872
  if not water_polygons:
869
873
  self.logger.warning("No water polygons found in background info layer.")
870
874
  return
871
875
 
876
+ self.logger.debug(
877
+ "Found %s water polygons in background info layer.", len(water_polygons) # type: ignore
878
+ )
879
+
872
880
  polygons: list[shapely.Polygon] = []
873
881
  for polygon_points in water_polygons:
874
882
  if not polygon_points or len(polygon_points) < 2:
@@ -1184,6 +1192,13 @@ class Background(MeshComponent, ImageComponent):
1184
1192
  dem_image = self.blur_by_mask(dem_image, full_mask, blur_radius=5)
1185
1193
  dem_image = self.blur_edges_by_mask(dem_image, full_mask)
1186
1194
 
1195
+ # Save the not resized DEM with flattened roads.
1196
+ cv2.imwrite(self.not_resized_with_flattened_roads_path, dem_image)
1197
+ self.logger.debug(
1198
+ "Not resized DEM with flattened roads saved to: %s",
1199
+ self.not_resized_with_flattened_roads_path,
1200
+ )
1201
+
1187
1202
  output_size = dem_image.shape[0] + 1
1188
1203
  resized_dem = cv2.resize(
1189
1204
  dem_image, (output_size, output_size), interpolation=cv2.INTER_NEAREST