maps4fs 2.2.2__py3-none-any.whl → 2.2.4__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/layer.py +3 -0
- maps4fs/generator/component/texture.py +41 -0
- {maps4fs-2.2.2.dist-info → maps4fs-2.2.4.dist-info}/METADATA +3 -1
- {maps4fs-2.2.2.dist-info → maps4fs-2.2.4.dist-info}/RECORD +7 -7
- {maps4fs-2.2.2.dist-info → maps4fs-2.2.4.dist-info}/WHEEL +0 -0
- {maps4fs-2.2.2.dist-info → maps4fs-2.2.4.dist-info}/licenses/LICENSE.md +0 -0
- {maps4fs-2.2.2.dist-info → maps4fs-2.2.4.dist-info}/top_level.txt +0 -0
@@ -49,6 +49,7 @@ class Layer:
|
|
49
49
|
area_type: str | None = None,
|
50
50
|
area_water: bool = False,
|
51
51
|
indoor: bool = False,
|
52
|
+
merge_into: str | None = None,
|
52
53
|
):
|
53
54
|
self.name = name
|
54
55
|
self.count = count
|
@@ -68,6 +69,7 @@ class Layer:
|
|
68
69
|
self.area_type = area_type
|
69
70
|
self.area_water = area_water
|
70
71
|
self.indoor = indoor
|
72
|
+
self.merge_into = merge_into
|
71
73
|
|
72
74
|
def to_json(self) -> dict[str, str | list[str] | bool]: # type: ignore
|
73
75
|
"""Returns dictionary with layer data.
|
@@ -93,6 +95,7 @@ class Layer:
|
|
93
95
|
"area_type": self.area_type,
|
94
96
|
"area_water": self.area_water,
|
95
97
|
"indoor": self.indoor,
|
98
|
+
"merge_into": self.merge_into,
|
96
99
|
}
|
97
100
|
|
98
101
|
data = {k: v for k, v in data.items() if v is not None}
|
@@ -172,6 +172,7 @@ class Texture(ImageComponent):
|
|
172
172
|
self._read_parameters()
|
173
173
|
self.draw()
|
174
174
|
self.rotate_textures()
|
175
|
+
self.merge_into()
|
175
176
|
|
176
177
|
if not self.kwargs.get("skip_scaling", False):
|
177
178
|
self.scale_textures()
|
@@ -256,6 +257,46 @@ class Texture(ImageComponent):
|
|
256
257
|
"Procedural file %s copied from %s.", procedural_save_path, texture_paths[0]
|
257
258
|
)
|
258
259
|
|
260
|
+
def get_layer_by_name(self, layer_name: str) -> Layer | None:
|
261
|
+
"""Returns the layer with the given name.
|
262
|
+
|
263
|
+
Arguments:
|
264
|
+
layer_name: The name of the layer to retrieve.
|
265
|
+
|
266
|
+
Returns:
|
267
|
+
The layer with the given name, or None if not found.
|
268
|
+
"""
|
269
|
+
for layer in self.layers:
|
270
|
+
if layer.name == layer_name:
|
271
|
+
return layer
|
272
|
+
return None
|
273
|
+
|
274
|
+
def merge_into(self) -> None:
|
275
|
+
"""Merges the content of layers into their target layers."""
|
276
|
+
for layer in self.layers:
|
277
|
+
if layer.merge_into:
|
278
|
+
target_layer = self.get_layer_by_name(layer.merge_into)
|
279
|
+
if target_layer:
|
280
|
+
target_layer_image = cv2.imread(
|
281
|
+
target_layer.path(self._weights_dir), cv2.IMREAD_UNCHANGED
|
282
|
+
)
|
283
|
+
layer_image = cv2.imread(layer.path(self._weights_dir), cv2.IMREAD_UNCHANGED)
|
284
|
+
if target_layer_image is not None and layer_image is not None:
|
285
|
+
if target_layer_image.shape != layer_image.shape:
|
286
|
+
self.logger.warning(
|
287
|
+
"Layer %s and target layer %s have different shapes, skipping merge.",
|
288
|
+
layer.name,
|
289
|
+
target_layer.name,
|
290
|
+
)
|
291
|
+
continue
|
292
|
+
target_layer_image = cv2.add(target_layer_image, layer_image)
|
293
|
+
cv2.imwrite(target_layer.path(self._weights_dir), target_layer_image)
|
294
|
+
self.logger.debug("Merged layer %s into %s.", layer.name, target_layer.name)
|
295
|
+
|
296
|
+
# Clear the content of the layer which have merge_into property.
|
297
|
+
cv2.imwrite(layer.path(self._weights_dir), np.zeros_like(layer_image))
|
298
|
+
self.logger.debug("Cleared layer %s.", layer.name)
|
299
|
+
|
259
300
|
def rotate_textures(self) -> None:
|
260
301
|
"""Rotates textures of the layers which have tags."""
|
261
302
|
if self.rotation:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 2.2.
|
3
|
+
Version: 2.2.4
|
4
4
|
Summary: Generate map templates for Farming Simulator from real places.
|
5
5
|
Author-email: iwatkot <iwatkot@gmail.com>
|
6
6
|
License: Apache License 2.0
|
@@ -36,6 +36,7 @@ Dynamic: license-file
|
|
36
36
|
<p align="center">
|
37
37
|
<a href="https://github.com/iwatkot/maps4fs">maps4fs</a> •
|
38
38
|
<a href="https://github.com/iwatkot/maps4fsui">maps4fs UI</a> •
|
39
|
+
<a href="https://github.com/iwatkot/maps4fsdata">maps4fs Data</a> •
|
39
40
|
<a href="https://github.com/iwatkot/maps4fsapi">maps4fs API</a> •
|
40
41
|
<a href="https://github.com/iwatkot/maps4fsstats">maps4fs Stats</a> •
|
41
42
|
<a href="https://github.com/iwatkot/maps4fsbot">maps4fs Bot</a><br>
|
@@ -566,6 +567,7 @@ Let's have a closer look at the fields:
|
|
566
567
|
- `area_type` - one of the supported by Giants Editor area types, such as: "open_land", "city", "village", "harbor", "industrial", "open_water". It will be reflected in the environment info layer file.
|
567
568
|
- `area_water` - whenever this field is set to true, the area will be considered as water, and it will be changed in the environment info layer file.
|
568
569
|
- `indoor` - whenever this field is set to true, the area will be considered as indoor, and it will be reflected in the indoorMask info layer.
|
570
|
+
- `merge_into` - if specified, the layer with this parameter will be merged into the target layer and the content of the layer will be transferred to the target layer.
|
569
571
|
|
570
572
|
## Background terrain
|
571
573
|
|
@@ -13,16 +13,16 @@ maps4fs/generator/component/config.py,sha256=uL76h9UwyhZKZmbxz0mBmWtEPN6qYay4epT
|
|
13
13
|
maps4fs/generator/component/dem.py,sha256=mtsdTIcEHmR9mW1LMcCaX4F2OCch9BM_WXHkvJby9ZY,11930
|
14
14
|
maps4fs/generator/component/grle.py,sha256=3BKGlR0q0t0NvmqeT81WieS6MIc_UlMQjIDDZiqTiws,27243
|
15
15
|
maps4fs/generator/component/i3d.py,sha256=RvpiW9skkZ6McyahC-AeIdPuSQjpXiFs1l0xOioJAu4,26638
|
16
|
-
maps4fs/generator/component/layer.py,sha256=
|
16
|
+
maps4fs/generator/component/layer.py,sha256=bdy1XGOODyPqYUM3b_wEY2H9Piz-AaHsCDecl-qRHiM,6627
|
17
17
|
maps4fs/generator/component/satellite.py,sha256=9nKwL8zQ-BB6WFMx2m8zduFn6RaxSNv6Vtpge1-QMYE,5052
|
18
|
-
maps4fs/generator/component/texture.py,sha256=
|
18
|
+
maps4fs/generator/component/texture.py,sha256=gXZgr73ehT3_qjuIku0j7N7exloywtmmEQKBJ-MDcco,36988
|
19
19
|
maps4fs/generator/component/base/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
20
20
|
maps4fs/generator/component/base/component.py,sha256=lf0V9CLUXMg88Nm2yI3rP5taVYYlNivud0x6kbhBYqA,23312
|
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.2.
|
25
|
-
maps4fs-2.2.
|
26
|
-
maps4fs-2.2.
|
27
|
-
maps4fs-2.2.
|
28
|
-
maps4fs-2.2.
|
24
|
+
maps4fs-2.2.4.dist-info/licenses/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
25
|
+
maps4fs-2.2.4.dist-info/METADATA,sha256=eERUUj3CU-kYEDNWZebq5xjGnwbBKy-bdLfBL94F8V0,46314
|
26
|
+
maps4fs-2.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
27
|
+
maps4fs-2.2.4.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
28
|
+
maps4fs-2.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|