Spaces:
Sleeping
Sleeping
Commit ·
1588088
1
Parent(s): e2c45bb
[FIX] modulo geocoding
Browse files- __pycache__/geocoding.cpython-311.pyc +0 -0
- __pycache__/means.cpython-311.pyc +0 -0
- app.py +1 -0
- geocoding.py +11 -6
- means.py +0 -0
__pycache__/geocoding.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/geocoding.cpython-311.pyc and b/__pycache__/geocoding.cpython-311.pyc differ
|
|
|
__pycache__/means.cpython-311.pyc
ADDED
|
Binary file (732 Bytes). View file
|
|
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
|
|
| 3 |
import streamlit as st
|
| 4 |
from sklearn.cluster import KMeans
|
| 5 |
from streamlit_folium import folium_static
|
|
|
|
| 6 |
import geocoding
|
| 7 |
|
| 8 |
st.set_page_config(layout='wide') # Para usar todo el ancho de la página
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
from sklearn.cluster import KMeans
|
| 5 |
from streamlit_folium import folium_static
|
| 6 |
+
|
| 7 |
import geocoding
|
| 8 |
|
| 9 |
st.set_page_config(layout='wide') # Para usar todo el ancho de la página
|
geocoding.py
CHANGED
|
@@ -7,8 +7,10 @@ from dotenv import load_dotenv
|
|
| 7 |
load_dotenv()
|
| 8 |
|
| 9 |
API_KEY = os.getenv('API_KEY')
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
def geocode_address(address):
|
|
@@ -18,7 +20,7 @@ def geocode_address(address):
|
|
| 18 |
'address': address,
|
| 19 |
'key': api_key
|
| 20 |
}
|
| 21 |
-
|
| 22 |
try:
|
| 23 |
response = requests.get(base_url, params=params)
|
| 24 |
data = response.json()
|
|
@@ -30,12 +32,15 @@ def geocode_address(address):
|
|
| 30 |
|
| 31 |
return latitude, longitude
|
| 32 |
else:
|
|
|
|
| 33 |
st.error(
|
| 34 |
-
'No se encontraron resultados para la dirección '
|
| 35 |
-
'
|
| 36 |
)
|
|
|
|
| 37 |
except requests.exceptions.RequestException as e:
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
direcciones = [
|
|
|
|
| 7 |
load_dotenv()
|
| 8 |
|
| 9 |
API_KEY = os.getenv('API_KEY')
|
| 10 |
+
BASE_URL = os.getenv('BASE_URL')
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
error_index = 1
|
| 14 |
|
| 15 |
|
| 16 |
def geocode_address(address):
|
|
|
|
| 20 |
'address': address,
|
| 21 |
'key': api_key
|
| 22 |
}
|
| 23 |
+
global error_index
|
| 24 |
try:
|
| 25 |
response = requests.get(base_url, params=params)
|
| 26 |
data = response.json()
|
|
|
|
| 32 |
|
| 33 |
return latitude, longitude
|
| 34 |
else:
|
| 35 |
+
|
| 36 |
st.error(
|
| 37 |
+
f'Error {error_index}: No se encontraron resultados para la dirección especificada. '
|
| 38 |
+
'Cargaste la API_KEY: https://console.cloud.google.com/google/maps-apis/credentials'
|
| 39 |
)
|
| 40 |
+
error_index += 1
|
| 41 |
except requests.exceptions.RequestException as e:
|
| 42 |
+
error_index += 1 # Índice para los errores
|
| 43 |
+
st.error(f'Error {error_index}: Error en la solicitud: {e}')
|
| 44 |
|
| 45 |
|
| 46 |
direcciones = [
|
means.py
ADDED
|
File without changes
|