Skip to content

Commit

Permalink
[BUILD]
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Jul 30, 2021
1 parent 10bcaed commit 779e0af
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 21 deletions.
6 changes: 6 additions & 0 deletions dist/ol-ext.css
Original file line number Diff line number Diff line change
Expand Up @@ -4550,6 +4550,12 @@ ul.ol-legend li div {
.ol-ext-dialog.ol-wmtscapabilities [data-param="map"] {
display: none;
}
.ol-ext-dialog [data-param="style"] {
display: none;
}
.ol-ext-dialog.ol-wmtscapabilities [data-param="style"] {
display: list-item;
}
.ol-ext-dialog.ol-wmtscapabilities [data-param="proj"],
.ol-ext-dialog.ol-wmtscapabilities [data-param="version"] {
opacity: .6;
Expand Down
66 changes: 48 additions & 18 deletions dist/ol-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,6 @@ ol.legend.Legend.prototype.getLegendImage = function(options, canvas, row) {
* @param {int|undefined} row row number to draw in canvas, default 0
*/
ol.legend.Legend.getLegendImage = function(item, canvas, row) {
console.log('ok')
item = item || {};
if (typeof(item.margin) === 'undefined') item.margin = 10;
var size = item.size || [40,25];
Expand Down Expand Up @@ -14334,6 +14333,8 @@ ol.control.WMSCapabilities = function (options) {
this.set('loadLabel', options.loadLabel);
// Dialog
this.createDialog(options);
// Default version
this._elements.formVersion.value = '1.0.0';
// Ajax request
var parser = this._getParser();
this._ajax = new ol.ext.Ajax({ dataType:'text', auth: options.authentication });
Expand Down Expand Up @@ -14383,6 +14384,7 @@ ol.control.WMSCapabilities.prototype.labels = {
formTitle: 'Title:',
formLayer: 'Layers:',
formMap: 'Map:',
formStyle: 'Style:',
formFormat: 'Format:',
formMinZoom: 'Min zoom level:',
formMaxZoom: 'Max zoom level:',
Expand All @@ -14391,7 +14393,7 @@ ol.control.WMSCapabilities.prototype.labels = {
formProjection: 'Projection:',
formCrossOrigin: 'CrossOrigin:',
formVersion: 'Version:',
formAttribution: 'Attribution'
formAttribution: 'Attribution:'
};
/** Create dialog
* @private
Expand Down Expand Up @@ -14561,6 +14563,8 @@ ol.control.WMSCapabilities.prototype.createDialog = function (options) {
addLine('formLayer', '', 'layer1,layer2,...');
var li = addLine('formMap');
li.setAttribute('data-param', 'map');
li = addLine('formStyle');
li.setAttribute('data-param', 'style');
addLine('formFormat', ['image/png', 'image/jpeg']);
addLine('formMinZoom', 0);
addLine('formMaxZoom', 20);
Expand Down Expand Up @@ -14698,6 +14702,7 @@ ol.control.WMSCapabilities.prototype.getCapabilities = function(url, options) {
// reset
this._elements.formMap.value = '';
this._elements.formLayer.value = '';
this._elements.formStyle.value = '';
this._elements.formTitle.value = '';
this._elements.formProjection.value = this.getMap().getView().getProjection().getCode();
this._elements.formFormat.selectedIndex = 0;
Expand All @@ -14715,6 +14720,9 @@ ol.control.WMSCapabilities.prototype.getCapabilities = function(url, options) {
this._elements.formLayer.value = s[1];
this._elements.formTitle.value = s[1].split(',')[0];
}
if (/^style$/i.test(s[0])) {
this._elements.formStyle.value = s[1];
}
if (/^crs$/i.test(s[0])) {
this._elements.formProjection.value = s[1];
}
Expand Down Expand Up @@ -15058,6 +15066,7 @@ ol.control.WMSCapabilities.prototype._getFormOptions = function() {
ol.control.WMSCapabilities.prototype._fillForm = function(opt) {
this._elements.formTitle.value = opt.title;
this._elements.formLayer.value = opt.layers;
this._elements.formStyle.value = opt.style;
var o, i;
for (i=0; o=this._elements.formFormat.options[i]; i++) {
if (o.value === opt.format) {
Expand Down Expand Up @@ -15159,7 +15168,7 @@ ol.ext.inherits(ol.control.WMTSCapabilities, ol.control.WMSCapabilities);
VERSION: options.version || '1.0.0'
}
};
/** Get tile matrix
/** Get tile grid options
* @returns {*}
* @private
*/
Expand All @@ -15178,7 +15187,17 @@ ol.control.WMTSCapabilities.prototype._getTG = function(tileMatrixSet, minZoom,
matrixIds: matrixIds,
minZoom: (minZoom ? minZoom : 0)
}
}
};
/** Get WMTS tile grid
* @param {sting} tileMatrixSet
* @param {number} minZoom
* @param {number} maxZoom
* @returns {ol.tilegrid.WMTS}
* @private
*/
ol.control.WMTSCapabilities.prototype.getTileGrid = function(tileMatrixSet, minZoom, maxZoom) {
return new ol.tilegrid.WMTS(this._getTG(tileMatrixSet, minZoom, maxZoom));
};
/** Return a WMTS options for the given capabilities
* @param {*} caps layer capabilities (read from the capabilities)
* @param {*} parent capabilities
Expand All @@ -15190,7 +15209,6 @@ ol.control.WMTSCapabilities.prototype.getOptionsFromCap = function(caps, parent)
// Tilematrix zoom
var minZoom = Infinity, maxZoom = -Infinity;
var tmatrix;
console.log(caps)
caps.TileMatrixSetLink.forEach(function(tm) {
if (tm.TileMatrixSet === 'PM' || tm.TileMatrixSet === 'EPSG:3857') {
tmatrix = tm;
Expand All @@ -15206,8 +15224,6 @@ ol.control.WMTSCapabilities.prototype.getOptionsFromCap = function(caps, parent)
minZoom = Math.min(minZoom, parseInt(zoom));
maxZoom = Math.max(maxZoom, parseInt(zoom));
});
// Tilematrix
var tg = this._getTG(caps.TileMatrixSet, minZoom, maxZoom);
var view = new ol.View();
view.setZoom(minZoom);
var layer_opt = {
Expand All @@ -15222,7 +15238,9 @@ ol.control.WMTSCapabilities.prototype.getOptionsFromCap = function(caps, parent)
matrixSet: caps.TileMatrixSet,
format: caps.Format[0] || 'image/jpeg',
projection: 'EPSG:3857',
tileGrid: tg,
//tileGrid: tg,
minZoom: minZoom,
maxZoom: maxZoom,
style: caps.Style ? caps.Style[0].Identifier : 'normal',
attributions: caps.Attribution.Title,
crossOrigin: this.get('cors') ? 'anonymous' : null,
Expand All @@ -15232,6 +15250,7 @@ ol.control.WMTSCapabilities.prototype.getOptionsFromCap = function(caps, parent)
this._fillForm({
title: layer_opt.title,
layers: source_opt.layer,
style: source_opt.style,
format: source_opt.format,
minZoom: minZoom,
maxZoom: maxZoom,
Expand All @@ -15242,9 +15261,16 @@ ol.control.WMTSCapabilities.prototype.getOptionsFromCap = function(caps, parent)
});
// Trace
if (this.get('trace')) {
// Source
source_opt.tileGrid = 'TILEGRID';
var tso = JSON.stringify([ source_opt ], null, "\t").replace(/\\"/g,'"');
tso = tso.replace('"TILEGRID"', 'new ol.tilegrid.WMTS('
+ JSON.stringify(this._getTG(source_opt.matrixSet, source_opt.minZoom, source_opt.maxZoom), null, '\t').replace(/\n/g, '\n\t\t')
+ ')'
);
delete source_opt.tileGrid;
// Layer
layer_opt.source = "SOURCE";
layer_opt.source.tileGrid = "new ol.tilegrid.WMTS("+layer_opt.source.tileGrid+")";
var t = "new ol.layer.Tile (" +JSON.stringify(layer_opt, null, "\t")+ ")"
t = t.replace(/\\"/g,'"')
.replace('"SOURCE"', "new ol.source.WMTS("+tso+")")
Expand Down Expand Up @@ -15272,9 +15298,12 @@ ol.control.WMTSCapabilities.prototype.getOptionsFromCap = function(caps, parent)
* @private
*/
ol.control.WMTSCapabilities.prototype._getFormOptions = function() {
var options = this._currentOptions;
var minZoom = parseInt(this._elements.formMinZoom.value);
var maxZoom = parseInt(this._elements.formMaxZoom.value);
var options = this._currentOptions || {};
if (!options.layer) options.layer = {};
if (!options.source) options.source = {};
if (!options.data) options.data = {};
var minZoom = parseInt(this._elements.formMinZoom.value) || 0;
var maxZoom = parseInt(this._elements.formMaxZoom.value) || 20;
var ext = [];
if (this._elements.formExtent.value) {
this._elements.formExtent.value.split(',').forEach(function(b) {
Expand All @@ -15291,7 +15320,7 @@ ol.control.WMTSCapabilities.prototype._getFormOptions = function() {
var layer_opt = {
title: this._elements.formTitle.value,
extent: ext,
abstract: options.layer.abstract,
abstract: options.layer.abstract || '',
maxResolution: view.getResolution()
}
var source_opt = {
Expand All @@ -15300,8 +15329,10 @@ ol.control.WMTSCapabilities.prototype._getFormOptions = function() {
matrixSet: options.source.matrixSet || 'PM',
format: this._elements.formFormat.options[this._elements.formFormat.selectedIndex].value,
projection: 'EPSG:3857',
tileGrid: this._getTG(options.source.matrixSet || 'PM', minZoom, maxZoom),
style: options.source.style || 'normal',
minZoom: minZoom,
maxZoom: maxZoom,
// tileGrid: this._getTG(options.source.matrixSet || 'PM', minZoom, maxZoom),
style: this._elements.formStyle.value || 'normal',
attributions: attributions,
crossOrigin: this._elements.formCrossOrigin.checked ? 'anonymous' : null,
wrapX: (this.get('wrapX') !== false),
Expand All @@ -15321,13 +15352,12 @@ ol.control.WMTSCapabilities.prototype._getFormOptions = function() {
*/
ol.control.WMTSCapabilities.prototype.getLayerFromOptions = function (options) {
if (!options) return;
var tg = options.source.tileGrid;
options.source.tileGrid = new ol.tilegrid.WMTS(tg);
options.source.tileGrid = this.getTileGrid(options.source.matrixSet, options.source.minZoom, options.source.maxZoom);
options.layer.source = new ol.source.WMTS(options.source);
var layer = new ol.layer.Tile(options.layer);
// Restore options
delete options.layer.source;
options.source.tileGrid = tg;
delete options.source.tileGrid;
return layer;
};

Expand Down
2 changes: 1 addition & 1 deletion dist/ol-ext.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ol-ext.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/control/map.switcher.shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ <h1>ol-ext: LayerShop control</h1>
services: {
'BRGM': 'https://geoservices.brgm.fr/geologie',
'OSM': 'https://wms.openstreetmap.fr/wms',
'OSM-Mundialis': 'https://ows.mundialis.de/services/service',
'CorineLandCover': 'https://wxs.ign.fr/corinelandcover/geoportail/r/wms'
}
});
Expand Down
1 change: 0 additions & 1 deletion src/legend/Legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ ol_legend_Legend.prototype.getLegendImage = function(options, canvas, row) {
* @param {int|undefined} row row number to draw in canvas, default 0
*/
ol_legend_Legend.getLegendImage = function(item, canvas, row) {
console.log('ok')
item = item || {};
if (typeof(item.margin) === 'undefined') item.margin = 10;
var size = item.size || [40,25];
Expand Down

0 comments on commit 779e0af

Please sign in to comment.