Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
4fc77fd
1
Parent(s):
818b1ef
Update app.py
Browse files
app.py
CHANGED
@@ -105,8 +105,25 @@ with st.sidebar:
|
|
105 |
radius_visible = False # Hide radius slider for random coordinates
|
106 |
max_distance_all = 0 # Initialize max_distance_all here
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
|
|
|
|
|
|
110 |
# Geocode the custom address using the Google Maps API
|
111 |
gmaps = googlemaps.Client(key='AIzaSyDoJ6C7NE2CHqFcaHTnhreOfgJeTk4uSH0') # Replace with your API key
|
112 |
|
@@ -117,9 +134,9 @@ with st.sidebar:
|
|
117 |
st.error("Erro: Não foi possível geocodificar o endereço fornecido. Por favor, verifique e tente novamente.")
|
118 |
|
119 |
# Slider for setting the zoom level
|
120 |
-
if selected_coords == 'Custom':
|
121 |
-
#
|
122 |
-
st.
|
123 |
else:
|
124 |
for index, row in data.iterrows():
|
125 |
distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
|
@@ -166,4 +183,4 @@ with st.container():
|
|
166 |
# Display the predicted Vunit values if applicable
|
167 |
if 'Predicted_Vunit' in filtered_data.columns:
|
168 |
st.write("Valores (R$/m²) previstos com algoritmo KNN:")
|
169 |
-
st.write(filtered_data[['latitude', 'longitude', 'Vunit', 'Predicted_Vunit']])
|
|
|
105 |
radius_visible = False # Hide radius slider for random coordinates
|
106 |
max_distance_all = 0 # Initialize max_distance_all here
|
107 |
|
108 |
+
# Slider for setting the radius
|
109 |
+
if radius_visible:
|
110 |
+
radius_in_meters = st.slider('Selecione raio (em metros)', min_value=100, max_value=5000, value=1000)
|
111 |
+
|
112 |
+
# Calculate a zoom level based on the radius
|
113 |
+
radius_zoom_mapping = {
|
114 |
+
500: 15,
|
115 |
+
1000: 14,
|
116 |
+
2000: 13,
|
117 |
+
4000: 12,
|
118 |
+
5000: 11
|
119 |
+
}
|
120 |
+
|
121 |
+
# Find the closest radius in the mapping
|
122 |
+
closest_radius = min(radius_zoom_mapping.keys(), key=lambda x: abs(x - radius_in_meters))
|
123 |
|
124 |
+
# Set the zoom level based on the mapping
|
125 |
+
zoom_level = radius_zoom_mapping[closest_radius]
|
126 |
+
|
127 |
# Geocode the custom address using the Google Maps API
|
128 |
gmaps = googlemaps.Client(key='AIzaSyDoJ6C7NE2CHqFcaHTnhreOfgJeTk4uSH0') # Replace with your API key
|
129 |
|
|
|
134 |
st.error("Erro: Não foi possível geocodificar o endereço fornecido. Por favor, verifique e tente novamente.")
|
135 |
|
136 |
# Slider for setting the zoom level
|
137 |
+
if selected_coords == 'Custom' and not radius_visible:
|
138 |
+
# Use the zoom level slider based on the entire dataset
|
139 |
+
zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level_all)
|
140 |
else:
|
141 |
for index, row in data.iterrows():
|
142 |
distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
|
|
|
183 |
# Display the predicted Vunit values if applicable
|
184 |
if 'Predicted_Vunit' in filtered_data.columns:
|
185 |
st.write("Valores (R$/m²) previstos com algoritmo KNN:")
|
186 |
+
st.write(filtered_data[['latitude', 'longitude', 'Vunit', 'Predicted_Vunit']])
|