Skip to content

Commit

Permalink
Merge pull request #35 from GIScience/development
Browse files Browse the repository at this point in the history
Nested Else Indent Correction
  • Loading branch information
TimMcCauley authored May 8, 2018
2 parents d0b60ae + a8fda0e commit 9cb4df0
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions openpoiservice/server/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,43 +230,43 @@ def parse_geometries(geometry):
message='Your linestring geometry is too long ({} meters), check the server restrictions.'.format(
length))

elif geojson_obj.geom_type == 'Polygon':
elif geojson_obj.geom_type == 'Polygon':

check_for_buffer(geometry, ops_settings['maximum_search_radius_for_polygons'])
check_for_buffer(geometry, ops_settings['maximum_search_radius_for_polygons'])

# check if area not too large
area = transform_geom(geojson_obj, 'epsg:4326', 'epsg:3857').area
if area > ops_settings['maximum_area']:
raise api_exceptions.InvalidUsage(
message='Your polygon geometry is too large ({} square meters), check the server '
'restrictions.'.format(area),
status_code=500, error_code=4008)
# check if area not too large
area = transform_geom(geojson_obj, 'epsg:4326', 'epsg:3857').area
if area > ops_settings['maximum_area']:
raise api_exceptions.InvalidUsage(
message='Your polygon geometry is too large ({} square meters), check the server '
'restrictions.'.format(area),
status_code=500, error_code=4008)

else:
# type not supported
raise api_exceptions.InvalidUsage(error_code=4007,
message='GeoJSON type {} not supported'.format(geojson_obj.geom_type),
status_code=500)
else:
# type not supported
raise api_exceptions.InvalidUsage(error_code=4007,
message='GeoJSON type {} not supported'.format(geojson_obj.geom_type),
status_code=500)

geometry['geom'] = geojson_obj
geometry['geom'] = geojson_obj

# parse bbox, can be provided additionally to geometry
if 'bbox' in geometry:
# parse bbox, can be provided additionally to geometry
if 'bbox' in geometry:

try:
geojson_obj = MultiPoint(parse_geometry(geometry['bbox']))
except ValueError as e:
raise api_exceptions.InvalidUsage(status_code=500, error_code=4007, message=str(e))
try:
geojson_obj = MultiPoint(parse_geometry(geometry['bbox']))
except ValueError as e:
raise api_exceptions.InvalidUsage(status_code=500, error_code=4007, message=str(e))

geometry['bbox'] = check_validity(geojson_obj).envelope
geometry['bbox'] = check_validity(geojson_obj).envelope

# print(geometry['bbox'].wkt)
# print(geometry['bbox'].wkt)

# check if area not too large
area = transform_geom(geometry['bbox'], 'epsg:4326', 'epsg:3857').area
if area > ops_settings['maximum_area']:
raise api_exceptions.InvalidUsage(error_code=4008, status_code=500,
message='Your polygon geometry is too large ({} square meters), '
'check the server restrictions.'.format(area))
# check if area not too large
area = transform_geom(geometry['bbox'], 'epsg:4326', 'epsg:3857').area
if area > ops_settings['maximum_area']:
raise api_exceptions.InvalidUsage(error_code=4008, status_code=500,
message='Your polygon geometry is too large ({} square meters), '
'check the server restrictions.'.format(area))

return geometry
return geometry

0 comments on commit 9cb4df0

Please sign in to comment.