Skip to content

Commit

Permalink
hotfix in v2 dataset publishing (bulk) (#54)
Browse files Browse the repository at this point in the history
if geonames is not found then it will break publishing
bump version

Co-authored-by: dustinlo <dustin.k.lo@jpl.nasa.gov>
  • Loading branch information
DustinKLo and dustinlo authored Aug 15, 2022
1 parent c74a154 commit 72d448d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions grq2/services/api_v02/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 72d448d

Please sign in to comment.