@@ -40,28 +40,31 @@ def add_coordinates(seatmap, cursor):
4040
4141 switches = switches_by_table (cursor )
4242
43+ table_coordinates = {}
44+ scales = []
4345 for hall in halls :
44- table_coordinates = []
45- x_min = float ("inf" )
46- y_max = 0
47- y_min = float ("inf" )
48- scales = []
46+ table_coordinates [hall ] = []
4947 for table in sorted (tables [hall ].keys (), key = lambda x : (len (x ), x )):
5048 # Ignore tables without switches
5149 if not switches .get (table , []):
5250 logging .debug ("Table %s has no switches, ignoring" , table )
5351 continue
5452 c , scale = table_location (table , tables )
5553 scales .append (scale )
56- table_coordinates .append ((table , c ))
54+ table_coordinates [hall ].append ((table , c ))
55+
56+ # Select a scale (median)
57+ scale = sorted (scales )[len (scales )/ 2 ] if scales else 1.0
58+ logging .debug ("Selected median scale %f" , scale )
5759
58- # Select a scale (median)
59- scale = sorted (scales )[len (scales )/ 2 ] if scales else 1.0
60- logging .debug ("Selected median scale %f" , scale )
60+ for hall in halls :
61+ x_min = float ("inf" )
62+ y_max = 0
63+ y_min = float ("inf" )
6164
6265 # Calculate common offsets
6366 scaled_table_coordinates = []
64- for table , c in table_coordinates :
67+ for table , c in table_coordinates [ hall ] :
6568 s = Rectangle (
6669 even (c .x1 * scale ),
6770 even (c .x2 * scale ),
0 commit comments