@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
71 lines (70 loc) • 2.89 kB
TypeScript
import type { MFPSpec, MFPReportResponse, MFPCancelResponse } from '@geoblocks/mapfishprint';
import type Feature from 'ol/Feature.js';
import type Geometry from 'ol/geom/Geometry.js';
import type { EncodeLegendOptions, MFPLegendClass } from './MFPLegendEncoder.js';
import type State from '../../../tools/state/state.js';
import type I18nManager from '../../../tools/i18n/i18nmanager.js';
import type MapManager from '../../../tools/state/mapManager.js';
import type { MFPPrintDatasource } from './MFPTypes.js';
import { BaseCustomizer } from '@geoblocks/mapfishprint';
import { MFPLegendEncoder } from './MFPLegendEncoder.js';
import MFPEncoder from './MFPEncoder.js';
/**
* Represents encoding options to print the map.
*/
export interface EncodeOptions {
mapManager: MapManager;
i18nManager: I18nManager;
state: State;
scale: number;
printResolution: number;
dpi: number;
layout: string;
format: string;
pageSize: number[];
customAttributes: Record<string, unknown>;
}
/**
* An interface class that manages printing functionality (including legend).
*/
export default class PrintManager {
protected legendEncoder: MFPLegendEncoder;
protected encoder: MFPEncoder;
protected customizer: BaseCustomizer;
constructor();
/**
* Requests a print report.
* @returns A promise that resolves with the response from the report request.
*/
requestReport(printUrl: string, spec: MFPSpec): Promise<MFPReportResponse>;
/**
* Cancels a report.
* @returns A promise that resolves with the cancellation response.
*/
cancelReport(printUrl: string, ref: string): Promise<MFPCancelResponse>;
/**
* Retrieves the download URL for a given request report.
* @returns A promise that resolves to the download URL.
*/
getDownloadUrl(requestReport: string, response: MFPReportResponse, interval?: number, timeout?: number): Promise<string>;
/**
* Introspect the map and convert each of its layers to MFP v3 format.
* @returns a top level MFP spec
*/
encode(options: EncodeOptions): MFPSpec | null;
/**
* Encodes a print legend based on the given options.
* @returns The encoded legend, or null if encoding is empty or fails.
*/
encodeLegend(options: EncodeLegendOptions): MFPLegendClass | null;
/**
* Calculates the extent of the paper based on the given scale and center coordinates.
* @returns The extent of the paper.
*/
getExtent(pageSize: number[], scale: number, center: number[]): import("ol/extent.js").Extent;
/**
* Formats the data source for printing, based on selected features filtered by the given extent.
* @static
* */
static getPrintDatasourceFromSelectedFeatures(selectedFeatures: Feature<Geometry>[], extent: number[], i18nManager: I18nManager): MFPPrintDatasource[];
}