valetudo-map-parser 0.1.9a7__tar.gz → 0.1.9a8__tar.gz

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 (27) hide show
  1. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/PKG-INFO +1 -1
  2. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/hypfer_draw.py +55 -53
  3. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/hypfer_handler.py +1 -1
  4. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/pyproject.toml +1 -1
  5. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/LICENSE +0 -0
  6. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/NOTICE.txt +0 -0
  7. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/README.md +0 -0
  8. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/__init__.py +0 -0
  9. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/__init__.py +0 -0
  10. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/auto_crop.py +0 -0
  11. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/color_utils.py +0 -0
  12. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/colors.py +0 -0
  13. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/drawable.py +0 -0
  14. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/drawable_elements.py +0 -0
  15. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/enhanced_drawable.py +0 -0
  16. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/optimized_element_map.py +0 -0
  17. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/rand25_parser.py +0 -0
  18. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/room_outline.py +0 -0
  19. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/shared.py +0 -0
  20. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/types.py +0 -0
  21. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/config/utils.py +0 -0
  22. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/hypfer_rooms_handler.py +0 -0
  23. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/map_data.py +0 -0
  24. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/py.typed +0 -0
  25. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/rand25_handler.py +0 -0
  26. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/reimg_draw.py +0 -0
  27. {valetudo_map_parser-0.1.9a7 → valetudo_map_parser-0.1.9a8}/SCR/valetudo_map_parser/rooms_handler.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: valetudo-map-parser
3
- Version: 0.1.9a7
3
+ Version: 0.1.9a8
4
4
  Summary: A Python library to parse Valetudo map data returning a PIL Image object.
5
5
  License: Apache-2.0
6
6
  Author: Sandro Cantarella
@@ -426,6 +426,39 @@ class ImageDraw:
426
426
  _LOGGER.info("%s: Got the points in the json.", self.file_name)
427
427
  return entity_dict
428
428
 
429
+ def _check_active_zone_and_set_zooming(self) -> None:
430
+ """Helper function to check active zones and set zooming state."""
431
+ if self.img_h.active_zones and self.img_h.robot_in_room:
432
+ from .config.types import RoomStore
433
+ segment_id = str(self.img_h.robot_in_room["id"])
434
+ room_store = RoomStore(self.file_name)
435
+ room_keys = list(room_store.get_rooms().keys())
436
+
437
+ _LOGGER.debug(
438
+ "%s: Active zones debug - segment_id: %s, room_keys: %s, active_zones: %s",
439
+ self.file_name, segment_id, room_keys, self.img_h.active_zones
440
+ )
441
+
442
+ if segment_id in room_keys:
443
+ position = room_keys.index(segment_id)
444
+ _LOGGER.debug(
445
+ "%s: Segment ID %s found at position %s, active_zones[%s] = %s",
446
+ self.file_name, segment_id, position, position,
447
+ self.img_h.active_zones[position] if position < len(self.img_h.active_zones) else "OUT_OF_BOUNDS"
448
+ )
449
+ if position < len(self.img_h.active_zones):
450
+ self.img_h.zooming = bool(self.img_h.active_zones[position])
451
+ else:
452
+ self.img_h.zooming = False
453
+ else:
454
+ _LOGGER.warning(
455
+ "%s: Segment ID %s not found in room_keys %s",
456
+ self.file_name, segment_id, room_keys
457
+ )
458
+ self.img_h.zooming = False
459
+ else:
460
+ self.img_h.zooming = False
461
+
429
462
  @staticmethod
430
463
  def point_in_polygon(x: int, y: int, polygon: list) -> bool:
