Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions app/streamlit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))},
Expand Down Expand Up @@ -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])),
Expand All @@ -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,
)

Expand Down
15 changes: 6 additions & 9 deletions app/streamlit/hydrofabric_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down
40 changes: 22 additions & 18 deletions app/streamlit/ras_xs_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading