valetudo-map-parser 0.1.10rc7__py3-none-any.whl → 0.1.11b1__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.
@@ -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
@@ -1,35 +0,0 @@
1
- valetudo_map_parser/__init__.py,sha256=re58j6L6cWDartKcpimFbkXN3AsItm9Al4K2T62SeMc,1822
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=nXD6WeNmdFdoMxPDW-JFpjnxJSaZR1jX-ouNfrx6zvE,4502
6
- valetudo_map_parser/config/colors.py,sha256=DMY5aHDS-alW2CZ2j8U7QVGHK_H8M0fBDX2OGuryirc,29914
7
- valetudo_map_parser/config/drawable.py,sha256=npc4eReHvc1Aw-mbK1o0AJgyqn8fu2v1AxR5H1hvP5k,33338
8
- valetudo_map_parser/config/drawable_elements.py,sha256=o-5oiXmfqPwNQLzKIhkEcZD_A47rIU9E0CqKgWipxgc,11516
9
- valetudo_map_parser/config/enhanced_drawable.py,sha256=QlGxlUMVgECUXPtFwIslyjubWxQuhIixsRymWV3lEvk,12586
10
- valetudo_map_parser/config/fonts/FiraSans.ttf,sha256=Pavz1Iv0WZ-Vz_2S-Z6kJqAU1TEfUqXrXsOvJl6XzZc,440984
11
- valetudo_map_parser/config/fonts/Inter-VF.ttf,sha256=zzy0OwNm4txt9g4RMrHJpMFXd_DNjlpT4MFRJAA-ntQ,804612
12
- valetudo_map_parser/config/fonts/Lato-Regular.ttf,sha256=6CVCrtgpP0n8g8Sq6lZrH2tPx6mrXaEeb7m8CXO1Mks,75152
13
- valetudo_map_parser/config/fonts/MPLUSRegular.ttf,sha256=IGdcNSRP4dDxQskbE3Ybuwz7T0flhCBuzwfhLMcPt9s,3380812
14
- valetudo_map_parser/config/fonts/NotoKufiArabic-VF.ttf,sha256=NaIy40eLx7d3ts0kuenp0GjWd-YN24J6DpSvX2L3vLA,433800
15
- valetudo_map_parser/config/fonts/NotoSansCJKhk-VF.ttf,sha256=xIXXLKCJzmWoPEg8HdvxeRgotMjjxF6l6ugGP-IWRJU,36135040
16
- valetudo_map_parser/config/fonts/NotoSansKhojki.ttf,sha256=XJWzSmpN-Ql6jTfTvFojP_JkCHOztQvixQc1_7hPWrc,107388
17
- valetudo_map_parser/config/optimized_element_map.py,sha256=52BCnkvVv9bre52LeVIfT8nhnEIpc0TuWTv1xcNu0Rk,15744
18
- valetudo_map_parser/config/rand256_parser.py,sha256=jsUiuShrNY3UpgfdEMgmTJjH6fj-lC-0y2TdIt43aG0,20161
19
- valetudo_map_parser/config/shared.py,sha256=58R6kaYl7RF0ESTIKarVy8pB1jo4LUlPHTb27_ubZFo,11789
20
- valetudo_map_parser/config/status_text/status_text.py,sha256=PaynYW11vXH_vhDxhZrR9j-xeDrCxbB6YQQtN-kcaxQ,4052
21
- valetudo_map_parser/config/status_text/translations.py,sha256=mmPbJkl_2A59w49wnesQf3ocXqwZxBsrqNX-yt5FSCQ,9132
22
- valetudo_map_parser/config/types.py,sha256=vSJjEsosbx9ZaM_JEuqhdzFIHnf97bfzDBMvx_V3U0s,18067
23
- valetudo_map_parser/config/utils.py,sha256=sk6Vy3_QpJhX9Hvb6S36Womyu0n8bfxWejfuNEaEM-I,38658
24
- valetudo_map_parser/hypfer_draw.py,sha256=4zajujSOvtpRI_GMlmlioM3mDo19MvuOP861LhZmVlw,22495
25
- valetudo_map_parser/hypfer_handler.py,sha256=8g2zitibQkgVh-crqDO41kp1DQzZaMMixUdFqgPjfis,20477
26
- valetudo_map_parser/map_data.py,sha256=OSscuvlYpAZ9q7pfjzIjh98UvT0PV8zjPk5eUEwmLb8,27355
27
- valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- valetudo_map_parser/rand256_handler.py,sha256=jpbvhNr2tm6Gp1Xs7yMMLwjCN1dOnNUtED7MrjnH4Os,21504
29
- valetudo_map_parser/reimg_draw.py,sha256=tDQGMDTYprgPZjETxws3rzgVfpPxm_K-armzYFyGzGw,12474
30
- valetudo_map_parser/rooms_handler.py,sha256=tE8BrXcdL0SeFAYsdFvjR3NVDfDi2RPKnXw9jD1e5k8,17494
31
- valetudo_map_parser-0.1.10rc7.dist-info/METADATA,sha256=NPYlwO902_zvejWWjfzzjOkTVyn_CoquAG9zs1cRG0E,3404
32
- valetudo_map_parser-0.1.10rc7.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
33
- valetudo_map_parser-0.1.10rc7.dist-info/licenses/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
34
- valetudo_map_parser-0.1.10rc7.dist-info/licenses/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
35
- valetudo_map_parser-0.1.10rc7.dist-info/RECORD,,