jableable commited on
Commit
4ce749d
·
verified ·
1 Parent(s): 420d6f8

Update new_app.py

Browse files
Files changed (1) hide show
  1. new_app.py +9 -6
new_app.py CHANGED
@@ -98,17 +98,20 @@ with col3:
98
  with st.form("coords_form"):
99
  c1, c2 = st.columns(2)
100
  with c1:
101
- lat_input = st.number_input('Latitude', value=float(state.lat), min_value=-90., max_value=90., step=.01)
102
  st.write('The current lat/long are:')
103
  with c2:
104
- lng_input = st.number_input('Longitude', value=float(state.lng), min_value=-180., max_value=180., step=.01)
105
- st.write(f"{state.lat:.2f}, {state.lng:.2f}")
106
  submitted = st.form_submit_button("Get Image and Prediction")
107
 
108
  if submitted:
109
- api_key = os.getenv("goog_api", "")
110
- state.lat, state.lng = float(lat_input), float(lng_input)
111
- state.img = fetch_satellite_tile(state.lat, state.lng, api_key=api_key)
 
 
 
112
 
113
  with col2:
114
  if state.coords_submitted:
 
98
  with st.form("coords_form"):
99
  c1, c2 = st.columns(2)
100
  with c1:
101
+ st.number_input('Latitude', key="lat", value=float(state.lat), min_value=-90.0, max_value=90.0, step=0.01, format="%.4f")
102
  st.write('The current lat/long are:')
103
  with c2:
104
+ st.number_input('Longitude', key="lng", value=float(state.lng), min_value=-180.0, max_value=180.0, step=0.01, format="%.4f")
105
+ st.write(f"{st.session_state.lat:.2f}, {st.session_state.lng:.2f}")
106
  submitted = st.form_submit_button("Get Image and Prediction")
107
 
108
  if submitted:
109
+ try:
110
+ api_key = os.getenv("goog_api", "")
111
+ state.img = fetch_satellite_tile(st.session_state.lat, st.session_state.lng, api_key=api_key)
112
+ st.rerun() # ensures the updated lat/lng render immediately
113
+ except Exception as e:
114
+ st.error(f"Error fetching image: {e}")
115
 
116
  with col2:
117
  if state.coords_submitted: