/** * Get the print legend for MapFishPrint V3 from the OpenLayers map and the GMF Layertree. * * @hidden */ export default class LegendMapFishPrintV3 { /** * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper The ngeo Layer Helper service. * @param {import('gmf/datasource/ExternalDataSourcesManager').ExternalDatSourcesManager} gmfExternalDataSourcesManager The manager of external datasources. * @param {import('gmf/options').OptionsLegendType} legendOptions The options for the legend. * @param {import('ol/Map').default} map the map to extract the legend from. */ constructor(gettextCatalog: angular.gettext.gettextCatalog, ngeoLayerHelper: import("ngeo/map/LayerHelper").LayerHelper, gmfExternalDataSourcesManager: import("gmf/datasource/ExternalDataSourcesManager").ExternalDatSourcesManager, legendOptions: import("gmf/options").OptionsLegendType, map: import("ol/Map").default); /** * @type {angular.gettext.gettextCatalog} * @private */ private gettextCatalog_; /** * @type {import('ngeo/map/LayerHelper').LayerHelper} * @private */ private ngeoLayerHelper_; /** * @type {import('gmf/datasource/ExternalDataSourcesManager').ExternalDatSourcesManager} * @private */ private gmfExternalDataSourcesManager_; /** * @type {import('gmf/options').OptionsLegendType} * @private */ private gmfLegendOptions_; /** * @type {import('ol/Map').default} * @private */ private map_; /** * Return a legend for MapFishPrint V3 based on the map and the GMF layertree. * * @param {import('gmf/themes').GmfTheme[]} nodesThemes all the nodes of the themes object. * @param {number} scale The scale to get the legend (for wms layers only). * @param {number} dpi The DPI. * @param {number[]} bbox The bbox. * @returns {unknown?} Legend object for print report or null. */ getLegend(nodesThemes: import("gmf/themes").GmfTheme[], scale: number, dpi: number, bbox: number[]): unknown | null; /** * Get legend classes from the layertree only. * * @param {import('gmf/themes').GmfTheme[]} nodesThemes the current themes. * @param {number} scale The scale to get the legend. * @param {number} dpi The DPI. * @param {number[]} bbox The bbox. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass[]} Legend classes. * @private */ private getInternalLegendItems_; /** * Extract recursively a legend from a node and regardings activated layers. * * @param {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} node the current themes node. * @param {import("ol/layer/Base").default} layer or layer group to extract the legend from. * @param {number} scale The scale to get the legend. * @param {number} dpi The DPI. * @param {number[]} bbox The bbox. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} Legend classes. * @private */ private collectLegendClassesInTree_; /** * Get legend classes from external datasources. * * @param {number} scale The scale to get the legend. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass[]} Legend classes. * @private */ private getExternalLegendItems_; /** * Add a classItem to a classes array if the classItem to add is not null. * If the classItem have embedded classes, these classes must have classItem. Otherwise the given * classItem will be not added. * * @param {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass[]} classes Array to add an element. * @param {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} classItem The class to add. * @private */ private addClassItemToArray_; /** * If a Legend item have only one children and the children name is identical to its name, then return * only the children (cut one level). Shrink also if both names are null or undefined. * Otherwise return the given legend item. * * @param {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} legendGroupItem A legend item. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} The same legend item or a * shrunk one. * @private */ private tryToSimplifyLegendGroup_; /** * Create a legend item from the given WMTS layer. * * @param {import('gmf/themes').GmfLayer} node the current themes node. * @param {import("ol/layer/WebGLTile").default} layer The layer to extract the legend from. * @param {number} dpi The DPI. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} Legend object for print report * or null. * @private */ private getLegendItemFromTileLayer_; /** * Create a legend item from the given WMS layer and from the given node. * * @param {import('gmf/themes').GmfLayerWMS} node the current themes node. * @param {import("ol/layer/Layer").default} layer the layer * that match the given node. * @param {number} scale The scale to get the legend. * @param {number} dpi The DPI. * @param {number[]} bbox The bbox. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} Legend object for print report * or null. * @private */ private getLegendItemFromlayerWms_; /** * TODO * * @param {string} nodeName * @param {LegendURLDPI} icon_dpi * @param {string} serverType * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} * @private */ private getLegendItemForWMSNode_; /** * Create a legend item from the given external datasource. * * @param {import('ngeo/datasource/DataSource').default} dataSource The datasource to extract the legend * from. * @param {number} scale The scale to get the legend. * @returns {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass} Legend object for print report * or null. * @private */ private getLegendItemFromExternalDatasource_; /** * @typedef {Object} LegendURLDPI * @property {string} url The URL * @property {number} dpi The DPI */ /** * Return the metadata legendImage of a layer from the given node * or undefined. * * @param {number} [dpi=96] the image DPI. * @param {import('gmf/themes').GmfLayer|import('gmf/themes').GmfLayerWMS} node the node to extract metadata from. * @returns {LegendURLDPI|undefined} The legendImage with selected DPI or undefined. * @private */ private getMetadataLegendImage_; }