From 86a45351114da18a06d39c0d820f821e5e36aa90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Sat, 28 Dec 2024 17:58:28 +0100 Subject: [PATCH] improve importpoc some more --- src/c3nav/mapdata/management/commands/importpoc.py | 2 +- src/c3nav/mapdata/models/geometry/space.py | 2 +- src/c3nav/mapdata/utils/importer.py | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/c3nav/mapdata/management/commands/importpoc.py b/src/c3nav/mapdata/management/commands/importpoc.py index cfe6284e..f0522db1 100644 --- a/src/c3nav/mapdata/management/commands/importpoc.py +++ b/src/c3nav/mapdata/management/commands/importpoc.py @@ -78,7 +78,7 @@ class Command(BaseCommand): # build resulting object altitude_quest = True if not result: - result = RangingBeacon(import_tag=import_tag, beacon_type=RangingBeacon.BeaconType.EVENT_WIFI) + result = RangingBeacon(import_tag=import_tag, beacon_type=RangingBeacon.BeaconType.DECT) else: if result.space == new_space and distance(unwrap_geom(result.geometry), point) < 0.03: continue diff --git a/src/c3nav/mapdata/models/geometry/space.py b/src/c3nav/mapdata/models/geometry/space.py index fb818534..a8d6d4f5 100644 --- a/src/c3nav/mapdata/models/geometry/space.py +++ b/src/c3nav/mapdata/models/geometry/space.py @@ -553,7 +553,7 @@ class RangingBeacon(SpaceGeometryMixin, models.Model): else: title = f'#{self.pk}' if self.addresses: - ssids = self.addresses[0] + (', …' if len(self.adresses) > 1 else '') + ssids = self.addresses[0] + (', …' if len(self.addresses) > 1 else '') title += f' ({ssids})' if self.comment: title += f' ({self.comment})' diff --git a/src/c3nav/mapdata/utils/importer.py b/src/c3nav/mapdata/utils/importer.py index a756c9f6..79481b70 100644 --- a/src/c3nav/mapdata/utils/importer.py +++ b/src/c3nav/mapdata/utils/importer.py @@ -20,16 +20,17 @@ class PointImportHelper: if space.geometry.intersects(point)] if not possible_spaces: possible_spaces = [space for space in self.spaces_for_level[level_id] - if distance(unwrap_geom(space.geometry), point) < 0.3] + if distance(unwrap_geom(space.geometry), point) < 1.5] if len(possible_spaces) == 1: new_space = possible_spaces[0] the_distance = distance(unwrap_geom(new_space.geometry), point) print(f"SUCCESS: {name} is {the_distance:.02f}m away from {new_space.title}") - elif len(possible_spaces) == 2: + elif len(possible_spaces) > 1: new_space = min(possible_spaces, key=lambda s: distance(unwrap_geom(s.geometry), point)) - print(f"WARNING: {name} could be in multiple spaces ({possible_spaces}, picking {new_space}...") + print(f"WARNING: {name} could be in multiple spaces ({possible_spaces}, picking {new_space}, " + f"which is {distance(unwrap_geom(new_space.geometry), point)}m away...") else: - print(f"ERROR: {name} is not within any space ({point})") + print(f"ERROR: {name} is not within any space on level {level_id} ({point})") return None, None # move point into space if needed