mirix commited on
Commit
fb310cc
·
verified ·
1 Parent(s): 1d85ced

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -30,7 +30,6 @@ OVERPASS_URL = "https://maps.mail.ru/osm/tools/overpass/api/interpreter"
30
  ICON_URL = "https://raw.githubusercontent.com/basmilius/weather-icons/refs/heads/dev/production/fill/svg/"
31
 
32
  DEFAULT_LAT, DEFAULT_LON = 49.6116, 6.1319
33
- MIN_ALTITUDE_M = 300
34
  MAX_PEAKS = 100
35
 
36
 
@@ -70,7 +69,7 @@ def get_elevation_from_srtm(lat, lon):
70
 
71
  # --- PEAK FETCHING (REFACTORED LOGIC) ---
72
 
73
- def get_peaks_from_overpass(lat, lon, dist_km):
74
  bbox = compute_bbox(lat, lon, dist_km)
75
 
76
  query = f"""
@@ -107,7 +106,7 @@ def get_peaks_from_overpass(lat, lon, dist_km):
107
  if alt is None or alt <= 0:
108
  alt = get_elevation_from_srtm(lat_e, lon_e)
109
 
110
- if alt is None or alt < MIN_ALTITUDE_M:
111
  continue
112
 
113
  rows.append({
@@ -228,7 +227,7 @@ def geocode_location(location_text):
228
 
229
  # --- CORE LOGIC ---
230
 
231
- def find_snowy_peaks(min_snow_cm, radius_km, lat, lon):
232
  if lat is None or lon is None:
233
  fig = create_empty_map(DEFAULT_LAT, DEFAULT_LON)
234
  fig.update_layout(title_text="Enter valid coordinates.")
@@ -239,7 +238,7 @@ def find_snowy_peaks(min_snow_cm, radius_km, lat, lon):
239
  fig.update_layout(title_text="Invalid coordinates.")
240
  return fig, "Coordinates out of range."
241
 
242
- df_peaks = get_peaks_from_overpass(lat, lon, radius_km)
243
  if df_peaks.empty:
244
  fig = create_map_with_center(lat, lon)
245
  fig.update_layout(title_text=f"No peaks found within {radius_km} km.")
@@ -378,6 +377,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Snow Finder") as demo:
378
  lon_input = gr.Number(value=DEFAULT_LON, label="Longitude", precision=4)
379
  snow_slider = gr.Radio(choices=[1, 2, 3, 4, 5, 6], value=1, label="Min Snow (cm)")
380
  radius_slider = gr.Radio(choices=[10, 20, 30, 40, 50, 60], value=30, label="Radius (km)")
 
381
  search_button = gr.Button("❄️ Find Snow!", variant="primary")
382
  status_output = gr.Textbox(lines=4, interactive=False)
383
 
@@ -394,9 +394,9 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Snow Finder") as demo:
394
 
395
  search_button.click(
396
  fn=find_snowy_peaks,
397
- inputs=[snow_slider, radius_slider, lat_input, lon_input],
398
  outputs=[map_plot, status_output],
399
  )
400
 
401
  if __name__ == "__main__":
402
- demo.launch()
 
30
  ICON_URL = "https://raw.githubusercontent.com/basmilius/weather-icons/refs/heads/dev/production/fill/svg/"
31
 
32
  DEFAULT_LAT, DEFAULT_LON = 49.6116, 6.1319
 
33
  MAX_PEAKS = 100
34
 
35
 
 
69
 
70
  # --- PEAK FETCHING (REFACTORED LOGIC) ---
71
 
72
+ def get_peaks_from_overpass(lat, lon, dist_km, min_altitude_m):
73
  bbox = compute_bbox(lat, lon, dist_km)
74
 
75
  query = f"""
 
106
  if alt is None or alt <= 0:
107
  alt = get_elevation_from_srtm(lat_e, lon_e)
108
 
109
+ if alt is None or alt < min_altitude_m:
110
  continue
111
 
112
  rows.append({
 
227
 
228
  # --- CORE LOGIC ---
229
 
230
+ def find_snowy_peaks(min_snow_cm, radius_km, min_altitude_m, lat, lon):
231
  if lat is None or lon is None:
232
  fig = create_empty_map(DEFAULT_LAT, DEFAULT_LON)
233
  fig.update_layout(title_text="Enter valid coordinates.")
 
238
  fig.update_layout(title_text="Invalid coordinates.")
239
  return fig, "Coordinates out of range."
240
 
241
+ df_peaks = get_peaks_from_overpass(lat, lon, radius_km, min_altitude_m)
242
  if df_peaks.empty:
243
  fig = create_map_with_center(lat, lon)
244
  fig.update_layout(title_text=f"No peaks found within {radius_km} km.")
 
377
  lon_input = gr.Number(value=DEFAULT_LON, label="Longitude", precision=4)
378
  snow_slider = gr.Radio(choices=[1, 2, 3, 4, 5, 6], value=1, label="Min Snow (cm)")
379
  radius_slider = gr.Radio(choices=[10, 20, 30, 40, 50, 60], value=30, label="Radius (km)")
380
+ altitude_slider = gr.Radio(choices=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], value=300, label="Min Altitude (m)")
381
  search_button = gr.Button("❄️ Find Snow!", variant="primary")
382
  status_output = gr.Textbox(lines=4, interactive=False)
383
 
 
394
 
395
  search_button.click(
396
  fn=find_snowy_peaks,
397
+ inputs=[snow_slider, radius_slider, altitude_slider, lat_input, lon_input],
398
  outputs=[map_plot, status_output],
399
  )
400
 
401
  if __name__ == "__main__":
402
+ demo.launch()