From 55d13a59ab942947d2d1a1d72e1914ba2881cb1b Mon Sep 17 00:00:00 2001 From: DavidQuartz Date: Mon, 30 May 2022 13:24:33 +0000 Subject: [PATCH 1/2] handling invalid bbox --- geonode_mapstore_client/client/js/epics/gnresource.js | 6 ++++-- geonode_mapstore_client/client/js/utils/ResourceUtils.js | 8 +++++++- .../client/static/mapstore/translations/data.de-DE.json | 4 +++- .../client/static/mapstore/translations/data.en-US.json | 4 +++- .../client/static/mapstore/translations/data.es-ES.json | 4 +++- .../client/static/mapstore/translations/data.fr-FR.json | 4 +++- .../client/static/mapstore/translations/data.it-IT.json | 4 +++- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/geonode_mapstore_client/client/js/epics/gnresource.js b/geonode_mapstore_client/client/js/epics/gnresource.js index 5c4194c7f9..6e0de9dcf9 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,7 +162,8 @@ 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', diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json b/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json index 5d79d7ea43..769ac44799 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json @@ -278,7 +278,9 @@ "cancelUpload": "Hochladen abbrechen", "parallelUploadLimit": "Die ausgewählte Anzahl von Dateien überschreitet das zulässige Limit von {limit} Dateien. Bitte entfernen Sie einige Dateien aus der Liste.", "parallelLimitError": "Die Anzahl aktiver paralleler Uploads überschreitet {limit}. Warten Sie, bis die ausstehenden abgeschlossen sind.", - "thisPage": "Diese Seite" + "thisPage": "Diese Seite", + "invalidBbox": "Ungültige Datensatzerweiterung", + "invalidBboxMsg": "Die Datensatzerweiterung überschreitet die maximale WGS84-Ausdehnung [-180, -90, 180, 90]" } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json b/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json index e2a475dad6..2c23136487 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json @@ -278,7 +278,9 @@ "cancelUpload": "Cancel upload", "parallelUploadLimit": "The selected number of files exceeds the allowed limit of {limit} files. Please remove some files from the list.", "parallelLimitError": "The number of active parallel uploads exceeds {limit}. Wait for the pending ones to finish.", - "thisPage": "This page" + "thisPage": "This page", + "invalidBbox": "Invalid dataset extension", + "invalidBboxMsg": "The dataset extension exceed the WGS84 maximum extent [-180, -90, 180, 90]" } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json b/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json index c91b87693e..418100a009 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json @@ -277,7 +277,9 @@ "cancelUpload": "Cancelar carga", "parallelUploadLimit": "El número de archivos seleccionado supera el límite permitido de {limit} archivos. Elimine algunos archivos de la lista.", "parallelLimitError": "El número de subidas paralelas activas supera {limit}. Espera a que terminen las pendientes.", - "thisPage": "Esta página" + "thisPage": "Esta página", + "invalidBbox": "Extensión de conjunto de datos no válida", + "invalidBboxMsg": "La extensión del conjunto de datos supera la extensión máxima de WGS84 [-180, -90, 180, 90]" } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json b/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json index adcb47eddf..fa9969c458 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json @@ -278,7 +278,9 @@ "cancelUpload": "Annuler le téléchargement", "parallelUploadLimit": "Le nombre de fichiers sélectionné dépasse la limite autorisée de {limit} fichiers. Veuillez supprimer certains fichiers de la liste.", "parallelLimitError": "Le nombre de téléchargements parallèles actifs dépasse {limit}. Attendez que ceux en attente se terminent.", - "thisPage": "Cette page" + "thisPage": "Cette page", + "invalidBbox": "Extension d'ensemble de données non valide", + "invalidBboxMsg": "L'extension du jeu de données dépasse l'étendue maximale du WGS84 [-180, -90, 180, 90]" } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json b/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json index 339d2ccd87..00ed92652d 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json @@ -280,7 +280,9 @@ "cancelUpload": "Annulla caricamento", "parallelUploadLimit": "Il numero selezionato di file supera il limite consentito di {limit} file. Si prega di rimuovere alcuni file dall'elenco.", "parallelLimitError": "Il numero di caricamenti paralleli attivi supera {limit}. Aspetta che quelli in sospeso finiscano.", - "thisPage": "Questa pagina" + "thisPage": "Questa pagina", + "invalidBbox": "Estensione del dataset non valida", + "invalidBboxMsg": "L'estensione del dataset è maggiore del'estensione massima supportata della proiezione WGS84 [-180, -90, 180, 90]" } } } From 2f5b98879e4d2c3e43af834484a779725aa707e7 Mon Sep 17 00:00:00 2001 From: DavidQuartz Date: Mon, 6 Jun 2022 10:04:33 +0000 Subject: [PATCH 2/2] find undefined rx bug --- geonode_mapstore_client/client/js/epics/gnresource.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/geonode_mapstore_client/client/js/epics/gnresource.js b/geonode_mapstore_client/client/js/epics/gnresource.js index 6e0de9dcf9..923a86055a 100644 --- a/geonode_mapstore_client/client/js/epics/gnresource.js +++ b/geonode_mapstore_client/client/js/epics/gnresource.js @@ -163,7 +163,9 @@ const resourceTypes = { resizeMap() ] : []), - newLayer?.bboxError && warningNotification({ title: "gnviewer.invalidBbox", message: "gnviewer.invalidBboxMsg" }) + ...(newLayer?.bboxError + ? [warningNotification({ title: "gnviewer.invalidBbox", message: "gnviewer.invalidBboxMsg" })] + : []) ); }); }