Spaces:
Build error
Build error
File size: 1,591 Bytes
7d36845 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import streamlit as st
import numpy as np
import matplotlib.pyplot as plt
# Streamlit App Title
st.title("Road Design Application")
# Sidebar Input Section
st.sidebar.header("Road Design Parameters")
# Input Parameters
road_length = st.sidebar.slider("Road Length (meters)", 50, 1000, 500)
road_width = st.sidebar.slider("Road Width (meters)", 5, 20, 10)
curvature = st.sidebar.slider("Curvature (degrees, 0 for straight road)", 0, 90, 0)
material = st.sidebar.selectbox("Material Type", ["Asphalt", "Concrete", "Gravel"])
# Display Selected Parameters
st.write("### Selected Parameters")
st.write(f"- Road Length: {road_length} meters")
st.write(f"- Road Width: {road_width} meters")
st.write(f"- Curvature: {curvature} degrees")
st.write(f"- Material: {material}")
# Road Visualization
def generate_road(length, width, curvature):
x = np.linspace(0, length, 500)
if curvature == 0:
y = np.zeros_like(x)
else:
radius = length / np.radians(curvature)
y = radius * (1 - np.cos(x / radius))
return x, y
x, y = generate_road(road_length, road_width, curvature)
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(x, y, label="Road Center Line", color="black")
ax.fill_between(x, y - road_width / 2, y + road_width / 2, color="gray", alpha=0.5, label="Road Width")
ax.set_title("Road Design Visualization")
ax.set_xlabel("Length (meters)")
ax.set_ylabel("Offset (meters)")
ax.legend()
st.pyplot(fig)
st.write("### Note")
st.info("This is a basic road design visualization. For more detailed engineering design, consider using specialized software.")
|