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

Print - Selected scale must not be auto. adapted #3649

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 21 additions & 4 deletions contribs/gmf/src/directives/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ gmf.PrintController = function($rootScope, $scope, $timeout, $q, $injector,
*/
this.pointerDragListenerKey_;

/**
* @type {ol.EventsKey}
* @private
*/
this.mapViewResolutionChangeKey_;

/**
* Current report reference id.
* @type {string}
Expand Down Expand Up @@ -364,6 +370,12 @@ gmf.PrintController = function($rootScope, $scope, $timeout, $q, $injector,
*/
this.hiddenAttributeNames;

/**
* @type {boolean}
* @private
*/
this.scaleManuallySelected_ = false;

/**
* @return {ol.Size} Size in dots of the map to print.
*/
Expand All @@ -378,8 +390,8 @@ gmf.PrintController = function($rootScope, $scope, $timeout, $q, $injector,
// the pre-defined scales. (`scaleInput` in `gmfPrintOptions`).
goog.asserts.assert(this.layoutInfo.scales);
goog.asserts.assert(this.layoutInfo.scale !== undefined);
if (this.layoutInfo.scale === -1 ||
ol.array.includes(this.layoutInfo.scales, this.layoutInfo.scale)) {
if (!this.scaleManuallySelected_ &&
(this.layoutInfo.scale === -1 || ol.array.includes(this.layoutInfo.scales, this.layoutInfo.scale))) {
const mapSize = frameState.size;
const viewResolution = frameState.viewState.resolution;
this.layoutInfo.scale = this.getOptimalScale_(mapSize, viewResolution);
Expand Down Expand Up @@ -468,6 +480,9 @@ gmf.PrintController.prototype.togglePrintPanel_ = function(active) {
this.postcomposeListener_);
this.pointerDragListenerKey_ = this.map.on('pointerdrag',
this.onPointerDrag_.bind(this));
this.mapViewResolutionChangeKey_ = this.map.getView().on('change:resolution', () => {
this.scaleManuallySelected_ = false;
});
this.map.render();
}, (resp) => {
// Get capabilities - On error
Expand All @@ -477,6 +492,7 @@ gmf.PrintController.prototype.togglePrintPanel_ = function(active) {
} else {
ol.Observable.unByKey(this.postComposeListenerKey_);
ol.Observable.unByKey(this.pointerDragListenerKey_);
ol.Observable.unByKey(this.mapViewResolutionChangeKey_);
this.getSetRotation(0);
this.map.render(); // Redraw (remove) post compose mask;
}
Expand Down Expand Up @@ -735,15 +751,15 @@ gmf.PrintController.prototype.print = function(format) {

const mapSize = this.map.getSize();
const viewResolution = this.map.getView().getResolution();
const scale = this.getOptimalScale_(mapSize, viewResolution);
const scale = this.layoutInfo.scale || this.getOptimalScale_(mapSize, viewResolution);
const rotation = this.rotateMask_ ? -this.rotation : this.rotation;
const datasource = this.getDataSource_();

const customAttributes = {
'datasource': datasource,
'lang': this.gettextCatalog_.currentLanguage,
'rotation': rotation,
'scale': this.layoutInfo.scale
'scale': scale
};

if (this.layoutInfo.simpleAttributes) {
Expand Down Expand Up @@ -1099,6 +1115,7 @@ gmf.PrintController.prototype.getSetScale = function(opt_scale) {
const res = this.ngeoPrintUtils_.getOptimalResolution(mapSize, this.paperSize_, opt_scale);
const contrainRes = this.map.getView().constrainResolution(res, 0, 1);
this.map.getView().setResolution(contrainRes);
this.scaleManuallySelected_ = true;
}
return this.layoutInfo.scale;
};
Expand Down