Skip to content

Commit

Permalink
streamlit no data errors afgevangne
Browse files Browse the repository at this point in the history
  • Loading branch information
JJFlorian committed Feb 27, 2024
1 parent 89b927f commit 350ed89
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 87 deletions.
51 changes: 30 additions & 21 deletions streamlit/components/gmn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,40 @@ def gmn_table() -> None:
"""Fetches GMN data and shows it in a table"""
gmn_df = utils.get_endpoint_data("gmn/gmns")

gmn_df = gmn_df[[
"bro_id",
"delivery_accountable_party",
"quality_regime",
"name",
"delivery_context",
"monitoring_purpose",
"groundwater_aspect",
"start_date_monitoring",
"registration_status",
]]
if gmn_df.empty :
st.text("Er zijn nog geen GMNs geimporteerd.")

st.dataframe(gmn_df, hide_index=True)
else:
gmn_df = gmn_df[[
"bro_id",
"delivery_accountable_party",
"quality_regime",
"name",
"delivery_context",
"monitoring_purpose",
"groundwater_aspect",
"start_date_monitoring",
"registration_status",
]]

st.dataframe(gmn_df, hide_index=True)

def measuringpoints_table() -> None:
"""Fetches measuringpoints data and shows it in a table"""
measuringpoints_df = utils.get_endpoint_data("gmn/measuringpoints")

measuringpoints_df = measuringpoints_df[[
"gmn",
"measuringpoint_code",
"measuringpoint_start_date",
"gmw_bro_id",
"tube_number",
"tube_start_date",
]]
if measuringpoints_df.empty :
st.text("Er zijn nog geen meetpunten geimporteerd.")

else:

measuringpoints_df = measuringpoints_df[[
"gmn",
"measuringpoint_code",
"measuringpoint_start_date",
"gmw_bro_id",
"tube_number",
"tube_start_date",
]]

st.dataframe(measuringpoints_df, hide_index=True)
st.dataframe(measuringpoints_df, hide_index=True)
101 changes: 55 additions & 46 deletions streamlit/components/gmw.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,68 @@ def gmw_table() -> None:
"""Fetches GMW data and shows it in a table"""
gmw_df = utils.get_endpoint_data("gmw/gmws")

gmw_df = gmw_df[[
"bro_id",
"well_code",
"quality_regime",
"delivery_context",
"construction_standard",
"initial_function",
"ground_level_stable",
"removed",
"well_stability",
"nitg_code",
"well_head_protector",
"delivered_location",
"local_vertical_reference_point",
"offset",
"vertical_datum",
"ground_level_position",
"standardized_location",
"registration_status",
]]
if gmw_df.empty :
st.text("Er zijn nog geen GMWs geimporteerd.")

st.dataframe(gmw_df, hide_index=True)
else:
gmw_df = gmw_df[[
"bro_id",
"well_code",
"quality_regime",
"delivery_context",
"construction_standard",
"initial_function",
"ground_level_stable",
"removed",
"well_stability",
"nitg_code",
"well_head_protector",
"delivered_location",
"local_vertical_reference_point",
"offset",
"vertical_datum",
"ground_level_position",
"standardized_location",
"registration_status",
]]

st.dataframe(gmw_df, hide_index=True)

def monitoringtubes_table() -> None:
"""Fetches monitoringtubes data and shows it in a table"""
monitoringtubes_df = utils.get_endpoint_data("gmw/monitoringtubes")

