import type { BaseCustomizer, MFPLayer, MFPMap, MFPWmtsLayer, MFPWmsLayer } from '@geoblocks/mapfishprint'; import GroupLayer from '../../../models/layers/grouplayer.js'; import type BaseLayer from '../../../models/layers/baselayer.js'; import MapManager from '../../../tools/state/mapManager.js'; import State from '../../../tools/state/state.js'; import LayerLocalFile from '../../../models/layers/layerlocalfile.js'; import LayerWms from '../../../models/layers/layerwms.js'; import LayerWmts from '../../../models/layers/layerwmts.js'; /** Options for encoding a map. */ export interface EncodeMapOptions { state: State; mapManager: MapManager; scale: number; printResolution: number; dpi: number; customizer: BaseCustomizer; } /** * Class representing a Mapfish Print Encoder. */ export default class MFPEncoder { private printResolution; private options?; /** * Sets the options for encoding the map. */ setOptions(options: EncodeMapOptions): void; /** * Encodes the map options, notably the map state and the ol map into a top-level MFPMap object. * @returns A Promise that resolves with the encoded map object. */ encodeMap(options: EncodeMapOptions): MFPMap; /** * @returns An array of all active layers from the state object in the right order */ getAllLayers(state: State): BaseLayer[]; /** * @returns The flattened array of base layers. */ getFlatLayers(baseLayers: BaseLayer[]): BaseLayer[]; /** * Encode special layers, meaning not-in-the-layer-tree layers. * These layers are from the mapManager.getLayersToPrint method. * @returns An array of encodedlayers. */ encodeSpecialLayers(mapManager: MapManager, customizer: BaseCustomizer): MFPLayer[]; /** * Encode layers recursively. * @returns a list of Mapfish print layer specs for the given layers. */ encodeLayers(baseLayers: BaseLayer[]): MFPLayer[]; /** * Encodes a layer object according to it's className and options. * @returns A promise that resolves to an array of MFP layers, a single MFP layer, or null. */ encodeLayer(layer: BaseLayer): MFPLayer[] | MFPLayer | null; /** * Only non mixed groups of WMS layers are supported. * * Will convert a group of WMS layers sharing the same OGC server into a single MFPWmsLayer * where its 'layers' property is a concatenation of all child layers' 'layers' property. * * @param groupLayer */ encodeGroupLayer(groupLayer: GroupLayer): MFPWmsLayer | null; /** * Encodes an image layer from a WMS layer object. * @returns The encoded image layer or null if the layer is not visible. */ encodeWmsLayer(layerWms: LayerWms): MFPWmsLayer | null; /** * Encodes a WMTS layer into a MFPWmtsLayer or MFPWmsLayer object. * @returns The encoded layer object, or null if the layer is not visible. */ encodeTileWmtsLayer(layerWmts: LayerWmts): MFPWmtsLayer | MFPWmsLayer | null; /** * Encodes a local file layer. * @returns The encoded local file layer or null if the layer is not visible. */ encodeLocalFileLayer(layer: LayerLocalFile): MFPLayer | null; /** * Encodes a WMS layer from a WMTS layer. * @returns The encoded WMS layer or null if the ogcServer is missing. */ encodeWmsFromWmtsLayer(layerWmts: LayerWmts): MFPWmsLayer | null; }