fix 500 in locate

This commit is contained in:
Laura Klünder 2024-12-28 20:59:29 +01:00
parent fae4c6f148
commit 7cc0973800

View file

@ -244,10 +244,12 @@ class Locator:
(peer_id, value) for peer_id, value in scan_data_we_can_use if self.peers[peer_id].space_id == space_id (peer_id, value) for peer_id, value in scan_data_we_can_use if self.peers[peer_id].space_id == space_id
], key=lambda a: a[1].rssi) ], key=lambda a: a[1].rssi)
router = Router.load()
if len(scan_data_in_the_same_room) == 1: if len(scan_data_in_the_same_room) == 1:
point = space.point point = router.spaces[space.pk].point
return CustomLocation( return CustomLocation(
level=space.level_id, level=router.spaces[space.pk].level_id,
x=point.x, x=point.x,
y=point.y, y=point.y,
permissions=permissions, permissions=permissions,
@ -262,7 +264,7 @@ class Locator:
x = self.peers[peer_id].xyz[0] * value.rssi / the_sum x = self.peers[peer_id].xyz[0] * value.rssi / the_sum
y = self.peers[peer_id].xyz[1] * value.rssi / the_sum y = self.peers[peer_id].xyz[1] * value.rssi / the_sum
return CustomLocation( return CustomLocation(
level=space.level_id, level=router.spaces[space.pk].level_id,
x=x, x=x,
y=y, y=y,
permissions=permissions, permissions=permissions,