Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9685 measurements issues and added some enhancements to it #9809

Merged
merged 7 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions web/client/epics/__tests__/geoProcessing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ describe('geoProcessing epics', () => {
flat: [{
id: "id",
url: "mockUrl",
type: "wfs",
search: {
type: "wfs"
},
describeFeatureType: {

}
}]
}
Expand Down Expand Up @@ -197,7 +200,11 @@ describe('geoProcessing epics', () => {
layers: {
flat: [{
id: "id",
url: "mockUrl"
url: "mockUrl",
type: "wfs",
search: {
type: "wfs"
}
}]
}
});
Expand Down Expand Up @@ -225,7 +232,11 @@ describe('geoProcessing epics', () => {
layers: {
flat: [{
id: "id",
url: "mockUrl"
url: "mockUrl",
type: "wfs",
search: {
type: "wfs"
}
}]
}
});
Expand Down Expand Up @@ -253,7 +264,11 @@ describe('geoProcessing epics', () => {
layers: {
flat: [{
id: "id",
url: "mockUrl"
url: "mockUrl",
type: "wfs",
search: {
type: "wfs"
}
}]
}
});
Expand Down Expand Up @@ -315,7 +330,11 @@ describe('geoProcessing epics', () => {
flat: [{
id: "id",
url: "mockUrl",
describeFeatureType: DESCRIBE_POIS
describeFeatureType: DESCRIBE_POIS,
type: "wfs",
search: {
type: "wfs"
}
}]
}
});
Expand Down Expand Up @@ -343,7 +362,11 @@ describe('geoProcessing epics', () => {
flat: [{
id: "id",
url: "mockUrl",
describeFeatureType: DESCRIBE_POIS
describeFeatureType: DESCRIBE_POIS,
type: "wfs",
search: {
type: "wfs"
}
}]
}
});
Expand All @@ -366,7 +389,11 @@ describe('geoProcessing epics', () => {
layers: {
flat: [{
id: "id",
url: "mockUrl"
url: "mockUrl",
type: "wfs",
search: {
type: "wfs"
}
}]
}
});
Expand Down Expand Up @@ -457,7 +484,9 @@ describe('geoProcessing epics', () => {
id: "id",
url: "mockUrl",
name: "name",
type: "wfs",
search: {
type: "wfs",
url: "mockUrl"
}
}]
Expand Down Expand Up @@ -594,7 +623,9 @@ describe('geoProcessing epics', () => {
id: "id",
url: "mockUrl",
name: "name",
type: "wfs",
search: {
type: "wfs",
url: "mockUrl"
}
}]
Expand Down Expand Up @@ -674,7 +705,9 @@ describe('geoProcessing epics', () => {
id: "id",
url: "mockUrl",
name: "name",
type: "wfs",
search: {
type: "wfs",
url: "mockUrl"
}
}]
Expand Down Expand Up @@ -718,8 +751,10 @@ describe('geoProcessing epics', () => {
flat: [{
id: "id",
url: "mockUrl",
type: "wfs",
name: "name",
search: {
type: "wfs",
url: "mockUrl"
}
}]
Expand Down Expand Up @@ -1005,6 +1040,7 @@ describe('geoProcessing epics', () => {
name: "name",
type: "wms",
search: {
type: "wfs",
url: "mockUrl"
}
}]
Expand Down
28 changes: 20 additions & 8 deletions web/client/epics/geoProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
maxFeaturesSelector,
distanceSelector,
distanceUomSelector,
getLayerFromIdSelector,
isListeningClickSelector,
quadrantSegmentsSelector,
capStyleSelector,
Expand All @@ -115,9 +116,9 @@ import {
sourceFeatureSelector,
showHighlightLayersSelector,
wpsUrlSelector,
wfsBackedLayersSelector
availableLayersSelector
} from '../selectors/geoProcessing';
import {getLayerFromId as getLayerFromIdSelector, groupsSelector} from '../selectors/layers';
import {groupsSelector} from '../selectors/layers';
import {additionalLayersSelector} from '../selectors/additionallayers';
import {isGeoProcessingEnabledSelector} from '../selectors/controls';
import {mapSelector} from '../selectors/map';
Expand Down Expand Up @@ -354,7 +355,7 @@ export const getFeaturesGPTEpic = (action$, store) => action$
*/
export const getFeatureDataGPTEpic = (action$, store) => action$
.ofType(SET_SOURCE_FEATURE_ID)
.filter(a => a.featureId !== "")
.filter(a => a.featureId && a.featureId !== "")
.switchMap(({featureId}) => {
const state = store.getState();
const layerId = sourceLayerIdSelector(state);
Expand Down Expand Up @@ -467,7 +468,7 @@ export const runBufferProcessGPTEpic = (action$, store) => action$
const state = store.getState();
const layerId = sourceLayerIdSelector(state);
const layer = getLayerFromIdSelector(state, layerId);
const layers = wfsBackedLayersSelector(state);
const layers = availableLayersSelector(state);
const layerUrl = wpsUrlSelector(state) || head(castArray(layer.url));
const quadrantSegments = quadrantSegmentsSelector(state);
const capStyle = capStyleSelector(state);
Expand Down Expand Up @@ -670,7 +671,7 @@ export const runIntersectProcessGPTEpic = (action$, store) => action$
const state = store.getState();
const layerId = sourceLayerIdSelector(state);
const layer = getLayerFromIdSelector(state, layerId);
const layers = wfsBackedLayersSelector(state);
const layers = availableLayersSelector(state);
const layerUrl = wpsUrlSelector(state) || head(castArray(layer.url));
const sourceFeature = sourceFeatureSelector(state);
const executeOptions = {};
Expand Down Expand Up @@ -764,6 +765,16 @@ export const runIntersectProcessGPTEpic = (action$, store) => action$
const intersection$ = executeProcess$
.switchMap((featureCollection) => {
const groups = groupsSelector(state);
if (typeof featureCollection === "string") {
const msg = featureCollection.substring(featureCollection.indexOf("<ows:ExceptionText>") + "<ows:ExceptionText>".length, featureCollection.indexOf("</ows:ExceptionText>"));
console.error(featureCollection);
return Rx.Observable.of(showErrorNotification({
title: "errorTitleDefault",
message: msg,
autoDismiss: 6,
position: "tc"
}));
}
const defaultGroup = find(groups, ({id}) => id === "Default");
const groupExist = find(defaultGroup?.nodes || [], (g) => g.id === GPT_INTERSECTION_GROUP_ID) || find(groups, (g) => g.id === GPT_INTERSECTION_GROUP_ID);
let extent = getGeoJSONExtent(featureCollection);
Expand All @@ -786,8 +797,9 @@ export const runIntersectProcessGPTEpic = (action$, store) => action$
group: GPT_INTERSECTION_GROUP_ID,
title: "Intersection Layer " + counter,
visibility: true,
features: featureCollection.features.map(f => ({
features: featureCollection.features.map((f, i) => ({
...f,
id: "Feature #" + i,
properties: {
...f.properties,
geomType: getGeom(f.geometry.type)
Expand Down Expand Up @@ -953,9 +965,9 @@ export const clickToSelectFeatureGPTEpic = (action$, {getState}) =>
const basePath = url;
const param = {...request};
if (url) {
return getFeatureInfo(basePath, param, layer, {attachJSON: true})
return (url !== "client" ? getFeatureInfo(basePath, param, layer, {attachJSON: true}) : Rx.Observable.defer(() => Rx.Observable.of(
request?.features?.[0]?.properties?.features?.length ? request?.features?.[0]?.properties : request?.features?.length ? request : {features: []})))
.switchMap(({features}) => {

if (features?.length) {
return Rx.Observable.from([
updateFeature(features[0]),
Expand Down
2 changes: 1 addition & 1 deletion web/client/epics/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const toggleWidgetConnectFlow = (action$, {getState = () => {}} = {}) =>
if (widget.widgetType === 'map') {
deps = deps.filter(d => (WIDGETS_MAPS_REGEX.exec(d) || [])[2] === widget.selectedMapId);
}
return configureDependency(active, deps[0], options, widget.dependeciesMap).concat(Rx.Observable.of(toggleDependencySelector(false, {})));
return configureDependency(active, deps[0], options, widget.dependencesMap).concat(Rx.Observable.of(toggleDependencySelector(false, {})));
}).takeUntil(
action$.ofType(LOCATION_CHANGE)
.merge(action$.filter(({ type, key } = {}) => type === EDITOR_SETTING_CHANGE && key === DEPENDENCY_SELECTOR_KEY))
Expand Down
7 changes: 4 additions & 3 deletions web/client/plugins/GeoProcessing/IntersectionLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ import {
intersectionCurrentPageSelector,
isIntersectionFeaturesLoadingSelector,
selectedLayerTypeSelector,
wfsBackedLayersSelector
availableLayersSelector
} from '../../selectors/geoProcessing';
import { createFeatureId } from '../../utils/LayersUtils';

const Addon = tooltip(InputGroup.Addon);
const Intersection = ({
Expand Down Expand Up @@ -123,7 +124,7 @@ const Intersection = ({
value={intersectionFeatureId}
noResultsText={<Message msgId="GeoProcessing.noMatchedFeature" />}
onChange={handleOnChangeIntersectionFeatureId}
options={intersectionFeatures.map((f, i) => ({value: f.id ?? `id: ${f.id} Feature #${i}`, label: `id: ${f.id} Feature #${i}` }))}
options={intersectionFeatures.map((f, i) => ({value: createFeatureId(f).id, label: f?.properties?.measureType ? `${f?.properties?.measureType} #${i}` : createFeatureId(f).id }))}
onOpen={() => {
if (selectedLayerType !== "intersection" && intersectionFeatures.length === 0 ) {
onGetFeatures(intersectionLayerId, "intersection", 0);
Expand Down Expand Up @@ -193,7 +194,7 @@ const IntersectionConnected = connect(
createSelector(
[
areAllWPSAvailableForIntersectionLayerSelector,
wfsBackedLayersSelector,
availableLayersSelector,
isIntersectionFeaturesLoadingSelector,
intersectionLayerIdSelector,
intersectionFeatureIdSelector,
Expand Down
8 changes: 5 additions & 3 deletions web/client/plugins/GeoProcessing/SourceLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ import {
isSourceLayerInvalidSelector,
isSourceFeaturesLoadingSelector,
selectedLayerTypeSelector,
wfsBackedLayersSelector
availableLayersSelector
} from '../../selectors/geoProcessing';

import { createFeatureId } from '../../utils/LayersUtils';

const Addon = tooltip(InputGroup.Addon);

const Source = ({
Expand Down Expand Up @@ -121,7 +123,7 @@ const Source = ({
clearable
noResultsText={<Message msgId="GeoProcessing.noMatchedFeature" />}
onChange={handleOnChangeSourceFeatureId}
options={sourceFeatures.map((f, i) => ({value: f.id ?? `id: ${f.id} Feature #${i}`, label: `id: ${f.id} Feature #${i}` }))}
options={sourceFeatures.map((f, i) => ({value: createFeatureId(f).id, label: f?.properties?.measureType ? `${f?.properties?.measureType} #${i}` : createFeatureId(f).id }))}
value={sourceFeatureId}

onOpen={() => {
Expand Down Expand Up @@ -188,7 +190,7 @@ const SourceConnected = connect(
[
areAllWPSAvailableForSourceLayerSelector,
runningProcessSelector,
wfsBackedLayersSelector,
availableLayersSelector,
sourceLayerIdSelector,
sourceFeatureIdSelector,
sourceFeaturesSelector,
Expand Down
18 changes: 3 additions & 15 deletions web/client/reducers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { MAP_TYPE_CHANGED, VISUALIZATION_MODE_CHANGED } from '../actions/maptype
import assign from 'object-assign';
import ConfigUtils from '../utils/ConfigUtils';
import { set, unset } from '../utils/ImmutableUtils';
import { updateAnnotationsLayer } from '../plugins/Annotations/utils/AnnotationsUtils';
import { findIndex, castArray } from 'lodash';
import { normalizeLayer } from '../utils/LayersUtils';
import { castArray } from 'lodash';
import {
getVisualizationModeFromMapLibrary,
VisualizationModes
Expand All @@ -43,26 +43,14 @@ function mapConfig(state = null, action) {
// we get from the configuration what will be used as the initial state
let mapState = action.legacy && !hasVersion ? ConfigUtils.convertFromLegacy(action.config) : ConfigUtils.normalizeConfig(action.config.map);


// regenerate geodesic lines as property since that info has not been saved
let annotationsLayerIndex = findIndex(mapState.layers, layer => layer.id === "annotations");
if (annotationsLayerIndex !== -1) {
mapState.layers = mapState.layers.reduce((acc, layer, idx) => {
if (annotationsLayerIndex === idx) {
return [...acc, ...updateAnnotationsLayer(mapState.layers[annotationsLayerIndex])];
}
return [...acc, layer];
}, []);
}

let newMapState = {
...mapState,
layers: mapState.layers.map( l => {
if (l.group === "background" && (l.type === "ol" || l.type === "OpenLayers.Layer")) {
l.type = "empty";
}
return l;
}),
}).map(normalizeLayer),
mapConfigRawData: { ...action.config }
};
// if map is loaded from an already saved map keep the same id
Expand Down
5 changes: 3 additions & 2 deletions web/client/reducers/geoProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ function geoProcessing( state = {
};
}
case SET_FEATURES: {
// filtering out the features with measureId because they are not the measures, the LineString for length and bering or the Polygon for the area one. We do not want to do the buffer on the point where the measure text label is stored
return action.data.features ? {
...state,
[action.source]: {
...state[action.source],
features: (state[action.source].features || []).concat(action.data.features || []),
features: (state[action.source].features || []).concat(action.data.features || []).filter(f => !f?.properties?.measureId),
totalCount: action.data.totalFeatures,
currentPage: action.nextPage
},
Expand Down Expand Up @@ -287,7 +288,7 @@ function geoProcessing( state = {
source: {
...state.source,
feature: action.feature,
features: find(state.source.features, ft => ft.id === action.feature.id) ? state.source.features : [action.feature]
features: find(state.source.features, ft => ft?.id === action.feature?.id) ? state.source.features : [action.feature]
}
};
}
Expand Down
6 changes: 4 additions & 2 deletions web/client/reducers/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import {
sortLayers,
removeEmptyGroups,
getLayerId,
getGroupNodes
getGroupNodes,
normalizeLayer
} from '../utils/LayersUtils';

/**
Expand Down Expand Up @@ -343,9 +344,10 @@ function layers(state = { flat: [] }, action) {
return state;
}
case ADD_LAYER: {
const layer = normalizeLayer(action.layer);
let newLayers = (state.flat || []).concat();
let newGroups = (state.groups || []).concat();
const newLayer = (action.layer.id) ? action.layer : assign({}, action.layer, {id: getLayerId(action.layer)});
const newLayer = (layer.id) ? layer : assign({}, layer, {id: getLayerId(layer)});
newLayers.push(newLayer);
const groupId = newLayer.group || 'Default';
if (groupId !== "background") {
Expand Down
Loading
Loading