monitoringtubes_df = monitoringtubes_df[[
"gmw",
"tube_number",
"tube_type",
"artesian_well_cap_present",
"sediment_sump_present",
"number_of_geo_ohm_cables",
"tube_top_diameter",
"variable_diameter",
"tube_status",
"tube_top_position",
"tube_top_positioning_method",
"tube_part_inserted",
"tube_packing_material",
"tube_material",
"glue",
"screen_length",
"sock_material",
"screen_top_position",
"screen_bottom_position",
"plain_tube_part_length",
if monitoringtubes_df.empty :
st.text("Er zijn nog geen monitoringbuizen geimporteerd.")

else:

monitoringtubes_df = monitoringtubes_df[[
"gmw",
"tube_number",
"tube_type",
"artesian_well_cap_present",
"sediment_sump_present",
"number_of_geo_ohm_cables",
"tube_top_diameter",
"variable_diameter",
"tube_status",
"tube_top_position",
"tube_top_positioning_method",
"tube_part_inserted",
"tube_packing_material",
"tube_material",
"glue",
"screen_length",
"sock_material",
"screen_top_position",
"screen_bottom_position",
"plain_tube_part_length",





]]
]]

st.dataframe(monitoringtubes_df, hide_index=True)
st.dataframe(monitoringtubes_df, hide_index=True)
44 changes: 24 additions & 20 deletions streamlit/components/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,39 @@ def map() -> None:

# Import Data
gmn_df = utils.get_endpoint_data("gmn/gmns")
measuringpoing_df = utils.get_endpoint_data("gmn/measuringpoints")
measuringpoint_df = utils.get_endpoint_data("gmn/measuringpoints")
gmw_df = utils.get_endpoint_data("gmw/gmws")

# Select GMN
gmn_options = gmn_df['name'].tolist()
gmn_options = ["Selecteer een Meetnet"] + gmn_options
if gmn_df.empty or measuringpoint_df.empty or gmw_df.empty:
st.text("Om de kaart te laten werken moeten er minimaal 1 GMN, en minimaal 1 GMW geimporteerd zijn.")

selected_gmn = st.selectbox("Selecteer een GMN:", options=gmn_options)
else:
# Select GMN
gmn_options = gmn_df['name'].tolist()
gmn_options = ["Selecteer een Meetnet"] + gmn_options

if not selected_gmn == 'Selecteer een Meetnet':
selected_gmn_uuid = gmn_df.loc[gmn_df['name'] == selected_gmn, 'uuid'].values[0]
selected_gmn = st.selectbox("Selecteer een GMN:", options=gmn_options)

# Filter measuringpoint df
measuringpoing_df = measuringpoing_df[measuringpoing_df["gmn"] == selected_gmn_uuid]

# filter GMW df based on selected GMN
gmw_df = pd.merge(measuringpoing_df, gmw_df, left_on='gmw_bro_id', right_on='bro_id', how='inner')
if not selected_gmn == 'Selecteer een Meetnet':
selected_gmn_uuid = gmn_df.loc[gmn_df['name'] == selected_gmn, 'uuid'].values[0]

# Transform GMW df
gmw_df[['lat', 'long']] = gmw_df['standardized_location'].str.split(expand=True)
geometry = [Point(xy) for xy in zip(gmw_df['long'], gmw_df['lat'])]
geo_gmw_df = gpd.GeoDataFrame(gmw_df, geometry=geometry)
geo_gmw_df.drop(columns=['lat', 'long'], inplace=True)
# Filter measuringpoint df
measuringpoint_df = measuringpoint_df[measuringpoint_df["gmn"] == selected_gmn_uuid]
# filter GMW df based on selected GMN
gmw_df = pd.merge(measuringpoint_df, gmw_df, left_on='gmw_bro_id', right_on='bro_id', how='inner')

# Transform GMW df
gmw_df[['lat', 'long']] = gmw_df['standardized_location'].str.split(expand=True)
geometry = [Point(xy) for xy in zip(gmw_df['long'], gmw_df['lat'])]
geo_gmw_df = gpd.GeoDataFrame(gmw_df, geometry=geometry)
geo_gmw_df.drop(columns=['lat', 'long'], inplace=True)

m = foliumap.Map()

m.add_gdf(geo_gmw_df, layer_name='GMWs')
m = foliumap.Map()

m.to_streamlit()
m.add_gdf(geo_gmw_df, layer_name='GMWs')

m.to_streamlit()


0 comments on commit 350ed89

Please sign in to comment.