Skip to content

Commit

Permalink
Add h3 to interactive tools for overlapping
Browse files Browse the repository at this point in the history
  • Loading branch information
alephcero committed Nov 12, 2024
1 parent 51c7733 commit 25e7556
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions urbantrips/run_interactive_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def seleccionar_linea(nombre_columna, key_input, key_select, branch_key, conn_in
col1, col2, col3 = st.columns([1, 3, 3])

with col1:
h3_res_comp = st.slider("Resolución H3", min_value=7, max_value=9, value=8)

if st.button("Comparar líneas"):
for i in [1, 2]:
if f"seleccion_{i}" in st.session_state:
Expand Down Expand Up @@ -177,18 +179,21 @@ def seleccionar_linea(nombre_columna, key_input, key_select, branch_key, conn_in
)

# Evita cálculos repetidos si ya se han realizado para las mismas líneas
if f"overlapping_dict_{base_route_id}_{comp_route_id}" not in st.session_state:
if (
f"overlapping_dict_{base_route_id}_{comp_route_id}_res{h3_res_comp}"
not in st.session_state
):

overlapping_dict = ovl.compute_supply_overlapping(
"weekday",
base_route_id,
comp_route_id,
"branches" if use_branches else "lines",
8,
)
st.session_state[f"overlapping_dict_{base_route_id}_{comp_route_id}"] = (
overlapping_dict
h3_res_comp,
)
st.session_state[
f"overlapping_dict_{base_route_id}_{comp_route_id}_res{h3_res_comp}"
] = overlapping_dict
st.session_state[f"supply_overlapping_{base_route_id}_{comp_route_id}"] = (
overlapping_dict["text_base_v_comp"]
)
Expand All @@ -197,7 +202,7 @@ def seleccionar_linea(nombre_columna, key_input, key_select, branch_key, conn_in
)

overlapping_dict = st.session_state[
f"overlapping_dict_{base_route_id}_{comp_route_id}"
f"overlapping_dict_{base_route_id}_{comp_route_id}_res{h3_res_comp}"
]

# Renderiza el primer mapa
Expand Down

0 comments on commit 25e7556

Please sign in to comment.