Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
+145
-145
@@ -8,8 +8,8 @@ import WMTS from '../../../../src/ol/source/WMTS.js';
|
||||
describe('ol.source.WMTS', function() {
|
||||
|
||||
describe('when creating options from capabilities', function() {
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities, content;
|
||||
const parser = new _ol_format_WMTSCapabilities_();
|
||||
let capabilities, content;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
|
||||
try {
|
||||
@@ -23,7 +23,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns null if the layer was not found in the capabilities', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'invalid'
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('passes the crossOrigin option', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
matrixSet: 'google3857',
|
||||
crossOrigin: ''
|
||||
@@ -41,71 +41,71 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can create KVP options from spec/ol/format/wmts/ogcsample.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(
|
||||
capabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(
|
||||
capabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?');
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?');
|
||||
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
|
||||
expect(options.format).to.be.eql('image/jpeg');
|
||||
expect(options.format).to.be.eql('image/jpeg');
|
||||
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
|
||||
expect(options.requestEncoding).to.be.eql('KVP');
|
||||
expect(options.requestEncoding).to.be.eql('KVP');
|
||||
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
|
||||
expect(options.crossOrigin).to.be(undefined);
|
||||
expect(options.crossOrigin).to.be(undefined);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('can create REST options from spec/ol/format/wmts/ogcsample.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
matrixSet: 'google3857',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png');
|
||||
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
|
||||
expect(options.format).to.be.eql('image/png');
|
||||
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
|
||||
expect(options.requestEncoding).to.be.eql('REST');
|
||||
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
matrixSet: 'google3857',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png');
|
||||
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
|
||||
expect(options.format).to.be.eql('image/png');
|
||||
|
||||
expect(options.projection).to.be.a(Projection);
|
||||
expect(options.projection).to.be.eql(getProjection('EPSG:3857'));
|
||||
|
||||
expect(options.requestEncoding).to.be.eql('REST');
|
||||
|
||||
expect(options.tileGrid).to.be.a(WMTSTileGrid);
|
||||
|
||||
expect(options.style).to.be.eql('DarkBlue');
|
||||
|
||||
expect(options.dimensions).to.eql({Time: '20110805'});
|
||||
|
||||
});
|
||||
|
||||
it('can find a MatrixSet by SRS identifier', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: 'EPSG:3857',
|
||||
requestEncoding: 'REST'
|
||||
@@ -116,7 +116,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can find a MatrixSet by equivalent SRS identifier', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: 'EPSG:900913',
|
||||
requestEncoding: 'REST'
|
||||
@@ -127,7 +127,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can find the default MatrixSet', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
requestEncoding: 'REST'
|
||||
});
|
||||
@@ -137,7 +137,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() {
|
||||
var options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
const options = WMTS.optionsFromCapabilities(capabilities, {
|
||||
layer: 'BlueMarbleNextGeneration',
|
||||
projection: new Projection({
|
||||
code: 'EPSG:2056',
|
||||
@@ -150,24 +150,24 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('doesn\'t fail if the GetCap doesn\'t contains Constraint tags', function() {
|
||||
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
var tmpCapabilities = parser.read(tmpXml);
|
||||
const tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
const tmpCapabilities = parser.read(tmpXml);
|
||||
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
|
||||
var options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
const options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
});
|
||||
|
||||
it('set KVP as default request encoding if the GetCap doesn\'t contains Constraint and ResourceUrl tags', function() {
|
||||
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
let tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
|
||||
tmpXml = tmpXml.replace(/<ResourceURL[\s\S]*?"\/>/g, '');
|
||||
|
||||
var tmpCapabilities = parser.read(tmpXml);
|
||||
const tmpCapabilities = parser.read(tmpXml);
|
||||
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
|
||||
expect(tmpCapabilities['Contents']['Layer'][0]['ResourceURL']).to.be(undefined);
|
||||
var options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
const options = WMTS.optionsFromCapabilities(tmpCapabilities,
|
||||
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
|
||||
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(options.matrixSet).to.be.eql('google3857');
|
||||
expect(options.urls).to.be.an('array');
|
||||
@@ -179,61 +179,61 @@ describe('ol.source.WMTS', function() {
|
||||
describe('when creating tileUrlFunction', function() {
|
||||
|
||||
it('can replace lowercase REST parameters',
|
||||
function() {
|
||||
var source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{layer}/{style}/' +
|
||||
function() {
|
||||
const source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{layer}/{style}/' +
|
||||
'{tilematrixset}/{TileMatrix}/{TileCol}/{TileRow}.jpg'],
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
'layer/default/EPSG:3857/1/1/1.jpg');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('can replace camelcase REST parameters',
|
||||
function() {
|
||||
var source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{Layer}/{Style}/' +
|
||||
function() {
|
||||
const source = new WMTS({
|
||||
layer: 'layer',
|
||||
style: 'default',
|
||||
urls: ['http://www.example.com/wmts/coastlines/{Layer}/{Style}/' +
|
||||
'{tilematrixset}/{TileMatrix}/{TileCol}/{TileRow}.jpg'],
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
matrixSet: 'EPSG:3857',
|
||||
requestEncoding: 'REST',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: [-20037508.342789244, 20037508.342789244],
|
||||
resolutions: [559082264.029 * 0.28E-3,
|
||||
279541132.015 * 0.28E-3,
|
||||
139770566.007 * 0.28E-3],
|
||||
matrixIds: [0, 1, 2]
|
||||
})
|
||||
});
|
||||
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
'layer/default/EPSG:3857/1/1/1.jpg');
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when creating options from Esri capabilities', function() {
|
||||
var parser = new _ol_format_WMTSCapabilities_();
|
||||
var capabilities;
|
||||
const parser = new _ol_format_WMTSCapabilities_();
|
||||
let capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/arcgis.xml', function(xml) {
|
||||
try {
|
||||
@@ -246,44 +246,44 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('can create KVP options from spec/ol/format/wmts/arcgis.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
requestEncoding: 'KVP',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
requestEncoding: 'KVP',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
'Demographics/USA_Population_Density/MapServer/WMTS?');
|
||||
});
|
||||
});
|
||||
|
||||
it('can create REST options from spec/ol/format/wmts/arcgis.xml',
|
||||
function() {
|
||||
var options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
function() {
|
||||
const options = WMTS.optionsFromCapabilities(
|
||||
capabilities, {
|
||||
layer: 'Demographics_USA_Population_Density',
|
||||
matrixSet: 'default028mm'
|
||||
});
|
||||
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
expect(options.urls).to.be.an('array');
|
||||
expect(options.urls).to.have.length(1);
|
||||
expect(options.urls[0]).to.be.eql(
|
||||
'https://services.arcgisonline.com/arcgis/rest/services/' +
|
||||
'Demographics/USA_Population_Density/MapServer/WMTS/' +
|
||||
'tile/1.0.0/Demographics_USA_Population_Density/' +
|
||||
'{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrls()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
var source = new WMTS({});
|
||||
const source = new WMTS({});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
@@ -294,9 +294,9 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
var source = new WMTS({});
|
||||
const source = new WMTS({});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
@@ -307,8 +307,8 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('generates the correct tileUrlFunction during application of setUrl()', function() {
|
||||
var projection = getProjection('EPSG:3857');
|
||||
var source = new WMTS({
|
||||
const projection = getProjection('EPSG:3857');
|
||||
const source = new WMTS({
|
||||
projection: projection,
|
||||
requestEncoding: 'REST',
|
||||
urls: [
|
||||
@@ -322,31 +322,31 @@ describe('ol.source.WMTS', function() {
|
||||
})
|
||||
});
|
||||
|
||||
var urls = [
|
||||
const urls = [
|
||||
'https://a.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg',
|
||||
'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg'
|
||||
];
|
||||
source.setUrls(urls);
|
||||
var tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection);
|
||||
const tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection);
|
||||
expect(tileUrl1).to.match(/https\:\/\/[ab]\.example\.com\/2\/-5\/9\.jpg/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('url option', function() {
|
||||
it('expands url template', function() {
|
||||
var tileSource = new WMTS({
|
||||
const tileSource = new WMTS({
|
||||
url: '{1-3}'
|
||||
});
|
||||
|
||||
var urls = tileSource.getUrls();
|
||||
const urls = tileSource.getUrls();
|
||||
expect(urls).to.eql(['1', '2', '3']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
var sourceOptions;
|
||||
var source;
|
||||
let sourceOptions;
|
||||
let source;
|
||||
|
||||
beforeEach(function() {
|
||||
sourceOptions = {
|
||||
@@ -369,7 +369,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns the WMTS URLs', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_wmts_url']);
|
||||
});
|
||||
|
||||
@@ -382,7 +382,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns the WMTS URLs', function() {
|
||||
var urls = source.getUrls();
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_wmts_url1', 'some_wmts_url2']);
|
||||
});
|
||||
|
||||
@@ -392,7 +392,7 @@ describe('ol.source.WMTS', function() {
|
||||
|
||||
describe('#getRequestEncoding', function() {
|
||||
|
||||
var source;
|
||||
let source;
|
||||
|
||||
beforeEach(function() {
|
||||
source = new WMTS({
|
||||
@@ -409,7 +409,7 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
it('returns the request encoding', function() {
|
||||
var requestEncoding = source.getRequestEncoding();
|
||||
const requestEncoding = source.getRequestEncoding();
|
||||
expect(requestEncoding).to.be.eql('REST');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user