Spaces:
Runtime error
Runtime error
Create app_old.py
Browse files- app_old.py +31 -0
app_old.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import streamlit as st
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
# Page config
|
6 |
+
st.set_page_config(layout="wide")
|
7 |
+
|
8 |
+
# Load grid data
|
9 |
+
with open('grid.json') as f:
|
10 |
+
grid_data = json.load(f)
|
11 |
+
|
12 |
+
# Extract coordinates
|
13 |
+
buildings = [[b['coords'][0], b['coords'][1]] for b in grid_data['buildings']]
|
14 |
+
stores = [[s['coords'][0], s['coords'][1]] for s in grid_data['stores']]
|
15 |
+
roads = [(r['start'], r['end']) for r in grid_data['roads']]
|
16 |
+
|
17 |
+
# Plot map
|
18 |
+
fig, ax = plt.subplots()
|
19 |
+
ax.axis([0, 10, 0, 10])
|
20 |
+
ax.set_xticks([i for i in range(11)])
|
21 |
+
ax.set_yticks([i for i in range(11)])
|
22 |
+
ax.grid(color='grey', linestyle='-', linewidth=0.25)
|
23 |
+
ax.scatter(*zip(*buildings), color='red')
|
24 |
+
ax.scatter(*zip(*stores), color='green')
|
25 |
+
|
26 |
+
# Draw roads
|
27 |
+
for start, end in roads:
|
28 |
+
ax.plot([start[0], end[0]], [start[1], end[1]], color='black')
|
29 |
+
|
30 |
+
# Show figure in Streamlit
|
31 |
+
st.pyplot(fig)
|