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

#9139: Fix - New WFS layers no longer visible in dashboards #9230

Merged
merged 1 commit into from
Jun 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,36 @@ describe('handleMapZoomLayer enhancer', function() {
}));
ReactDOM.render(<Provider store={store}><Sink editorData={editorData} selectedNodes={selectedNodes} /></Provider>, document.getElementById("container"));
});
it('test zoom map and epsgSupported with boundingBox', (done) => {
const editorData = {
selectedMapId: 'MAP_ID',
maps: [{
mapId: 'MAP_ID',
size: {
width: 518,
height: 351
},
layers: [{
id: "layer.id1",
boundingBox: {
crs: 'EPSG:4326',
bounds: {
minx: -12,
miny: 24,
maxx: -66,
maxy: 49
}
}
}]
}]
};
const selectedNodes = ["layer.id1"];
const Sink = handleMapZoomLayer(createSink(props => {
props.zoomTo(selectedNodes);
expect(props.isEpsgSupported()).toBeTruthy();
done();
}));
ReactDOM.render(<Provider store={store}><Sink editorData={editorData} selectedNodes={selectedNodes} /></Provider>, document.getElementById("container"));
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 { addSearchObservable } from '../layerSelector';


describe('layerSelector enhancer', function() {

it('test addSearchObservable with addSearch', () => {
expect(addSearchObservable({
type: "wms",
name: "test-layer"
}, {
type: "wms"
}).value).toBeFalsy();
});
it('test addSearchObservable skip addSearch', () => {
expect(addSearchObservable({
type: "wfs",
name: "test-layer"
}, {
type: "wfs"
}).value).toBeTruthy();
});

});

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const toBoundsArray = extent => {
}
return null;
};
const getBbox = l => l.bbox || l.boundingBox;
const getLayersBbox = (layers) => {
return layers?.filter(getBbox).map(getBbox) ?? [];
};

const enhancer = compose(
connect(() => ({}), {
Expand All @@ -54,7 +58,7 @@ const enhancer = compose(
isEpsgSupported: ({ editorData = {}, selectedNodes = [] }) => () => {
const layers = editorData.maps?.find(m => m.mapId === editorData.selectedMapId)?.layers || [];
const selectedLayers = selectedNodes.map(nodeId => layers.find(layer => layer.id === nodeId)).filter(l => l);
const layersBbox = selectedLayers.filter(l => l.bbox).map(l => l.bbox);
const layersBbox = getLayersBbox(selectedLayers);
const uniqueCRS = layersBbox.length > 0 ? layersBbox.reduce((a, b) => a.crs === b.crs ? a : { crs: 'differentCRS' }) : { crs: 'differentCRS' };
const currentEPSG = !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS' && uniqueCRS.crs;
return currentEPSG && Proj4js.defs(currentEPSG);
Expand All @@ -63,7 +67,7 @@ const enhancer = compose(
const map = editorData.maps?.find(m => m.mapId === editorData.selectedMapId) || {};
const layers = map.layers || [];
const selectedLayers = selectedNodes.map(nodeId => layers.find(layer => layer.id === nodeId)).filter(l => l);
const layersBbox = selectedLayers.filter(l => l.bbox).map(l => l.bbox);
const layersBbox = getLayersBbox(selectedLayers);
const bbox = layersBbox.length > 1 ? layersBbox.reduce((a, b) => {
return {
bounds: {
Expand Down
4 changes: 2 additions & 2 deletions web/client/plugins/widgetbuilder/enhancers/layerSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const toLayer = (r, service) => ["tms", "wfs"].includes(service?.type) //
// the type wms is default (for csw and wms), wmts have to be passed. // TODO: improve and centralize more
: API[service?.type || 'wms'].getLayerFromRecord(r, { service });

// checks for tms wmts in order to addSearch() to skip addSearch
export const addSearchObservable = (selected, service) => ["tms", "wmts"].includes(service?.type) ? Rx.Observable.of(toLayer(selected, service)) : addSearch(toLayer(selected, service));
// checks for tms, wmts & wfs, in order to skip addSearch
export const addSearchObservable = (selected, service) => ["tms", "wmts", "wfs"].includes(service?.type) ? Rx.Observable.of(toLayer(selected, service)) : addSearch(toLayer(selected, service));

/**
* enhancer for CompactCatalog (or a container) to validate a selected record,
Expand Down