fschwartzer commited on
Commit
818b1ef
1 Parent(s): 2737b30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -70,8 +70,25 @@ for index, row in data.iterrows():
70
  if distance > max_distance:
71
  max_distance = distance
72
 
73
- # Calculate a zoom level based on the maximum distance
74
- zoom_level = round(15 - np.log10(max_distance))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  # Create a sidebar for controls
77
  with st.sidebar:
@@ -101,7 +118,8 @@ with st.sidebar:
101
 
102
  # Slider for setting the zoom level
103
  if selected_coords == 'Custom':
104
- zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level)
 
105
  else:
106
  for index, row in data.iterrows():
107
  distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
 
70
  if distance > max_distance:
71
  max_distance = distance
72
 
73
+ # Calculate a zoom level based on the radius
74
+ if radius_visible:
75
+ radius_zoom_mapping = {
76
+ 500: 15,
77
+ 1000: 14,
78
+ 2000: 13,
79
+ 4000: 12,
80
+ 5000: 11
81
+ }
82
+
83
+ # Find the closest radius in the mapping
84
+ closest_radius = min(radius_zoom_mapping.keys(), key=lambda x: abs(x - radius_in_meters))
85
+
86
+ # Set the zoom level based on the mapping
87
+ zoom_level = radius_zoom_mapping[closest_radius]
88
+
89
+ else:
90
+ # Calculate a zoom level based on the maximum distance
91
+ zoom_level = round(15 - np.log10(max_distance))
92
 
93
  # Create a sidebar for controls
94
  with st.sidebar:
 
118
 
119
  # Slider for setting the zoom level
120
  if selected_coords == 'Custom':
121
+ # The zoom level slider is no longer needed if radius is used for zoom adjustment
122
+ st.markdown("O nível de zoom é ajustado automaticamente com base no raio.")
123
  else:
124
  for index, row in data.iterrows():
125
  distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())