Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port default print layout #5661

Merged
merged 3 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions contribs/gmf/src/print/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ module.component('gmfPrint', printComponent);
* @property {boolean} [scaleInput]
* @property {OptionsLegendType} [legend]
* @property {number} [goodnessOfFit]
* @property {string} [defaultLayout]
*/


Expand Down Expand Up @@ -328,6 +329,11 @@ export class PrintController {
*/
this.fieldValues = {};

/**
* @type {string}
*/
this.defaultLayout;

/**
* @type {import('ngeo/print/mapfish-print-v3').MapFishPrintCapabilitiesLayoutAttribute[]}
*/
Expand Down Expand Up @@ -445,6 +451,9 @@ export class PrintController {
if (typeof options.goodnessOfFit === 'number') {
this.goodnessOfFit_ = options.goodnessOfFit;
}
if (options.defaultLayout) {
this.defaultLayout = options.defaultLayout;
}
}

/**
Expand Down Expand Up @@ -716,6 +725,9 @@ export class PrintController {
// Get capabilities - On success
this.parseCapabilities_(resp);
this.map.addLayer(this.maskLayer_);
if (this.defaultLayout) {
this.setLayout(this.defaultLayout);
}
this.pointerDragListenerKey_ = listen(this.map, 'pointerdrag', this.onPointerDrag_, this);
this.mapViewResolutionChangeKey_ = listen(this.map.getView(), 'change:resolution', () => {
this.scaleManuallySelected_ = false;
Expand Down Expand Up @@ -1065,8 +1077,6 @@ export class PrintController {
throw new Error('Wrong layoutInfo.layout type');
}

customAttributes.goodnessOfFit = this.goodnessOfFit_;

// convert the WMTS layers to WMS
const map = new olMap({});
map.setView(this.map.getView());
Expand Down Expand Up @@ -1117,7 +1127,7 @@ export class PrintController {
const email = this.smtpSupported && this.smtpEmail && this.smtpEnabled ? this.smtpEmail : undefined;

const spec = this.ngeoPrint_.createSpec(map, scale, this.layoutInfo.dpi,
this.layoutInfo.layout, format, customAttributes, email);
this.layoutInfo.layout, format, customAttributes, email, this.goodnessOfFit_);

// Add feature overlay layer to print spec.
/** @type {import('ngeo/print/mapfish-print-v3.js').MapFishPrintLayer[]} */
Expand Down
7 changes: 5 additions & 2 deletions src/print/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,20 @@ PrintService.prototype.cancel = function(ref, opt_httpConfig) {
* @param {string} format Formats.
* @param {Object<string, *>} customAttributes Custom attributes.
* @param {string=} email Email to send the file to.
* @param {number=} goodnessOfFit Goodness of fit.
* @return {import('ngeo/print/mapfish-print-v3.js').MapFishPrintSpec} The print spec.
*/
PrintService.prototype.createSpec = function(
map, scale, dpi, layout, format, customAttributes, email) {
map, scale, dpi, layout, format, customAttributes, email, goodnessOfFit) {

const specMap = /** @type {import('ngeo/print/mapfish-print-v3.js').MapFishPrintMap} */ ({
dpi: dpi,
rotation: customAttributes.rotation
});

this.goodnessOfFit_ = customAttributes['goodnessOfFit'];
if (goodnessOfFit) {
this.goodnessOfFit_ = goodnessOfFit;
}

this.encodeMap_(map, scale, specMap);

Expand Down
4 changes: 2 additions & 2 deletions src/print/VectorEncoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ VectorEncoder.prototype.encodeVectorLayer = function(arr, layer, resolution, goo
* @param {import("ol/style/Style.js").default} style Style.
* @param {string} styleId Style id.
* @param {string} featureStyleProp Feature style property name.
* @param {number} [goodnessOfFit] Goodness of fit.
* @param {number=} [goodnessOfFit] Goodness of fit.
*/
VectorEncoder.prototype.encodeVectorStyle = function(object, geometryType, style,
styleId, featureStyleProp, goodnessOfFit) {
Expand Down Expand Up @@ -411,7 +411,7 @@ VectorEncoder.prototype.encodeVectorStyleStroke = function(symbolizer, strokeSty
* @param {Array<import('ngeo/print/mapfish-print-v3.js').MapFishPrintSymbolizer>} symbolizers Array of
* MapFish Print symbolizers.
* @param {import("ol/style/Text.js").default} textStyle Text style.
* @param {number} [goodnessOfFit] Goodness of fit.
* @param {number=} [goodnessOfFit] Goodness of fit.
* @protected
*/
VectorEncoder.prototype.encodeTextStyle = function(symbolizers, textStyle, goodnessOfFit) {
Expand Down