valetudo-map-parser 0.1.9b75__py3-none-any.whl → 0.1.10__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.
Files changed (33) hide show
  1. valetudo_map_parser/__init__.py +25 -7
  2. valetudo_map_parser/config/auto_crop.py +2 -27
  3. valetudo_map_parser/config/color_utils.py +3 -4
  4. valetudo_map_parser/config/colors.py +2 -2
  5. valetudo_map_parser/config/drawable.py +102 -153
  6. valetudo_map_parser/config/drawable_elements.py +0 -2
  7. valetudo_map_parser/config/fonts/FiraSans.ttf +0 -0
  8. valetudo_map_parser/config/fonts/Inter-VF.ttf +0 -0
  9. valetudo_map_parser/config/fonts/Lato-Regular.ttf +0 -0
  10. valetudo_map_parser/config/fonts/MPLUSRegular.ttf +0 -0
  11. valetudo_map_parser/config/fonts/NotoKufiArabic-VF.ttf +0 -0
  12. valetudo_map_parser/config/fonts/NotoSansCJKhk-VF.ttf +0 -0
  13. valetudo_map_parser/config/fonts/NotoSansKhojki.ttf +0 -0
  14. valetudo_map_parser/config/rand256_parser.py +169 -44
  15. valetudo_map_parser/config/shared.py +103 -101
  16. valetudo_map_parser/config/status_text/status_text.py +96 -0
  17. valetudo_map_parser/config/status_text/translations.py +280 -0
  18. valetudo_map_parser/config/types.py +42 -13
  19. valetudo_map_parser/config/utils.py +221 -181
  20. valetudo_map_parser/hypfer_draw.py +6 -169
  21. valetudo_map_parser/hypfer_handler.py +40 -130
  22. valetudo_map_parser/map_data.py +403 -84
  23. valetudo_map_parser/rand256_handler.py +53 -197
  24. valetudo_map_parser/reimg_draw.py +14 -24
  25. valetudo_map_parser/rooms_handler.py +3 -18
  26. {valetudo_map_parser-0.1.9b75.dist-info → valetudo_map_parser-0.1.10.dist-info}/METADATA +7 -4
  27. valetudo_map_parser-0.1.10.dist-info/RECORD +34 -0
  28. {valetudo_map_parser-0.1.9b75.dist-info → valetudo_map_parser-0.1.10.dist-info}/WHEEL +1 -1
  29. valetudo_map_parser/config/enhanced_drawable.py +0 -324
  30. valetudo_map_parser/hypfer_rooms_handler.py +0 -599
  31. valetudo_map_parser-0.1.9b75.dist-info/RECORD +0 -27
  32. {valetudo_map_parser-0.1.9b75.dist-info → valetudo_map_parser-0.1.10.dist-info/licenses}/LICENSE +0 -0
  33. {valetudo_map_parser-0.1.9b75.dist-info → valetudo_map_parser-0.1.10.dist-info/licenses}/NOTICE.txt +0 -0
@@ -7,7 +7,6 @@ Version: 0.1.9
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
- import time
11
10
  from typing import Any, Dict, List, Optional, Tuple
12
11
 
13
12
  import numpy as np
@@ -16,8 +15,7 @@ from scipy.spatial import ConvexHull
16
15
 
17
16
  from .config.drawable_elements import DrawableElement, DrawingConfig
18
17
  from .config.types import LOGGER, RoomsProperties
19
-
20
- from .map_data import RandImageData, ImageData
18
+ from .map_data import RandImageData
21
19
 
22
20
 
23
21
  class RoomsHandler:
@@ -104,14 +102,11 @@ class RoomsHandler:
104
102
  is_enabled = self.drawing_config.is_enabled(room_element)
105
103
  if not is_enabled:
106
104
  # Skip this room if it's disabled
107
- LOGGER.debug("Skipping disabled room %s", segment_id)
108
105
  return None, None
109
106
  except (ValueError, TypeError):
110
107
  # If segment_id is not a valid integer, we can't map it to a room element
111
108
  # In this case, we'll include the room (fail open)
112
- LOGGER.debug(
113
- "Could not convert segment_id %s to room element", segment_id
114
- )
109
+ pass
115
110
 
116
111
  # Optimization: Create a smaller mask for just the room area
117
112
  if not pixels:
