Skip to content

Commit

Permalink
Add support for LAYERFONTSIZE, ITEMFONTSIZE and `SHOWFEATURECOUNT…
Browse files Browse the repository at this point in the history
…` parameters (rif: `GetLegendGraphic`) (#709)

* 🐛 Get image only if legend tab is active

* 🐛 get legend parameter url boolen.
Add two param:
 - LAYERFONTSIZE,
 - ITEMFONTSIZE

* ✨ add showfeaturecount SHOWFEATURECOUNT

* Clean code space
  • Loading branch information
volterra79 authored Feb 4, 2025
1 parent f70e6a5 commit 6c7ae1d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
5 changes: 2 additions & 3 deletions src/components/Catalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<!-- ORIGINAL SOURCE: src/components/[email protected] -->
<!-- ORIGINAL SOURCE: src/components/[email protected] -->
<div
v-if = "'tab' === legend_position"
v-if = "'tab' === legend_position && 'legend' === activeTab"
v-for = "tree in state.layerstrees"
:key = "tree.id"
role = "tabpanel"
Expand Down Expand Up @@ -523,8 +523,7 @@ export default {
obj.loading = false;
}
}

return legendurls;
return legendurls;
},

/**
Expand Down
67 changes: 36 additions & 31 deletions src/map/layers/imagelayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { get_legend_params } from 'utils/get_legend_params';
* @returns { string | null } a string if value is set or null
*/
function __(name, value) {
return (value || 0 === value) ? `${name}${value}` : null;
return [null, undefined].includes(value) ? value : `${name}${value}`;
}

/**
Expand Down Expand Up @@ -823,7 +823,7 @@ class ImageLayer extends GeoLayerMixin(Layer) {
*
* @see https://docs.qgis.org/3.28/en/docs/server_manual/services/wms.html#getlegendgraphics
*/
getLegendUrl(params = {}, opts = {categories:false, all:false,format:'image/png',}) {
getLegendUrl(params = {}, opts = { categories:false, all:false,format:'image/png',}) {

let base_url, url_params;

Expand All @@ -845,7 +845,10 @@ class ImageLayer extends GeoLayerMixin(Layer) {
layerfontfamily,
layerfontbold,
itemfontbold,
itemfontsize, //@since 3.11.3
layerfontitalic,
layerfontsize, //@since 3.11.3
showfeaturecount, //@since 3.11.3
itemfontitalic,
rulelabel,
crs,
Expand Down Expand Up @@ -887,35 +890,37 @@ class ImageLayer extends GeoLayerMixin(Layer) {
'SERVICE=WMS',
'VERSION=1.3.0',
'REQUEST=GetLegendGraphic',
__('SLD_VERSION=', sld_version),
__('WIDTH=', width),
__('HEIGHT=', height),
__('FORMAT=', (undefined === opts.format ? 'image/png' : opts.format)),
__('TRANSPARENT=', transparent),
__('ITEMFONTCOLOR=', color),
__('LAYERFONTCOLOR=', color),
__('LAYERTITLE=', layertitle),
__('ITEMFONTSIZE=', fontsize),
__('CRS=', crs),
__('BBOX=', ([false, undefined].includes(opts.all) && bbox && bbox.join(','))),
__('BOXSPACE=', boxspace),
__('LAYERSPACE=', layerspace),
__('LAYERTITLESPACE=', layertitlespace),
__('SYMBOLSPACE=', symbolspace),
__('ICONLABELSPACE=', iconlabelspace),
__('SYMBOLWIDTH=', (opts.categories && 'application/json' === opts.format ? 16 : symbolwidth)),
__('SYMBOLHEIGHT=', (opts.categories && 'application/json' === opts.format ? 16 : symbolheight)),
__('LAYERFONTFAMILY=', layerfontfamily),
__('ITEMFONTFAMILY=', itemfontfamily),
__('LAYERFONTBOLD=', layerfontbold),
__('ITEMFONTBOLD=', itemfontbold),
__('LAYERFONTITALIC=', layerfontitalic),
__('ITEMFONTITALIC=', itemfontitalic),
__('RULELABEL=', rulelabel),
__('LEGEND_ON=', ctx_legend && ctx_legend.LEGEND_ON),
__('LEGEND_OFF=', ctx_legend && ctx_legend.LEGEND_OFF),
__('STYLES=', (opts.categories && 'application/json' === opts.format ? encodeURIComponent(this.getCurrentStyle().name) : undefined)),
__('LAYER=', this.getWMSLayerName({ type: 'legend' }))
__('SLD_VERSION=', sld_version),
__('WIDTH=', width),
__('HEIGHT=', height),
__('FORMAT=', (undefined === opts.format ? 'image/png' : opts.format)),
__('TRANSPARENT=', transparent),
__('ITEMFONTCOLOR=', color),
__('LAYERFONTCOLOR=', color),
__('LAYERTITLE=', layertitle),
__('ITEMFONTSIZE=', itemfontsize || fontsize), //@since 3.11.3 check itemfontsize or fontsize
__('CRS=', crs),
__('BBOX=', ((true === opts.all ? undefined : [false, undefined].includes(opts.all) && bbox && bbox.join(',')))),
__('BOXSPACE=', boxspace),
__('LAYERSPACE=', layerspace),
__('LAYERTITLESPACE=', layertitlespace),
__('SYMBOLSPACE=', symbolspace),
__('ICONLABELSPACE=', iconlabelspace),
__('SYMBOLWIDTH=', (opts.categories && 'application/json' === opts.format ? 16 : symbolwidth)),
__('SYMBOLHEIGHT=', (opts.categories && 'application/json' === opts.format ? 16 : symbolheight)),
__('LAYERFONTFAMILY=', layerfontfamily),
__('ITEMFONTFAMILY=', itemfontfamily),
__('LAYERFONTBOLD=', layerfontbold),
__('ITEMFONTBOLD=', itemfontbold),
__('LAYERFONTITALIC=', layerfontitalic),
__('LAYERFONTSIZE=', layerfontsize), //@since 3.11.3
__('SHOWFEATURECOUNT=', showfeaturecount), //@since 3.11.3
__('ITEMFONTITALIC=', itemfontitalic),
__('RULELABEL=', rulelabel),
__('LEGEND_ON=', ctx_legend && ctx_legend.LEGEND_ON),
__('LEGEND_OFF=', ctx_legend && ctx_legend.LEGEND_OFF),
__('STYLES=', (opts.categories && 'application/json' === opts.format ? encodeURIComponent(this.getCurrentStyle().name) : undefined)),
__('LAYER=', this.getWMSLayerName({ type: 'legend' }))
];
}

Expand Down

0 comments on commit 6c7ae1d

Please sign in to comment.