Skip to content

Commit

Permalink
feat(WMTS): Support vendor specific parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mbenevole authored and mgermerie committed Mar 24, 2023
1 parent 9b6d59f commit cff042c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Source/WMTSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import TMSSource from 'Source/TMSSource';
* is 2.
* @property {number} zoom.max - The maximum level of the source. Default value
* is 20.
* @property {Object} vendorSpecific - An object containing vendor specific
* parameters. This object is read simply with the `key` being the name of the
* parameter and `value` being the value of the parameter. If used, this
* property should be set in the constructor parameters.
*
* @example
* // Create the source
Expand Down Expand Up @@ -84,6 +88,13 @@ class WMTSSource extends TMSSource {
`&STYLE=${source.style || 'normal'}` +
`&TILEMATRIXSET=${source.tileMatrixSet}` +
'&TILEMATRIX=%TILEMATRIX&TILEROW=%ROW&TILECOL=%COL';

this.vendorSpecific = source.vendorSpecific;
for (const name in this.vendorSpecific) {
if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/unit/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ describe('Sources', function () {
assert.ok(source.urlFromExtent(extent));
assert.ok(source.extentInsideLimit(extent, 5));
});

it('should use vendor specific parameters for the creation of the WMTS url', function () {
paramsWMTS.vendorSpecific = vendorSpecific;
const source = new WMTSSource(paramsWMTS);
const extent = new Extent('EPSG:4326', 0, 10, 0, 10);
const url = source.urlFromExtent(extent);
const end = '&buffer=4096&format_options=dpi:300;quantizer:octree&tiled=true';
assert.ok(url.endsWith(end));
});
});

describe('WMSSource', function () {
Expand Down

0 comments on commit cff042c

Please sign in to comment.