@@ -207,7 +202,6 @@ class RoomsHandler:
207
202
  Returns:
208
203
  Dictionary of room properties
209
204
  """
210
- start_total = time.time()
211
205
  room_properties = {}
212
206
  pixel_size = json_data.get("pixelSize", 5)
213
207
  height = json_data["size"]["y"]
@@ -220,10 +214,6 @@ class RoomsHandler:
220
214
  )
221
215
  if room_id is not None and room_data is not None:
222
216
  room_properties[room_id] = room_data
223
-
224
- # Log timing information
225
- total_time = time.time() - start_total
226
- LOGGER.debug("Room extraction Total time: %.3fs", total_time)
227
217
  return room_properties
228
218
 
229
219
 
@@ -339,11 +329,11 @@ class RandRoomsHandler:
339
329
  is_enabled = self.drawing_config.is_enabled(room_element)
340
330
  if not is_enabled:
341
331
  # Skip this room if it's disabled
342
- LOGGER.debug("Skipping disabled room %s", segment_id)
343
332
  return None, None
344
333
  except (ValueError, TypeError):
345
334
  # If segment_id is not a valid integer, we can't map it to a room element
346
335
  # In this case, we'll include the room (fail open)
336
+ pass
347
337
  LOGGER.debug(
348
338
  "Could not convert segment_id %s to room element", segment_id
349
339
  )
@@ -399,7 +389,6 @@ class RandRoomsHandler:
399
389
  Returns:
400
390
  Dictionary of room properties
401
391
  """
402
- start_total = time.time()
403
392
  room_properties = {}
404
393
 
405
394
  # Get basic map information
@@ -467,8 +456,4 @@ class RandRoomsHandler:
467
456
 
468
457
  room_properties[room_id] = room_data
469
458
 
470
- # Log timing information
471
- total_time = time.time() - start_total
472
- LOGGER.debug("Room extraction Total time: %.3fs", total_time)
473
-
474
459
  return room_properties
@@ -1,16 +1,19 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: valetudo-map-parser
3
- Version: 0.1.9b75
3
+ Version: 0.1.10
4
4
  Summary: A Python library to parse Valetudo map data returning a PIL Image object.
5
5
  License: Apache-2.0
6
+ License-File: LICENSE
7
+ License-File: NOTICE.txt
6
8
  Author: Sandro Cantarella
7
9
  Author-email: gsca075@gmail.com
8
- Requires-Python: >=3.12
10
+ Requires-Python: >=3.13
9
11
  Classifier: License :: OSI Approved :: Apache Software License
10
12
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.12
12
13
  Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
13
15
  Requires-Dist: Pillow (>=10.3.0)
16
+ Requires-Dist: mvcrender (>=0.0.5)
14
17
  Requires-Dist: numpy (>=1.26.4)
15
18
  Requires-Dist: scipy (>=1.12.0)
16
19
  Project-URL: Bug Tracker, https://github.com/sca075/Python-package-valetudo-map-parser/issues
