Skip to content

Commit

Permalink
[Fixes #4333] Upload from GUI doesn't handle projection properly
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Apr 3, 2019
1 parent 5219096 commit 427cb95
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions geonode/geoserver/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
get_store,
get_sld_for,
ogc_server_settings,
cascading_delete,
_create_db_featurestore,
_create_featurestore,
_create_coveragestore)
Expand Down Expand Up @@ -185,26 +184,22 @@ def geoserver_upload(
_native_bbox = gs_resource.native_bbox
except BaseException:
pass

if _native_bbox and len(_native_bbox) >= 5 and _native_bbox[4:5][0] == 'EPSG:4326':
box = _native_bbox[:4]
minx, maxx, miny, maxy = [float(a) for a in box]
if -180 <= round(minx, 5) <= 180 and -180 <= round(maxx, 5) <= 180 and \
-90 <= round(miny, 5) <= 90 and -90 <= round(maxy, 5) <= 90:
logger.info('GeoServer failed to detect the projection for layer '
'[%s]. Guessing EPSG:4326', name)
# If GeoServer couldn't figure out the projection, we just
# assume it's lat/lon to avoid a bad GeoServer configuration

-90 <= round(miny, 5) <= 90 and -90 <= round(maxy, 5) <= 90:
gs_resource.latlon_bbox = _native_bbox
gs_resource.projection = "EPSG:4326"
cat.save(gs_resource)
else:
msg = ('GeoServer failed to detect the projection for layer '
'[%s]. It doesn\'t look like EPSG:4326, so backing out '
'the layer.')
logger.info(msg, name)
cascading_delete(cat, name)
raise GeoNodeException(msg % name)
logger.warning('BBOX coordinates outside normal EPSG:4326 values for layer '
'[%s].', name)
_native_bbox = [-180, -90, 180, 90, "EPSG:4326"]
gs_resource.latlon_bbox = _native_bbox
gs_resource.projection = "EPSG:4326"
cat.save(gs_resource)

# Step 7. Create the style and assign it to the created resource
# FIXME: Put this in gsconfig.py
Expand Down

0 comments on commit 427cb95

Please sign in to comment.