Skip to content

Commit 3e1c379

Browse files
committed
Solved wrong score in coordinates
1 parent 9013593 commit 3e1c379

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

plugins/gbif/gbif_data.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,18 +707,23 @@ def coordinate_in_country(codigo_pais, latitud, longitud):
707707
interior."""
708708
# Buscamos el país correspondiente al código ISO alpha-2
709709
try:
710-
pais = pycountry.countries.get(alpha_2=codigo_pais).alpha_3
710+
if len(codigo_pais) == 2:
711+
pais = pycountry.countries.get(alpha_2=codigo_pais).alpha_3
712+
elif len(codigo_pais) == 3:
713+
pais = pycountry.countries.get(alpha_3=codigo_pais).alpha_3
711714
if pais:
712715
# Cargamos el conjunto de datos de límites de países
716+
__BD_BORDERS = gpd.read_file("static/ne_110m_admin_0_countries.shp")
713717
world = __BD_BORDERS.copy()
714718

715719
# Obtenemos el polígono del país
716-
poligono_pais = world[world["iso_a3"] == pais].geometry.squeeze()
720+
poligono_pais = world[world["ADM0_A3"] == pais].geometry.squeeze()
717721

718722
# Verificamos si el polígono del país contiene el punto con las coordenadas dadas
719723
if poligono_pais.contains(Point(longitud, latitud)):
720724
return True
721-
except Exception:
725+
except Exception as e:
726+
logger.error(e)
722727
pass
723728

724729
# Si no se encuentra el país o no contiene las coordenadas, devolvemos False

static/ne_110m_admin_0_countries.cpg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UTF-8

static/ne_110m_admin_0_countries.dbf

519 KB
Binary file not shown.

static/ne_110m_admin_0_countries.prj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]]

0 commit comments

Comments
 (0)