@@ -0,0 +1,34 @@
1
+ valetudo_map_parser/__init__.py,sha256=l_O2iyvj49KkUtuW7lMIZJcEaV_6_-YFaVZkiVeSh9g,1743
2
+ valetudo_map_parser/config/__init__.py,sha256=DQ9plV3ZF_K25Dp5ZQHPDoG-40dQoJNdNi-dfNeR3Zc,48
3
+ valetudo_map_parser/config/async_utils.py,sha256=e1j9uTtg4dhPVWvB2_XgqaH4aeSjRAPz-puRMbGoOs8,3204
4
+ valetudo_map_parser/config/auto_crop.py,sha256=oNb8oazitd0h5q3hUkCZXeF7KxDGK90QuugLe5VEZeo,18180
5
+ valetudo_map_parser/config/color_utils.py,sha256=LBdXo_40Ff9llgsIzjxD7V-hP9NceZIvAaxhBpI_Fhw,4463
6
+ valetudo_map_parser/config/colors.py,sha256=DMY5aHDS-alW2CZ2j8U7QVGHK_H8M0fBDX2OGuryirc,29914
7
+ valetudo_map_parser/config/drawable.py,sha256=WuoDuiFwLkPLHBMZEGrsRQGACrOdmrUeWgLbi406PNE,31565
8
+ valetudo_map_parser/config/drawable_elements.py,sha256=_iHdAuzbAoIOeT8JEZrvSu5fVojIdhAyH5ABUVi-x3Y,11496
9
+ valetudo_map_parser/config/fonts/FiraSans.ttf,sha256=Pavz1Iv0WZ-Vz_2S-Z6kJqAU1TEfUqXrXsOvJl6XzZc,440984
10
+ valetudo_map_parser/config/fonts/Inter-VF.ttf,sha256=zzy0OwNm4txt9g4RMrHJpMFXd_DNjlpT4MFRJAA-ntQ,804612
11
+ valetudo_map_parser/config/fonts/Lato-Regular.ttf,sha256=6CVCrtgpP0n8g8Sq6lZrH2tPx6mrXaEeb7m8CXO1Mks,75152
12
+ valetudo_map_parser/config/fonts/MPLUSRegular.ttf,sha256=IGdcNSRP4dDxQskbE3Ybuwz7T0flhCBuzwfhLMcPt9s,3380812
13
+ valetudo_map_parser/config/fonts/NotoKufiArabic-VF.ttf,sha256=NaIy40eLx7d3ts0kuenp0GjWd-YN24J6DpSvX2L3vLA,433800
14
+ valetudo_map_parser/config/fonts/NotoSansCJKhk-VF.ttf,sha256=xIXXLKCJzmWoPEg8HdvxeRgotMjjxF6l6ugGP-IWRJU,36135040
15
+ valetudo_map_parser/config/fonts/NotoSansKhojki.ttf,sha256=XJWzSmpN-Ql6jTfTvFojP_JkCHOztQvixQc1_7hPWrc,107388
16
+ valetudo_map_parser/config/optimized_element_map.py,sha256=52BCnkvVv9bre52LeVIfT8nhnEIpc0TuWTv1xcNu0Rk,15744
17
+ valetudo_map_parser/config/rand256_parser.py,sha256=3ZoVu7Wj091prm80QTnJ06F2pcbXB0EMF948-BCt478,21505
18
+ valetudo_map_parser/config/shared.py,sha256=1MN04rZAicZ4ZyKnpEYLkF-Yx5PjCzfvB0DoYdiMnok,11790
19
+ valetudo_map_parser/config/status_text/status_text.py,sha256=29E8b3adl_Rr_BH8-J35ia2cOS716sPzVk_cezFiWQ4,4053
20
+ valetudo_map_parser/config/status_text/translations.py,sha256=mmPbJkl_2A59w49wnesQf3ocXqwZxBsrqNX-yt5FSCQ,9132
21
+ valetudo_map_parser/config/types.py,sha256=ospbcr6apPvDm91KWjiB4SoYVuU6z0OwEMX5cwczpBc,18134
22
+ valetudo_map_parser/config/utils.py,sha256=vpHxapGPyYjWwzc23J4XTm6EgCzC2wq7icjqUuiEK4o,38369
23
+ valetudo_map_parser/hypfer_draw.py,sha256=4zajujSOvtpRI_GMlmlioM3mDo19MvuOP861LhZmVlw,22495
24
+ valetudo_map_parser/hypfer_handler.py,sha256=WTIM3UQaW2XXtnxbRF0M-yzSJtptYI6RW1MIYAdfvPg,19968
25
+ valetudo_map_parser/map_data.py,sha256=1-kxE82o8BfaJojYrD0LXoUAgCNpD6d50yLGc4w7ZWc,27433
26
+ valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ valetudo_map_parser/rand256_handler.py,sha256=K5ygOilr1jri-amMpqybC_4Fp9x0pZr3PAVgG98rC_M,21495
28
+ valetudo_map_parser/reimg_draw.py,sha256=Pwm_QUHiJd4o657qr-mlsWQ_TtGCBB-ucsA84t-IwOg,12474
29
+ valetudo_map_parser/rooms_handler.py,sha256=vr_1LUZg11-z9dHo6fnWZTnTpguM4oNbtw6ZnxvKZ6Y,17175
30
+ valetudo_map_parser-0.1.10.dist-info/METADATA,sha256=_FCSBZ7vNOkbxzhn42MkattttPLlNMshSxdWS98V58E,3401
31
+ valetudo_map_parser-0.1.10.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
32
+ valetudo_map_parser-0.1.10.dist-info/licenses/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
33
+ valetudo_map_parser-0.1.10.dist-info/licenses/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
34
+ valetudo_map_parser-0.1.10.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,324 +0,0 @@
1
- """
2
- Enhanced Drawable Class.
3
- Provides drawing utilities with element selection support.
4
- Version: 0.1.9
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- import logging
10
-
11
- # math is not used in this file
12
- from typing import Optional, Tuple
13
-
14
- import numpy as np
15
-
16
- from .colors import ColorsManagement
17
- from .drawable import Drawable
18
- from .drawable_elements import (
19
- DrawableElement,
20
- DrawingConfig,
21
- )
22
-
23
-
24
- # Type aliases
25
- NumpyArray = np.ndarray
26
- Color = Tuple[int, int, int, int]
27
-
28
- _LOGGER = logging.getLogger(__name__)
29
-
30
-
31
- class EnhancedDrawable(Drawable):
32
- """Enhanced drawing utilities with element selection support."""
33
-
34
- def __init__(self, drawing_config: Optional[DrawingConfig] = None):
35
- """Initialize with optional drawing configuration."""
36
- super().__init__()
37
- self.drawing_config = drawing_config or DrawingConfig()
38
-
39
- # Color blending methods have been moved to ColorsManagement class in colors.py
40
-
41
- # Pixel blending methods have been moved to ColorsManagement class in colors.py
42
-
43
- async def draw_map(
44
- self, map_data: dict, base_array: Optional[NumpyArray] = None
45
- ) -> NumpyArray:
46
- """
47
- Draw the map with selected elements.
48
-
49
- Args:
50
- map_data: The map data dictionary
51
- base_array: Optional base array to draw on
52
-
53
- Returns:
54
- The image array with all elements drawn
55
- """
56
- # Get map dimensions
57
- size_x = map_data.get("size", {}).get("x", 1024)
58
- size_y = map_data.get("size", {}).get("y", 1024)
59
-
60
- # Create empty image if none provided
61
- if base_array is None:
62
- background_color = self.drawing_config.get_property(
63
- DrawableElement.FLOOR, "color", (200, 200, 200, 255)
64
- )
65
- base_array = await self.create_empty_image(size_x, size_y, background_color)
66
-
67
- # Draw elements in order of z-index
68
- for element in self.drawing_config.get_drawing_order():
69
- if element == DrawableElement.FLOOR:
70
- base_array = await self._draw_floor(map_data, base_array)
71
- elif element == DrawableElement.WALL:
72
- base_array = await self._draw_walls(map_data, base_array)
73
- elif element == DrawableElement.ROBOT:
74
- base_array = await self._draw_robot(map_data, base_array)
75
- elif element == DrawableElement.CHARGER:
76
- base_array = await self._draw_charger(map_data, base_array)
77
- elif element == DrawableElement.VIRTUAL_WALL:
78
- base_array = await self._draw_virtual_walls(map_data, base_array)
79
- elif element == DrawableElement.RESTRICTED_AREA:
80
- base_array = await self._draw_restricted_areas(map_data, base_array)
81
- elif element == DrawableElement.NO_MOP_AREA:
82
- base_array = await self._draw_no_mop_areas(map_data, base_array)
83
- elif element == DrawableElement.PATH:
84
- base_array = await self._draw_path(map_data, base_array)
85
- elif element == DrawableElement.PREDICTED_PATH:
86
- base_array = await self._draw_predicted_path(map_data, base_array)
87
- elif element == DrawableElement.GO_TO_TARGET:
88
- base_array = await self._draw_go_to_target(map_data, base_array)
89
- elif DrawableElement.ROOM_1 <= element <= DrawableElement.ROOM_15:
90
- room_id = element - DrawableElement.ROOM_1 + 1
91
- base_array = await self._draw_room(map_data, room_id, base_array)
92
-
93
- return base_array
94
-
95
- async def _draw_floor(self, map_data: dict, array: NumpyArray) -> NumpyArray:
96
- """Draw the floor layer."""
97
- if not self.drawing_config.is_enabled(DrawableElement.FLOOR):
98
- return array
99
-
100
- # Implementation depends on the map data format
101
- # This is a placeholder - actual implementation would use map_data to draw floor
102
-
103
- return array
104
-
105
- async def _draw_walls(self, map_data: dict, array: NumpyArray) -> NumpyArray:
106
- """Draw the walls."""
107
- if not self.drawing_config.is_enabled(DrawableElement.WALL):
108
- return array
109
-
110
- # Get wall color from drawing config
111
- wall_color = self.drawing_config.get_property(
112
- DrawableElement.WALL, "color", (255, 255, 0, 255)
113
- )
114
-
115
- # Implementation depends on the map data format
116
- # For Valetudo maps, we would look at the layers with type "wall"
117
- # This is a simplified example - in a real implementation, we would extract the actual wall pixels
118
-
119
- # Find wall data in map_data
120
- wall_pixels = []
121
- for layer in map_data.get("layers", []):
122
- if layer.get("type") == "wall":
123
- # Extract wall pixels from the layer
124
- # This is a placeholder - actual implementation would depend on the map data format
125
- wall_pixels = layer.get("pixels", [])
126
- break
127
-
128
- # Draw wall pixels with color blending
129
- for x, y in wall_pixels:
130
- # Use sample_and_blend_color from ColorsManagement
131
- blended_color = ColorsManagement.sample_and_blend_color(
132
- array, x, y, wall_color
133
- )
134
- if 0 <= y < array.shape[0] and 0 <= x < array.shape[1]:
135
- array[y, x] = blended_color
136
-
137
- return array
138
-
139
- async def _draw_robot(self, map_data: dict, array: NumpyArray) -> NumpyArray:
140
- """Draw the robot."""
141
- if not self.drawing_config.is_enabled(DrawableElement.ROBOT):
142
- return array
143
-
144
- # Get robot color from drawing config
145
- robot_color = self.drawing_config.get_property(
146
- DrawableElement.ROBOT, "color", (255, 255, 204, 255)
147
- )
148
-
149
- # Extract robot position and angle from map_data
150
- robot_position = map_data.get("robot", {}).get("position", None)
151
- robot_angle = map_data.get("robot", {}).get("angle", 0)
152
-
153
- if robot_position:
154
- x, y = robot_position.get("x", 0), robot_position.get("y", 0)
155
-
156
- # Draw robot with color blending
157
- # Create a circle around the robot position
158
- radius = 25 # Same as in the robot drawing method
159
- for dy in range(-radius, radius + 1):
160
- for dx in range(-radius, radius + 1):
161
- if dx * dx + dy * dy <= radius * radius:
162
- map_x, map_y = int(x + dx), int(y + dy)
163
- # Use sample_and_blend_color from ColorsManagement
164
- blended_color = ColorsManagement.sample_and_blend_color(
165
- array, map_x, map_y, robot_color
166
- )
167
- if 0 <= map_y < array.shape[0] and 0 <= map_x < array.shape[1]:
168
- array[map_y, map_x] = blended_color
169
- return array
170
-
171
- async def _draw_charger(self, map_data: dict, array: NumpyArray) -> NumpyArray:
172
- """Draw the charger."""
173
- if not self.drawing_config.is_enabled(DrawableElement.CHARGER):
174
- return array
175
-
176
- # Get charger color from drawing config
177
- charger_color = self.drawing_config.get_property(
178
- DrawableElement.CHARGER, "color", (255, 128, 0, 255)
179
- )
180
-
181
- # Implementation depends on the map data format
182
- # This would extract charger data from map_data and draw it
183
-
184
- return array
185
-
186
- async def _draw_virtual_walls(
187
- self, map_data: dict, array: NumpyArray
188
- ) -> NumpyArray:
189
- """Draw virtual walls."""
190
- if not self.drawing_config.is_enabled(DrawableElement.VIRTUAL_WALL):
191
- return array
192
-
193
- # Get virtual wall color from drawing config
194
- wall_color = self.drawing_config.get_property(
195
- DrawableElement.VIRTUAL_WALL, "color", (255, 0, 0, 255)
196
- )
197
-
198
- # Implementation depends on the map data format
199
- # This would extract virtual wall data from map_data and draw it
200
-
201
- return array
202
-
203
- async def _draw_restricted_areas(
204
- self, map_data: dict, array: NumpyArray
205
- ) -> NumpyArray:
206
- """Draw restricted areas."""
207
- if not self.drawing_config.is_enabled(DrawableElement.RESTRICTED_AREA):
208
- return array
209
-
210
- # Get restricted area color from drawing config
211
- area_color = self.drawing_config.get_property(
212
- DrawableElement.RESTRICTED_AREA, "color", (255, 0, 0, 125)
213
- )
214
-
215
- # Implementation depends on the map data format
216
- # This would extract restricted area data from map_data and draw it
217
-
218
- return array
219
-
220
- async def _draw_no_mop_areas(self, map_data: dict, array: NumpyArray) -> NumpyArray:
221
- """Draw no-mop areas."""
222
- if not self.drawing_config.is_enabled(DrawableElement.NO_MOP_AREA):
223
- return array
224
-
225
- # Get no-mop area color from drawing config
226
- area_color = self.drawing_config.get_property(
227
- DrawableElement.NO_MOP_AREA, "color", (0, 0, 255, 125)
228
- )
229
-
230
- # Implementation depends on the map data format
231
- # This would extract no-mop area data from map_data and draw it
232
-
233
- return array
234
-
235
- async def _draw_path(self, map_data: dict, array: NumpyArray) -> NumpyArray:
236
- """Draw the robot's path."""
237
- if not self.drawing_config.is_enabled(DrawableElement.PATH):
238
- return array
239
-
240
- # Get path color from drawing config
241
- path_color = self.drawing_config.get_property(
242
- DrawableElement.PATH, "color", (238, 247, 255, 255)
243
- )
244
-
245
- # Implementation depends on the map data format
246
- # This would extract path data from map_data and draw it
247
-
248
- return array
249
-
250
- async def _draw_predicted_path(
251
- self, map_data: dict, array: NumpyArray
252
- ) -> NumpyArray:
253
- """Draw the predicted path."""
254
- if not self.drawing_config.is_enabled(DrawableElement.PREDICTED_PATH):
255
- return array
256
-
257
- # Get predicted path color from drawing config
258
- path_color = self.drawing_config.get_property(
259
- DrawableElement.PREDICTED_PATH, "color", (238, 247, 255, 125)
260
- )
261
-
262
- # Implementation depends on the map data format
263
- # This would extract predicted path data from map_data and draw it
264
-
265
- return array
266
-
267
- async def _draw_go_to_target(self, map_data: dict, array: NumpyArray) -> NumpyArray:
268
- """Draw the go-to target."""
269
- if not self.drawing_config.is_enabled(DrawableElement.GO_TO_TARGET):
270
- return array
271
-
272
- # Get go-to target color from drawing config
273
- target_color = self.drawing_config.get_property(
274
- DrawableElement.GO_TO_TARGET, "color", (0, 255, 0, 255)
275
- )
276
-
277
- # Implementation depends on the map data format
278
- # This would extract go-to target data from map_data and draw it
279
-
280
- return array
281
-
282
- async def _draw_room(
283
- self, map_data: dict, room_id: int, array: NumpyArray
284
- ) -> NumpyArray:
285
- """Draw a specific room."""
286
- element = getattr(DrawableElement, f"ROOM_{room_id}")
287
- if not self.drawing_config.is_enabled(element):
288
- return array
289
-
290
- # Get room color from drawing config
291
- room_color = self.drawing_config.get_property(
292
- element,
293
- "color",
294
- (135, 206, 250, 255), # Default light blue
295
- )
296
-
297
- # Implementation depends on the map data format
298
- # For Valetudo maps, we would look at the layers with type "segment"
299
- # This is a simplified example - in a real implementation, we would extract the actual room pixels
300
-
301
- # Find room data in map_data
302
- room_pixels = []
303
- for layer in map_data.get("layers", []):
304
- if layer.get("type") == "segment" and str(
305
- layer.get("metaData", {}).get("segmentId")
306
- ) == str(room_id):
307
- # Extract room pixels from the layer
308
- # This is a placeholder - actual implementation would depend on the map data format
309
- # For example, it might use compressed pixels or other data structures
310
-
311
- # For demonstration, let's assume we have a list of (x, y) coordinates
312
- room_pixels = layer.get("pixels", [])
313
- break
314
-
315
- # Draw room pixels with color blending
316
- for x, y in room_pixels:
317
- # Use sample_and_blend_color from ColorsManagement
318
- blended_color = ColorsManagement.sample_and_blend_color(
319
- array, x, y, room_color
320
- )
321
- if 0 <= y < array.shape[0] and 0 <= x < array.shape[1]:
322
- array[y, x] = blended_color
323
-
324
- return array