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 #4005 Print tool with vendor param (CQL_FILTER) #4006

Merged
merged 1 commit into from
Jul 25, 2019
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
11 changes: 9 additions & 2 deletions web/client/utils/PrintUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
const CoordinatesUtils = require('./CoordinatesUtils');
const SecurityUtils = require('./SecurityUtils');
const MapUtils = require('./MapUtils');
const {optionsToVendorParams} = require('./VendorParamsUtils');
const AnnotationsUtils = require("./AnnotationsUtils");
const {colorToHexStr} = require("./ColorUtils");

Expand Down Expand Up @@ -202,8 +203,14 @@ const PrintUtils = {
"TILED": true,
"EXCEPTIONS": "application/vnd.ogc.se_inimage",
"scaleMethod": "accurate"
}, layer.baseParams || {}, layer.params || {}))
}),
}, layer.baseParams || {}, layer.params || {}, {
...optionsToVendorParams({
nativeCrs: layer.nativeCrs,
layerFilter: layer.layerFilter,
filterObj: layer.filterObj
})
}
))}),
legend: (layer, spec) => ({
"name": layer.title || layer.name,
"classes": [
Expand Down
96 changes: 96 additions & 0 deletions web/client/utils/__tests__/PrintUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,71 @@ const layer = {
type: "wms",
params: {myparam: "myvalue"}
};

const layerSottoPasso = {
id: 'DBT:SOTTOPASSO__6',
type: 'wms',
url: 'http://localhost:8081/geoserver-test/wms',
nativeCrs: 'EPSG:3003'
};

const layerFilterSottoPasso = {
groupFields: [
{
id: 1,
logic: 'OR',
index: 0
}
],
filterFields: [
{
rowId: 1563970241851,
groupId: 1,
attribute: 'TIPO',
operator: '=',
value: 2,
type: 'number',
fieldOptions: {
valuesCount: 0,
currentPage: 1
},
exception: null
}
],
spatialField: {
method: null,
operation: 'INTERSECTS',
geometry: null,
attribute: 'GEOMETRY'
}
};
const filterObjSottoPasso = {
featureTypeName: 'DBT:SOTTOPASSO',
filterType: 'OGC',
ogcVersion: '1.1.0',
pagination: {
startIndex: 0,
maxFeatures: 20
},
groupFields: [
{
id: 1,
logic: 'AND',
index: 0
}
],
filterFields: [
{
attribute: 'ID_OGGETTO',
rowId: 1563970257711,
type: 'number',
groupId: 1,
operator: '<',
value: 44
}
]
};

const featurePoint = {
"type": "Feature",
"geometry": {
Expand Down Expand Up @@ -208,6 +273,37 @@ describe('PrintUtils', () => {
expect(specs[0].customParams.authkey).toExist();
expect(specs[0].customParams.authkey).toBe("mykey");
});
it('custom params include layerFilter and filterObj', () => {
const specs = PrintUtils.getMapfishLayersSpecification([{
...layerSottoPasso,
layerFilter: layerFilterSottoPasso,
filterObj: filterObjSottoPasso
}], {}, 'map');
expect(specs).toExist();
expect(specs.length).toBe(1);
expect(specs[0].customParams.CQL_FILTER).toExist();
expect(specs[0].customParams.CQL_FILTER).toBe(`(("TIPO" = '2')) AND (("ID_OGGETTO" < '44'))`);
});
it('custom params include cql_filter', () => {
const specs = PrintUtils.getMapfishLayersSpecification([{
...layerSottoPasso,
filterObj: filterObjSottoPasso
}], {}, 'map');
expect(specs).toExist();
expect(specs.length).toBe(1);
expect(specs[0].customParams.CQL_FILTER).toExist();
expect(specs[0].customParams.CQL_FILTER).toBe(`("ID_OGGETTO" < '44')`);
});
it('custom params include layerFilter', () => {
const specs = PrintUtils.getMapfishLayersSpecification([{
...layerSottoPasso,
layerFilter: layerFilterSottoPasso
}], {}, 'map');
expect(specs).toExist();
expect(specs.length).toBe(1);
expect(specs[0].customParams.CQL_FILTER).toExist();
expect(specs[0].customParams.CQL_FILTER).toBe(`("TIPO" = '2')`);
});
it('wms layer generation for legend includes scale', () => {
const specs = PrintUtils.getMapfishLayersSpecification([layer], testSpec, 'legend');
expect(specs).toExist();
Expand Down