Skip to content

Commit

Permalink
WMTS layers get metadata limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie authored and fredj committed Nov 4, 2019
1 parent 95d3193 commit 40e63e4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
19 changes: 14 additions & 5 deletions contribs/gmf/src/layertree/SyncLayertreeMap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import angular from 'angular';
import gmfThemeThemes from 'gmf/theme/Themes.js';
import gmfThemeThemes, {getNodeMinResolution, getNodeMaxResolution} from 'gmf/theme/Themes.js';
import ngeoLayertreeController, {LayertreeVisitorDecision} from 'ngeo/layertree/Controller.js';
import ngeoMiscWMSTime from 'ngeo/misc/WMSTime.js';
import {getUid as olUtilGetUid} from 'ol/util.js';
Expand Down Expand Up @@ -391,10 +391,19 @@ SyncLayertreeMap.prototype.createWMTSLayer_ = function(gmfLayerWMTS) {
if (!gmfLayerWMTS.layer) {
throw new Error('Missing gmfLayerWMTS.layer');
}
this.layerHelper_.createWMTSLayerFromCapabilitites(gmfLayerWMTS.url,
gmfLayerWMTS.layer, gmfLayerWMTS.matrixSet, gmfLayerWMTS.dimensions).then((layer) => {
newLayer.setSource(layer.getSource());
newLayer.set('capabilitiesStyles', layer.get('capabilitiesStyles'));
const minResolution = getNodeMinResolution(gmfLayerWMTS);
const maxResolution = getNodeMaxResolution(gmfLayerWMTS);

this.layerHelper_.createWMTSLayerFromCapabilitites(
gmfLayerWMTS.url,
gmfLayerWMTS.layer,
gmfLayerWMTS.matrixSet,
gmfLayerWMTS.dimensions,
undefined,
minResolution,
maxResolution
).then((layer) => {
newLayer.setProperties(layer.getProperties());
});
return newLayer;
};
Expand Down
6 changes: 5 additions & 1 deletion contribs/gmf/src/theme/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ export class ThemesService extends olEventsEventTarget {
if (!gmfLayerWMTS.url) {
throw 'Layer URL is required';
}
const minResolution = getNodeMinResolution(gmfLayerWMTS);
const maxResolution = getNodeMaxResolution(gmfLayerWMTS);
const layer = layerHelper.createWMTSLayerFromCapabilitites(
gmfLayerWMTS.url,
gmfLayerWMTS.layer || '',
gmfLayerWMTS.matrixSet,
gmfLayer.dimensions,
gmfLayerWMTS.metadata.customOpenLayersOptions
gmfLayerWMTS.metadata.customOpenLayersOptions,
minResolution,
maxResolution
).then(callback.bind(null, gmfLayer)).then(null, (response) => {
let message = `Unable to build layer "${gmfLayerWMTS.layer}" `
+ `from WMTSCapabilities: ${gmfLayerWMTS.url}\n`;
Expand Down
14 changes: 12 additions & 2 deletions src/map/LayerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,25 @@ LayerHelper.prototype.createBasicWMSLayerFromDataSource = function(
* @param {string=} opt_matrixSet Optional WMTS matrix set.
* @param {Object<string, ?string>=} opt_dimensions WMTS dimensions.
* @param {Object=} opt_customOptions Some initial options.
* @param {number|undefined} opt_minResolution WMTS minimum resolution.
* @param {number|undefined} opt_maxResolution WMTS maximum resolution.
* @return {angular.IPromise<import("ol/layer/Tile.js").default>} A Promise with a layer (with source) on
* success, no layer else.
*/
LayerHelper.prototype.createWMTSLayerFromCapabilitites = function(
capabilitiesURL, layerName, opt_matrixSet, opt_dimensions, opt_customOptions
capabilitiesURL,
layerName,
opt_matrixSet,
opt_dimensions,
opt_customOptions,
opt_minResolution,
opt_maxResolution
) {
const parser = new olFormatWMTSCapabilities();
const layer = new olLayerTile({
preload: this.tilesPreloadingLimit_
preload: this.tilesPreloadingLimit_,
minResolution: opt_minResolution,
maxResolution: opt_maxResolution
});
const $q = this.$q_;

Expand Down

0 comments on commit 40e63e4

Please sign in to comment.