@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
77 lines (76 loc) • 3.02 kB
TypeScript
import type { BaseCustomizer, MFPLayer, MFPImageLayer, MFPMap, MFPWmtsLayer } from '@geoblocks/mapfishprint';
import type BaseLayer from '../../../models/layers/baselayer';
import MapManager from '../../../tools/state/mapManager';
import State from '../../../tools/state/state';
import LayerLocalFile from '../../../models/layers/layerlocalfile';
import LayerWms from '../../../models/layers/layerwms';
import LayerWmts from '../../../models/layers/layerwmts';
/** 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;
/**
* Encodes an image layer from a WMS layer object.
* @returns The encoded image layer or null if the layer is not visible.
*/
encodeImageLayer(layerWms: LayerWms): MFPImageLayer | null;
/**
* Encodes a WMTS layer into a MFPWmtsLayer or MFPImageLayer object.
* @returns The encoded layer object, or null if the layer is not visible.
*/
encodeTileWmtsLayer(layerWmts: LayerWmts): MFPWmtsLayer | MFPImageLayer | 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): MFPImageLayer | null;
}