diff --git a/web/client/actions/__tests__/geoProcessing-test.js b/web/client/actions/__tests__/geoProcessing-test.js index cde8b35cde..2c25e213c8 100644 --- a/web/client/actions/__tests__/geoProcessing-test.js +++ b/web/client/actions/__tests__/geoProcessing-test.js @@ -164,14 +164,16 @@ describe('Test Geo Processing Tools related actions', () => { const source = ""; const data = {}; const nextPage = 2; + const geometryProperty = {}; - const action = setFeatures(layerId, source, data, nextPage); + const action = setFeatures(layerId, source, data, nextPage, geometryProperty); expect(action).toEqual({ type: SET_FEATURES, layerId, source, data, - nextPage + nextPage, + geometryProperty }); }); it('setFeatureSourceLoading', () => { diff --git a/web/client/actions/geoProcessing.js b/web/client/actions/geoProcessing.js index e54541be34..33c3c2e865 100644 --- a/web/client/actions/geoProcessing.js +++ b/web/client/actions/geoProcessing.js @@ -197,12 +197,13 @@ export const setBufferCapStyle = (capStyle) => ({ * @param {string} source can be "source" or "intersection" * @param {object[]|object} data list of features or error */ -export const setFeatures = (layerId, source, data, nextPage) => ({ +export const setFeatures = (layerId, source, data, nextPage, geometryProperty) => ({ type: SET_FEATURES, layerId, source, data, - nextPage + nextPage, + geometryProperty }); /** * action for the loading flag of the features diff --git a/web/client/epics/geoProcessing.js b/web/client/epics/geoProcessing.js index db0e69f5a2..1627ba6d6c 100644 --- a/web/client/epics/geoProcessing.js +++ b/web/client/epics/geoProcessing.js @@ -133,7 +133,7 @@ import {buildIdentifyRequest} from "../utils/MapInfoUtils"; import {logError} from "../utils/DebugUtils"; import {getFeatureInfo} from "../api/identify"; import {getFeatureSimple} from '../api/WFS'; -import {findNonGeometryProperty} from '../utils/ogc/WFS/base'; +import {findNonGeometryProperty, findGeometryProperty} from '../utils/ogc/WFS/base'; import toWKT from '../utils/ogc/WKT/toWKT'; const OFFSET = 550; @@ -261,6 +261,7 @@ export const getFeaturesGPTEpic = (action$, store) => action$ startIndex: page * maxFeatures, maxFeatures }; + const geometryProperty = findGeometryProperty(layer.describeFeatureType); return Rx.Observable.merge( getLayerJSONFeature({ ...layer, @@ -270,11 +271,11 @@ export const getFeaturesGPTEpic = (action$, store) => action$ url: layer.url } }, filterObj, options) - .map(data => setFeatures(layerId, source, data, page)) + .map(data => setFeatures(layerId, source, data, page, geometryProperty)) .catch(e => { logError(e); return Rx.Observable.of( - setFeatures(layerId, source, e, page), + setFeatures(layerId, source, e, page, geometryProperty), showErrorNotification({ title: "errorTitleDefault", message: "GeoProcessing.notifications.errorGettingFeaturesList", @@ -631,9 +632,9 @@ export const runIntersectProcessGPTEpic = (action$, store) => action$ } return Rx.Observable.forkJoin(sourceFC$, intersectionFC$) .switchMap(([firstGeom, secondGeom]) => { - if (firstGeom.error) { + if (firstGeom?.error || secondGeom?.error) { const errorActions = []; - if (firstGeom.error.message.includes("Failed to retrieve value for input features")) { + if (firstGeom?.error?.message?.includes("Failed to retrieve value for input features")) { logError(firstGeom.error); errorActions.push(showErrorNotification({ title: "errorTitleDefault", @@ -643,7 +644,7 @@ export const runIntersectProcessGPTEpic = (action$, store) => action$ values: {layerName: firstGeom.layerName + " - " + firstGeom.layerTitle} })); } - if (secondGeom.error.message.includes("Failed to retrieve value for input features")) { + if (secondGeom?.error?.message?.includes("Failed to retrieve value for input features")) { logError(secondGeom.error); errorActions.push(showErrorNotification({ title: "errorTitleDefault", @@ -655,7 +656,7 @@ export const runIntersectProcessGPTEpic = (action$, store) => action$ } errorActions.push(showErrorNotification({ title: "errorTitleDefault", - message: "GeoProcessing.notifications.errorBuffer", + message: "GeoProcessing.notifications.errorIntersectGFI", autoDismiss: 6, position: "tc" })); diff --git a/web/client/plugins/GeoProcessing/processes.js b/web/client/plugins/GeoProcessing/processes.js index 9b7feb7edc..918e02b5ec 100644 --- a/web/client/plugins/GeoProcessing/processes.js +++ b/web/client/plugins/GeoProcessing/processes.js @@ -115,10 +115,11 @@ export const processes = [ {props.runningProcess ? : null} ); diff --git a/web/client/reducers/__tests__/geoProcessing-test.js b/web/client/reducers/__tests__/geoProcessing-test.js index f84fc834a3..6610160011 100644 --- a/web/client/reducers/__tests__/geoProcessing-test.js +++ b/web/client/reducers/__tests__/geoProcessing-test.js @@ -288,7 +288,6 @@ describe('Test Geo Processing Tools reducer', () => { }, action); expect(state.source.feature).toEqual(feature); expect(state.source.features).toEqual([feature]); - expect(state.flags.isIntersectionEnabled).toEqual(true); }); it('SET_INTERSECTION_LAYER_ID', () => { const layerId = "id"; diff --git a/web/client/reducers/geoProcessing.js b/web/client/reducers/geoProcessing.js index d2254da865..b98623be84 100644 --- a/web/client/reducers/geoProcessing.js +++ b/web/client/reducers/geoProcessing.js @@ -46,7 +46,6 @@ import { RESET_CONTROLS } from '../actions/controls'; import { LOCATION_CHANGE } from 'connected-react-router'; -import { checkIfIntersectionIsPossible } from '../utils/GeoProcessingUtils'; /** * reducer for GeoProcessing @@ -208,6 +207,10 @@ function geoProcessing( state = { features: (state[action.source].features || []).concat(action.data.features || []), totalCount: action.data.totalFeatures, currentPage: action.nextPage + }, + flags: { + ...state.flags, + isIntersectionEnabled: action.source === "source" ? !action.geometryProperty?.type?.includes("Point") : state.flags.isIntersectionEnabled } } : { ...state, @@ -308,10 +311,6 @@ function geoProcessing( state = { ...state.source, feature: action.feature, features: find(state.source.features, ft => ft.id === action.feature.id) ? state.source.features : [action.feature] - }, - flags: { - ...state.flags, - isIntersectionEnabled: checkIfIntersectionIsPossible(action?.feature, state?.intersection?.feature) } }; } @@ -350,10 +349,6 @@ function geoProcessing( state = { ...state.intersection, feature: action.feature, features: find(state.intersection.features, ft => ft.id === action.feature.id) ? state.intersection.features : [action.feature] - }, - flags: { - ...state.flags, - isIntersectionEnabled: checkIfIntersectionIsPossible(state?.source?.feature, action?.feature) } }; } diff --git a/web/client/translations/data.de-DE.json b/web/client/translations/data.de-DE.json index 2155d76f0b..6a7adb3bf2 100644 --- a/web/client/translations/data.de-DE.json +++ b/web/client/translations/data.de-DE.json @@ -3991,6 +3991,7 @@ "invalidLayers": "Eine der von Ihnen ausgewählten Ebenen kann in diesem Prozess nicht verwendet werden", "fillRequiredDataIntersection": "Bitte wählen Sie mindestens den Quell-Layer und den Schnittpunkt-Layer aus", "fillRequiredDataBuffer": "Bitte wählen Sie mindestens die Quellebene aus", + "pointAndPolygon": "Sie können einen Punkt nur als Schnittpunkt-Feature auswählen, während der Quell-Layer ein Polygon-Layer ist", "siderBarBtn": "Geoverarbeitung", "selectFeature": "Bitte wählen Sie eine Funktion aus", "validFeature": "Diese Funktion ist gültig", diff --git a/web/client/translations/data.en-US.json b/web/client/translations/data.en-US.json index 2a5f332d45..f0494e3508 100644 --- a/web/client/translations/data.en-US.json +++ b/web/client/translations/data.en-US.json @@ -3965,6 +3965,7 @@ "invalidLayers": "One of the layers you have selected cannot be used within this process", "fillRequiredDataIntersection": "Please select at least the source layer and the intersection layer", "fillRequiredDataBuffer": "Please select at least the source layer", + "pointAndPolygon": "You can select a point only as an intersection feature, while the source layer must be a polygon layer", "siderBarBtn": "GeoProcessing", "selectFeature": "Please select a feature", "validFeature": "This feature is valid", diff --git a/web/client/translations/data.es-ES.json b/web/client/translations/data.es-ES.json index 5acf75b543..ad42affca3 100644 --- a/web/client/translations/data.es-ES.json +++ b/web/client/translations/data.es-ES.json @@ -3954,6 +3954,7 @@ "invalidLayers": "Una de las capas que ha seleccionado no se puede utilizar dentro de este proceso", "fillRequiredDataIntersection": "Seleccione al menos la capa de origen y la capa de intersección", "fillRequiredDataBuffer": "Seleccione al menos la capa de origen", + "pointAndPolygon": "Puede seleccionar un punto solo como una entidad de intersección, mientras que la capa de origen es una capa de polígono.", "siderBarBtn": "Geoprocesamiento", "selectFeature": "Seleccione una función", "validFeature": "Esta función es válida", diff --git a/web/client/translations/data.fr-FR.json b/web/client/translations/data.fr-FR.json index b1a8c52037..58f87181d4 100644 --- a/web/client/translations/data.fr-FR.json +++ b/web/client/translations/data.fr-FR.json @@ -3954,6 +3954,7 @@ "invalidLayers": "L'un des calques que vous avez sélectionnés ne peut pas être utilisé dans ce processus", "fillRequiredDataIntersection": "Veuillez sélectionner au moins la couche source et la couche d'intersection", "fillRequiredDataBuffer": "Veuillez sélectionner au moins la couche source", + "pointAndPolygon": "Vous pouvez sélectionner un point uniquement en tant qu'entité d'intersection, tandis que la couche source est une couche de polygones.", "siderBarBtn": "Géotraitement", "selectFeature": "Veuillez sélectionner une fonctionnalité", "validFeature": "Cette fonctionnalité est valide", diff --git a/web/client/translations/data.it-IT.json b/web/client/translations/data.it-IT.json index 3b288287e3..8d71310f7a 100644 --- a/web/client/translations/data.it-IT.json +++ b/web/client/translations/data.it-IT.json @@ -3954,6 +3954,7 @@ "invalidLayers": "Uno dei livelli che hai selezionato non può essere utilizzato all'interno di questo processo", "fillRequiredDataIntersection": "Seleziona almeno il livello di origine e il livello di intersezione", "fillRequiredDataBuffer": "Seleziona almeno il livello di origine", + "pointAndPolygon": "Puoi selezionare un punto solo come feature di intersezion, mentre il livello sorgente è un livello poligonale", "siderBarBtn": "Strumenti di geoelaborazione", "selectFeature": "Seleziona una funzione", "validFeature": "Questa feature è valida", diff --git a/web/client/utils/GeoProcessingUtils.js b/web/client/utils/GeoProcessingUtils.js deleted file mode 100644 index 32407a7a21..0000000000 --- a/web/client/utils/GeoProcessingUtils.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2023, GeoSolutions Sas. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -/** - * check if intersection is possible between two features - * @param {object} sourceFeature the geojson feature - * @param {object} intersectionFeature the geojson feature - * @returns {string} the converted string in wkt - */ -export const checkIfIntersectionIsPossible = (sourceFeature = {}, intersectionFeature = {}) => { - - if ( - sourceFeature?.geometry?.type.includes("Point") || - intersectionFeature?.geometry?.type.includes("Point") - ) { - return (sourceFeature?.geometry?.type.includes("Point") && intersectionFeature?.geometry?.type.includes("Polygon")) || - (intersectionFeature?.geometry?.type.includes("Point") && sourceFeature?.geometry?.type.includes("Polygon") ); - } - return true; -}; diff --git a/web/client/utils/__tests__/GeoProcessingUtils-test.js b/web/client/utils/__tests__/GeoProcessingUtils-test.js deleted file mode 100644 index 41ae87d656..0000000000 --- a/web/client/utils/__tests__/GeoProcessingUtils-test.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2023, GeoSolutions Sas. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ -import expect from 'expect'; - -import { - checkIfIntersectionIsPossible -} from '../GeoProcessingUtils'; - - -describe('GeoProcessingUtils', () => { - const pointFT = { - type: "Feature", - geometry: { - coordinates: [1, 2], - type: "Point" - } - }; - const polygonFT = { - type: "Feature", - geometry: { - type: "Polygon" - } - }; - const lineStringFT = { - type: "Feature", - geometry: { - type: "LineString" - } - }; - describe('checkIfIntersectionIsPossible', () => { - - it('successful result', () => { - let result = checkIfIntersectionIsPossible(polygonFT, pointFT); - expect(result).toBeTruthy(); - result = checkIfIntersectionIsPossible(polygonFT, lineStringFT); - expect(result).toBeTruthy(); - result = checkIfIntersectionIsPossible(polygonFT, polygonFT); - expect(result).toBeTruthy(); - result = checkIfIntersectionIsPossible(lineStringFT, lineStringFT); - expect(result).toBeTruthy(); - }); - it(' failing result', () => { - let result = checkIfIntersectionIsPossible(lineStringFT, pointFT); - expect(result).toBeFalsy(); - result = checkIfIntersectionIsPossible(pointFT, pointFT); - expect(result).toBeFalsy(); - }); - }); - -});