maps4fs 2.1.6__py3-none-any.whl → 2.1.8__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 +1 -3
- maps4fs/generator/component/i3d.py +11 -12
- maps4fs/generator/map.py +18 -23
- {maps4fs-2.1.6.dist-info → maps4fs-2.1.8.dist-info}/METADATA +1 -1
- {maps4fs-2.1.6.dist-info → maps4fs-2.1.8.dist-info}/RECORD +8 -8
- {maps4fs-2.1.6.dist-info → maps4fs-2.1.8.dist-info}/WHEEL +0 -0
- {maps4fs-2.1.6.dist-info → maps4fs-2.1.8.dist-info}/licenses/LICENSE.md +0 -0
- {maps4fs-2.1.6.dist-info → maps4fs-2.1.8.dist-info}/top_level.txt +0 -0
@@ -601,9 +601,7 @@ class Background(MeshComponent, ImageComponent):
|
|
601
601
|
fitted_polygon = shapely.Polygon(fitted_polygon_points)
|
602
602
|
fitted_polygons.append(fitted_polygon)
|
603
603
|
except Exception as e:
|
604
|
-
self.logger.
|
605
|
-
"Could not fit polygon into bounds with error: %s, polygon: %s", e, polygon
|
606
|
-
)
|
604
|
+
self.logger.debug("Could not fit polygon into bounds with error: %s.", e)
|
607
605
|
continue
|
608
606
|
|
609
607
|
if not fitted_polygons:
|
@@ -562,12 +562,14 @@ class I3d(XMLComponent):
|
|
562
562
|
self.map.i3d_settings.forest_density,
|
563
563
|
)
|
564
564
|
|
565
|
+
shift = (
|
566
|
+
self.map.i3d_settings.forest_density
|
567
|
+
* self.map.i3d_settings.trees_relative_shift
|
568
|
+
/ 100
|
569
|
+
)
|
570
|
+
|
565
571
|
for x, y in self.non_empty_pixels(forest_image, step=step): # type: ignore
|
566
|
-
shifted_x, shifted_y = self.randomize_coordinates(
|
567
|
-
(x, y),
|
568
|
-
step,
|
569
|
-
self.map.i3d_settings.trees_relative_shift,
|
570
|
-
)
|
572
|
+
shifted_x, shifted_y = self.randomize_coordinates((x, y), shift)
|
571
573
|
|
572
574
|
shifted_x, shifted_y = int(shifted_x), int(shifted_y)
|
573
575
|
|
@@ -600,25 +602,23 @@ class I3d(XMLComponent):
|
|
600
602
|
self.forest_info["tree_limit"] = self.map.i3d_settings.tree_limit
|
601
603
|
self.forest_info["initial_step"] = self.map.i3d_settings.forest_density
|
602
604
|
self.forest_info["actual_step"] = step
|
605
|
+
self.forest_info["shift"] = shift
|
603
606
|
|
604
607
|
self.assets.forests = self.xml_path
|
605
608
|
|
606
609
|
@staticmethod
|
607
610
|
def randomize_coordinates(
|
608
|
-
coordinates: tuple[int, int],
|
611
|
+
coordinates: tuple[int, int], shift_range: float
|
609
612
|
) -> tuple[float, float]:
|
610
613
|
"""Randomizes the coordinates of the point with the given density.
|
611
614
|
|
612
615
|
Arguments:
|
613
616
|
coordinates (tuple[int, int]): The coordinates of the point.
|
614
|
-
|
615
|
-
shift_percent (int): Maximum relative shift in percent.
|
617
|
+
shift_range (float): Maximum absolute shift in pixels.
|
616
618
|
|
617
619
|
Returns:
|
618
620
|
tuple[float, float]: The randomized coordinates of the point.
|
619
621
|
"""
|
620
|
-
shift_range = density * shift_percent / 100
|
621
|
-
|
622
622
|
x_shift = uniform(-shift_range, shift_range)
|
623
623
|
y_shift = uniform(-shift_range, shift_range)
|
624
624
|
|
@@ -658,8 +658,7 @@ class I3d(XMLComponent):
|
|
658
658
|
Returns:
|
659
659
|
int: The number of non-empty pixels in the image.
|
660
660
|
"""
|
661
|
-
|
662
|
-
return result
|
661
|
+
return int(np.count_nonzero(image > 0))
|
663
662
|
|
664
663
|
def get_step_by_limit(
|
665
664
|
self, image: np.ndarray, limit: int, current_step: int | None = None
|
maps4fs/generator/map.py
CHANGED
@@ -290,8 +290,6 @@ class Map:
|
|
290
290
|
self.size,
|
291
291
|
self.rotation,
|
292
292
|
)
|
293
|
-
error_text = None
|
294
|
-
|
295
293
|
for game_component in self.game.components:
|
296
294
|
component = game_component(
|
297
295
|
self.game,
|
@@ -311,35 +309,18 @@ class Map:
|
|
311
309
|
|
312
310
|
try:
|
313
311
|
component.process()
|
314
|
-
except Exception as e:
|
315
|
-
self.logger.error(
|
316
|
-
"Error processing component %s: %s",
|
317
|
-
component.__class__.__name__,
|
318
|
-
e,
|
319
|
-
)
|
320
|
-
error_text = str(e)
|
321
|
-
raise e
|
322
|
-
|
323
|
-
finally:
|
324
|
-
with open(self.main_settings_path, "r", encoding="utf-8") as file:
|
325
|
-
main_settings_json = json.load(file)
|
326
|
-
|
327
|
-
main_settings_json["completed"] = True
|
328
|
-
main_settings_json["error"] = error_text
|
329
|
-
|
330
|
-
with open(self.main_settings_path, "w", encoding="utf-8") as file:
|
331
|
-
json.dump(main_settings_json, file, indent=4)
|
332
|
-
|
333
|
-
try:
|
334
312
|
component.commit_generation_info()
|
335
313
|
except Exception as e:
|
336
314
|
self.logger.error(
|
337
|
-
"Error committing generation info for component %s: %s",
|
315
|
+
"Error processing or committing generation info for component %s: %s",
|
338
316
|
component.__class__.__name__,
|
339
317
|
e,
|
340
318
|
)
|
319
|
+
self._update_main_settings({"error": str(e)})
|
341
320
|
raise e
|
342
321
|
|
322
|
+
self._update_main_settings({"completed": True})
|
323
|
+
|
343
324
|
self.logger.debug(
|
344
325
|
"Map generation completed. Game code: %s. Coordinates: %s, size: %s. Rotation: %s.",
|
345
326
|
self.game.code,
|
@@ -348,6 +329,20 @@ class Map:
|
|
348
329
|
self.rotation,
|
349
330
|
)
|
350
331
|
|
332
|
+
def _update_main_settings(self, data: dict[str, Any]) -> None:
|
333
|
+
"""Update main settings with provided data.
|
334
|
+
|
335
|
+
Arguments:
|
336
|
+
data (dict[str, Any]): Data to update main settings.
|
337
|
+
"""
|
338
|
+
with open(self.main_settings_path, "r", encoding="utf-8") as file:
|
339
|
+
main_settings_json = json.load(file)
|
340
|
+
|
341
|
+
main_settings_json.update(data)
|
342
|
+
|
343
|
+
with open(self.main_settings_path, "w", encoding="utf-8") as file:
|
344
|
+
json.dump(main_settings_json, file, indent=4)
|
345
|
+
|
351
346
|
def get_component(self, component_name: str) -> Component | None:
|
352
347
|
"""Get component by name.
|
353
348
|
|
@@ -3,16 +3,16 @@ maps4fs/logger.py,sha256=6sem0aFKQqtVjQ_yNu9iGcc-hqzLQUhfxco05K6nqow,763
|
|
3
3
|
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
4
4
|
maps4fs/generator/config.py,sha256=hBJqCay6mzV2h32EqTCFYywvrOuMpkvOCF9IDBBtO2U,1572
|
5
5
|
maps4fs/generator/game.py,sha256=Qqeh1rg0RFghhu9uhBMn_XKXYkTkg7fsjY1xO2eIZRw,13777
|
6
|
-
maps4fs/generator/map.py,sha256=
|
6
|
+
maps4fs/generator/map.py,sha256=VOJJYQYzSkk-ed38R__SoYpi50YUYWO8kpLeZ2TB6tM,19024
|
7
7
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
8
8
|
maps4fs/generator/settings.py,sha256=8dN96L5Ueb5LxgJaKNv8-zH2Yym627o4Uj8zJYHfT8g,11312
|
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=JANbVgcBXpaQ0HB1eeV16KkFgpU-Txj5kB5eJNEDAv0,34473
|
12
12
|
maps4fs/generator/component/config.py,sha256=uL76h9UwyhZKZmbxz0mBmWtEPN6qYay4epTEqqtej60,8601
|
13
13
|
maps4fs/generator/component/dem.py,sha256=mtsdTIcEHmR9mW1LMcCaX4F2OCch9BM_WXHkvJby9ZY,11930
|
14
14
|
maps4fs/generator/component/grle.py,sha256=3BKGlR0q0t0NvmqeT81WieS6MIc_UlMQjIDDZiqTiws,27243
|
15
|
-
maps4fs/generator/component/i3d.py,sha256=
|
15
|
+
maps4fs/generator/component/i3d.py,sha256=RvpiW9skkZ6McyahC-AeIdPuSQjpXiFs1l0xOioJAu4,26638
|
16
16
|
maps4fs/generator/component/layer.py,sha256=U_DzJTn1m_yGOtwuvbXxr7oL7YHHBGBcK37lyJNnZDk,6508
|
17
17
|
maps4fs/generator/component/satellite.py,sha256=9nKwL8zQ-BB6WFMx2m8zduFn6RaxSNv6Vtpge1-QMYE,5052
|
18
18
|
maps4fs/generator/component/texture.py,sha256=Ngvfe51grb6Ead6WvNjx1Zr0yz65y8y2vY8xUteLoNo,35019
|
@@ -21,8 +21,8 @@ maps4fs/generator/component/base/component.py,sha256=AP7b6rmYV_HdyyHlCTo9s6fyBXy
|
|
21
21
|
maps4fs/generator/component/base/component_image.py,sha256=WTGC6v1KuS5sLNCC95Z48nCspvATKKNOuhTNYzTWXr4,8315
|
22
22
|
maps4fs/generator/component/base/component_mesh.py,sha256=3hC-qDT8Vde6SmRMqs9USAkrF-gL2dDTYW71ATpxUS4,9130
|
23
23
|
maps4fs/generator/component/base/component_xml.py,sha256=MT-VhU2dEckLFxAgmxg6V3gnv11di_94Qq6atfpOLdc,5342
|
24
|
-
maps4fs-2.1.
|
25
|
-
maps4fs-2.1.
|
26
|
-
maps4fs-2.1.
|
27
|
-
maps4fs-2.1.
|
28
|
-
maps4fs-2.1.
|
24
|
+
maps4fs-2.1.8.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
25
|
+
maps4fs-2.1.8.dist-info/METADATA,sha256=A1yjg3hwPS8EptLoOemoTdMW645MbvQDfAv8aKvRDII,45431
|
26
|
+
maps4fs-2.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
27
|
+
maps4fs-2.1.8.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
28
|
+
maps4fs-2.1.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|