Skip to content

Commit

Permalink
geosolutions-it#8871 Improve getLegendGraphic compatibility for print
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Mar 7, 2024
1 parent 064d31c commit f979c8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions web/client/utils/PrintUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,13 @@ export const specCreators = {
SERVICE: "WMS",
REQUEST: "GetLegendGraphic",
LAYER: layer.name,
LANGUAGE: spec.language || '',
STYLE: layer.style || '',
SCALE: spec.scale,
...getLegendIconsSize(spec, layer),
LEGEND_OPTIONS: "forceLabels:" + (spec.forceLabels ? "on" : "") + ";fontAntialiasing:" + spec.antiAliasing + ";dpi:" + spec.legendDpi + ";fontStyle:" + (spec.bold && "bold" || (spec.italic && "italic") || '') + ";fontName:" + spec.fontFamily + ";fontSize:" + spec.fontSize,
format: "image/png",
...assign({}, layer.params)
...(spec.language ? {LANGUAGE: spec.language} : {}),
...layer?.params
})
})
]
Expand Down
11 changes: 11 additions & 0 deletions web/client/utils/__tests__/PrintUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,17 @@ describe('PrintUtils', () => {
const specs = getMapfishLayersSpecification([layer], { projection: "EPSG:3857" }, {}, 'legend');
expect(specs).toExist();
expect(specs.length).toBe(1);
expect(specs[0].classes.length).toBe(1);
// legendURL is a GetLegendGraphic request
expect(specs[0].classes[0].icons[0].indexOf('GetLegendGraphic') !== -1).toBe(true);
// LANGUAGE, if not included, should not be a parameter of the legend URL
expect(specs[0].classes[0].icons[0].indexOf('LANGUAGE')).toBe(-1);
const specs2 = getMapfishLayersSpecification([layer], { projection: "EPSG:3857", language: 'de' }, {}, 'legend');
expect(specs2).toExist();
expect(specs2.length).toBe(1);
expect(specs2[0].classes.length).toBe(1);
// LANGUAGE, if included, should be a parameter of the legend URL
expect(specs2[0].classes[0].icons[0].indexOf('LANGUAGE=de')).toBeGreaterThan(0);
});
it('toOpenLayers2Style for vector layer wich contains a FeatureCollection using the default style', () => {
const style = toOpenLayers2Style(vectorWithFtCollInside, null, "FeatureCollection");
Expand Down

0 comments on commit f979c8c

Please sign in to comment.