Skip to content

Commit

Permalink
adds check for gpolygon, returns empty wkt if no gpolygon is parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
kim committed Feb 28, 2024
1 parent 2ff40bf commit 93af966
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions SearchAPI/CMR/Translate/parse_cmr_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,19 @@ def wkt_from_gpolygon(gpoly):
# Close the shape if needed
shapes[-1].append(shapes[-1][0])

longest = shapes[0]
for shape in shapes:
if len(shape) > len(longest):
longest = shape

wkt_shape = 'POLYGON(({0}))'.format(
','.join(['{0} {1}'.format(x['lon'], x['lat']) for x in longest])
)
if len(shapes):
longest = shapes[0]
for shape in shapes:
if len(shape) > len(longest):
longest = shape

wkt_shape = 'POLYGON(({0}))'.format(
','.join(['{0} {1}'.format(x['lon'], x['lat']) for x in longest])
)

return longest, wkt_shape
return longest, wkt_shape

return '', ''


def shape_not_closed(shapes):
Expand Down

0 comments on commit 93af966

Please sign in to comment.