diff --git a/src/modules/olMap/services/Mfp3Encoder.js b/src/modules/olMap/services/Mfp3Encoder.js index e6ee334270..3e34f1c383 100644 --- a/src/modules/olMap/services/Mfp3Encoder.js +++ b/src/modules/olMap/services/Mfp3Encoder.js @@ -21,6 +21,8 @@ import { BaOverlay, OVERLAY_STYLE_CLASS } from '../components/BaOverlay'; import { findAllBySelector } from '../../../utils/markup'; import { setQueryParams } from '../../../utils/urlUtils'; import { QueryParameters } from '../../../domain/queryParameters'; +import { OlHighlightLayerHandler } from '../handler/highlight/OlHighlightLayerHandler'; +import { HIGHLIGHT_LAYER_ID } from '../../../plugins/HighlightPlugin'; const UnitsRatio = 39.37; //inches per meter const PointsPerInch = 72; // PostScript points 1/72" @@ -147,12 +149,18 @@ export class BvvMfp3Encoder { return layerExtent ? extentIntersects(layer.getExtent(), this._pageExtent) && layer.getVisible() : layer.getVisible(); }); + console.log( + 'encodableLayers', + encodableLayers.map((l) => l.get('id')) + ); + const errors = []; const collectErrors = (label, errorType) => { errors.push({ label: label, type: errorType }); }; const encodedLayers = encodableLayers.flatMap((l) => this._encode(l, collectErrors)); + const copyRights = this._getCopyrights(olMap, encodableLayers); const encodedOverlays = this._encodeOverlays(olMap.getOverlays().getArray()); const encodedGridLayer = this._mfpProperties.showGrid ? this._encodeGridLayer(this._mfpProperties.scale) : {}; @@ -241,7 +249,10 @@ export class BvvMfp3Encoder { * - WMTS/XYZ layers are defined for a specific projection. If the application projection and the print projection differs, the layer must be replaced. */ const encodableLayer = this._getSubstitutionLayerOptional(layer); - const geoResource = this._geoResourceService.byId(encodableLayer.get('geoResourceId')); + const geoResource = + layer.get('id') === HIGHLIGHT_LAYER_ID + ? { exportable: true, getType: () => GeoResourceTypes.VECTOR } + : this._geoResourceService.byId(encodableLayer.get('geoResourceId')); if (!geoResource) { encodingErrorCallback(`[${layer.get('id')}]`, MFP_ENCODING_ERROR_TYPE.MISSING_GEORESOURCE); diff --git a/test/modules/olMap/formats/Mfp3Encoder.test.js b/test/modules/olMap/formats/Mfp3Encoder.test.js index d405e03a93..5c6eb421e7 100644 --- a/test/modules/olMap/formats/Mfp3Encoder.test.js +++ b/test/modules/olMap/formats/Mfp3Encoder.test.js @@ -24,6 +24,7 @@ import TileGrid from 'ol/tilegrid/TileGrid'; import { AdvWmtsTileGrid } from '../../../../src/modules/olMap/ol/tileGrid/AdvWmtsTileGrid'; import { BaOverlayTypes } from '../../../../src/modules/olMap/components/BaOverlay'; import { QueryParameters } from '../../../../src/domain/queryParameters'; +import { HIGHLIGHT_LAYER_ID } from '../../../../src/plugins/HighlightPlugin'; describe('BvvMfp3Encoder', () => { const viewMock = { getCenter: () => [50, 50], calculateExtent: () => [0, 0, 100, 100], getResolution: () => 10, getZoomForResolution: () => 21 }; @@ -445,6 +446,25 @@ describe('BvvMfp3Encoder', () => { expect(errorSpy).toHaveBeenCalledWith('[foo]', MFP_ENCODING_ERROR_TYPE.MISSING_GEORESOURCE); }); + it('encodes the highlight layer as vector layer', () => { + spyOn(geoResourceServiceMock, 'byId') + .withArgs(HIGHLIGHT_LAYER_ID) + .and.callFake(() => null); + const encoder = new BvvMfp3Encoder(); + const encodingResult = {}; + const layerMock = { get: () => HIGHLIGHT_LAYER_ID }; + const encodingSpy = spyOn(encoder, '_encodeVector').and.callFake(() => { + return encodingResult; + }); + const errorSpy = jasmine.createSpy(); + + const actualEncoded = encoder._encode(layerMock, errorSpy); + + expect(actualEncoded).toBe(encodingResult); + expect(encodingSpy).toHaveBeenCalled(); + expect(errorSpy).not.toHaveBeenCalled(); + }); + it('does NOT encode a layer, if a geoResource is not exportable', () => { const notExportableGeoResource = new TestGeoResource('something', 'foo label', false);