Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
643a822
1
Parent(s):
0f74558
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,16 @@ def calculate_distance(lat1, lon1, lat2, lon2):
|
|
13 |
coords_2 = (lat2, lon2)
|
14 |
return geodesic(coords_1, coords_2).meters
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Create a sidebar for controls
|
17 |
with st.sidebar:
|
18 |
# Display a title
|
@@ -27,7 +37,7 @@ with st.sidebar:
|
|
27 |
custom_lat, custom_lon = data['latitude'].mean(), data['longitude'].mean()
|
28 |
|
29 |
# Slider for setting the zoom level
|
30 |
-
zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=
|
31 |
|
32 |
# Slider to set the radius in meters
|
33 |
radius_in_meters = st.slider('Selecione raio (em metros)', min_value=100, max_value=5000, value=1000)
|
|
|
13 |
coords_2 = (lat2, lon2)
|
14 |
return geodesic(coords_1, coords_2).meters
|
15 |
|
16 |
+
# Find the maximum distance between coordinates
|
17 |
+
max_distance = 0
|
18 |
+
for index, row in data.iterrows():
|
19 |
+
distance = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
|
20 |
+
if distance > max_distance:
|
21 |
+
max_distance = distance
|
22 |
+
|
23 |
+
# Calculate a zoom level based on the maximum distance
|
24 |
+
zoom_level = 15 - np.log10(max_distance / 25000)
|
25 |
+
|
26 |
# Create a sidebar for controls
|
27 |
with st.sidebar:
|
28 |
# Display a title
|
|
|
37 |
custom_lat, custom_lon = data['latitude'].mean(), data['longitude'].mean()
|
38 |
|
39 |
# Slider for setting the zoom level
|
40 |
+
zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level)
|
41 |
|
42 |
# Slider to set the radius in meters
|
43 |
radius_in_meters = st.slider('Selecione raio (em metros)', min_value=100, max_value=5000, value=1000)
|