Spaces:
Build error

roaddesign / app.py
mohsin06's picture
Update app.py
7d36845 verified
Raw History Blame Contribute Delete
1.59 kB
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.")