From 81b455b874ff8dc7de09224f81d3b191ff568ceb Mon Sep 17 00:00:00 2001 From: David Quartey <42542676+DavidQuartz@users.noreply.github.com> Date: Tue, 21 Jun 2022 10:33:56 +0000 Subject: [PATCH] [Fixes #961 & #1011] Show an error if dataset as a ll_bbox_polygon is greater then the WGS84 max extent (#1031) --- geonode_mapstore_client/client/js/epics/gnresource.js | 6 +++++- geonode_mapstore_client/client/js/utils/ResourceUtils.js | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/geonode_mapstore_client/client/js/epics/gnresource.js b/geonode_mapstore_client/client/js/epics/gnresource.js index 5c4194c7f9..923a86055a 100644 --- a/geonode_mapstore_client/client/js/epics/gnresource.js +++ b/geonode_mapstore_client/client/js/epics/gnresource.js @@ -79,7 +79,8 @@ import { CLICK_ON_MAP, resizeMap } from '@mapstore/framework/actions/map'; import { saveError } from '@js/actions/gnsave'; import { error as errorNotification, - success as successNotification + success as successNotification, + warning as warningNotification } from '@mapstore/framework/actions/notifications'; import { getStyleProperties } from '@js/api/geonode/style'; @@ -161,6 +162,9 @@ const resourceTypes = { updateStatus('edit'), resizeMap() ] + : []), + ...(newLayer?.bboxError + ? [warningNotification({ title: "gnviewer.invalidBbox", message: "gnviewer.invalidBboxMsg" })] : []) ); }); diff --git a/geonode_mapstore_client/client/js/utils/ResourceUtils.js b/geonode_mapstore_client/client/js/utils/ResourceUtils.js index 142235738f..eada14b33f 100644 --- a/geonode_mapstore_client/client/js/utils/ResourceUtils.js +++ b/geonode_mapstore_client/client/js/utils/ResourceUtils.js @@ -33,6 +33,12 @@ function getExtentFromResource({ ll_bbox_polygon: llBboxPolygon }) { geometry: llBboxPolygon }); const [minx, miny, maxx, maxy] = extent; + + // if the extent is greater than the max extent of the WGS84 return null + const WGS84_MAX_EXTENT = [-180, -90, 180, 90]; + if (minx < WGS84_MAX_EXTENT[0] || miny < WGS84_MAX_EXTENT[1] || maxx > WGS84_MAX_EXTENT[2] || maxy > WGS84_MAX_EXTENT[3]) { + return null; + } const bbox = { crs: 'EPSG:4326', bounds: { minx, miny, maxx, maxy } @@ -138,7 +144,7 @@ export const resourceToLayerConfig = (resource) => { url: wfsUrl } }), - ...(bbox && { bbox }), + ...(bbox ? { bbox } : { bboxError: true }), ...(template && { featureInfo: { format: 'TEMPLATE',