431
464
  """
@@ -473,23 +506,8 @@ class ImageDraw:
473
506
  "angle": angle,
474
507
  "in_room": self.img_h.robot_in_room["room"],
475
508
  }
476
- # Handle active zones - Map segment ID to active_zones position
477
- if self.img_h.active_zones:
478
- from .config.types import RoomStore
479
- segment_id = str(self.img_h.robot_in_room["id"])
480
- room_store = RoomStore(self.file_name)
481
- room_keys = list(room_store.get_rooms().keys())
482
-
483
- if segment_id in room_keys:
484
- position = room_keys.index(segment_id)
485
- if position < len(self.img_h.active_zones):
486
- self.img_h.zooming = bool(self.img_h.active_zones[position])
487
- else:
488
- self.img_h.zooming = False
489
- else:
490
- self.img_h.zooming = False
491
- else:
492
- self.img_h.zooming = False
509
+ # Handle active zones
510
+ self._check_active_zone_and_set_zooming()
493
511
  return temp
494
512
  # Fallback to bounding box check if no outline data
495
513
  elif all(
@@ -508,23 +526,8 @@ class ImageDraw:
508
526
  "angle": angle,
509
527
  "in_room": self.img_h.robot_in_room["room"],
510
528
  }
511
- # Handle active zones - Map segment ID to active_zones position
512
- if self.img_h.active_zones:
513
- from .config.types import RoomStore
514
- segment_id = str(self.img_h.robot_in_room["id"])
515
- room_store = RoomStore(self.file_name)
516
- room_keys = list(room_store.get_rooms().keys())
517
-
518
- if segment_id in room_keys:
519
- position = room_keys.index(segment_id)
520
- if position < len(self.img_h.active_zones):
521
- self.img_h.zooming = bool(self.img_h.active_zones[position])
522
- else:
523
- self.img_h.zooming = False
524
- else:
525
- self.img_h.zooming = False
526
- else:
527
- self.img_h.zooming = False
529
+ # Handle active zones
530
+ self._check_active_zone_and_set_zooming()
528
531
  return temp
529
532
 
530
533
  # If we don't have a cached room or the robot is not in it, search all rooms
@@ -577,7 +580,7 @@ class ImageDraw:
577
580
  if self.point_in_polygon(int(robot_x), int(robot_y), outline):
578
581
  # Robot is in this room
579
582
  self.img_h.robot_in_room = {
580
- "id": room_count,
583
+ "id": room.get("id", room_count), # Use actual segment ID if available
581
584
  "room": str(room["name"]),
582
585
  "outline": outline,
583
586
  }
@@ -595,13 +598,27 @@ class ImageDraw:
595
598
  room_store = RoomStore(self.file_name)
596
599
  room_keys = list(room_store.get_rooms().keys())
597
600
 
601
+ _LOGGER.debug(
602
+ "%s: Active zones debug - segment_id: %s, room_keys: %s, active_zones: %s",
603
+ self.file_name, segment_id, room_keys, self.img_h.active_zones
604
+ )
605
+
598
606
  if segment_id in room_keys:
599
607
  position = room_keys.index(segment_id)
608
+ _LOGGER.debug(
609
+ "%s: Segment ID %s found at position %s, active_zones[%s] = %s",
610
+ self.file_name, segment_id, position, position,
611
+ self.img_h.active_zones[position] if position < len(self.img_h.active_zones) else "OUT_OF_BOUNDS"
612
+ )
600
613
  if position < len(self.img_h.active_zones):
601
614
  self.img_h.zooming = bool(self.img_h.active_zones[position])
602
615
  else:
603
616
  self.img_h.zooming = False
604
617
  else:
618
+ _LOGGER.warning(
619
+ "%s: Segment ID %s not found in room_keys %s",
620
+ self.file_name, segment_id, room_keys
621
+ )
605
622
  self.img_h.zooming = False
606
623
  else:
607
624
  self.img_h.zooming = False
@@ -617,7 +634,7 @@ class ImageDraw:
617
634
  corners = room["corners"]
618
635
  # Create a bounding box from the corners
619
636
  self.img_h.robot_in_room = {
620
- "id": room_count,
637
+ "id": room.get("id", room_count), # Use actual segment ID if available
621
638
  "left": int(corners[0][0]),
622
639
  "right": int(corners[2][0]),
623
640
  "up": int(corners[0][1]),
@@ -639,23 +656,8 @@ class ImageDraw:
639
656
  "in_room": self.img_h.robot_in_room["room"],
640
657
  }
641
658
 
642
- # Handle active zones - Map segment ID to active_zones position
643
- if self.img_h.active_zones:
644
- from .config.types import RoomStore
645
- segment_id = str(self.img_h.robot_in_room["id"])
646
- room_store = RoomStore(self.file_name)
647
- room_keys = list(room_store.get_rooms().keys())
648
-
649
- if segment_id in room_keys:
650
- position = room_keys.index(segment_id)
651
- if position < len(self.img_h.active_zones):
652
- self.img_h.zooming = bool(self.img_h.active_zones[position])
653
- else:
654
- self.img_h.zooming = False
655
- else:
656
- self.img_h.zooming = False
657
- else:
658
- self.img_h.zooming = False
659
+ # Handle active zones
660
+ self._check_active_zone_and_set_zooming()
659
661
 
660
662
  _LOGGER.debug(
661
663
  "%s is in %s room (bounding box detection).",
@@ -81,7 +81,7 @@ class HypferMapImageHandler(BaseHandler, AutoCrop):
81
81
  self.rooms_pos = []
82
82
  for room_id, room_data in room_properties.items():
83
83
  self.rooms_pos.append(
84
- {"name": room_data["name"], "outline": room_data["outline"]}
84
+ {"id": room_id, "name": room_data["name"], "outline": room_data["outline"]}
85
85
  )
86
86
  else:
87
87
  LOGGER.debug("%s: Rooms data not available!", self.file_name)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "valetudo-map-parser"
3
- version = "0.1.9a7"
3
+ version = "0.1.9a8"
4
4
  description = "A Python library to parse Valetudo map data returning a PIL Image object."
5
5
  authors = ["Sandro Cantarella <gsca075@gmail.com>"]
6
6
  license = "Apache-2.0"