From 14338fc50d8908670a65c7ce12998169f627da2d Mon Sep 17 00:00:00 2001 From: Brock Hinkson Date: Thu, 21 May 2026 03:12:22 -0500 Subject: [PATCH] NGWPC-10798 --- app/streamlit/helpers.py | 20 +++++++++------- app/streamlit/hydrofabric_dash.py | 15 +++++------- app/streamlit/ras_xs_dash.py | 40 +++++++++++++++++-------------- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/app/streamlit/helpers.py b/app/streamlit/helpers.py index bd189f7..f4179c4 100644 --- a/app/streamlit/helpers.py +++ b/app/streamlit/helpers.py @@ -43,6 +43,13 @@ "weight": 6, }, }, + "channel_geometries": { + "highlight_styling": { + "stroke": True, + "color": "black", + "weight": 2, + }, + }, "nexus": {"marker_styling": folium.Marker(icon=folium.Icon(color="orange", icon="filter"))}, "waterbodies": {"marker_styling": folium.Marker(icon=folium.Icon(color="blue", icon="tint"))}, "gages": {"marker_styling": folium.Marker(icon=folium.Icon(color="darkred", icon="record"))}, @@ -216,6 +223,7 @@ def format_xs_map(_catalog, xs_gdf, domain): # Scale factor for better visualization; may need to adjust as needed three_dim_fp_data["topwdth_half"] = (three_dim_fp_data["width"] / 2) / 3 three_dim_fp_data["geometry"] = three_dim_fp_data.geometry.buffer(three_dim_fp_data["topwdth_half"]) + three_dim_fp_hl = STYLE_MAP["channel_geometries"].get("highlight_styling", {}) three_dim_fp_poly = folium.GeoJson( data=three_dim_fp_data, popup=folium.GeoJsonPopup(fields=list(fp_popup_fields[:25])), @@ -226,17 +234,13 @@ def format_xs_map(_catalog, xs_gdf, domain): ), style_function=lambda x: fp_style | { - "stroke": False, + "stroke": False if x["properties"]["depth"] else True, + "color": "black" if x["properties"]["depth"] else {}, "fillColor": depth_to_gradient(x["properties"]["depth"], domain="XS"), "fillOpacity": 1, - "dashArray": [5, 5] if not x["properties"]["width"] else {}, - }, - highlight_function=lambda x: fp_hl_style - | { - "stroke": True, - "color": "black", - "weight": 2, + "dashArray": [5, 5] if not x["properties"]["depth"] else {}, }, + highlight_function=lambda x: three_dim_fp_hl, popup_keep_highlighted=True, ) diff --git a/app/streamlit/hydrofabric_dash.py b/app/streamlit/hydrofabric_dash.py index afd33dc..f20f0be 100644 --- a/app/streamlit/hydrofabric_dash.py +++ b/app/streamlit/hydrofabric_dash.py @@ -166,15 +166,17 @@ marker=marker_style, ) if layer_name == "divides" or layer_name == "flowpaths": - gdf_fig = folium.FeatureGroup(name=layer_name) + gdf_fig = folium.FeatureGroup(name=layer_name.title().replace("_", " ")) else: - gdf_fig = folium.FeatureGroup(name=layer_name, show=False) + gdf_fig = folium.FeatureGroup( + name=layer_name.title().replace("_", " "), show=False + ) gdf_fig.add_child(gdf_poly) m.add_child(gdf_fig) fp_popup_fields = [c for c in fp_data.columns if c != "geometry"] fp_styling = STYLE_MAP["flowpaths"].get("styling", {}) - fp_hl_style = STYLE_MAP["flowpaths"].get("highlight_styling", {}) + three_dim_fp_hl = STYLE_MAP["channel_geometries"].get("highlight_styling", {}) # Project flowpath line geometry to a metric CRS for buffering (to visualize width as a buffer around the line) fp_data = fp_data.to_crs(epsg=5070) @@ -200,12 +202,7 @@ "fillOpacity": 1, "dashArray": [5, 5] if not x["properties"]["topwdth"] else {}, }, - highlight_function=lambda x: fp_hl_style - | { - "stroke": True, - "color": "black", - "weight": 2, - }, + highlight_function=lambda x: three_dim_fp_hl, popup_keep_highlighted=True, ) m.add_child( diff --git a/app/streamlit/ras_xs_dash.py b/app/streamlit/ras_xs_dash.py index d8e6579..74f0cb6 100644 --- a/app/streamlit/ras_xs_dash.py +++ b/app/streamlit/ras_xs_dash.py @@ -115,24 +115,28 @@ def get_ras_xs_user_input(): ).add_to(m) output = st_folium(m, use_container_width=True, height=500) if output["last_active_drawing"]: - sw_corner = output["last_active_drawing"]["geometry"]["coordinates"][0][0] - ne_corner = output["last_active_drawing"]["geometry"]["coordinates"][0][2] - min_lat, min_lon = sw_corner[1], sw_corner[0] - max_lat, max_lon = ne_corner[1], ne_corner[0] - box_area = box(min_lon, min_lat, max_lon, max_lat).area - coord_disp = f"""\ - ##### Selected Coordinates: - - **Min. Latitude:** {sw_corner[1]:.4f}° - - **Min. Longitude:** {sw_corner[0]:.4f}° - - **Max. Latitude:** {ne_corner[1]:.4f}° - - **Max. Longitude:** {ne_corner[0]:.4f}° - """ - st.markdown(coord_disp) - if box_area >= 140: - st.warning( - "The selected bounding box is quite large and may take a long time to process. Please select a smaller area.", - icon=":material/warning:", - ) + if ( + output["all_drawings"] != [] + and output["last_active_drawing"]["geometry"]["type"] == "Polygon" + ): + sw_corner = output["last_active_drawing"]["geometry"]["coordinates"][0][0] + ne_corner = output["last_active_drawing"]["geometry"]["coordinates"][0][2] + min_lat, min_lon = sw_corner[1], sw_corner[0] + max_lat, max_lon = ne_corner[1], ne_corner[0] + box_area = box(min_lon, min_lat, max_lon, max_lat).area + coord_disp = f"""\ + ##### Selected Coordinates: + - **Min. Latitude:** {sw_corner[1]:.4f}° + - **Min. Longitude:** {sw_corner[0]:.4f}° + - **Max. Latitude:** {ne_corner[1]:.4f}° + - **Max. Longitude:** {ne_corner[0]:.4f}° + """ + st.markdown(coord_disp) + if box_area >= 140: + st.warning( + "The selected bounding box is quite large and may take a long time to process. Please select a smaller area.", + icon=":material/warning:", + ) elif xs_query == "Bounding Box (manual entry)": st.markdown("#### __Manually Enter Bounding Box Coordinates__") with st.container(border=True):