From 61f7ad0ee83fe3f8cf0b450dbed01a8206418c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Sat, 10 Dec 2016 12:19:31 +0100 Subject: [PATCH] buildgraph: remove Point.connect_to() --- src/c3nav/routing/graph.py | 8 ++++---- src/c3nav/routing/level.py | 4 ++-- src/c3nav/routing/point.py | 6 ------ src/c3nav/routing/room.py | 4 ++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/c3nav/routing/graph.py b/src/c3nav/routing/graph.py index ac3e9b09..17add9b9 100644 --- a/src/c3nav/routing/graph.py +++ b/src/c3nav/routing/graph.py @@ -20,8 +20,8 @@ class Graph: for level in Level.objects.all(): self.levels[level.name] = GraphLevel(self, level) - self.rooms = () - self.points = () + self.rooms = [] + self.points = [] self.connections = [] self.level_transfer_points = [] @@ -94,8 +94,8 @@ class Graph: room.points.append(center_point) for point in points: - center_point.connect_to(point) - point.connect_to(center_point) + self.add_connection(center_point, point) + self.add_connection(point, center_point) # Loading/Saving the Graph def serialize(self): diff --git a/src/c3nav/routing/level.py b/src/c3nav/routing/level.py index 756c6bc9..50a80311 100644 --- a/src/c3nav/routing/level.py +++ b/src/c3nav/routing/level.py @@ -81,8 +81,8 @@ class GraphLevel(): room.points.append(center_point) for point in points: - center_point.connect_to(point) - point.connect_to(center_point) + self.graph.add_connection(center_point, point) + self.graph.add_connection(point, center_point) def create_levelconnectors(self): for levelconnector in self.level.levelconnectors.all(): diff --git a/src/c3nav/routing/point.py b/src/c3nav/routing/point.py index d83916dc..cb8ad441 100644 --- a/src/c3nav/routing/point.py +++ b/src/c3nav/routing/point.py @@ -10,9 +10,6 @@ class GraphPoint(): self.y = y self.xy = np.array((x, y)) - # self.level = room.level - self.graph = self.rooms[0].graph - self.connections = {} self.connections_in = {} @@ -21,6 +18,3 @@ class GraphPoint(): x = self.x * settings.RENDER_SCALE y = self.y * settings.RENDER_SCALE return ((x-5, y-5), (x+5, y+5)) - - def connect_to(self, to_point): - self.graph.add_connection(self, to_point) diff --git a/src/c3nav/routing/room.py b/src/c3nav/routing/room.py index a123d147..c2767152 100644 --- a/src/c3nav/routing/room.py +++ b/src/c3nav/routing/room.py @@ -154,8 +154,8 @@ class GraphRoom(): if not valid: continue - point1.connect_to(point2) - point2.connect_to(point1) + self.graph.add_connection(point1, point2) + self.graph.add_connection(point2, point1) i += 1 # Routing