Spaces:
Sleeping
Sleeping
Update app/building_info_form.py
Browse files- app/building_info_form.py +9 -12
app/building_info_form.py
CHANGED
|
@@ -130,7 +130,10 @@ class BuildingInfoForm:
|
|
| 130 |
help="Enter the total floor area of the building in square meters (optional if width and depth provided)"
|
| 131 |
)
|
| 132 |
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
col1, col2 = st.columns(2)
|
| 136 |
with col1:
|
|
@@ -150,7 +153,7 @@ class BuildingInfoForm:
|
|
| 150 |
help="Enter the building's depth in meters (optional if area provided)"
|
| 151 |
)
|
| 152 |
|
| 153 |
-
st.subheader("Building Orientation")
|
| 154 |
session_state["building_info"]["orientation"] = st.selectbox(
|
| 155 |
"Building Orientation",
|
| 156 |
["NORTH", "NORTHEAST", "EAST", "SOUTHEAST", "SOUTH", "SOUTHWEST", "WEST", "NORTHWEST"],
|
|
@@ -158,7 +161,7 @@ class BuildingInfoForm:
|
|
| 158 |
help="Select the direction of the building's main facade"
|
| 159 |
)
|
| 160 |
|
| 161 |
-
st.subheader("Operating Hours")
|
| 162 |
session_state["building_info"]["operating_hours"] = st.text_input(
|
| 163 |
"Operating Hours",
|
| 164 |
value=session_state["building_info"]["operating_hours"],
|
|
@@ -168,23 +171,18 @@ class BuildingInfoForm:
|
|
| 168 |
submitted = st.form_submit_button("Save Building Information")
|
| 169 |
|
| 170 |
if submitted:
|
| 171 |
-
# Validate before saving
|
| 172 |
valid, errors = self.validate_building_info(session_state["building_info"])
|
| 173 |
if not valid:
|
| 174 |
for error in errors:
|
| 175 |
st.error(error)
|
| 176 |
else:
|
| 177 |
-
# Logic for handling dimensions
|
| 178 |
if session_state["building_info"]["width"] > 0 and session_state["building_info"]["depth"] > 0:
|
| 179 |
calculated_area = session_state["building_info"]["width"] * session_state["building_info"]["depth"]
|
| 180 |
-
# If no area provided or area is 0, use calculated area
|
| 181 |
if session_state["building_info"]["floor_area"] == 0:
|
| 182 |
session_state["building_info"]["floor_area"] = calculated_area
|
| 183 |
-
# If area is provided, keep it
|
| 184 |
|
| 185 |
total_volume = session_state["building_info"]["floor_area"] * session_state["building_info"]["building_height"]
|
| 186 |
|
| 187 |
-
# Store results in session state to persist across rerenders
|
| 188 |
session_state["save_results"] = {
|
| 189 |
"success": "Building information saved successfully!",
|
| 190 |
"area": f"Total Floor Area: {session_state['building_info']['floor_area']:.1f} m²",
|
|
@@ -192,20 +190,19 @@ class BuildingInfoForm:
|
|
| 192 |
}
|
| 193 |
session_state["data_saved"] = True
|
| 194 |
|
| 195 |
-
# Display
|
| 196 |
if "save_results" in session_state and session_state["data_saved"]:
|
| 197 |
st.success(session_state["save_results"]["success"])
|
| 198 |
st.info(session_state["save_results"]["area"])
|
| 199 |
st.info(session_state["save_results"]["volume"])
|
| 200 |
|
| 201 |
-
#
|
| 202 |
if session_state["data_saved"]:
|
| 203 |
if st.button("Proceed to Climate Data"):
|
| 204 |
session_state["page"] = "Climate Data"
|
| 205 |
-
|
| 206 |
if "save_results" in session_state:
|
| 207 |
del session_state["save_results"]
|
| 208 |
-
session_state["data_saved"] = False
|
| 209 |
|
| 210 |
@staticmethod
|
| 211 |
def validate_building_info(building_info: Dict[str, Any]) -> Tuple[bool, List[str]]:
|
|
|
|
| 130 |
help="Enter the total floor area of the building in square meters (optional if width and depth provided)"
|
| 131 |
)
|
| 132 |
|
| 133 |
+
# Center the OR using columns
|
| 134 |
+
col1, col2, col3 = st.columns([2, 1, 2])
|
| 135 |
+
with col2:
|
| 136 |
+
st.markdown("OR")
|
| 137 |
|
| 138 |
col1, col2 = st.columns(2)
|
| 139 |
with col1:
|
|
|
|
| 153 |
help="Enter the building's depth in meters (optional if area provided)"
|
| 154 |
)
|
| 155 |
|
| 156 |
+
st.subheader("Building Orientation")
|
| 157 |
session_state["building_info"]["orientation"] = st.selectbox(
|
| 158 |
"Building Orientation",
|
| 159 |
["NORTH", "NORTHEAST", "EAST", "SOUTHEAST", "SOUTH", "SOUTHWEST", "WEST", "NORTHWEST"],
|
|
|
|
| 161 |
help="Select the direction of the building's main facade"
|
| 162 |
)
|
| 163 |
|
| 164 |
+
st.subheader("Operating Hours")
|
| 165 |
session_state["building_info"]["operating_hours"] = st.text_input(
|
| 166 |
"Operating Hours",
|
| 167 |
value=session_state["building_info"]["operating_hours"],
|
|
|
|
| 171 |
submitted = st.form_submit_button("Save Building Information")
|
| 172 |
|
| 173 |
if submitted:
|
|
|
|
| 174 |
valid, errors = self.validate_building_info(session_state["building_info"])
|
| 175 |
if not valid:
|
| 176 |
for error in errors:
|
| 177 |
st.error(error)
|
| 178 |
else:
|
|
|
|
| 179 |
if session_state["building_info"]["width"] > 0 and session_state["building_info"]["depth"] > 0:
|
| 180 |
calculated_area = session_state["building_info"]["width"] * session_state["building_info"]["depth"]
|
|
|
|
| 181 |
if session_state["building_info"]["floor_area"] == 0:
|
| 182 |
session_state["building_info"]["floor_area"] = calculated_area
|
|
|
|
| 183 |
|
| 184 |
total_volume = session_state["building_info"]["floor_area"] * session_state["building_info"]["building_height"]
|
| 185 |
|
|
|
|
| 186 |
session_state["save_results"] = {
|
| 187 |
"success": "Building information saved successfully!",
|
| 188 |
"area": f"Total Floor Area: {session_state['building_info']['floor_area']:.1f} m²",
|
|
|
|
| 190 |
}
|
| 191 |
session_state["data_saved"] = True
|
| 192 |
|
| 193 |
+
# Display results if they exist
|
| 194 |
if "save_results" in session_state and session_state["data_saved"]:
|
| 195 |
st.success(session_state["save_results"]["success"])
|
| 196 |
st.info(session_state["save_results"]["area"])
|
| 197 |
st.info(session_state["save_results"]["volume"])
|
| 198 |
|
| 199 |
+
# Proceed button with immediate navigation
|
| 200 |
if session_state["data_saved"]:
|
| 201 |
if st.button("Proceed to Climate Data"):
|
| 202 |
session_state["page"] = "Climate Data"
|
| 203 |
+
session_state["data_saved"] = False
|
| 204 |
if "save_results" in session_state:
|
| 205 |
del session_state["save_results"]
|
|
|
|
| 206 |
|
| 207 |
@staticmethod
|
| 208 |
def validate_building_info(building_info: Dict[str, Any]) -> Tuple[bool, List[str]]:
|