Skip to content

Commit da249a5

Browse files
#11162: Improve MS actions to automatically zoom to filtered features (#11163)
* #11162: Improve MS actions to automatically zoom to filtered features - enhance zooming functionality if the queried layers is just one by auto zooming - automate that zoom process without the need to include any coordinates - add unit tests * resolve review comments: - handle when no center, marker, bbox or zoom are provided as query params the zoom to feature bbox must not be used - add unit tests - add jsdocs * resolve FE test failure in QueryParamsUtils
1 parent 6a77a98 commit da249a5

10 files changed

Lines changed: 556 additions & 30 deletions

File tree

web/client/actions/__tests__/mapInfo-test.js

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ import {
4242
checkIdentifyIsMounted,
4343
IDENTIFY_IS_MOUNTED,
4444
onInitPlugin,
45-
INIT_PLUGIN
45+
INIT_PLUGIN,
46+
loadFeatureInfo,
47+
LOAD_FEATURE_INFO
4648
} from '../mapInfo';
4749

4850
describe('Test correctness of the map actions', () => {
@@ -126,6 +128,84 @@ describe('Test correctness of the map actions', () => {
126128
expect(action.itemId).toBe(itemId);
127129
expect(action.ignoreVisibilityLimits).toBe(ignoreVisibilityLimits);
128130
});
131+
it('test featureInfoClick with filterNameList, overrideParams, ignoreVisibilityLimits flag [search service case] and bbox of feature', () => {
132+
const point = {latlng: {lat: 1, lng: 3}};
133+
const layer = {id: "layer.1"};
134+
const filterNameList = [];
135+
const itemId = "itemId";
136+
const overrideParams = {cql_filter: "ID_ORIG=1234"};
137+
const ignoreVisibilityLimits = true;
138+
139+
const action = featureInfoClick(point, layer, filterNameList, overrideParams, itemId, ignoreVisibilityLimits, [1, 2, 3, 4]);
140+
expect(action).toExist();
141+
expect(action.type).toBe(FEATURE_INFO_CLICK);
142+
expect(action.point).toBe(point);
143+
expect(action.layer).toBe(layer);
144+
expect(action.filterNameList).toBe(filterNameList);
145+
expect(action.overrideParams).toBe(overrideParams);
146+
expect(action.itemId).toBe(itemId);
147+
expect(action.ignoreVisibilityLimits).toBe(ignoreVisibilityLimits);
148+
expect(action.bbox).toEqual([1, 2, 3, 4]);
149+
});
150+
it('test featureInfoClick with filterNameList, overrideParams, ignoreVisibilityLimits flag [search service case], bbox of feature and queryParamZoomOption', () => {
151+
const point = {latlng: {lat: 1, lng: 3}};
152+
const layer = {id: "layer.1"};
153+
const filterNameList = [];
154+
const itemId = "itemId";
155+
const overrideParams = {cql_filter: "ID_ORIG=1234"};
156+
const ignoreVisibilityLimits = true;
157+
const queryParamZoomOption = {
158+
overrideZoomLvl: 5,
159+
isCoordsProvided: false
160+
};
161+
const action = featureInfoClick(point, layer, filterNameList, overrideParams, itemId, ignoreVisibilityLimits, [1, 2, 3, 4], queryParamZoomOption);
162+
expect(action).toExist();
163+
expect(action.type).toBe(FEATURE_INFO_CLICK);
164+
expect(action.point).toBe(point);
165+
expect(action.layer).toBe(layer);
166+
expect(action.filterNameList).toBe(filterNameList);
167+
expect(action.overrideParams).toBe(overrideParams);
168+
expect(action.itemId).toBe(itemId);
169+
expect(action.ignoreVisibilityLimits).toBe(ignoreVisibilityLimits);
170+
expect(action.bbox).toEqual([1, 2, 3, 4]);
171+
expect(action.queryParamZoomOption).toEqual(queryParamZoomOption);
172+
});
173+
it('test loadFeatureInfo default', () => {
174+
const reqId = "123";
175+
const data = {id: "layer.1"};
176+
const rParams = {cql_filter: "ID_ORIG=1234"};
177+
const lMetaData = {features: [], featuresCrs: "EPSG:4326"};
178+
const layer = {name: "layer01"};
179+
const action = loadFeatureInfo(reqId, data, rParams, lMetaData, layer);
180+
expect(action).toExist();
181+
expect(action.type).toEqual(LOAD_FEATURE_INFO);
182+
expect(action.data).toEqual(data);
183+
expect(action.reqId).toEqual(reqId);
184+
expect(action.requestParams).toEqual(rParams);
185+
expect(action.layerMetadata).toEqual(lMetaData);
186+
expect(action.layer).toEqual(layer);
187+
expect(action.queryParamZoomOption).toEqual(null);
188+
});
189+
it('test loadFeatureInfo with queryParamZoomOption', () => {
190+
const reqId = "123";
191+
const data = {id: "layer.1"};
192+
const rParams = {cql_filter: "ID_ORIG=1234"};
193+
const lMetaData = {features: [], featuresCrs: "EPSG:4326"};
194+
const layer = {name: "layer01"};
195+
const queryParamZoomOption = {
196+
overrideZoomLvl: 5,
197+
isCoordsProvided: false
198+
};
199+
const action = loadFeatureInfo(reqId, data, rParams, lMetaData, layer, queryParamZoomOption);
200+
expect(action).toExist();
201+
expect(action.type).toEqual(LOAD_FEATURE_INFO);
202+
expect(action.data).toEqual(data);
203+
expect(action.reqId).toEqual(reqId);
204+
expect(action.requestParams).toEqual(rParams);
205+
expect(action.layerMetadata).toEqual(lMetaData);
206+
expect(action.layer).toEqual(layer);
207+
expect(action.queryParamZoomOption).toEqual(queryParamZoomOption);
208+
});
129209
it('reset reverse geocode data', () => {
130210
const e = hideMapinfoRevGeocode();
131211
expect(e).toExist();

web/client/actions/__tests__/search-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,16 @@ describe('Test correctness of the search actions', () => {
149149
expect(retval.layer).toBe('layer1');
150150
expect(retval.cql_filter).toBe("mm='nn'");
151151
});
152+
it('scheduleSearchLayerWithFilter with queryParamZoomOption', () => {
153+
const queryParamZoomOption = {
154+
overrideZoomLvl: 5,
155+
isCoordsProvided: false
156+
};
157+
const retval = scheduleSearchLayerWithFilter({ layer: 'layer1', cql_filter: "mm='nn'", queryParamZoomOption});
158+
expect(retval).toExist();
159+
expect(retval.type).toEqual(SCHEDULE_SEARCH_LAYER_WITH_FILTER);
160+
expect(retval.layer).toEqual('layer1');
161+
expect(retval.cql_filter).toEqual("mm='nn'");
162+
expect(retval.queryParamZoomOption).toEqual(queryParamZoomOption);
163+
});
152164
});

web/client/actions/mapInfo.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ export const toggleEmptyMessageGFI = () => ({type: TOGGLE_EMPTY_MESSAGE_GFI});
4545
* Private
4646
* @return a LOAD_FEATURE_INFO action with the response data to a wms GetFeatureInfo
4747
*/
48-
export function loadFeatureInfo(reqId, data, rParams, lMetaData, layer) {
48+
export function loadFeatureInfo(reqId, data, rParams, lMetaData, layer, queryParamZoomOption = null) {
4949
return {
5050
type: LOAD_FEATURE_INFO,
5151
data: data,
5252
reqId: reqId,
5353
requestParams: rParams,
5454
layerMetadata: lMetaData,
55-
layer
55+
layer,
56+
queryParamZoomOption
5657
};
5758
}
5859

@@ -195,16 +196,22 @@ export function updateCenterToMarker(status) {
195196
* @param {object} [overrideParams={}] a map based on name as key and objec as value for overriding request params
196197
* @param {string} [itemId=null] id of the item needed for filtering results
197198
* @param {string} [ignoreVisibilityLimits=false] a boolean flag for ignoring layer visibility limits restrictions to apply GFI
199+
* @param {number[]} [bbox=[]] bbox of the identified fearure in the form of [minx, miny, maxx, maxy]
200+
* @param {object} queryParamZoomOption the override zoom option
201+
* @param {number} queryParamZoomOption.overrideZoomLvl the override zoom level value if exist to make map zoom within this value
202+
* @param {boolean} queryParamZoomOption.isCoordsProvided a flag to skip zooming to identified feature to use map zoom level if center/marker or bbox provided
198203
*/
199-
export function featureInfoClick(point, layer, filterNameList = [], overrideParams = {}, itemId = null, ignoreVisibilityLimits = false) {
204+
export function featureInfoClick(point, layer, filterNameList = [], overrideParams = {}, itemId = null, ignoreVisibilityLimits = false, bbox = null, queryParamZoomOption = null) {
200205
return {
201206
type: FEATURE_INFO_CLICK,
202207
point,
203208
layer,
204209
filterNameList,
205210
overrideParams,
206211
itemId,
207-
ignoreVisibilityLimits
212+
ignoreVisibilityLimits,
213+
bbox,
214+
queryParamZoomOption
208215
};
209216
}
210217

web/client/actions/search.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ export function changeFormat(format) {
4545
* @prop {object} options {layer, cql_filter}
4646
* @prop {string} options.cql_filter optional filter to apply for both requests
4747
* @prop {string} options.layer name of the layer with workspace
48+
* @param {object} queryParamZoomOption the override zoom option
49+
* @param {number} queryParamZoomOption.overrideZoomLvl the override zoom level value if exist to make map zoom within this value
50+
* @param {boolean} queryParamZoomOption.isCoordsProvided a flag to skip zooming to identified feature to use map zoom level if center/marker or bbox provided
4851
*/
4952
// eslint-disable-next-line camelcase
50-
export function searchLayerWithFilter({layer, cql_filter} = {}) {
53+
export function searchLayerWithFilter({layer, cql_filter, queryParamZoomOption = null} = {}) {
5154
return {
5255
type: SEARCH_LAYER_WITH_FILTER,
5356
layer,
54-
cql_filter: cql_filter
57+
cql_filter: cql_filter,
58+
queryParamZoomOption
5559
};
5660
}
5761

@@ -63,13 +67,17 @@ export function searchLayerWithFilter({layer, cql_filter} = {}) {
6367
* @prop {object} options {layer, cql_filter}
6468
* @prop {string} options.cql_filter optional filter to apply for both requests
6569
* @prop {string} options.layer name of the layer with workspace
70+
* @param {object} queryParamZoomOption the override zoom option
71+
* @param {number} queryParamZoomOption.overrideZoomLvl the override zoom level value if exist to make map zoom within this value
72+
* @param {boolean} queryParamZoomOption.isCoordsProvided a flag to skip zooming to identified feature to use map zoom level if center/marker or bbox provided
6673
*/
6774
// eslint-disable-next-line camelcase
68-
export function scheduleSearchLayerWithFilter({layer, cql_filter} = {}) {
75+
export function scheduleSearchLayerWithFilter({layer, cql_filter, queryParamZoomOption = null} = {}) {
6976
return {
7077
type: SCHEDULE_SEARCH_LAYER_WITH_FILTER,
7178
layer,
72-
cql_filter: cql_filter
79+
cql_filter: cql_filter,
80+
queryParamZoomOption
7381
};
7482
}
7583

0 commit comments

Comments
 (0)