eaglelandsonce commited on
Commit
a6436b7
1 Parent(s): dffc1fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -57,7 +57,19 @@ def draw_grid(data):
57
  # Plotting the building on the grid with color
58
  ax.add_patch(plt.Rectangle((coords[1], nrows-coords[0]-size), size, size, color=color, edgecolor='black', linewidth=1))
59
  ax.text(coords[1]+0.5*size, nrows-coords[0]-0.5*size, b_type, ha='center', va='center', fontsize=8, color='black')
60
-
 
 
 
 
 
 
 
 
 
 
 
 
61
  # Setting labels and title
62
  ax.set_xlabel('Columns')
63
  ax.set_ylabel('Rows')
 
57
  # Plotting the building on the grid with color
58
  ax.add_patch(plt.Rectangle((coords[1], nrows-coords[0]-size), size, size, color=color, edgecolor='black', linewidth=1))
59
  ax.text(coords[1]+0.5*size, nrows-coords[0]-0.5*size, b_type, ha='center', va='center', fontsize=8, color='black')
60
+
61
+ # Draw roads
62
+ for road in data.get('roads', []): # Check for roads in the data, default to empty list if not found
63
+ start, end = road['start'], road['end']
64
+ # Determine if the road is vertical or horizontal based on start and end coordinates
65
+ if start[0] == end[0]: # Vertical road
66
+ for y in range(min(start[1], end[1]), max(start[1], end[1]) + 1):
67
+ ax.add_patch(plt.Rectangle((start[0], nrows-y-1), 1, 1, color=road['color']))
68
+ else: # Horizontal road
69
+ for x in range(min(start[0], end[0]), max(start[0], end[0]) + 1):
70
+ ax.add_patch(plt.Rectangle((x, nrows-start[1]-1), 1, 1, color=road['color']))
71
+
72
+
73
  # Setting labels and title
74
  ax.set_xlabel('Columns')
75
  ax.set_ylabel('Rows')