Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
6262455
1
Parent(s):
d54bc6d
Update app.py
Browse files
app.py
CHANGED
@@ -62,8 +62,6 @@ custom_lat = data['latitude'].mean()
|
|
62 |
custom_lon = data['longitude'].mean()
|
63 |
radius_in_meters = 1500
|
64 |
filtered_data = data # Initialize with the entire dataset
|
65 |
-
max_distance_all = 0 # Initialize max_distance_all here
|
66 |
-
|
67 |
|
68 |
# Find the maximum distance between coordinates
|
69 |
max_distance = 0
|
@@ -88,10 +86,6 @@ if radius_visible:
|
|
88 |
# Set the zoom level based on the mapping
|
89 |
zoom_level = radius_zoom_mapping[closest_radius]
|
90 |
|
91 |
-
else:
|
92 |
-
# Calculate a zoom level based on the maximum distance
|
93 |
-
zoom_level = round(15 - np.log10(max_distance))
|
94 |
-
|
95 |
# Create a sidebar for controls
|
96 |
with st.sidebar:
|
97 |
st.title('avalia.se')
|
@@ -107,25 +101,8 @@ with st.sidebar:
|
|
107 |
radius_visible = False # Hide radius slider for random coordinates
|
108 |
max_distance_all = 0 # Initialize max_distance_all here
|
109 |
|
110 |
-
|
111 |
-
if radius_visible:
|
112 |
-
radius_in_meters = st.slider('Selecione raio (em metros)', key='radius_slider', min_value=100, max_value=5000, value=1000)
|
113 |
-
|
114 |
-
# Calculate a zoom level based on the radius
|
115 |
-
radius_zoom_mapping = {
|
116 |
-
500: 15,
|
117 |
-
1000: 14,
|
118 |
-
2000: 13,
|
119 |
-
4000: 12,
|
120 |
-
5000: 11
|
121 |
-
}
|
122 |
-
|
123 |
-
# Find the closest radius in the mapping
|
124 |
-
closest_radius = min(radius_zoom_mapping.keys(), key=lambda x: abs(x - radius_in_meters))
|
125 |
|
126 |
-
# Set the zoom level based on the mapping
|
127 |
-
zoom_level = radius_zoom_mapping[closest_radius]
|
128 |
-
|
129 |
# Geocode the custom address using the Google Maps API
|
130 |
gmaps = googlemaps.Client(key='AIzaSyDoJ6C7NE2CHqFcaHTnhreOfgJeTk4uSH0') # Replace with your API key
|
131 |
|
@@ -136,9 +113,9 @@ with st.sidebar:
|
|
136 |
st.error("Erro: Não foi possível geocodificar o endereço fornecido. Por favor, verifique e tente novamente.")
|
137 |
|
138 |
# Slider for setting the zoom level
|
139 |
-
if selected_coords == 'Custom'
|
140 |
-
#
|
141 |
-
|
142 |
else:
|
143 |
for index, row in data.iterrows():
|
144 |
distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
|
@@ -151,9 +128,9 @@ with st.sidebar:
|
|
151 |
# Slider for setting the zoom level based on the entire dataset
|
152 |
zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level_all)
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
|
158 |
# Filter data based on the radius
|
159 |
if selected_coords == 'Custom':
|
|
|
62 |
custom_lon = data['longitude'].mean()
|
63 |
radius_in_meters = 1500
|
64 |
filtered_data = data # Initialize with the entire dataset
|
|
|
|
|
65 |
|
66 |
# Find the maximum distance between coordinates
|
67 |
max_distance = 0
|
|
|
86 |
# Set the zoom level based on the mapping
|
87 |
zoom_level = radius_zoom_mapping[closest_radius]
|
88 |
|
|
|
|
|
|
|
|
|
89 |
# Create a sidebar for controls
|
90 |
with st.sidebar:
|
91 |
st.title('avalia.se')
|
|
|
101 |
radius_visible = False # Hide radius slider for random coordinates
|
102 |
max_distance_all = 0 # Initialize max_distance_all here
|
103 |
|
104 |
+
max_distance_all = 0 # Initialize max_distance_all here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
|
|
|
|
|
|
106 |
# Geocode the custom address using the Google Maps API
|
107 |
gmaps = googlemaps.Client(key='AIzaSyDoJ6C7NE2CHqFcaHTnhreOfgJeTk4uSH0') # Replace with your API key
|
108 |
|
|
|
113 |
st.error("Erro: Não foi possível geocodificar o endereço fornecido. Por favor, verifique e tente novamente.")
|
114 |
|
115 |
# Slider for setting the zoom level
|
116 |
+
if selected_coords == 'Custom':
|
117 |
+
# The zoom level slider is no longer needed if radius is used for zoom adjustment
|
118 |
+
st.markdown("O nível de zoom é ajustado automaticamente com base no raio.")
|
119 |
else:
|
120 |
for index, row in data.iterrows():
|
121 |
distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
|
|
|
128 |
# Slider for setting the zoom level based on the entire dataset
|
129 |
zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level_all)
|
130 |
|
131 |
+
# Conditionally render the radius slider
|
132 |
+
if radius_visible:
|
133 |
+
radius_in_meters = st.slider('Selecione raio (em metros)', min_value=100, max_value=5000, value=1000)
|
134 |
|
135 |
# Filter data based on the radius
|
136 |
if selected_coords == 'Custom':
|