From 72d448df8a6bc93e5fc622692ee628fa267f76e8 Mon Sep 17 00:00:00 2001 From: Dustin Lo Date: Mon, 15 Aug 2022 11:07:39 -0700 Subject: [PATCH] hotfix in v2 dataset publishing (bulk) (#54) if geonames is not found then it will break publishing bump version Co-authored-by: dustinlo --- grq2/services/api_v02/datasets.py | 11 ++++++++--- setup.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/grq2/services/api_v02/datasets.py b/grq2/services/api_v02/datasets.py index c7c2d28..b9f734a 100644 --- a/grq2/services/api_v02/datasets.py +++ b/grq2/services/api_v02/datasets.py @@ -82,15 +82,20 @@ def reverse_geolocation(prod_json): if geo_json_type in (_POLYGON, _MULTIPOLYGON): mp = True if geo_json_type == _MULTIPOLYGON else False coords = location['coordinates'][0] - prod_json['city'] = get_cities(coords, multipolygon=mp) + cities = get_cities(coords, multipolygon=mp) + if cities: + prod_json['city'] = cities elif geo_json_type in (_POINT, _MULTIPOINT, _LINESTRING, _MULTILINESTRING): - prod_json['city'] = get_nearest_cities(lon, lat) + nearest_cities = get_nearest_cities(lon, lat) + if nearest_cities: + prod_json['city'] = nearest_cities else: raise TypeError('%s is not a valid GEOJson type (or un-supported): %s' % (geo_json_type, GEOJSON_TYPES)) # add closest continent continents = get_continents(lon, lat) - prod_json['continent'] = continents[0]['name'] if len(continents) > 0 else None + if continents: + prod_json['continent'] = continents[0]['name'] if len(continents) > 0 else None # set temporal_span if prod_json.get('starttime', None) is not None and prod_json.get('endtime', None) is not None: diff --git a/setup.py b/setup.py index 8d38535..082c519 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='grq2', - version='2.0.17', + version='2.0.18', long_description='GeoRegionQuery REST API using ElasticSearch backend', packages=find_packages(), include_package_data=True,