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

fix: replace logic for deprecated tilePixelRatio #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
51 changes: 25 additions & 26 deletions src/anol/layer/wmts.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,6 @@ class WMTS extends AnolBaseLayer {
}
};
var options = $.extend(true, {}, defaults, _options );
var hqUrl = options.olLayer.source.hqUrl || false;
delete options.olLayer.source.hqUrl;
var hqLayer = options.olLayer.source.hqLayer || false;
delete options.olLayer.source.hqLayer;
var hqMatrixSet = options.olLayer.source.hqMatrixSet || false;
delete options.olLayer.source.hqMatrixSet;

if(DEVICE_PIXEL_RATIO > 1) {
var useHq = false;
if(hqUrl !== false) {
options.olLayer.source.url = hqUrl;
useHq = true;
}
if(hqLayer !== false) {
options.olLayer.source.layer = hqLayer;
useHq = true;
}
if(hqMatrixSet !== false) {
options.olLayer.source.matrixSet = hqMatrixSet;
useHq = true;
}
if(useHq) {
options.olLayer.source.tilePixelRatio = 2;
}
}
super(options);
this.constructorOptions = angular.copy(_options);
this.CLASS_NAME = 'anol.layer.WMTS';
Expand Down Expand Up @@ -90,6 +65,28 @@ class WMTS extends AnolBaseLayer {
}
_createSourceOptions(srcOptions) {
srcOptions = super._createSourceOptions(srcOptions);
var hqUrl = srcOptions.hqUrl || false;
delete srcOptions.hqUrl;
var hqLayer = srcOptions.hqLayer || false;
delete srcOptions.hqLayer;
var hqMatrixSet = srcOptions.hqMatrixSet || false;
delete srcOptions.hqMatrixSet;

let useHq = false;
if(DEVICE_PIXEL_RATIO > 1) {
if(hqUrl !== false) {
srcOptions.url = hqUrl;
useHq = true;
}
if(hqLayer !== false) {
srcOptions.layer = hqLayer;
useHq = true;
}
if(hqMatrixSet !== false) {
srcOptions.matrixSet = hqMatrixSet;
useHq = true;
}
}
var levels = srcOptions.levels;
var extent = srcOptions.extent || srcOptions.projection.getExtent();
var w = getWidth(extent);
Expand All @@ -98,11 +95,13 @@ class WMTS extends AnolBaseLayer {
var url = this._createRequestUrl(srcOptions);
srcOptions = $.extend(true, {}, srcOptions, {
url: url,
tileSize: useHq ? srcOptions.tileSize.map(val => val * 2) : srcOptions.tileSize,
tileGrid: new WMTSTileGrid({
extent: extent,
origin: getTopLeft(extent),
resolutions: this._createResolution(levels, minRes),
matrixIds: this._createMatrixIds(levels)
matrixIds: this._createMatrixIds(levels),
tileSize: srcOptions.tileSize
}),
requestEncoding: 'REST',
style: 'default'
Expand Down